Checks if all items are collected (win or loose)
TODO draws items counter and message
This commit is contained in:
parent
c0a3c1d1f2
commit
1104e34040
|
@ -53,7 +53,7 @@ guard without all the objects, he dies (according to the evolution theory).
|
|||
* [x] The way he pick them up
|
||||
* [ ] Add a counter that will list them.
|
||||
4. Win!
|
||||
* [ ] _McGyver_ has picked up all the objects and asleep the guard
|
||||
* [x] _McGyver_ has picked up all the objects and asleep the guard
|
||||
|
||||
### Deliverables
|
||||
|
||||
|
|
6
conf.py
6
conf.py
|
@ -19,11 +19,11 @@ ELEMENT_LIST = [
|
|||
]
|
||||
|
||||
# Possible returns of a move, keep the «ok» at the end
|
||||
MOVE_STATUS = ['bad', 'wall', 'exit', 'collect', 'ok']
|
||||
MOVE_STATUS = ['looser', 'wall', 'winner', 'collect', 'ok']
|
||||
MOVE_STATUS_MSG = {
|
||||
'bad': "Le déplacement «{}» n'est pas autorisé.",
|
||||
'looser': "Vous vous êtes fait assommé! Pour endormir le garde, il manqait: {}.\nPerdu!",
|
||||
'wall': "Le déplacement est stoppé par un mur.",
|
||||
'exit': "Vous êtes sortit du labyrinte",
|
||||
'winner': "Gagné! Vous avez endormis le garde avec votre seringue.",
|
||||
'collect': "Vous ramassez l'objet «{}»",
|
||||
'ok': "Jusqu'ici, tout va bien…"
|
||||
}
|
||||
|
|
10
map.py
10
map.py
|
@ -81,7 +81,6 @@ class Map:
|
|||
|
||||
def map_print(self):
|
||||
""" Affiche la carte avec la position de jeu courante """
|
||||
# print(self._map_in_a_string)
|
||||
return self._map_in_a_string
|
||||
|
||||
def move_to(self, pressed_key):
|
||||
|
@ -128,9 +127,12 @@ class Map:
|
|||
self.collected_items.append(elmt_val('name', 'symbol', next_char, 0))
|
||||
|
||||
elif next_char == elmt_val('symbol', 'name', 'exit', 0):
|
||||
self._player_position = next_position
|
||||
self.status = False
|
||||
self.status_message = MOVE_STATUS_MSG['exit']
|
||||
if sorted(self.collected_items) == sorted(elmt_val('name', 'collect', True)):
|
||||
self.status_message = MOVE_STATUS_MSG['winner']
|
||||
else:
|
||||
missed_item_flist = ', '.join((item for item in elmt_val('name', 'collect', True) if item not in self.collected_items))
|
||||
self.status_message = MOVE_STATUS_MSG['looser'].format(missed_item_flist)
|
||||
|
||||
else: # wall, door or nline
|
||||
self.status_message = MOVE_STATUS_MSG['wall']
|
||||
|
@ -139,8 +141,6 @@ class Map:
|
|||
|
||||
# place le plyr sur sa nouvelle position
|
||||
self.place_element(elmt_val('symbol', 'name', 'player', 0))
|
||||
# Debug
|
||||
self.status_message += "|"+str(self.collected_items)
|
||||
|
||||
def place_element(self, element, **kwargs):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue