Change map gestion

This commit is contained in:
Shadow15510 2021-08-30 16:35:28 +02:00
parent 28917b7e30
commit 2d62d5d8b2
3 changed files with 17 additions and 26 deletions

View File

@ -50,10 +50,7 @@ class Screen:
class Asci:
def __init__(self, maps, events_mapping, keys_mapping, screen_width=21, screen_height=6):
# Load maps
self.maps = []
for i in maps:
if type(i) == str: self.maps.append(Map(i))
else: self.maps.append(Map(*i))
self.maps = [Map(*i) for i in maps]
# Custom functions
self.legend = list(events_mapping.keys())
@ -157,18 +154,12 @@ class Asci:
if event.answer and (0 < answer_selected <= event.answer): self.data[0] += answer_selected
def _get_map(self, direction):
x, y = self._looked_case(direction)
current_coords = self._looked_case(direction)
current_map = self.data[1]
if (x, y) == self.maps[current_map].coords_out:
return self.maps[current_map].parent, self.maps[current_map].coords_in[0] - 10, self.maps[current_map].coords_in[1] - 3
else:
maps_available = [(i, self.maps[i]) for i in range(len(self.maps)) if self.maps[i].parent == current_map]
for index, map_looked in maps_available:
if (x, y) == map_looked.coords_in:
return index, map_looked.coords_out[0] - 10, map_looked.coords_out[1] - 3
for coords in self.maps[current_map].coords:
if coords[:2] == current_coords:
return coords[2], coords[3] - 10, coords[4] - 3
return current_map, self.data[2], self.data[3]
@ -211,12 +202,9 @@ class Event:
class Map:
def __init__(self, map_data, coords_in=None, coords_out=None, parent=None):
def __init__(self, map_data, *coords):
self.map_data = map_data
self.coords_in = coords_in
self.coords_out = coords_out
self.parent = parent
self.coords = coords
def convert(string):

View File

@ -2,7 +2,7 @@ from asci_lib import *
cartes = (
r"""
(r"""
_ ###
/o\__ #####
|_ <>\ ###
@ -12,6 +12,7 @@ r"""
|==|==|==|==|==|==|==|""",
(1, 3, 1, 5, 7)),
(r"""
+--+--+--------+--+--+
@ -22,7 +23,7 @@ r"""
+--/ \--------/ \--+
| |
+---|^|--------------+""",
(1, 3), (5, 7), 0)
(5, 7, 0, 1, 3))
)

View File

@ -3,7 +3,7 @@ from random import randint
cartes = (
r"""
(r"""
__
/ \___ ### *
|<> \ ##### _
@ -13,8 +13,10 @@ r"""
__ __
$ ## / \___/ \ ##
#### |<> <>| ####
## |___|^|___| ##
## |_________| ##
|| ||""",
(1, 3, 1, 5, 7),
(19, 4, 2, 4, 4)),
(r"""
+--+--+--------+--+--+
@ -25,7 +27,7 @@ r"""
+--/ *\--------/ \--+
| |
+---|^|--------------+""",
(1, 3), (5, 7), 0),
(5, 7, 0, 1, 3)),
(r"""
+-------+
@ -34,7 +36,7 @@ r"""
| |
+--|^|--+
""",
(19, 4), (4, 4), 0)
(4, 4, 0, 19, 4))
)
@ -44,7 +46,7 @@ def pnj(data, stat):
if carte_actuelle == 0:
if coords == (24, 4):
if stat[0] < 100: return [0, "Oh, mais tu es blesse !", 0, 50]
if stat[0] < 100: return [0, "Oh, mais tu es blesse !", 0, (0, 50)]
else: return [0, "Reviens me voir quand tu seras blesse."]
elif coords == (16, 1): return {