In this exercise, you'll be extending the quest logic for the new role-playing game a friend is developing. To make the game more interesting, your friend wants you to add random events that change the situation.
The general setting hasn't changed from the previous exercise. The new random events are highlighted in the text below.
The game's main character is Annalyn, a brave girl with a fierce and loyal pet dog. Unfortunately, disaster strikes, as her best human friend was kidnapped while searching for berries in the forest. Annalyn will try to find and free her best friend, optionally taking her dog with her on this quest.
After some time spent following her best friend's trail, she finds the camp in which her best friend is imprisoned. It turns out there are two kidnappers: a mighty knight and a cunning archer.
Having found the kidnappers, Annalyn considers which of the following actions she can engage in:
After freeing her friend, Annalyn still has some time to quickly loot the camp. She can find anywhere between three and thirteen coins. She also comes across a treasure chest with a random item inside.
Your tasks are to implement the functions that determine if these random events occur, and to determine Annalyn's loot.
Implement a function named is_foggy. This function returns true half the time. Otherwise, it returns false.
julia> is_foggy()
true
julia> is_foggy()
falseImplement a function named is_dog_distracted. This function returns true 25% of the time. Otherwise, it returns false.
julia> is_dog_distracted()
false
julia> is_dog_distracted()
true
julia> is_dog_distracted()
falseImplement a function named loot that returns the number of coins Annalyn finds in the camp. For example:
julia> loot()
4
julia> loot()
7
julia> loot()
3Implement a function named loot that takes a collection of items as an argument and returns the item Annalyn finds in the chest. For example:
julia> loot(["Cabbage", "Daring Dagger", "Sneaky Shoes"])
"Cabbage"
julia> loot(["Cabbage", "Daring Dagger", "Sneaky Shoes"])
"Sneaky Shoes"In this exercise, you'll be extending the quest logic for the new role-playing game a friend is developing. To make the game more interesting, your friend wants you to add random events that change the situation.
The general setting hasn't changed from the previous exercise. The new random events are highlighted in the text below.
The game's main character is Annalyn, a brave girl with a fierce and loyal pet dog. Unfortunately, disaster strikes, as her best human friend was kidnapped while searching for berries in the forest. Annalyn will try to find and free her best friend, optionally taking her dog with her on this quest.
After some time spent following her best friend's trail, she finds the camp in which her best friend is imprisoned. It turns out there are two kidnappers: a mighty knight and a cunning archer.
Having found the kidnappers, Annalyn considers which of the following actions she can engage in:
After freeing her friend, Annalyn still has some time to quickly loot the camp. She can find anywhere between three and thirteen coins. She also comes across a treasure chest with a random item inside.
Your tasks are to implement the functions that determine if these random events occur, and to determine Annalyn's loot.
Implement a function named is_foggy. This function returns true half the time. Otherwise, it returns false.
julia> is_foggy()
true
julia> is_foggy()
falseImplement a function named is_dog_distracted. This function returns true 25% of the time. Otherwise, it returns false.
julia> is_dog_distracted()
false
julia> is_dog_distracted()
true
julia> is_dog_distracted()
falseImplement a function named loot that returns the number of coins Annalyn finds in the camp. For example:
julia> loot()
4
julia> loot()
7
julia> loot()
3Implement a function named loot that takes a collection of items as an argument and returns the item Annalyn finds in the chest. For example:
julia> loot(["Cabbage", "Daring Dagger", "Sneaky Shoes"])
"Cabbage"
julia> loot(["Cabbage", "Daring Dagger", "Sneaky Shoes"])
"Sneaky Shoes"