print message to console when agent take the herb works

This commit is contained in:
Mateusz 2020-05-29 00:47:11 +02:00
parent 14850cd230
commit 5c8a48e30d
2 changed files with 19 additions and 14 deletions

View File

@ -29,27 +29,25 @@ class Interactable(Entity):
elif classifier == "herb":
self.classifier = Classifiers.HERB
def on_interaction(self, Player):
def on_interaction(self, player):
"""
Applies outcome to the Player
:param Player: Player object
"""
Player.statistics.set_hp(self.Statistics.hp)
Player.statistics.set_stamina(self.Statistics.stamina)
Player.statistics.set_thirst(self.Statistics.thirst)
Player.statistics.set_hunger(self.Statistics.hunger)
player.statistics.set_hp(self.Statistics.hp)
player.statistics.set_stamina(self.Statistics.stamina)
player.statistics.set_thirst(self.Statistics.thirst)
player.statistics.set_hunger(self.Statistics.hunger)
if self.classifier == Classifiers.HERB:
Player.herbs += 1
print(Player.herbs)
player.herbs += 1
if Player.herbs == 10 and self.classifier == Classifiers.REST:
print("Should reset")
Player.statistics.set_hp(100)
Player.statistics.set_stamina(100)
Player.statistics.set_thirst(-100)
Player.statistics.set_hunger(-100)
if player.herbs == 10 and self.classifier == Classifiers.REST:
player.statistics.set_hp(100)
player.statistics.set_stamina(100)
player.statistics.set_thirst(-100)
player.statistics.set_hunger(-100)
def __str__(self):
return "Entity - ID:{}, pos:({}x, {}y), {}".format(self.id, self.x, self.y, self.classifier.name)

View File

@ -26,6 +26,8 @@ class EventManager:
self.iterator = 0
self.takenHerbs = self.player.herbs
# TODO
def loadKeyboardSettings(self):
pass
@ -115,11 +117,16 @@ class EventManager:
self.player.gotoToTarget(target, self.game.map)
if keys[pygame.K_t]:
if self.player.movementTarget is None:
if self.player.movementTarget is None and self.iterator <= 10:
target = self.game.entityToVisitList[self.iterator]
self.player.gotoToTarget(target, self.game.map)
self.iterator += 1
if self.player.herbs > self.takenHerbs:
self.game.screen.ui.console.printToConsole("Ziele zebrane! Ilość: " + str(self.player.herbs))
self.takenHerbs = self.player.herbs
if keys[pygame.K_r]:
self.game.map.respawn()