From a6e8ac6c86ccb66a5366f3ae18dddd2b96234147 Mon Sep 17 00:00:00 2001 From: Shadow15510 Date: Fri, 10 Jun 2022 10:36:11 +0200 Subject: [PATCH] Fix bug with houses and shops --- idk/asci.py | 22 ++++++++++++---------- idk/idk.py | 8 ++++---- idk/nidavellir.py | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/idk/asci.py b/idk/asci.py index a90d213..e1aa917 100644 --- a/idk/asci.py +++ b/idk/asci.py @@ -1,4 +1,4 @@ -# Asci (1.8.2) +# Asci (1.8.3) class Asci: def __init__(self, maps, entities, events_mapping, keys_mapping, behaviors=None, screen_width=21, screen_height=7): @@ -182,7 +182,7 @@ class Asci: 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): + if entity.map_id == self.data[1] and (0 <= entity.pos_x - self.data[2] + self.screen.pos_player[0] < self.screen.screen_width) and (0 <= entity.pos_y - self.data[3] + self.screen.pos_player[1] < 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) @@ -221,6 +221,7 @@ class Screen: # Screen configuration self.screen_width = screen_width self.screen_height = screen_height + self.pos_player = (screen_width // 2, screen_height // 2) self._on_screen = [[" " for _ in range(screen_width)] for _ in range(screen_height)] self._asci_data = [] @@ -236,7 +237,7 @@ class Screen: self.map_height = len(self._world) def set_screen(self): - x = self._asci_data[2] - 10 ; y = self._asci_data[3] - 3 + x = self._asci_data[2] - self.pos_player[0] ; y = self._asci_data[3] - self.pos_player[1] 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] = " " @@ -259,7 +260,7 @@ class Screen: print("\n" * self.screen_height) def display_text(self, string): - paragraphs = [i for i in text_formater(string) if i] + paragraphs = [i for i in text_formater(string, self.screen_width, self.screen_height) if i] nb_par = len(paragraphs) for index in range(nb_par): self.clear() @@ -268,18 +269,19 @@ class Screen: else: input() def set_cell(self, x, y, value): - x = x - (self._asci_data[2] - 10) - y = y - (self._asci_data[3] - 3) + x = x - (self._asci_data[2] - self.pos_player[0]) + y = y - (self._asci_data[3] - self.pos_player[1]) 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) + x = x - (self._asci_data[2] - self.pos_player[0]) + y = y - (self._asci_data[3] - self.pos_player[1]) 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 @@ -386,8 +388,8 @@ def get_multi_move(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] +def print_text(text, min_value=0, max_value=0, default_value=0, screen_width=21, screen_height=7): + paragraphs = [i for i in text_formater(text, screen_width, screen_height) if i] nb = len(paragraphs) for index in range(nb): print("\n" * 7) diff --git a/idk/idk.py b/idk/idk.py index f741873..35ddb15 100644 --- a/idk/idk.py +++ b/idk/idk.py @@ -577,11 +577,11 @@ def h_24_npc(data, stat, entites, identifiant): break if spell_id == -1: - stat[7].append(spells_sale[i]) + stat[7].append(spell_sel) else: - stat[7][spell_id] = spells_sale[i] + stat[7][spell_id] = spell_sel - return [0, "[DIOMWAR OUVRIT UN LIVRE RELIE DE CUIR NOIR, ET TRACA DU DOIGT DES SIGNES CABALISTIQUES SUR LE SOL. LES RUNES BRILLERENT PUISSAMMENT AVANT DE S'ETEINDRE.]", 0, (1, -10 * spells_sel[1])] + return [0, "[DIOMWAR OUVRIT UN LIVRE RELIE DE CUIR NOIR, ET TRACA DU DOIGT DES SIGNES CABALISTIQUES SUR LE SOL. LES RUNES BRILLERENT PUISSAMMENT AVANT DE S'ETEINDRE.]", 0, (1, -10 * spell_sel[1])] # - - - Midgard - - - # @@ -977,7 +977,7 @@ def h_39_npc(data, stat, entites, identifiant): stat[3][0] = wpn return [0, "Tres bon choix ! [LE NAIN DECROCHA L'ARME DU RATELIER ET VOUS LA TENDIT.]", 0, (1, -10 * wpn)] - if coords == (9, 4): + elif coords == (9, 4): if stat[3][0] == 0: return [0, "Vous n'avez pas d'arme a me vendre. Allez voir mon collegue pour en acheter une."] if stat[9] == -1 or data[0]["main"] == stat[9]: diff --git a/idk/nidavellir.py b/idk/nidavellir.py index e2e44eb..6769b03 100644 --- a/idk/nidavellir.py +++ b/idk/nidavellir.py @@ -172,7 +172,7 @@ h_40 = (r""" | | |=========| |==============| |==========|^|===============|""", - (12, 14, 6, 22, 22)) + (12, 14, 6, 22, 42)) h_41 = (r"""