Add a new feature : routine system

This commit is contained in:
Shadow15510 2021-10-31 21:28:48 +01:00
parent 47008e5945
commit 34a11c4403
2 changed files with 15 additions and 7 deletions

View File

@ -48,7 +48,7 @@ class Screen:
class Asci:
def __init__(self, maps, events_mapping, keys_mapping, screen_width=21, screen_height=6):
def __init__(self, maps, events_mapping, keys_mapping, routine=None, screen_width=21, screen_height=6):
# Load maps
self.maps = [Map(*i) for i in maps]
@ -56,6 +56,7 @@ class Asci:
self.legend = list(events_mapping.keys())
self._game_events_mapping = [events_mapping[i] for i in self.legend]
self._game_keys_mapping = {key: keys_mapping[key] for key in keys_mapping if not key in (1, 2, 3, 5, 9)}
self._game_routine = routine
# Screen initialisation
self.screen = Screen(screen_width, screen_height)
@ -188,6 +189,8 @@ class Asci:
else: key_buffer = key
self._keyboard(key)
if self._game_routine: self._game_routine(self.data, self.stat)
if self.stat[0] <= 0: self.stat[0] = 100
return self.stat, self.data

View File

@ -1,6 +1,6 @@
from asci_lib import *
carte_monde = (
carte_monde = ((
r"""
_ ###
/o\__ #####
@ -10,7 +10,8 @@ r"""
*
|==|==|==|==|==|==|==|""",)
|==|==|==|==|==|==|==|""",),)
def pnj(data, stat):
@ -30,13 +31,17 @@ def pnj(data, stat):
return [0, "Hmm ?"]
def affichage_stat(data, stat):
pv, argent = stat
pv, argent, seconds = stat
minutes = seconds // 60
hours = minutes // 60
time = "{}:{}:{}".format(int(hours % 24), int(minutes % 60), int(seconds % 60))
print("Statistiques")
print("PV : {}".format(pv))
print("Argent : {}".format(argent))
print("{}".format(time))
input()
@ -46,4 +51,4 @@ touche = {6: affichage_stat}
def mon_jeu():
rpg_python = Asci(carte_monde, evenements, touche)
rpg_python.mainloop(4, [100, 5])
rpg_python.mainloop(4, stat=[100, 5, 0])