Compare commits

...

3 Commits

  1. 142
      hydromel_poetique/alfheim.py
  2. 467
      hydromel_poetique/asci.py
  3. 428
      hydromel_poetique/asgard.py
  4. 340
      hydromel_poetique/hy_po.py
  5. 523
      hydromel_poetique/idk_lib.py
  6. 322
      hydromel_poetique/jotunheim.py
  7. 213
      hydromel_poetique/midgard.py
  8. 219
      hydromel_poetique/muspellheim.py
  9. 221
      hydromel_poetique/nidavellir.py
  10. 139
      hydromel_poetique/niflheim.py
  11. 178
      hydromel_poetique/svartalfheim.py
  12. 113
      hydromel_poetique/vanaheim.py
  13. 2
      idk/alfheim.py
  14. 58
      idk/asci.py
  15. 261
      idk/idk.py
  16. 141
      idk/idk_lib.py
  17. 2
      idk/midgard.py
  18. 2
      idk/muspellheim.py
  19. 2
      idk/vanaheim.py

@ -1,142 +0,0 @@
alfheim = (r"""
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~ ~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~ ~~~~~~ ## ~~~~~~~~~~~~ ~~~~~~~~ ~~~~~~~~~~~~~~~
~~~~~ ~~~~~~~ #### ~~~~~~~ ## ~~~~~~~~
~~~ ~~~~~ || ~~~~~~~ #### __ ## ~~~~~~~
~~~ ~~~~~~~~ ## ~~~~~ ## || /[]\ #### ~~~~~
~~~ ~~~~~~~~~~~~ #### ## ## #### ` ' |__| || __ ~~~
~~~ ~~~~~~~~~~~~ ## || #### #### || ,' '.' / \ ~~~
~~~ ~~~~~ ~~~~ #### || || ` ' __ '`' . ` |__| ~~
~~~ ## ~~~ || '' /[]\ ' . ## ~~
~~ #### ## _ _________________ |__| ## `.` #### ~~
~~ || #### / \ / |]O[| |]O[| \ #### __ || ~~
~~~~ || |_| /___________________\ ## ## || /[]\ ~~
~~~~ ## _ |_/ \_/ _ \_/ \_| ## ## |__| ## ~~~~
~~~~ #### / \ |_| |_|/^\|_| |_| __ #### ~~~~
~~~~ || _ |_| ## ## / \ `' || ~~~~
~~~~ / \ ### ### ## ## |__| . , ~~~~
~~~~~~~~~ |_| _ ##### ##### `' `_ ,, , ~~~
~~~~~~~~~ /o\ ### ### ' _ ``' / \ ~~~
~~~~~~~~~~~ |_| /-\ /-\ , / \ |_| ~~~~ ~~~
~~~~~~~~~~~~ ### ### ' ,|_| .' _ ~~~~~ ~~~
~~~~~~ ~~~~~~~ ### ##### ` ##### . ` .,. / \ ~~~~~ ~~~
~~~~~ ~~~~~~~ ##### ### ' ### _ ` , _ |_| _ ~~~~~~ ~~~
~~~~~ __ ~~ ### /-\ /-\ ` / \ , /o\ / \ ~~~~~~~~~~
~~~~~~ / \ /-\ ' . '``,'' |_|` |_| |_| ~~~~~~~~~~
~~~~~~ |__| ,. ' .` ', ~~~~~~~~~~
~~~~~~ __ ### ., _ . , _ ,. ~~~~~~~~~~
~~~~~~~~ / \ ##### ### / \ ` ' /o\__ `. ~~~~~~~~~
~~~~~~~~~ |__| ### ##### ### |_| . |_ o \==| .'`. ~~~~~~~
~~~~~~~~~~~~ ### /-\ ### ##### ,.` ||^|__| | . . ~~~~~~~
~~~~~~~~~~~~ ##### /-\ ### | .' ~~~~~~
~~~~~~~~~~~~~ ##### ### /-\ ### ### | ,`','` '',, ~~~~~~
~~~~~~~~~~~ ### ##### ### ##### ##### |==|==|==| ~~~~~
~~~~~~~~~~ ### |_| ##### ##### ### ### _ ~~~~~
~~~~~~~~~ ##### ### ##### /-\ /-\ ### _ / \ _ ~~~~
~~~~~~~~~ ##### |_| ### ### ##### / \ |_| / \ ~~~~
~~~~~~~~~ ### |_| ##### ### ### |_| |_| ~~~~
~~~~~~~ |_| ~~~~~~~ ##### ##### /-\ _ ~~~~
~~~~~~~ ~~~~~~~~~~~~~~~~~~ ### ##### / \ _ ~~~~
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ |_| ### |_| / \ _ ~~~~
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~ |_| |_| / \ ~~~~
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ |_| ~~~~
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ ~~~
~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~ ~~~~~~
~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ #### #### ~~~~~~~~~~~~
~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~ ### ### ~~~~~~~~~~~~
~~~~~~~~~~ __ ~~~~~~~~~~~~~~~~~~~~ __ ### ## ## ~~~~~~~~~~~~
~~~~~~~~~~ / \ ~~~~~~~~~~~~~~~~~~~~ / \ ##### ~~~~~~ ~~~~
~~~~~~~~~~ |__| ~~~~~~~~~~~~~ |__| ##### ## ## ~~~~~ ~~~~
~~~~~~~~~~ ### ~~~~~~~~ ### ### ### ~~ ~~~~
~~~~~~~~~ ##### ,'' |_| #### #### ~~~
~~~~~~~~ ##### ' ### ,,,. ### ~~~
~~~~~~~~ ### ### ##### `,, ##### ~~~
~~~~~~~ |_| . ##### ##### ',, __ ### ##### ~~~
~~~~~~ ### ,##### ### ` / \ ### ##### ### ~~~
~~~~~~ ##### ### , ### |_|`' ### |__| ##### ##### |_| ~~~
~~~~~~ ##### #####``|_| ### ` ##### ##### ### ~~~
~~~~~~ ### ##### ' ##### ##### ### |_| ### ~~~
~~~~~~ |_| ### ,' ##### ### |_| ##### ~~~
~~~~~~ ## |_| ` ### |_| ~~ ##### ~~~
~~~~~ ## #### ` |_| ~~~~ ~~~~ ### ~~~
~~~~ #### || . ~~~~~~~ ~~~~~~ ~~~~~~~~ |_| ~~~
~~~~~ ## || ,` ' ~~~~~~~~~~~~~~~ ~~~~~~ ~~~~~~~~ ~~~
~~~~ #### _ ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ ~~~~~~~~~~~ ~~~
~~~~~ || /-\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ ~~~~
~~~~~~ ~ |_| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ ~~~~~
~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""",
# Autres mondes (Alfheim = 2)
(14, 68, 1, 28, 13), # Vanaheim
# Maisons
(34, 16, 23, 25, 19),
(52, 31, 24, 20, 19), # Librairie
)
h_23 = (r"""
|==================|
| |
| _ _ |
| / \ / \ |
| \_/ \_/ |
| |_| |_| |
| |
| _ _ |
| / \ / \ |
| \_/ \_/ |
|===========| |_| |_| |===========|
| |
| |
| _ _ |
|__ __ / \ / \ __ __|
/ \ / \ \_/ \_/ / \ / \
\__/ \__/ |_| |_| \__/ \__/
| | | | | | | |
| | | | | | | |
/ \______/ \_______|^|______/ \______/ \ """,
(25, 19, 2, 34, 16))
h_24 = (r"""
|====|_|======| |=====|_|====|
| /___\ | | /___\ |
| |===| |===========| |===| |
| | | |
| +---+ | _ _ | +---+ |
| | | | (~) (~) | | | |
| | | | |_| |_| | | | |
| | | | | |
| +---+ +---+ |
| | _ _ | |
|=============| (~) (~) |============|
| | |_| |_| | |
| |
| |
| | _ _ | |
|=============| (~) (~) |============|
|=============| |_| |_| |============|
| |
|====| |====|
|====|^|====| """,
(20, 19, 2, 52, 31))
alfheim_entities = (
[0, '?', 2, 34, 20, 'stand by'],
["alfeim_charretier", '*', 2, 23, 17, 'stand by'],
[0, '*', 2, 11, 4, 'stand by'],
[0, '*', 2, 46, 6, 'stand by'],
[0, '*', 2, 27, 54, 'stand by'],
["Sagriel", '*', 23, 23, 5, 'stand by'],
["Diomwar", '*', 24, 36, 12, 'stand by'],
[0, '*', 24, 12, 3, 'stand by'],
)

@ -1,467 +0,0 @@
# Asci (1.8.2)
class Asci:
def __init__(self, maps, entities, events_mapping, keys_mapping, behaviors=None, screen_width=21, screen_height=7):
# Load maps and entities
self.maps = [Map(*i) for i in maps]
self.entities = {}
entity_id = 0
for i in entities:
if not i[0]:
i[0] = entity_id
entity_id += 1
if i[0] in self.entities: raise KeyError("'{}' is already a registered entities".format(i[0]))
else: self.entities[i[0]] = Entity(*i)
# Custom functions
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)}
# Custom entities behavior
self._behaviors = {"permanent": permanent, "stand by": stand_by, "follow": follow, "walk between": walk_between, "walk to": walk_to, "follow by player": follow_by_player}
if behaviors:
for i in behaviors: self._behaviors[i] = behaviors[i]
# Screen initialisation
self.screen = Screen(screen_width, screen_height)
self.current_map = None
def _looked_case(self, direction):
if direction == 1: # Left
return self.data[2] - 1, self.data[3]
elif direction == 3: # Right
return self.data[2] + 1, self.data[3]
elif direction == 5: # Up
return self.data[2], self.data[3] - 1
elif direction == 2: # Down
return self.data[2], self.data[3] + 1
return self.data[2], self.data[3]
def _cell_test(self, direction):
if direction == 1:
if self.data[2] - 1 < 0: return -1
else: cell = self.screen.get_cell(self.data[2] - 1, self.data[3])
if direction == 3:
if self.data[2] + 1 >= self.map_width: return -1
else: cell = self.screen.get_cell(self.data[2] + 1, self.data[3])
if direction == 5:
if self.data[3] - 1 < 0: return -1
else: cell = self.screen.get_cell(self.data[2], self.data[3] - 1)
if direction == 2:
if self.data[3] + 1 >= self.map_height: return -1
else: cell = self.screen.get_cell(self.data[2], self.data[3] + 1)
cell_patterns = self._legend
for pattern_index in range(len(cell_patterns)):
if cell in cell_patterns[pattern_index]: return pattern_index
return -1
def _keyboard(self, key, interaction=True):
# Interaction while moving
if key in (1, 3, 5, 2):
cell_test = self._cell_test(key)
# Move
if cell_test == len(self._legend) - 1:
if key == 1: self.data[2] -= 1
if key == 3: self.data[2] += 1
if key == 5: self.data[3] -= 1
if key == 2: self.data[3] += 1
# Change map
elif interaction and cell_test == len(self._legend) - 2:
new_map, self.data[2], self.data[3] = self._get_map(key)
if self.data[1] != new_map: self._change_map(new_map)
# Interaction
elif interaction and cell_test >= 0: self._interaction(key, cell_test)
# Custom functions
elif key in self._game_keys_mapping:
self.screen.clear()
self._game_keys_mapping[key](self.data, self.stat)
def _get_map(self, direction):
current_coords = self._looked_case(direction)
for coords in self.current_map.coords:
if coords[:2] == current_coords:
return coords[2], coords[3], coords[4]
return self.data[1], self.data[2], self.data[3]
def _change_map(self, new_map):
# Update map id and data
old_map, self.data[1] = self.data[1], new_map
self.current_map = self.maps[self.data[1]]
self.current_map.entities = {}
# Update entities
for i in self.entities:
entity = self.entities[i]
if entity.map_id == old_map and entity.behavior == "follow":
entity.pos_x = entity.pos_y = -1
entity.map_id = new_map
if entity.map_id == new_map: self.current_map.entities[i] = entity
# Update screen configuration
self.screen.set_world(self.current_map.map_data)
self.map_width, self.map_height = self.screen.get_map_size()
def _interaction(self, direction, cell_content):
x, y = self._looked_case(direction)
data_copy = [self.data[0], self.data[1], x, y, self.data[4]]
# Get the event
event = self._game_events_mapping[cell_content](data_copy, self.stat, self.current_map.entities, self._get_entity_id(x, y))
if type(event) == tuple:
quest, event = event
else:
quest = "main"
# data modification
self.data[0] = data_copy[0]
if self.data[1] != data_copy[1]:
self._change_map(data_copy[1])
if data_copy[2] != x: self.data[2] = data_copy[2]
if data_copy[3] != y: self.data[3] = data_copy[3]
if not event: return
event = read_event(self.data, event, quest)
# XP and stat modification
self.data[0][quest] += event.xp
for index, value in event.stat:
self.stat[index] += value
# Display and get answer
if event.text:
answer_selected = convert(self.screen.display_text(event.text), True)
if event.answer and (0 < answer_selected <= event.answer):
self.data[0][quest] += answer_selected
self._interaction(direction, cell_content)
def _get_entity_id(self, x, y):
for entity in self.current_map.entities.values():
if entity.pos_x == x and entity.pos_y == y:
return entity.entity_id
# Mainloop
def mainloop(self, end_game, stat=None, data=None, routine=None, low_bar=None, player="@", door="^", walkable=" ", exit_key=9, multi_move="."):
if exit_key in self._game_keys_mapping:
raise ValueError("'{}' is already assigned to a function.".format(exit_key))
# Load save ; data = [XP, map_id, x, y]
if not stat or type(stat) != list: self.stat = [100]
else: self.stat = stat
if not data: self.data = [{"main": 0}, 0, 0, 0, 0]
else: self.data = [data[0], data[1], data[2], data[3], 0]
# Configuration
self._legend.append(door)
self._legend.append(walkable)
self._change_map(self.data[1])
self.screen.load_data(self.data)
key = 0
while key != exit_key and self.stat[0] > 0 and self.data[0]["main"] < end_game:
# Update the map
self.screen.set_screen()
# Compute the player's and entities' positions
data_copy = self.data[:]
for entity in self.current_map.entities.values():
self._behaviors[entity.behavior](entity, data_copy, self.stat, self.screen, walkable)
if entity.map_id == self.data[1] and (0 <= entity.pos_x - self.data[2] + 10 < self.screen.screen_width) and (0 <= entity.pos_y - self.data[3] + 3 < self.screen.screen_height):
self.screen.set_cell(entity.pos_x, entity.pos_y, entity.symbol)
self.screen.set_cell(self.data[2], self.data[3], player)
# Display map, low bar, get the key and update key buffer
if low_bar: bar = low_bar(self.data[:], self.stat[:])
else: bar = None
key = convert(self.screen.display(low_bar=bar))
if not key: key = self.data[4]
else: self.data[4] = key
# Multi-move and key gestion
if type(key) == str and key[0] == multi_move:
key = key[1:]
for k, r in get_multi_move(key):
for _ in range(r):
self._keyboard(k, False)
self.screen.set_screen()
self.data[4] = k
else:
self._keyboard(key)
# Launching the game routine
if routine:
data_copy = self.data[:]
routine(data_copy, self.stat)
if self.stat[0] <= 0: self.stat[0] = 100
return self.stat, self.data[:-1]
# Classes used by Asci
class Screen:
def __init__(self, screen_width=21, screen_height=7):
# Screen configuration
self.screen_width = screen_width
self.screen_height = screen_height
self._on_screen = [[" " for _ in range(screen_width)] for _ in range(screen_height)]
self._asci_data = []
def load_data(self, data):
self._asci_data = data
def get_map_size(self):
return self.map_width, self.map_height
def set_world(self, world):
self._world = [[char for char in line] for line in world.split("\n")[1:]]
self.map_width = max([len(line) for line in self._world])
self.map_height = len(self._world)
def set_screen(self):
x = self._asci_data[2] - 10 ; y = self._asci_data[3] - 3
for x_map in range(x, x + self.screen_width):
for y_map in range(y, y + self.screen_height):
self._on_screen[y_map - y][x_map - x] = " "
if 0 <= x_map < self.map_width and 0 <= y_map < self.map_height:
try: self._on_screen[y_map - y][x_map - x] = self._world[y_map][x_map]
except: pass
def display(self, return_input=True, low_bar=None):
for line_no in range(len(self._on_screen)):
line = "".join(self._on_screen[line_no])
if line_no + 1 == self.screen_height and return_input:
if not low_bar: line = line[:-6] + ">"
else: line = low_bar + ">"
print(line, end="")
return input()
else:
print(line)
def clear(self):
print("\n" * self.screen_height)
def display_text(self, string):
paragraphs = [i for i in text_formater(string) if i]
nb_par = len(paragraphs)
for index in range(nb_par):
self.clear()
print(paragraphs[index])
if index + 1 == nb_par: return input(">")
else: input()
def set_cell(self, x, y, value):
x = x - (self._asci_data[2] - 10)
y = y - (self._asci_data[3] - 3)
if 0 <= x < self.screen_width and 0 <= y < self.screen_height:
self._on_screen[y][x] = value
def get_cell(self, x, y):
x = x - (self._asci_data[2] - 10)
y = y - (self._asci_data[3] - 3)
if 0 <= x < self.screen_width and 0 <= y < self.screen_height:
return self._on_screen[y][x]
else: return " "
class Event:
def __init__(self, xp, text, answer=0, *stat):
self.xp = xp
self.text = text
self.answer = answer
self.stat = stat
class Map:
def __init__(self, map_data, *coords):
self.map_data = map_data
self.coords = coords
self.entities = {}
class Entity:
def __init__(self, entity_id, symbol, map_id, x, y, behavior, *args):
self.entity_id = entity_id
self.symbol = symbol
self.map_id = map_id
self.pos_x = x
self.pos_y = y
self.behavior = behavior
self.args = list(args)
def change_behavior(self, new_behavior):
if self.behavior != "permanent": self.behavior = new_behavior
def teleport(self, map_id, x, y):
if self.behavio != "permanent": self.map_id, self.pos_x, self.pos_y = map_id, x, y
# Functions used by Asci
def convert(string, force_int=False):
try: return int(string)
except:
if force_int: return 0
else: return string
def text_formater(string, screen_width=21, screen_height=6):
def line_formater(string, screen_width):
string_result = ""
while len(string) > screen_width:
stop_index = screen_width
while stop_index > 0 and not string[stop_index].isspace(): stop_index -= 1
if not stop_index: stop_index = screen_width
string_result += string[:stop_index].strip() + "\n"
string = string[stop_index:].strip()
return string_result + string
def paragraph_formater(lines, screen_height):
paragraphs = ""
while len(lines) >= screen_height:
paragraphs += "\n".join(lines[:screen_height]) + "\n\n"
lines = lines[screen_height:]
return paragraphs + "\n".join(lines)
lines = []
for line in string.split("\n"):
for formated_line in line_formater(line, screen_width).split("\n"):
lines.append(formated_line)
return paragraph_formater(lines, screen_height).split("\n\n")
def read_event(data, event, quest):
if not quest in data[0]:
data[0][quest] = 0
if type(event) == dict:
if data[0][quest] in event: event = event[data[0][quest]]
else: event = event["base"]
if type(event) != list:
raise TypeError("event is of type {} instead of list".format(type(event)))
return Event(*event)
def get_multi_move(key):
if "," in key:
result = []
for k in key.split(","):
if "*" in k:
k = k.split("*")
result.append((convert(k[0]), convert(k[1])))
else:
result.append((convert(k), 1))
return result
elif "*" in key:
key = key.split("*")
return [(convert(key[0]), convert(key[1]))]
else:
return [(convert(k), 1) for k in key]
# Extra functions
def print_text(text, min_value=0, max_value=0, default_value=0):
paragraphs = [i for i in text_formater(text) if i]
nb = len(paragraphs)
for index in range(nb):
print("\n" * 7)
print(paragraphs[index])
if index + 1 == nb and (min_value or max_value or default_value) and min_value <= max_value:
result = input(">")
try: result = int(result)
except: result = default_value
if not (min_value <= result <= max_value): result = default_value
return result
else: input()
def stand_by(entity, data, stat, screen, walkable):
pass
def permanent(entity, data, stat, screen, walkable):
pass
def follow(entity, data, stat, screen, walkable):
if entity.pos_x == entity.pos_y == -1:
entity.pos_x, entity.pos_y = data[2], data[3]
elif data[4] in (1, 2, 3, 5):
if entity.args: walkable += entity.args[0]
cases = ((data[2] + 1, data[3]), (data[2], data[3] - 1), (data[2] - 1, data[3]), 0, (data[2], data[3] + 1))[data[4] - 1]
if not (0 <= cases[0] < screen.map_width and 0 <= cases[1] < screen.map_height): entity.pos_x, entity.pos_y = data[2], data[3]
elif screen.get_cell(cases[0], cases[1]) in walkable: entity.pos_x, entity.pos_y = cases
def walk_between(entity, data, stat, screen, walkable):
frame = (entity.args[0] + 1) % len(entity.args[1])
new_x, new_y = _walk_engine(entity, frame)
if screen.get_cell(new_x, new_y) in walkable:
entity.pos_x, entity.pos_y = new_x, new_y
entity.args[0] = frame
def walk_to(entity, data, stat, screen, walkable):
frame = entity.args[0]
if len(entity.args[1]) == frame:
entity.behavior = "stand by"
entity.args = []
return
new_x, new_y = _walk_engine(entity, frame)
if screen.get_cell(new_x, new_y) in walkable:
entity.pos_x, entity.pos_y = new_x, new_y
entity.args[0] += 1
def follow_by_player(entity, data, stat, screen, walkable):
frame = entity.args[0]
if len(entity.args[1]) == frame:
entity.behavior = "stand by"
entity.args = []
return
new_x, new_y = _walk_engine(entity, frame)
if abs(data[2] - new_x) < 5 and abs(data[3] - new_y) < 3 and screen.get_cell(new_x, new_y) in walkable:
entity.pos_x, entity.pos_y = new_x, new_y
if (new_x, new_y) == entity.args[1][frame]: entity.args[0] += 1
def _walk_engine(entity, frame):
delta_x, delta_y = list(map(lambda x,y: y - x, (entity.pos_x, entity.pos_y), entity.args[1][frame]))
new_x = entity.pos_x
new_y = entity.pos_y
if delta_x: new_x += abs(delta_x) // delta_x
if delta_y: new_y += abs(delta_y) // delta_y
return new_x, new_y

@ -1,428 +0,0 @@
asgard = (r"""
/\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
/\ / \ /\ / \ /\ / \ /\ / \ /\ / \ /\ / \ /\ / \ /\ / \ /\ / \ /\ / \ /\ / \ /\ / \ /\ / \ /\ / \ /\ / \
\ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /
\ /\ / \ /\ / \ /\ / \ / \ / \ / \ /\ / \ /\ / \ /\ / \ /\ / \ / \ / \ / \ / \ /\ /
/ \ / \ / \ / \ / \ / \ / \ \ / \ / \ / \ / / \
/\ / \ /\ / \ /\ / \ /\ /\ / \ /\ / \ /\ / \ /\ / \ / \/ \/ \/ \/ /\ / \
\ / \ / \ / / \ / \ _ / \ / \ / \ / / \ /
\ / \ / \ / / \ /\ / \ /\ /o\ / \ / \ / \ / / \ /\ /
\ / /\ \ / \ _______ / ~\ / \ |_| \ / \ / \ / ___________________________ / / \
/ \ /\ /Glitnir\ /\ / ~~\ /\ / \ /\ /\ \/ \/ /___________________________\ \
/ \ / \ |__|^|__| / \ ~~ / \ / \ / \ /\ /\ | Valaskjalf | /\ \
/\ / \ /\ /\ / \ /\~/ \ /\ / \ /\ / \ / \ / \ /_______________________________\ / \
/ \ / \ / \ / \~ \ \ \ \ \ / \ /\ / \ |_/ \_/ \_/ _ \_/ \_/ \_| /\ / \ /\
/\ /\ / \ /\ / \ / \ / \~ / \ / \ \ / / \ /\ \ |_| |_| |_|/^\|_| |_| |_| / \ /
/ \ / \ / \ / ~ \ / \ / \ / \ | | / \ /\ /
/ \/ \ /\ / \ ### _ ~ _________ / /\ / \ /\ -|--|--|--|-/ | /\ / / \
/ \ ##### ## /o\ ~ /Gladsheim\ / \ / \ / / / \ / \
/\ / \ ### #### |_| ~~ ## |<o> _ <o>| ## / \ /\ / \ | |--|--|--|--|- /\ / \ /\ / /\\
/ \~ /-\ ## ###### ------- #### |___|^|___| #### / / \ \ \ / \ / \ / \
/\ / \~ #### ###### ###### ###### / \ /\ -|--|--|--|--| | / \ /\ / \ / \
/ \ ~~ ###### #### ###### ###### / /\ / \ / / / \ \/ \
/ \ /\ ~~ ### ###### || -------- #### #### /\ / \ \ | |--|--|--|--|- /\ / \ /\
\ / \ ~~ ##### #### ## ~~~ || __ || / \ \ \ \ /\ / \ /\ \/ \
\ /\ / \ ~~ ### || #### ~~~~ / \ ## / \ /\ -|--|--|--|--| | / \ /\ / \ \ /\
/ \ ~~ /-\ ###### ~~~ |__| _ #### /\ / \ / / \ \ \ / \
/ \ ~~ ### ###### ~~~~ / \ ###### /\ / \ \ /\ /\ / \ /\ / \
## ## ~~ ##### #### ### ~~~~~~ |_| ###### _ / \ \ /\ / \ / \ /\ /\ / \ / \
### #### ~~ ________ ### || ##### ~~~~~~ #### /o\ / \ / \ / / \ / \ /\ / \ /\ /
#### ###### ~~ / Ydalir \ /-\ ### ~~~~~ || |_| / \ / \ / / \ /\/ \/ \ /
#### ###### ~~~ /__________\ ### /-\ ~~~~~ / / \ / \ /
### #### ~~ |_//^^\\_| ##### ~~~ ### _________ / \ /\ / \/
|| ## || ~~ |_| |_| _ ### ### ~~~~~ | | ##### /Folkvangr\ / \ ~/\
#### ~~~ |_| |_| /o\ /-\ ##### ~~~~~| | ### |<o> _ <o>| _ / \ ~~/ \
###### _ ~~~ |_| ### ______ ~~| | /-\ |___|^|___| /o\ ~~~~~/
###### /o\ ~~~ /-\ /Noatun\ | |~~ ### |_| _ ~~/\ /
#### |_| ~~~~~~~~~~~~~~~~~ |_/^^\_| ### | |~~~~~~ ##### ##### /o\ ~~/ \
|| ~~~~~~~~~~~~~~~~~~~~~~ | | ##### | ~~~~~ ### ### ######### |_| ~~/ \ /\
## ___________ ~~~~~~~~| | ### ~~~~~ /-\ ##### _ #Landivi# ~/ \ /
#### /Breidablik \ ~| |~~~~ /-\ ~~~~~~ ### /o\ ######### ~~~ /
##### |o|o|o|o|o|o| ### | | ~~~~~~~~~~~~~ ~~~~~~ /-\ |_| ##### ~~~~ /\ /
##### /_____________\ ##### ### ### ~~~~~~~~~~~~ ~~~~~~~~ |^| _ ~~~~~ / \ /\
#### |_/ \_/ \_| ### ##### ##### ### ~~~~~~~~~~~~~~~~ ~~~~~~~~~ /o\ ~~~~ / \ / \
|| |_| |^| |_| /-\ ### ### ### ##### ~~~~~~~~~~~~~~| |~~~~~~~~~~~~~~~ |_| ~~~~ / \ / \
## /-\ /-\ ##### ### ~~~~~~~| |~~~~~~~~~~~~~~~~~~ ~~~~ / /
#### ### ### /-\ ~~~~~~~~~~~~~ ~~~~~ /\ /
###### ##### ### ### ### /-\ ### ___________ ~~~~~~~~~~ ~~~~~~ / \ /
###### ### ##### ##### ##### ~~~ ##### /Thrymrheimr\ ~~~~~~~~~~~~~~~~~~ /\ / \ /
#### _ ### /-\ ### ### ### ~(~)~ ### /_____________\ _ ~~~~~~~~~~~~~~ ### / \ \
|| /o\ ##### /-\ /-\ /-\ /~(___)~\ /-\ |_/ \_/ \_| ### ### /o\ ~~~~~~~~~~~ ##### / \ /\
## |_| ### \~~~~~~~/ |_| |^| |_| ##### ##### |_| ~~~~~~~~~~ ### / \ / \
~ #### /-\ ### ### ### ~~~~~~~~~~ /|\ ### / \
~###### ____________ #### #### ### /-\ /|\ ### ##### ~~~~~~~~~~ ### ##### /\ \
~###### / Himinbjorg \ #### #### ##### ### ### ##### ### ~~~~~~~~ ##### ### / \
~ #### /______________\ ### ### ### ##### ##### ### ### /|\ ~~~~~~~~~ _ ### /|\ / \ /
~ || ### | ]O[ __ ]O[ | /-\ ### ### _ ##### _ /|\ ~~~~~~~~~ /o\ /|\ / \ /
~ _ ##### |_____|^^|_____| ### ### ### /-\ /-\ ### /o\ ### /o\ ------------- |_| ### /
~ /o\ ### ##### #### #### ##### |_| /|\ |_| ### ##### ###/
~ |_| /-\ ### #### #### ### ### ##### ### #####
~ /-\ ##### ### /-\ ### ### ------------- /|\ ###
~~ ### ### _ ### ### ##### ##### /|\ ~~~~~~~ ### /|\ ###
~~ ##### ##### ### ### ### /o\ /-\ ##### ### ### ### ~~~~~~~ ### ##### ####
~~ ### ### ##### ##### ##### |_| ### ### /-\ ##### ### /|\ ### ~~~~~~ ### ##### ### ###
~~ /-\ /-\ ### ### ### ___________ /-\ ##### ### ##### ##### ~~~~~ ##### ### /|\ /|\
~~ |_| |_| |_| /Sokkvabekkr\ ### /|\ ### ### ~~~~~~ ### /|\ ###
~~ /_____________\ /-\ ### /|\ /|\ ~~~~~~~ /|\ ### #####
~~ ________ ### ### ### _ /_|_/__\_/__\_|_\ ##### ### ### ~~~~~~~~ ##### ###
~~ /Alfheimr\ ##### ##### ##### /o\ |_| |^| |_| _ ### ##### ### ##### ~~~~~~~~ ### /|\
~~~ |]O[__]O[| ### ### ### |_| /o\ /-\ ### ##### ### ~~~~~~~~~ _ /|\ ###
~~~ |__|^^|__| |_| |_| |_| ##### ##### |_| /-\ ### /|\ ~~~~~~~~~~ _ /o\ #####
~~~ ##### ##### /|\ ~~~~~~~~~~ /-\ |_| ### ~
~~~ ~~~~~~~~~~~~ |_| /|\ ~~
~~~~~ ~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""",
# Autres mondes (Asgard = 0)
(126, 71, 3, 72, 6), # Midgard
# Maisons
( 30, 11, 9, 15, 13), # Glitnir
(116, 14, 10, 29, 23), # Valaskjalf
( 70, 19, 11, 24, 19), # Gladsheim
( 25, 31, 12, 24, 19), # Ydalir (1/2)
( 26, 31, 12, 25, 19), # Ydalir (2/2)
(110, 34, 13, 20, 14), # Folkvangr
( 63, 36, 14, 14, 14), # Noatun (1/2)
( 64, 36, 14, 15, 14), # Noatun (2/2)
(120, 41, 15, 14, 14), # Landivi
( 13, 43, 16, 29, 29), # Breidablik
( 75, 50, 17, 24, 24), # Thrymrheimr
( 27, 56, 18, 24, 24), # Himinbjorg (1/2)
( 28, 56, 18, 25, 24), # Himinbjorg (2/2)
( 57, 67, 19, 25, 14), # Sokkvabekkr
( 10, 69, 20, 34, 24), # Alfheimr (1/2)
( 11, 69, 20, 35, 24), # Alfheimr (2/2)
)
h_9 = (r"""
|==========|
|[===][===]|
| |
| |
|=========| |=========|
| |
| _ _ _ _ |
| |_| |_| |_| |_| |
| |_| |_| |_| |_| |
| |_| |_| |_| |_| |
| |
|============| |=============|
| |
||^|| """,
(15, 13, 0, 30, 11))
h_10 = (r"""
|====================================================|
| |
| |
| |
| |================\ /=================| |
| | | |
| | | |
| \ __ / |
| |<>| |
| |__| |
| /____\ \ |
| / | |
| | | |
| | | |
| |================/ \=================| |
| |
| |
| |
|_______________________ _______________________|
|__/ \__/ \__/ \__/ \__/ \__|
|__| |__| |__| |__| |__| |__|
|__| |__| |__| |__| |__| |__|
|__| |__| |__| |__| |__| |__|
/__\ /__\ /__\__^^__/__\ /__\ /__\ """,
(29, 23, 0, 116, 14),
(30, 23, 0, 116, 14))
h_11 = (r"""
|============================|
| _ |
| |o| |
| /___\ |
| (___ ___) |
| (____ ____) |
|=========| (_____ _____) |========|
| |
| |
| __ ### __ |
| |__| +-#####-+ |__| |
| |__| | ### | |__| |
| |__| | /|\ | |__| |
| |__| +-------+ |__| |
| |__| |__| |
| |
| |
|======================| |======================|
|=+<>+=+<>+=+<>+=+<>+==| |==+<>+=+<>+=+<>+=+<>+=|
|^| """,
(24, 19, 0, 70, 19))
h_12 = (r"""
|=-=-=-=-=-=-=-=-=-=-=-=-=-=-|
| __ |
| |()| |
| |__| |
| |====| |
| |
| ~~~~ |
|=-=-=-=-=| ~~\/~~ |=-=-=-=-=|
| [=====] /~~~||~~~\ [=====] |
| [=====] [==========] [=====] |
| _ _ |
| (_) (_) |
| _ /_\ /_\ _ |
| (_) (_) |
| /_\ ______ ______ /_\ |
| \- - / \ - -/ |
|-=-=-=-=-=-| - -| |- - |-=-=-=-=-=-|
|=-=-=-=-=-=|- - | | - -|=-=-=-=-=-=|
| - -| |- - |
/- - \_____|^^|_____/ - -\ """,
(24, 19, 0, 25, 31),
(25, 19, 0, 26, 31))
h_13 = (r"""
||
|===================================||==|
|================|===o===o===o=====/ \=|
|[==-==/ \==-==]| |__| |
|[-===/ \==--]| _ |
|[=-=/ \-==]| |o| __ |
|[==/ \==]| (___) | | |
| | |__| |
|======/ \======| | | |
| |__| |
| | | |
| |__| |
| |
|==================| |==================|
|^| """,
(20, 14, 0, 110, 34))
h_14 = (r"""
|=|\/|==|\/|=|\/|=|\/|==|\/|=|
| |
| |
| |
| |================| |
| | __ __ | |
| | | | | | | |
| | |__| |__| | |
| | | |
| |======\ /======| |
|### ###|
|### ###|
||_| |_||
|=|\/|==|\/|=| |=|\/|==|\/|=|
|^^| """,
(14, 14, 0, 63, 36),
(15, 14, 0, 64, 36))
h_15 = (r"""
#########
## [=====] ##
# [=====] #
# #
#_ _#
#(_) [] (_)#
#|~| |__| |~|#
# #
# _ _ #
# (_) (_) #
#|~| |~|#
## ##
#### ####
| |
|^| """,
(14, 14, 0, 120, 41))
h_16 = (r"""
|======================================|
| |
| |
| ### ~~~~ ### |
| ##### ~(~~)~ ##### |
| ##### /~~~(____)~~~\ ##### |
| ### \~~~~~~~~~~~~/ ### |
| |=| |============| |=| |
| |
|========\ /========|
|==================| |==================|
| [=====][=====] | | [=====][=====] |
| [=====][=====] _ _ [=====][=====] |
| (_) (_) |
| |=| |=| |
| ___ ___ ___ ___ |
| | | | | | | | | |
| |___| |___| _ _ |___| |___| |
| | | | | (_) (_) | | | | |
| |___| |___| |=| |=| |___| |___| |
| | | | | | | | | |
| |___| |___| |___| |___| |
| | | | | _ _ | | | | |
| |___| |___| (_) (_) |___| |___| |
| |=| |=| |
| |
| |======| |=======| |
|===================| _ | | _ |===================|
(_) | | (_)
|=| |/^\| |=| """,
(29, 29, 0, 13, 43))
h_17 = (r"""
### |============================| ###
##### | | #####
### | | ###
|_| | ~~~~~~~~~~~~~~~~~~ | |_|
| ~~~~~~~~~~~~~~~~~~~~ |
### | ~~~~~~~~~~~~~~~~~~~~ | ###
##### | ~~~~~~~~~~~~~~~~~~~~ | #####
### | ~~~~~~~~~~~~~~~~~~ | ###
|_| | | |_|
| |
|===================/ \===================|
| |
| _ _ _ _ |
| (-) (-) (-) (-) |
| |_| |_| |_| |_| |
| |
| |
| |
| |
| _ _ _ _ |
| (-) (-) (-) (-) |
| |_| |_| |_| |_| |
| |
|======================| |=======================|
|^| """,
(24, 24, 0, 75, 50))
h_18 = (r"""
|================================================|
|================================================|
| |
| |
| __ __ |
| (~~) (~~) |
| |--| __ |--| |
| | | |<>| | | |
| | | |--| | | |
| |__| |____| |__| |
| |
| |
| __ __ |
| (~~) ## (~~) |
| |--| #### |--| |
| | | #### | | |
| | | ## | | |
| |__| || |__| |
| |
| |
| |
|=====================\| |/=====================|
|=====================/| |\=====================|
\| |/
/|^^|\ """,
(24, 24, 0, 27, 56),
(25, 24, 0, 28, 56))
h_19 = (r"""
|================================================|
| |
| ########## |
| ########## |
| ###### ###### |
| ###### __ |===[]===| __ ###### |
| (__) | |__| | (__) |
| |--| | | |--| |
| |__| | | |__| |
| ###### |==/ \==| ###### |
| ###### ###### |
| |
| |
| |
|=======================|^|======================|""",
(25, 14, 0, 57, 67))
h_20 = (r"""
|============================|
| |
| _ _ |
|===================| (-) (-) |
| | |_| __ |_| |
| | |[]| |
| ~~~ | | | |
| ~~~(~)~~~ | _ |____| _ |
| /~~(_____)~~\ | (-) (-) |
| \___________/ | |_| |_| |
| |
| |
| |
| |
| |
| ~~~ | _ _ |
| ~~~(~)~~~ | (-) (-) |
| /~~(_____)~~\ | |_| |_| |
| \___________/ | |
| | |
| | _ _ |
|===================| (-) (-) |
| |_| |_| |
| |
|============|^^|============|""",
(34, 24, 0, 10, 69),
(35, 24, 0, 11, 69))
asgard_entities = (
[0, '?', 0, 120, 26, 'stand by'],
[0, '?', 0, 51, 55, 'stand by'],
[0, '*', 0, 34, 7, 'stand by'],
[0, '*', 0, 121, 21, 'stand by'],
[0, '*', 0, 117, 32, 'stand by'],
[0, '*', 0, 29, 13, 'stand by'],
[0, '*', 0, 19, 20, 'stand by'],
[0, '*', 0, 28, 26, 'stand by'],
[0, '*', 0, 46, 35, 'stand by'],
[0, '*', 0, 57, 38, 'stand by'],
[0, '*', 0, 82, 38, 'stand by'],
[0, '*', 0, 22, 39, 'stand by'],
[0, '*', 0, 8, 44, 'stand by'],
[0, '*', 0, 58, 50, 'stand by'],
[0, '*', 0, 83, 51, 'stand by'],
[0, '*', 0, 32, 59, 'stand by'],
[0, '*', 0, 104, 63, 'stand by'],
[0, '*', 0, 46, 65, 'stand by'],
[0, '*', 0, 16, 71, 'stand by'],
[0, '*', 0, 138, 71, 'stand by'],
["Forseti", '*', 9, 19, 4, 'stand by'],
["Odin", '*', 10, 25, 11, 'stand by'],
[0, '*', 11, 34, 7, 'stand by'],
[0, '*', 12, 19, 4, 'stand by'],
[0, '*', 13, 21, 8, 'stand by'],
[0, '*', 14, 26, 2, 'stand by'],
["Vidar", '*', 15, 10, 6, 'stand by'],
[0, '*', 16, 50, 14, 'stand by'],
[0, '*', 17, 36, 14, 'stand by'],
[0, '*', 18, 30, 9, 'stand by'],
[0, '*', 19, 28, 7, 'stand by'],
[0, '*', 20, 39, 9, 'stand by'],
)

@ -1,340 +0,0 @@
from idk_lib import *
try:
import dlc_hy_po as dlc
spells = dlc.dlc_spells
spells_level = dlc.dlc_spells_level
spells_effect = dlc.dlc_spells_effect
weapons = dlc.dlc_weapons
armors = dlc.dlc_armors
dlc_entities = dlc.dlc_entities
except:
dlc = None
dlc_entities = ()
# Game
def npc(data, stat, entities, identifiant):
npc_data = (
asgard_npc,
vanaheim_npc,
alfheim_npc,
midgard_npc,
niflheim_npc,
jotunheim_npc,
nidavellir_npc,
muspellheim_npc,
svartalfheim_npc,
h_9_npc, h_10_npc, h_11_npc, h_12_npc, h_13_npc, h_14_npc, h_15_npc, h_16_npc, h_17_npc, h_18_npc, h_19_npc, h_20_npc,
h_21_npc, h_22_npc,
h_23_npc, h_24_npc,
h_25_npc, h_26_npc, h_27_npc, h_28_npc,
h_29_npc, h_30_npc,
h_31_npc, h_32_npc, h_33_npc, h_34_npc, h_35_npc, h_36_npc,
h_37_npc, h_38_npc, h_39_npc, h_40_npc, h_41_npc,
h_42_npc, h_43_npc, h_44_npc,
h_45_npc, h_46_npc, h_47_npc, h_48_npc)
if dlc:
event = dlc.dlc_npc(data, stat, entities, identifiant)
if event: return "dlc", event
return npc_core(npc_data[data[1]], data, stat, entities, identifiant)
def point_of_interest(data, stat, entities, identifiant):
po_data = (
asgard_po,
vanaheim_po,
alfheim_po,
midgard_po,
niflheim_po,
jotunheim_po,
nidavellir_po,
muspellheim_po,
svartalfheim_po
)
coords = data[2], data[3]
event = po_data[data[1]](coords, identifiant)
if not event: return [0, "Il n'y a rien à voir ici."]
else: return event
entities = asgard_entities + vanaheim_entities + alfheim_entities + midgard_entities + niflheim_entities + jotunheim_entities + nidavellir_entities + muspellheim_entities + svartalfheim_entities + dlc_entities
print(center("L'Hydromel Poétique", 21, " "))
print("Entrez 'hy_po()' pour\nune nouvelle partie.")
events = {"*": npc, "?": point_of_interest}
keys = {4: display_stat, 7: spell, 8: misc_stat, 6: inventory, 9: sleep, "s": quick_save}
def hy_po(save_code=None):
# stat = [0 - PV, 1 - pièces d'or, 2 - [vitesse, agilité, attaque, defense, magie], 3 - [arme, armure], 4 - ticks, 5 - nom, 6 - classe, 7 - sorts connus : (id, level), 8 - sous-quêtes terminées]
if not save_code:
stat = init_stat()
name = stat[5]
data = [{"main": 0}, 3, 44, 66]
print_text("introduction")
else:
stat, data = decode_save(save_code)
idk_game = Asci(maps, entities, events, keys)
stat, data = idk_game.mainloop(1, stat, data, routine=routine, low_bar=low_bar, door="^_", walkable=".,`' ", exit_key="q")
if stat[9] != -1: data[0]["main"] -= stat[9]
if data[0]["main"] == 1:
print_text("conclusion")
else:
print("hy_po(\"{}\")".format(encode_save(data, stat[:-1])))
# Scenario
def shop_interaction(data, stat, nb_choice, *events):
for choice in range(nb_choice):
if data[0]["main"] == stat[9] + choice + 1:
stat[9] = -1
if stat[1] < events[choice][0]: return events[choice][2], choice + 1
else: return events[choice][1], choice + 1
# - - - Asgard - - - #
def asgard_po(coords, identifiant):
pass
def asgard_npc(data, stat, entites, identifiant):
pass
def h_9_npc(data, stat, entites, identifiant):
pass
def h_10_npc(data, stat, entites, identifiant):
pass
def h_11_npc(data, stat, entites, identifiant):
pass
def h_12_npc(data, stat, entites, identifiant):
pass
def h_13_npc(data, stat, entites, identifiant):
pass
def h_14_npc(data, stat, entites, identifiant):
pass
def h_15_npc(data, stat, entites, identifiant):
pass