@@ -42,10 +42,9 @@ def update_traits(self, traits):
4242
4343 def has_traits (self , traits ):
4444 """Return true if the player has all traits in parameter traits (equal or more)"""
45- for trait , value in traits .items ():
46- if self .traits .get [trait ] < value :
47- return False
48- return True
45+ return all ([
46+ self .traits .get (trait , 0 ) > value
47+ for trait , value in traits .items ()])
4948
5049
5150 def update_items (self , items : dict ):
@@ -56,10 +55,9 @@ def update_items(self, items: dict):
5655
5756 def has_items (self , items : dict ):
5857 """Return true if the player has at least number of items specified in parameter items"""
59- for item , count in items .items ():
60- if self .items [item ] < count :
61- return False
62- return True
58+ return all ([
59+ self .items .get (item , 0 ) > count
60+ for item , count in items .items ()])
6361
6462
6563 def set_history (self , history : dict ):
@@ -70,10 +68,9 @@ def set_history(self, history: dict):
7068
7169 def has_history (self , history : dict ):
7270 """Return true if all values in player history and in parameter are equal"""
73- for story , value in history .items ():
74- if self .history [story ] != value :
75- return False
76- return True
71+ return all ([
72+ self .history .get (story , False ) == value
73+ for story , value in history .items ()])
7774
7875
7976def load_player_from (content ):
0 commit comments