Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions src/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ def update_traits(self, traits):

def has_traits(self, traits):
"""Return true if the player has all traits in parameter traits (equal or more)"""
for trait, value in traits.items():
if self.traits.get[trait] < value:
return False
return True
return all([
self.traits.get(trait, 0) > value
for trait, value in traits.items()])


def update_items(self, items: dict):
Expand All @@ -56,10 +55,9 @@ def update_items(self, items: dict):

def has_items(self, items: dict):
"""Return true if the player has at least number of items specified in parameter items"""
for item, count in items.items():
if self.items[item] < count:
return False
return True
return all([
self.items.get(item, 0) > count
for item, count in items.items()])


def set_history(self, history: dict):
Expand All @@ -70,10 +68,9 @@ def set_history(self, history: dict):

def has_history(self, history: dict):
"""Return true if all values in player history and in parameter are equal"""
for story, value in history.items():
if self.history[story] != value:
return False
return True
return all([
self.history.get(story, False) == value
for story, value in history.items()])


def load_player_from(content):
Expand Down