In this exercise, you'll be implementing the quest logic for a new RPG game a friend is developing. The game's main character is Annalyn, a brave girl with a fierce and loyal pet dog. Unfortunately, disaster strikes, as her best 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:
You have five tasks: to implement the logic for determining if the above actions are available based on the state of the three characters found in the forest and whether Annalyn's pet dog is present or not.
Implement the canFastAttack function that takes a boolean value that indicates if the knight is awake. This function returns True if a fast attack can be made based on the state of the knight. Otherwise, returns False:
knightIsAwake = True
canFastAttack knightIsAwake
--> FalseImplement the canSpy function that takes three boolean values, indicating if the knight, archer and the prisoner, respectively, are awake. The function returns True if the group can be spied upon, based on the state of the three characters. Otherwise, returns False:
knightIsAwake = False
archerIsAwake = True
prisonerIsAwake = False
canSpy knightIsAwake archerIsAwake prisonerIsAwake
--> TrueImplement the canSignalPrisoner function that takes two boolean values, indicating if the archer and the prisoner, respectively, are awake. The function returns True if the prisoner can be signalled, based on the state of the two characters. Otherwise, returns False:
archerIsAwake = False
prisonerIsAwake = True
canSignalPrisoner archerIsAwake prisonerIsAwake
--> TrueImplement the canFreePrisoner function that takes four boolean values. The first three parameters indicate if the knight, archer and the prisoner, respectively, are awake. The last parameter indicates if Annalyn's pet dog is present. The function returns True if the prisoner can be freed based on the state of the three characters and Annalyn's pet dog presence. Otherwise, it returns False:
knightIsAwake = False
archerIsAwake = True
prisonerIsAwake = False
petDogIsPresent = False
canFreePrisoner knightIsAwake archerIsAwake prisonerIsAwake petDogIsPresent
--> FalseImplement the stealthAttackDamage function that takes a boolean value indicating if Annalyn was detected. This function returns 7 if she was detected, 12 otherwise.
annalynIsDetected = True
stealthAttackDamage annalynIsDetected
--> 7In this exercise, you'll be implementing the quest logic for a new RPG game a friend is developing. The game's main character is Annalyn, a brave girl with a fierce and loyal pet dog. Unfortunately, disaster strikes, as her best 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:
You have five tasks: to implement the logic for determining if the above actions are available based on the state of the three characters found in the forest and whether Annalyn's pet dog is present or not.
Implement the canFastAttack function that takes a boolean value that indicates if the knight is awake. This function returns True if a fast attack can be made based on the state of the knight. Otherwise, returns False:
knightIsAwake = True
canFastAttack knightIsAwake
--> FalseImplement the canSpy function that takes three boolean values, indicating if the knight, archer and the prisoner, respectively, are awake. The function returns True if the group can be spied upon, based on the state of the three characters. Otherwise, returns False:
knightIsAwake = False
archerIsAwake = True
prisonerIsAwake = False
canSpy knightIsAwake archerIsAwake prisonerIsAwake
--> TrueImplement the canSignalPrisoner function that takes two boolean values, indicating if the archer and the prisoner, respectively, are awake. The function returns True if the prisoner can be signalled, based on the state of the two characters. Otherwise, returns False:
archerIsAwake = False
prisonerIsAwake = True
canSignalPrisoner archerIsAwake prisonerIsAwake
--> TrueImplement the canFreePrisoner function that takes four boolean values. The first three parameters indicate if the knight, archer and the prisoner, respectively, are awake. The last parameter indicates if Annalyn's pet dog is present. The function returns True if the prisoner can be freed based on the state of the three characters and Annalyn's pet dog presence. Otherwise, it returns False:
knightIsAwake = False
archerIsAwake = True
prisonerIsAwake = False
petDogIsPresent = False
canFreePrisoner knightIsAwake archerIsAwake prisonerIsAwake petDogIsPresent
--> FalseImplement the stealthAttackDamage function that takes a boolean value indicating if Annalyn was detected. This function returns 7 if she was detected, 12 otherwise.
annalynIsDetected = True
stealthAttackDamage annalynIsDetected
--> 7