From 7366edba3d22339ec035e5cdd4bda2e858f3e0b0 Mon Sep 17 00:00:00 2001 From: Janek Kermit Date: Sat, 4 May 2024 20:44:21 +0200 Subject: [PATCH 1/7] Improved roadmap - first iteration (DO NOT MERGE) --- pokete_classes/color.py | 4 +- pokete_classes/roadmap.py | 93 +++++-- pokete_data/mapstations.py | 496 +++++++++++++++++++++++++++++++------ 3 files changed, 490 insertions(+), 103 deletions(-) diff --git a/pokete_classes/color.py b/pokete_classes/color.py index 87cd1ab2..8035aef3 100644 --- a/pokete_classes/color.py +++ b/pokete_classes/color.py @@ -6,8 +6,8 @@ class Color: reset = "\033[0m" thicc = "\033[1m" underlined = "\033[4m" - grey = "\033[1;30m" - red = "\033[31m" + grey = "\033[38;5;237m" + red = "\033[38;5;160m" green = "\033[32m" yellow = "\033[33m" lightblue = "\033[1;34m" diff --git a/pokete_classes/roadmap.py b/pokete_classes/roadmap.py index 7c9531e0..f638f619 100644 --- a/pokete_classes/roadmap.py +++ b/pokete_classes/roadmap.py @@ -3,6 +3,9 @@ import scrap_engine as se import pokete_data as p_data import pokete_classes.ob_maps as obmp +import time +import threading +import signal from pokete_general_use_fns import liner from .hotkeys import ACTION_DIRECTIONS, Action, ActionList, get_action from .loops import std_loop, easy_exit_loop @@ -20,8 +23,40 @@ def __init__(self, _map): text = f"{_map} {_map.name} has no mapstation" super().__init__(text) - -class Station(se.Square): +"""A little hackaround""" +class StationObject(se.Box): + + def __init__(self, text, width, height, ob_class=se.Object): + super().__init__(height, width) + self.ob_class = ob_class + self.text = text + self.ob_args = {} + self.__create() + + def __create(self): + for ry in range(self.height): + for rx in range(self.width): + if len(self.text)==1: + r=0 + else: + r=ry*self.width+rx + self.add_ob( + self.ob_class( + self.text[r], self.state, arg_proto=self.ob_args + ), + rx, ry + ) + + def recolor(self, color): + r=0 + for obj in self.obs: + obj.rechar(color + self.text[r] + Color.reset) + if len(self.text)!=1: + r+=1 + + + +class Station(StationObject): """Selectable station for Roadmap ARGS: roadmap: RoadMap object @@ -35,15 +70,18 @@ class Station(se.Square): choosen = None obs = [] - def __init__(self, roadmap, associate, additionals, width, height, desc, - char="#", w_next="", a_next="", s_next="", d_next=""): + def __init__(self, roadmap, associate, additionals, width, height, desc, color="", + text="#", w_next="", a_next="", s_next="", d_next=""): self.desc = desc self.roadmap = roadmap - self.org_char = char + self.org_char = text self.associates = [associate] + [obmp.ob_maps[i] for i in additionals] - self.color = "" - self.name = self.associates[0].pretty_name - super().__init__(char, width, height, state="float") + self.color = color + if self.associates[0]: + self.name = self.associates[0].pretty_name + super().__init__(text, width, height) + self.set_color() + self.recolor(self.color) self.w_next = w_next self.a_next = a_next self.s_next = s_next @@ -52,15 +90,23 @@ def __init__(self, roadmap, associate, additionals, width, height, desc, def choose(self): """Chooses and hightlights the station""" - self.rechar(Color.red + Color.thicc + self.org_char + Color.reset) + Station.choosen = self self.roadmap.rechar_info( self.name if self.has_been_visited() else "???" ) - + threading.Thread(target = self.blink, daemon = True).start() + + def blink(self): + while Station.choosen == self: + self.recolor(Color.red+Color.thicc) + time.sleep(0.6) + self.recolor(self.color) + time.sleep(0.35) + def unchoose(self): """Unchooses the station""" - self.rechar(self.color + self.org_char + Color.reset) + self.recolor(self.color) def next(self, inp: ActionList): """Chooses the next station in a certain direction @@ -90,14 +136,15 @@ def is_city(self): in p_data.map_data[self.associates[0].name]["hard_obs"] def set_color(self, choose=False): - """Marks a station as visited - ARGS: - choose: Bool whether or not this done when choosing a city""" - if self.has_been_visited() and (self.is_city() if choose else True): - self.color = Color.yellow - else: - self.color = "" - self.unchoose() + """Marks a station as visited""" + + if self.associates[0] is not None and not self.has_been_visited() and self.is_city(): + self.text=self.text.replace("A", " ") + self.text=self.text.replace("P", " ") + self.text=self.text.replace("$", " ") + self.text=self.text.replace("C", " ") + self.text=self.text.replace("⌂", " ") + class RoadMap: @@ -108,7 +155,7 @@ class RoadMap: def __init__(self, fig): self.fig = fig self.box = Box( - 11, 40, "Roadmap", + 17, 61, "Roadmap", f"{Action.CANCEL.mapping}:close", overview=mvp.movemap ) @@ -118,6 +165,12 @@ def __init__(self, fig): obj = Station(self, obmp.ob_maps[sta], **_dict['gen']) self.box.add_ob(obj, **_dict['add']) setattr(self, sta, obj) + + for sta, _dict in p_data.decorations.items(): + obj = Station(self, None, **_dict['gen']) + self.box.add_ob(obj, **_dict['add']) + setattr(self, sta, obj) + @property def sta(self): diff --git a/pokete_data/mapstations.py b/pokete_data/mapstations.py index eef94cb6..a463a8a4 100644 --- a/pokete_data/mapstations.py +++ b/pokete_data/mapstations.py @@ -2,73 +2,83 @@ "playmap_1": { "gen": { "additionals": ["intromap"], - "width": 2, - "height": 1, + "width": 4, + "height": 3, "desc": "A small town.", - "d_next": "playmap_51" + "d_next": "playmap_51", + "text": """*P⌂ ┣━━━ ⌂⌂ """, + "color": "\033[38;5;28m" }, "add": { - "x": 4, - "y": 7 + "x": 3, + "y": 12 } }, "playmap_51": { "gen": { "additionals": [], - "width": 1, - "height": 1, + "width": 3, + "height": 2, "desc": "Some small patches of grass surrounded by forrest, near " "Nice Town.", "a_next": "playmap_1", - "w_next": "cave_1" + "w_next": "cave_1", + "text": r"""┗━┓━━┛""", + "color": "\033[38;5;22m" }, "add": { - "x": 6, - "y": 7 + "x": 7, + "y": 12 } }, "cave_1": { "gen": { "additionals": [], "width": 1, - "height": 2, + "height": 3, "desc": "A dark cave full of batos.", "s_next": "playmap_51", "d_next": "playmap_2", + "text": """▅██""", + "color": "\033[38;5;236m" }, "add": { - "x": 6, - "y": 5 + "x": 7, + "y": 9 } }, "playmap_2": { "gen": { "additionals": [], - "width": 2, + "width": 4, "height": 1, "desc": "Part of light areas near Sunny Dale.", "a_next": "cave_1", "d_next": "playmap_3", + "text": """━━━━""", + "color": "\033[38;5;28m" }, "add": { - "x": 7, - "y": 5 + "x": 8, + "y": 9 } }, "playmap_3": { "gen": { "additionals": ["playmap_49"], - "width": 2, - "height": 1, + "width": 3, + "height": 3, "desc": "A small sunny village.", "a_next": "playmap_2", "w_next": "playmap_4", "s_next": "playmap_6", + "text": """P┃$━┫⌂⌂┃⌂""", + "color": "\033[38;5;76m" }, "add": { - "x": 9, - "y": 5 + "x": 12, + "y": 8 } }, "playmap_4": { @@ -78,55 +88,63 @@ "height": 3, "desc": "The shores of the great Sunnydale lake.", "s_next": "playmap_3", - "d_next": "playmap_28" + "d_next": "playmap_28", + "text": """┣┃┃""", + "color": "\033[38;5;29m" }, "add": { - "x": 10, - "y": 2 + "x": 13, + "y": 5 } }, "playmap_6": { "gen": { "additionals": [], - "width": 1, - "height": 2, + "width": 3, + "height": 3, "desc": "The woodland edge at the foot of a great mountain full of \ caves.", "w_next": "playmap_3", "a_next": "playmap_7", "d_next": "playmap_8", + "text": """┃ ┃ ┻━━""", + "color": "\033[38;5;28m" }, "add": { - "x": 10, - "y": 6 + "x": 13, + "y": 11 } }, "playmap_7": { "gen": { "additionals": [], - "width": 1, + "width": 2, "height": 1, "desc": "A dark and mysterious cave.", "d_next": "playmap_6", + "text": """██""", + "color": "\033[38;5;236m" }, "add": { - "x": 9, - "y": 7 + "x": 11, + "y": 13 } }, "playmap_8": { "gen": { "additionals": ["playmap_10", "playmap_9"], - "width": 2, - "height": 1, + "width": 3, + "height": 2, "desc": "An abandoned fisher village.", "a_next": "playmap_6", "s_next": "playmap_11", "d_next": "playmap_12", + "text": """ ⌂ ━┳━""", + "color": "\033[38;5;136m" }, "add": { - "x": 11, - "y": 7 + "x": 16, + "y": 12 } }, "playmap_11": { @@ -136,95 +154,109 @@ "height": 1, "desc": "The shore of a lake near an olf fisher village.", "w_next": "playmap_8", + "text": """┃""", + "color": "\033[38;5;178m" }, "add": { - "x": 11, - "y": 8 + "x": 17, + "y": 14 } }, "playmap_12": { "gen": { - "width": 2, + "width": 3, "additionals": [], - "height": 1, + "height": 2, "desc": "A dense forest near Deepens forest.", "a_next": "playmap_8", "w_next": "playmap_13", + "text": """ ┃━━┛""", + "color": "\033[38;5;88m\033[1m" }, "add": { - "x": 13, - "y": 7 + "x": 19, + "y": 12 } }, "playmap_13": { "gen": { "additionals": ["playmap_14", "playmap_20"], - "width": 1, - "height": 2, + "width": 3, + "height": 3, "desc": "Deepens forest, a big town in the middle of the deepest \ forest, populated by thousands of people and cultural center of the region.", "s_next": "playmap_12", "w_next": "playmap_15", + "text": """⌂┃A⌂┃⌂P┃$""", + "color": "\033[38;5;94m\033[1m" }, "add": { - "x": 14, - "y": 5 + "x": 20, + "y": 9 } }, "playmap_15": { "gen": { "additionals": [], - "width": 2, + "width": 3, "height": 1, "desc": "A small clearing near Deepens forest.", "s_next": "playmap_13", "d_next": "playmap_16", + "text": """┏━━""", + "color": "\033[38;5;88m\033[1m" }, "add": { - "x": 14, - "y": 4 + "x": 21, + "y": 8 } }, "playmap_16": { "gen": { "additionals": ["playmap_17"], - "width": 1, + "width": 2, "height": 1, "desc": "A small 'village', that's not even worth talking about.", "a_next": "playmap_15", "d_next": "playmap_18", + "text": """━━""", + "color": "\033[38;5;154m\033[1m" }, "add": { - "x": 16, - "y": 4 + "x": 24, + "y": 8 } }, "playmap_18": { "gen": { "additionals": [], - "width": 2, + "width": 3, "height": 1, "desc": "A small see at the foot of the Big mountain.", "a_next": "playmap_16", "w_next": "playmap_19", + "text": """━━┛""", + "color": "\033[38;5;28m\033[1m" }, "add": { - "x": 17, - "y": 4 + "x": 26, + "y": 8 } }, "playmap_19": { "gen": { "additionals": [], "width": 1, - "height": 1, + "height": 2, "desc": "A dark and big cave in the Big mountain.", "s_next": "playmap_18", "w_next": "playmap_21", + "text": """██""", + "color": "\033[38;5;236m" }, "add": { - "x": 18, - "y": 3 + "x": 28, + "y": 6 } }, "playmap_21": { @@ -232,88 +264,100 @@ "additionals": ["playmap_22", "playmap_23", "playmap_24", "playmap_25", "playmap_26", "playmap_27", "playmap_29", "playmap_50"], - "width": 3, - "height": 1, + "width": 4, + "height": 3, "desc": "The great Rock-ville is the biggest city in the region \ around the Big mountain. With the Rocky hotel it's also a tourist \ hotspot.", "s_next": "playmap_19", "d_next": "playmap_33", - "w_next": "playmap_40" + "w_next": "playmap_40", + "text": """P┃⌂⌂┏┻━━┃⌂C """, + "color": "\033[38;5;246m" }, "add": { - "x": 18, - "y": 2 + "x": 28, + "y": 3 } }, "playmap_28": { "gen": { "additionals": [], - "width": 2, - "height": 1, + "width": 5, + "height": 2, "desc": "A foggy place full of ghosts and plants.", "a_next": "playmap_4", "d_next": "playmap_30", + "text": """ ┏━━━━┛ """, + "color": "\033[38;5;22m" }, "add": { - "x": 11, - "y": 3 + "x": 14, + "y": 4 } }, "playmap_30": { "gen": { "additionals": ["playmap_31", "playmap_32"], - "width": 1, - "height": 1, + "width": 4, + "height": 3, "desc": "With its plant Poketes, Flowy Town may be the greenest \ spot in the Pokete world and with the great git-tree it may also be one \ of the most spectacular.", "a_next": "playmap_28", + "text": """ $P ━━━┫⌂A⌂⌂""", + "color": "\033[38;5;34m" }, "add": { - "x": 13, + "x": 19, "y": 3 } }, "playmap_33": { "gen": { "additionals": ["playmap_34"], - "width": 1, + "width": 2, "height": 1, "desc": "Part of the great agracultural landscape near Agrawos.", "a_next": "playmap_21", "d_next": "playmap_35", + "text": """━━""", + "color": "\033[38;5;178m" }, "add": { - "x": 21, - "y": 2 + "x": 34, + "y": 4 } }, "playmap_35": { "gen": { "additionals": ["playmap_36", "playmap_37", "playmap_38"], - "width": 1, - "height": 2, + "width": 3, + "height": 3, "desc": "Part of the great agracultural landscape near Agrawos.", "a_next": "playmap_33", "s_next": "playmap_39", + "text": """━━┓┏━┛┗━┓""", + "color": "\033[38;5;154m" }, "add": { - "x": 22, - "y": 2 + "x": 36, + "y": 4 } }, "playmap_40": { "gen": { "additionals": [], - "width": 2, + "width": 1, "height": 1, "desc": "A Great beach, with great weather, always.", "s_next": "playmap_21", + "text": """┃""", + "color": "\033[38;5;178m" }, "add": { - "x": 18, - "y": 1 + "x": 29, + "y": 2 } }, "playmap_39": { @@ -321,8 +365,8 @@ "additionals": ["playmap_41", "playmap_42", "playmap_43", "playmap_44", "playmap_45", "playmap_46", "playmap_47", "playmap_48"], - "width": 2, - "height": 2, + "width": 4, + "height": 4, "desc": "The great city of Agrawos, agricultural and cultural " "center of the whole region. It's famous for its great " "Pokete-Arena and its master trainer. Check out the " @@ -330,12 +374,302 @@ "juiciest and most delicious Mowcow-burgers, cut from the " "happiest and most delicious Mowcows anywhere to find!", "w_next": "playmap_35", + "text": """ ┃⌂ P┃A┣━┛⌂⌂$⌂⌂""", + "color": "\033[38;5;227m\033[1m" }, "add": { - "x": 21, + "x": 36, + "y": 7 + } + }, + + + +} + +decorations={ + "wheeto": { + "gen": { + "additionals": [], + "width": 3, + "height": 4, + "desc": "", + "text": """\ /\|/\|/ | """, + "color": "\033[38;5;64m\033[1m" + }, + "add": { + "x": 41, + "y": 6 + } + }, + + "cave3": { + "gen": { + "additionals": [], + "width": 5, + "height": 3, + "desc": "", + "text": """█▄ ███▄ ▜█▙""", + "color": "\033[38;5;238m" + }, + "add": { + "x": 8, + "y": 10 + } + }, + + "cave2": { + "gen": { + "additionals": [], + "width": 4, + "height": 3, + "desc": "", + "text": """▐ ▐██ ▜█▆""", + "color": "\033[38;5;238m" + }, + "add": { + "x": 10, + "y": 13 + } + }, + + "cave1": { + "gen": { + "additionals": [], + "width": 6, + "height": 4, + "desc": "", + "text": """▄▄▂ ████▇▅██████ ▀▜""", + "color": "\033[38;5;238m" + }, + "add": { + "x": 1, + "y": 8 + } + }, + + "cave4-1": { + "gen": { + "additionals": [], + "width": 4, + "height": 2, + "desc": "", + "text": """████████""", + "color": "\033[38;5;238m" + }, + "add": { + "x": 23, + "y": 1 + } + }, + + "cave4": { + "gen": { + "additionals": [], + "width": 5, + "height": 5, + "desc": "", + "text": """▐███ ▕███▎ ▜██▊ ▜██ ▝██""", + "color": "\033[38;5;238m" + }, + "add": { + "x": 23, + "y": 3 + } + }, + + + "water_mountainsee": { + "gen": { + "additionals": [], + "width": 1, + "height": 1, + "desc": "", + "text": """█""", + "color": "\033[38;5;27m\033[1m" + }, + "add": { + "x": 29, + "y": 8 + } + }, + "cave5": { + "gen": { + "additionals": [], + "width": 5, + "height": 4, + "desc": "", + "text": """ ██▙▄▟█▛███▌ █▀ """, + "color": "\033[38;5;238m" + }, + "add": { + "x": 29, + "y": 5 + } + }, + + "water_rockybeach": { + "gen": { + "additionals": [], + "width": 6, + "height": 2, + "desc": "", + "text": """████▀▀▀▀ ▔ """, + "color": "\033[38;5;27m\033[1m" + }, + "add": { + "x": 27, + "y": 1 + } + }, + + "cave7": { + "gen": { + "additionals": [], + "width": 6, + "height": 3, + "desc": "", + "text": """ ██▀ ▗█▛ ▐█▀ """, + "color": "\033[38;5;238m" + }, + "add": { + "x": 31, + "y": 1 + } + }, + + "cave6": { + "gen": { + "additionals": [], + "width": 2, + "height": 1, + "desc": "", + "text": """██""", + "color": "\033[38;5;236m" + }, + "add": { + "x": 32, "y": 4 } }, + + "rose": { + "gen": { + "additionals": [], + "width": 7, + "height": 5, + "desc": "", + "text": """ N ▲ W ◀ ▶ E ▼ S """ + }, + "add": { + "x": 53, + "y": 11 + } + }, + "water_sunnylake": { + "gen": { + "additionals": [], + "width": 2, + "height": 2, + "desc": "", + "text": """▄▄██""", + "color": "\033[38;5;27m\033[1m" + }, + "add": { + "x": 12, + "y": 3 + } + }, + + "water_fisherlake": { + "gen": { + "additionals": [], + "width": 6, + "height": 1, + "desc": "", + "text": """▆▆██▆▃""", + "color": "\033[38;5;27m\033[1m" + }, + "add": { + "x": 14, + "y": 15 + } + }, + + "Legend": { + "gen": { + "additionals": [], + "width": 15, + "height": 6, + "desc": "", + "text": """│ Legend: │ P-Pokecenter │ $-Shop │ C-PoketeCare │ A-Arena └──────────────""" + #! - avaiable quests + }, + "add": { + "x": 45, + "y": 1 + } + }, + + "karpi": { + "gen": { + "additionals": [], + "width": 8, + "height": 1, + "desc": "", + "text": """<°))))><""", + "color": "\033[1m\033[34m" + }, + "add": { + "x": 21, + "y": 15 + } + }, + + "owl": { + "gen": { + "additionals": [], + "width": 5, + "height": 4, + "desc": "", + "text": """,___,{o,o}/)_) "" """, + "color": "\033[1m\033[38;5;22m" + }, + "add": { + "x": 24, + "y": 9 + } + }, + + "rosi_flower": { + "gen": { + "additionals": [], + "width": 3, + "height": 1, + "desc": "", + "text": """(@)""", + "color": "\033[1m\033[38;5;196m" + }, + "add": { + "x": 16, + "y": 1 + } + }, + + "rosi_trunk": { + "gen": { + "additionals": [], + "width": 3, + "height": 2, + "desc": "", + "text": """ | \|/""", + "color": "\033[1m\033[38;5;29m" + }, + "add": { + "x": 16, + "y": 2 + } + }, } if __name__ == "__main__": From ce42e7d5647fc4211befd9000285283eb0feb5f4 Mon Sep 17 00:00:00 2001 From: Janek Kermit Date: Mon, 6 May 2024 12:51:34 +0200 Subject: [PATCH 2/7] Little improvements to roadmap (DO NOT MERGE YET) --- .gitignore | 1 + pokete_classes/color.py | 10 +- pokete_classes/roadmap.py | 63 ++++++----- pokete_data/mapstations.py | 199 ++++++++++----------------------- pokete_data/station-poketes.py | 77 +++++++++++++ 5 files changed, 180 insertions(+), 170 deletions(-) create mode 100644 pokete_data/station-poketes.py diff --git a/.gitignore b/.gitignore index 371e9168..8e871ed7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ templates .idea scrap_engine.py +./pokete_data/station-pokete.py diff --git a/pokete_classes/color.py b/pokete_classes/color.py index 8035aef3..04860eef 100644 --- a/pokete_classes/color.py +++ b/pokete_classes/color.py @@ -6,13 +6,13 @@ class Color: reset = "\033[0m" thicc = "\033[1m" underlined = "\033[4m" - grey = "\033[38;5;237m" - red = "\033[38;5;160m" - green = "\033[32m" - yellow = "\033[33m" + grey = "\033[1;30m" + red = "\033[38;5;196m" + green = "\033[38;5;70m" + yellow = "\033[38;5;226m" lightblue = "\033[1;34m" blue = "\033[34m" - purple = "\033[1;35m" + purple = "\033[1;38;5;141m" cyan = "\033[1;36m" lightgrey = "\033[37m" white = "\033[1;37m" diff --git a/pokete_classes/roadmap.py b/pokete_classes/roadmap.py index f638f619..1e0ad4f2 100644 --- a/pokete_classes/roadmap.py +++ b/pokete_classes/roadmap.py @@ -5,7 +5,7 @@ import pokete_classes.ob_maps as obmp import time import threading -import signal +import random from pokete_general_use_fns import liner from .hotkeys import ACTION_DIRECTIONS, Action, ActionList, get_action from .loops import std_loop, easy_exit_loop @@ -32,6 +32,8 @@ def __init__(self, text, width, height, ob_class=se.Object): self.text = text self.ob_args = {} self.__create() + if self.desc == "_LAKE": + threading.Thread(target = self.animate_water, daemon = True).start() def __create(self): for ry in range(self.height): @@ -42,7 +44,7 @@ def __create(self): r=ry*self.width+rx self.add_ob( self.ob_class( - self.text[r], self.state, arg_proto=self.ob_args + self.text[r], "float", arg_proto=self.ob_args ), rx, ry ) @@ -53,6 +55,16 @@ def recolor(self, color): obj.rechar(color + self.text[r] + Color.reset) if len(self.text)!=1: r+=1 + + def animate_water(self): + #bruh i think this could be done better + water_colors = ["\033[38;5;38m", "\033[38;5;75m", "\033[38;5;39m", "\033[38;5;74m"] + while True: + r=0 + for obj in self.obs: + obj.rechar(water_colors[random.randint(0, len(water_colors)-1)] + self.text[r] + Color.reset) + r+=1 + time.sleep(0.7) @@ -80,8 +92,8 @@ def __init__(self, roadmap, associate, additionals, width, height, desc, color=" if self.associates[0]: self.name = self.associates[0].pretty_name super().__init__(text, width, height) - self.set_color() self.recolor(self.color) + self.hide_if_visited() self.w_next = w_next self.a_next = a_next self.s_next = s_next @@ -90,24 +102,23 @@ def __init__(self, roadmap, associate, additionals, width, height, desc, color=" def choose(self): """Chooses and hightlights the station""" - Station.choosen = self self.roadmap.rechar_info( self.name if self.has_been_visited() else "???" ) - threading.Thread(target = self.blink, daemon = True).start() - - def blink(self): - while Station.choosen == self: - self.recolor(Color.red+Color.thicc) - time.sleep(0.6) - self.recolor(self.color) - time.sleep(0.35) - + threading.Thread(target = self.animate_blink, daemon = True).start() + def unchoose(self): """Unchooses the station""" self.recolor(self.color) + def animate_blink(self): + while Station.choosen == self: + self.recolor(Color.red+Color.thicc) + time.sleep(0.8) + self.recolor(self.color) + time.sleep(0.5) + def next(self, inp: ActionList): """Chooses the next station in a certain direction ARGS: @@ -135,18 +146,13 @@ def is_city(self): return "pokecenter" \ in p_data.map_data[self.associates[0].name]["hard_obs"] - def set_color(self, choose=False): + def hide_if_visited(self, choose=False): """Marks a station as visited""" - - if self.associates[0] is not None and not self.has_been_visited() and self.is_city(): - self.text=self.text.replace("A", " ") - self.text=self.text.replace("P", " ") - self.text=self.text.replace("$", " ") - self.text=self.text.replace("C", " ") - self.text=self.text.replace("⌂", " ") + if self.associates[0] is not None and not self.has_been_visited(): + features = ["A", "P", "$", "C", "⌂"] + for ch in features: + self.text=self.text.replace(ch, " ") - - class RoadMap: """Map you can see and navigate maps on ARGS: @@ -161,15 +167,16 @@ def __init__(self, fig): ) self.info_label = se.Text("", state="float") self.box.add_ob(self.info_label, self.box.width - 2, 0) + for sta, _dict in p_data.decorations.items(): + obj = Station(self, None, **_dict['gen']) + self.box.add_ob(obj, **_dict['add']) + setattr(self, sta, obj) + for sta, _dict in p_data.stations.items(): obj = Station(self, obmp.ob_maps[sta], **_dict['gen']) self.box.add_ob(obj, **_dict['add']) setattr(self, sta, obj) - for sta, _dict in p_data.decorations.items(): - obj = Station(self, None, **_dict['gen']) - self.box.add_ob(obj, **_dict['add']) - setattr(self, sta, obj) @property @@ -192,7 +199,7 @@ def __call__(self, _map, choose=False): _map: se.Map this is shown on choose: Bool whether or not this is done to choose a city""" for i in Station.obs: - i.set_color(choose) + i.hide_if_visited(choose) [i for i in Station.obs if (self.fig.map if self.fig.map not in [obmp.ob_maps[i] for i in diff --git a/pokete_data/mapstations.py b/pokete_data/mapstations.py index a463a8a4..4c76c9c9 100644 --- a/pokete_data/mapstations.py +++ b/pokete_data/mapstations.py @@ -139,7 +139,7 @@ "a_next": "playmap_6", "s_next": "playmap_11", "d_next": "playmap_12", - "text": """ ⌂ ━┳━""", + "text": """⌂ ━┳━""", "color": "\033[38;5;136m" }, "add": { @@ -155,7 +155,7 @@ "desc": "The shore of a lake near an olf fisher village.", "w_next": "playmap_8", "text": """┃""", - "color": "\033[38;5;178m" + "color": "\033[38;5;220m" }, "add": { "x": 17, @@ -164,14 +164,14 @@ }, "playmap_12": { "gen": { - "width": 3, "additionals": [], + "width": 2, "height": 2, "desc": "A dense forest near Deepens forest.", "a_next": "playmap_8", "w_next": "playmap_13", - "text": """ ┃━━┛""", - "color": "\033[38;5;88m\033[1m" + "text": """ ┃━┛""", + "color": "\033[38;5;88m" }, "add": { "x": 19, @@ -188,10 +188,10 @@ "s_next": "playmap_12", "w_next": "playmap_15", "text": """⌂┃A⌂┃⌂P┃$""", - "color": "\033[38;5;94m\033[1m" + "color": "\033[38;5;94m" }, "add": { - "x": 20, + "x": 19, "y": 9 } }, @@ -204,26 +204,26 @@ "s_next": "playmap_13", "d_next": "playmap_16", "text": """┏━━""", - "color": "\033[38;5;88m\033[1m" + "color": "\033[38;5;88m" }, "add": { - "x": 21, + "x": 20, "y": 8 } }, "playmap_16": { "gen": { "additionals": ["playmap_17"], - "width": 2, + "width": 3, "height": 1, "desc": "A small 'village', that's not even worth talking about.", "a_next": "playmap_15", "d_next": "playmap_18", - "text": """━━""", - "color": "\033[38;5;154m\033[1m" + "text": """━━━""", + "color": "\033[38;5;154m" }, "add": { - "x": 24, + "x": 23, "y": 8 } }, @@ -236,7 +236,7 @@ "a_next": "playmap_16", "w_next": "playmap_19", "text": """━━┛""", - "color": "\033[38;5;28m\033[1m" + "color": "\033[38;5;64m" }, "add": { "x": 26, @@ -280,6 +280,21 @@ "y": 3 } }, + "playmap_40": { + "gen": { + "additionals": [], + "width": 1, + "height": 1, + "desc": "A Great beach, with great weather, always.", + "s_next": "playmap_21", + "text": """┃""", + "color": "\033[38;5;220m" + }, + "add": { + "x": 29, + "y": 2 + } + }, "playmap_28": { "gen": { "additionals": [], @@ -345,21 +360,6 @@ "y": 4 } }, - "playmap_40": { - "gen": { - "additionals": [], - "width": 1, - "height": 1, - "desc": "A Great beach, with great weather, always.", - "s_next": "playmap_21", - "text": """┃""", - "color": "\033[38;5;178m" - }, - "add": { - "x": 29, - "y": 2 - } - }, "playmap_39": { "gen": { "additionals": ["playmap_41", "playmap_42", "playmap_43", @@ -374,8 +374,8 @@ "juiciest and most delicious Mowcow-burgers, cut from the " "happiest and most delicious Mowcows anywhere to find!", "w_next": "playmap_35", - "text": """ ┃⌂ P┃A┣━┛⌂⌂$⌂⌂""", - "color": "\033[38;5;227m\033[1m" + "text": """⌂⌂┃⌂⌂P┃A┣━┛⌂⌂$⌂⌂""", + "color": "\033[38;5;227m" }, "add": { "x": 36, @@ -387,22 +387,7 @@ } -decorations={ - "wheeto": { - "gen": { - "additionals": [], - "width": 3, - "height": 4, - "desc": "", - "text": """\ /\|/\|/ | """, - "color": "\033[38;5;64m\033[1m" - }, - "add": { - "x": 41, - "y": 6 - } - }, - +decorations={ "cave3": { "gen": { "additionals": [], @@ -478,21 +463,6 @@ } }, - - "water_mountainsee": { - "gen": { - "additionals": [], - "width": 1, - "height": 1, - "desc": "", - "text": """█""", - "color": "\033[38;5;27m\033[1m" - }, - "add": { - "x": 29, - "y": 8 - } - }, "cave5": { "gen": { "additionals": [], @@ -507,19 +477,18 @@ "y": 5 } }, - - "water_rockybeach": { + "mountainsee": { "gen": { "additionals": [], - "width": 6, - "height": 2, - "desc": "", - "text": """████▀▀▀▀ ▔ """, - "color": "\033[38;5;27m\033[1m" + "width": 1, + "height": 1, + "desc": "_LAKE", + "text": """█""", + "color": "\033[38;5;39m" }, "add": { - "x": 27, - "y": 1 + "x": 29, + "y": 8 } }, @@ -538,6 +507,22 @@ } }, + "rockybeach": { + "gen": { + "additionals": [], + "width": 7, + "height": 1, + "desc": "_LAKE", + "text": """████▀▀▔""", + "color": "\033[38;5;39m" + }, + "add": { + "x": 27, + "y": 1 + } + }, + + "cave6": { "gen": { "additionals": [], @@ -566,14 +551,14 @@ "y": 11 } }, - "water_sunnylake": { + "sunnylake": { "gen": { "additionals": [], "width": 2, "height": 2, - "desc": "", + "desc": "_LAKE", "text": """▄▄██""", - "color": "\033[38;5;27m\033[1m" + "color": "\033[38;5;39m" }, "add": { "x": 12, @@ -581,14 +566,14 @@ } }, - "water_fisherlake": { + "fisherlake": { "gen": { "additionals": [], "width": 6, "height": 1, - "desc": "", + "desc": "_LAKE", "text": """▆▆██▆▃""", - "color": "\033[38;5;27m\033[1m" + "color": "\033[38;5;39m" }, "add": { "x": 14, @@ -610,66 +595,6 @@ "y": 1 } }, - - "karpi": { - "gen": { - "additionals": [], - "width": 8, - "height": 1, - "desc": "", - "text": """<°))))><""", - "color": "\033[1m\033[34m" - }, - "add": { - "x": 21, - "y": 15 - } - }, - - "owl": { - "gen": { - "additionals": [], - "width": 5, - "height": 4, - "desc": "", - "text": """,___,{o,o}/)_) "" """, - "color": "\033[1m\033[38;5;22m" - }, - "add": { - "x": 24, - "y": 9 - } - }, - - "rosi_flower": { - "gen": { - "additionals": [], - "width": 3, - "height": 1, - "desc": "", - "text": """(@)""", - "color": "\033[1m\033[38;5;196m" - }, - "add": { - "x": 16, - "y": 1 - } - }, - - "rosi_trunk": { - "gen": { - "additionals": [], - "width": 3, - "height": 2, - "desc": "", - "text": """ | \|/""", - "color": "\033[1m\033[38;5;29m" - }, - "add": { - "x": 16, - "y": 2 - } - }, } if __name__ == "__main__": diff --git a/pokete_data/station-poketes.py b/pokete_data/station-poketes.py new file mode 100644 index 00000000..44ea6b9a --- /dev/null +++ b/pokete_data/station-poketes.py @@ -0,0 +1,77 @@ + + +poketes={ + "wheeto": { + "gen": { + "additionals": [], + "width": 3, + "height": 4, + "desc": "", + "text": """\ /\|/\|/ | """, + "color": "\033[38;5;64m" + }, + "add": { + "x": 41, + "y": 6 + } + }, + "karpi": { + "gen": { + "additionals": [], + "width": 8, + "height": 1, + "desc": "", + "text": """<°))))><""", + "color": "\033[34m" + }, + "add": { + "x": 21, + "y": 15 + } + }, + + "owl": { + "gen": { + "additionals": [], + "width": 5, + "height": 4, + "desc": "", + "text": """,___,{o,o}/)_) "" """, + "color": "\033[38;5;22m" + }, + "add": { + "x": 24, + "y": 9 + } + }, + + "rosi_flower": { + "gen": { + "additionals": [], + "width": 3, + "height": 1, + "desc": "", + "text": """(@)""", + "color": "\033[38;5;196m" + }, + "add": { + "x": 16, + "y": 1 + } + }, + + "rosi_trunk": { + "gen": { + "additionals": [], + "width": 3, + "height": 2, + "desc": "", + "text": """ | \|/""", + "color": "\033[38;5;29m" + }, + "add": { + "x": 16, + "y": 2 + } + }, +} \ No newline at end of file From 00a348fc46741a4e48daa1ecec185754f879557d Mon Sep 17 00:00:00 2001 From: Janek Kermit Date: Tue, 7 May 2024 19:53:58 +0200 Subject: [PATCH 3/7] improved roadmap (DO NOT MERGE YET) --- .gitignore | 1 - pokete_data/station-poketes.py | 77 ---------------------------------- 2 files changed, 78 deletions(-) delete mode 100644 pokete_data/station-poketes.py diff --git a/.gitignore b/.gitignore index 8e871ed7..371e9168 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ templates .idea scrap_engine.py -./pokete_data/station-pokete.py diff --git a/pokete_data/station-poketes.py b/pokete_data/station-poketes.py deleted file mode 100644 index 44ea6b9a..00000000 --- a/pokete_data/station-poketes.py +++ /dev/null @@ -1,77 +0,0 @@ - - -poketes={ - "wheeto": { - "gen": { - "additionals": [], - "width": 3, - "height": 4, - "desc": "", - "text": """\ /\|/\|/ | """, - "color": "\033[38;5;64m" - }, - "add": { - "x": 41, - "y": 6 - } - }, - "karpi": { - "gen": { - "additionals": [], - "width": 8, - "height": 1, - "desc": "", - "text": """<°))))><""", - "color": "\033[34m" - }, - "add": { - "x": 21, - "y": 15 - } - }, - - "owl": { - "gen": { - "additionals": [], - "width": 5, - "height": 4, - "desc": "", - "text": """,___,{o,o}/)_) "" """, - "color": "\033[38;5;22m" - }, - "add": { - "x": 24, - "y": 9 - } - }, - - "rosi_flower": { - "gen": { - "additionals": [], - "width": 3, - "height": 1, - "desc": "", - "text": """(@)""", - "color": "\033[38;5;196m" - }, - "add": { - "x": 16, - "y": 1 - } - }, - - "rosi_trunk": { - "gen": { - "additionals": [], - "width": 3, - "height": 2, - "desc": "", - "text": """ | \|/""", - "color": "\033[38;5;29m" - }, - "add": { - "x": 16, - "y": 2 - } - }, -} \ No newline at end of file From 1cb8210969706b91645819ba064bea8774440902 Mon Sep 17 00:00:00 2001 From: Janek Kermit Date: Thu, 13 Jun 2024 16:34:26 +0200 Subject: [PATCH 4/7] Fixed broken characters and colors on TTY --- pokete_classes/roadmap.py | 14 ++-- pokete_data/mapstations.py | 144 ++++++++++++++++++++----------------- 2 files changed, 86 insertions(+), 72 deletions(-) diff --git a/pokete_classes/roadmap.py b/pokete_classes/roadmap.py index 1e0ad4f2..6fad8b73 100644 --- a/pokete_classes/roadmap.py +++ b/pokete_classes/roadmap.py @@ -6,6 +6,7 @@ import time import threading import random +from os import environ from pokete_general_use_fns import liner from .hotkeys import ACTION_DIRECTIONS, Action, ActionList, get_action from .loops import std_loop, easy_exit_loop @@ -32,8 +33,8 @@ def __init__(self, text, width, height, ob_class=se.Object): self.text = text self.ob_args = {} self.__create() - if self.desc == "_LAKE": - threading.Thread(target = self.animate_water, daemon = True).start() + #if self.desc == "_LAKE": + #threading.Thread(target = self.animate_water, daemon = True).start() def __create(self): for ry in range(self.height): @@ -82,13 +83,16 @@ class Station(StationObject): choosen = None obs = [] - def __init__(self, roadmap, associate, additionals, width, height, desc, color="", + def __init__(self, roadmap, associate, additionals, width, height, desc, color="", colorTTY="", text="#", w_next="", a_next="", s_next="", d_next=""): self.desc = desc self.roadmap = roadmap self.org_char = text self.associates = [associate] + [obmp.ob_maps[i] for i in additionals] - self.color = color + if colorTTY!="" and environ['TERM']=="linux": + self.color = colorTTY + else: + self.color = color if self.associates[0]: self.name = self.associates[0].pretty_name super().__init__(text, width, height) @@ -149,7 +153,7 @@ def is_city(self): def hide_if_visited(self, choose=False): """Marks a station as visited""" if self.associates[0] is not None and not self.has_been_visited(): - features = ["A", "P", "$", "C", "⌂"] + features = ["A", "P", "$", "C", "⌂", "#"] for ch in features: self.text=self.text.replace(ch, " ") diff --git a/pokete_data/mapstations.py b/pokete_data/mapstations.py index 4c76c9c9..10a93317 100644 --- a/pokete_data/mapstations.py +++ b/pokete_data/mapstations.py @@ -6,8 +6,8 @@ "height": 3, "desc": "A small town.", "d_next": "playmap_51", - "text": """*P⌂ ┣━━━ ⌂⌂ """, - "color": "\033[38;5;28m" + "text": """ *P#├─── # #""", + "color": "\033[38;5;46m" }, "add": { "x": 3, @@ -24,8 +24,9 @@ "Nice Town.", "a_next": "playmap_1", "w_next": "cave_1", - "text": r"""┗━┓━━┛""", - "color": "\033[38;5;22m" + "text": r"""└─┐──┘""", + "color": "\033[38;5;29m", + "colorTTY": "\033[38;5;22m" }, "add": { "x": 7, @@ -40,7 +41,8 @@ "desc": "A dark cave full of batos.", "s_next": "playmap_51", "d_next": "playmap_2", - "text": """▅██""", + "text": """███""", + "colorTTY": "\033[38;5;7m", "color": "\033[38;5;236m" }, "add": { @@ -56,8 +58,8 @@ "desc": "Part of light areas near Sunny Dale.", "a_next": "cave_1", "d_next": "playmap_3", - "text": """━━━━""", - "color": "\033[38;5;28m" + "text": """────""", + "color": "\033[38;5;29m" }, "add": { "x": 8, @@ -73,8 +75,9 @@ "a_next": "playmap_2", "w_next": "playmap_4", "s_next": "playmap_6", - "text": """P┃$━┫⌂⌂┃⌂""", - "color": "\033[38;5;76m" + "text": """P│$─┤ #│#""", + "color": "\033[38;5;76;1m", + "colorTTY": "\033[38;5;22m" }, "add": { "x": 12, @@ -89,8 +92,8 @@ "desc": "The shores of the great Sunnydale lake.", "s_next": "playmap_3", "d_next": "playmap_28", - "text": """┣┃┃""", - "color": "\033[38;5;29m" + "text": """├││""", + "color": "\033[38;5;29;1m" }, "add": { "x": 13, @@ -107,8 +110,8 @@ "w_next": "playmap_3", "a_next": "playmap_7", "d_next": "playmap_8", - "text": """┃ ┃ ┻━━""", - "color": "\033[38;5;28m" + "text": """│ │ ┴──""", + "color": "\033[38;5;46m" }, "add": { "x": 13, @@ -123,6 +126,7 @@ "desc": "A dark and mysterious cave.", "d_next": "playmap_6", "text": """██""", + "colorTTY": "\033[38;5;7m", "color": "\033[38;5;236m" }, "add": { @@ -139,8 +143,8 @@ "a_next": "playmap_6", "s_next": "playmap_11", "d_next": "playmap_12", - "text": """⌂ ━┳━""", - "color": "\033[38;5;136m" + "text": """# ─┬─""", + "color": "\033[38;5;10m" }, "add": { "x": 16, @@ -154,8 +158,8 @@ "height": 1, "desc": "The shore of a lake near an olf fisher village.", "w_next": "playmap_8", - "text": """┃""", - "color": "\033[38;5;220m" + "text": """│""", + "color": "\033[38;5;226m" }, "add": { "x": 17, @@ -170,8 +174,9 @@ "desc": "A dense forest near Deepens forest.", "a_next": "playmap_8", "w_next": "playmap_13", - "text": """ ┃━┛""", - "color": "\033[38;5;88m" + "text": """ │─┘""", + "color": "\033[38;5;88;1m", + "colorTTY": "\033[38;5;1m" }, "add": { "x": 19, @@ -187,8 +192,9 @@ forest, populated by thousands of people and cultural center of the region.", "s_next": "playmap_12", "w_next": "playmap_15", - "text": """⌂┃A⌂┃⌂P┃$""", - "color": "\033[38;5;94m" + "text": """#│A │ P│$""", + "color": "\033[38;5;94;1m", + "colorTTY": "\033[38;5;9m" }, "add": { "x": 19, @@ -203,8 +209,9 @@ "desc": "A small clearing near Deepens forest.", "s_next": "playmap_13", "d_next": "playmap_16", - "text": """┏━━""", - "color": "\033[38;5;88m" + "text": """┌──""", + "color": "\033[38;5;88;1m", + "colorTTY": "\033[38;5;1m" }, "add": { "x": 20, @@ -219,8 +226,8 @@ "desc": "A small 'village', that's not even worth talking about.", "a_next": "playmap_15", "d_next": "playmap_18", - "text": """━━━""", - "color": "\033[38;5;154m" + "text": """───""", + "color": "\033[38;5;154;1m" }, "add": { "x": 23, @@ -235,8 +242,8 @@ "desc": "A small see at the foot of the Big mountain.", "a_next": "playmap_16", "w_next": "playmap_19", - "text": """━━┛""", - "color": "\033[38;5;64m" + "text": """──┘""", + "color": "\033[38;5;64;1m" }, "add": { "x": 26, @@ -252,7 +259,8 @@ "s_next": "playmap_18", "w_next": "playmap_21", "text": """██""", - "color": "\033[38;5;236m" + "colorTTY": "\033[38;5;7m", + "color": "\033[38;5;236;1m" }, "add": { "x": 28, @@ -272,8 +280,8 @@ "s_next": "playmap_19", "d_next": "playmap_33", "w_next": "playmap_40", - "text": """P┃⌂⌂┏┻━━┃⌂C """, - "color": "\033[38;5;246m" + "text": """P│ #┌┴──│#C """, + "color": "\033[38;5;246;1m" }, "add": { "x": 28, @@ -287,8 +295,8 @@ "height": 1, "desc": "A Great beach, with great weather, always.", "s_next": "playmap_21", - "text": """┃""", - "color": "\033[38;5;220m" + "text": """│""", + "color": "\033[38;5;226m" }, "add": { "x": 29, @@ -303,8 +311,9 @@ "desc": "A foggy place full of ghosts and plants.", "a_next": "playmap_4", "d_next": "playmap_30", - "text": """ ┏━━━━┛ """, - "color": "\033[38;5;22m" + "text": """ ┌────┘ """, + "color": "\033[38;5;22;1m", + "colorTTY": "\033[38;5;22m" }, "add": { "x": 14, @@ -320,8 +329,8 @@ spot in the Pokete world and with the great git-tree it may also be one \ of the most spectacular.", "a_next": "playmap_28", - "text": """ $P ━━━┫⌂A⌂⌂""", - "color": "\033[38;5;34m" + "text": """A$P ───┤# # """, + "color": "\033[38;5;34;1m" }, "add": { "x": 19, @@ -336,8 +345,8 @@ "desc": "Part of the great agracultural landscape near Agrawos.", "a_next": "playmap_21", "d_next": "playmap_35", - "text": """━━""", - "color": "\033[38;5;178m" + "text": """──""", + "color": "\033[38;5;227;1m" }, "add": { "x": 34, @@ -352,8 +361,9 @@ "desc": "Part of the great agracultural landscape near Agrawos.", "a_next": "playmap_33", "s_next": "playmap_39", - "text": """━━┓┏━┛┗━┓""", - "color": "\033[38;5;154m" + "text": """──┐┌─┘└─┐""", + "color": "\033[38;5;100m", + "colorTTY": "\033[38;5;3m" }, "add": { "x": 36, @@ -374,8 +384,8 @@ "juiciest and most delicious Mowcow-burgers, cut from the " "happiest and most delicious Mowcows anywhere to find!", "w_next": "playmap_35", - "text": """⌂⌂┃⌂⌂P┃A┣━┛⌂⌂$⌂⌂""", - "color": "\033[38;5;227m" + "text": """ #│# P│A├─┘# $ #""", + "color": "\033[38;5;227;1m" }, "add": { "x": 36, @@ -394,8 +404,8 @@ "width": 5, "height": 3, "desc": "", - "text": """█▄ ███▄ ▜█▙""", - "color": "\033[38;5;238m" + "text": """██ ████ ███""", + "color": "\033[38;5;238;1m" }, "add": { "x": 8, @@ -409,8 +419,8 @@ "width": 4, "height": 3, "desc": "", - "text": """▐ ▐██ ▜█▆""", - "color": "\033[38;5;238m" + "text": """█ ███ ███""", + "color": "\033[38;5;238;1m" }, "add": { "x": 10, @@ -424,8 +434,8 @@ "width": 6, "height": 4, "desc": "", - "text": """▄▄▂ ████▇▅██████ ▀▜""", - "color": "\033[38;5;238m" + "text": """ ████████████ █""", + "color": "\033[38;5;238;1m" }, "add": { "x": 1, @@ -440,7 +450,7 @@ "height": 2, "desc": "", "text": """████████""", - "color": "\033[38;5;238m" + "color": "\033[38;5;238;1m" }, "add": { "x": 23, @@ -454,8 +464,8 @@ "width": 5, "height": 5, "desc": "", - "text": """▐███ ▕███▎ ▜██▊ ▜██ ▝██""", - "color": "\033[38;5;238m" + "text": """ ███ ███ ███ ███ ██""", + "color": "\033[38;5;238;1m" }, "add": { "x": 23, @@ -469,8 +479,8 @@ "width": 5, "height": 4, "desc": "", - "text": """ ██▙▄▟█▛███▌ █▀ """, - "color": "\033[38;5;238m" + "text": """ ███████████ ██ """, + "color": "\033[38;5;238;1m" }, "add": { "x": 29, @@ -484,7 +494,7 @@ "height": 1, "desc": "_LAKE", "text": """█""", - "color": "\033[38;5;39m" + "color": "\033[38;5;33;1m" }, "add": { "x": 29, @@ -498,8 +508,8 @@ "width": 6, "height": 3, "desc": "", - "text": """ ██▀ ▗█▛ ▐█▀ """, - "color": "\033[38;5;238m" + "text": """ ████ ███ ███ """, + "color": "\033[38;5;238;1m" }, "add": { "x": 31, @@ -513,8 +523,8 @@ "width": 7, "height": 1, "desc": "_LAKE", - "text": """████▀▀▔""", - "color": "\033[38;5;39m" + "text": """█████ """, + "color": "\033[38;5;33;1m" }, "add": { "x": 27, @@ -530,7 +540,7 @@ "height": 1, "desc": "", "text": """██""", - "color": "\033[38;5;236m" + "color": "\033[38;5;236;1m" }, "add": { "x": 32, @@ -554,15 +564,15 @@ "sunnylake": { "gen": { "additionals": [], - "width": 2, - "height": 2, + "width": 3, + "height": 1, "desc": "_LAKE", - "text": """▄▄██""", - "color": "\033[38;5;39m" + "text": """███""", + "color": "\033[38;5;33;1m" }, "add": { "x": 12, - "y": 3 + "y": 4 } }, @@ -572,8 +582,8 @@ "width": 6, "height": 1, "desc": "_LAKE", - "text": """▆▆██▆▃""", - "color": "\033[38;5;39m" + "text": """ ████ """, + "color": "\033[38;5;33;1m" }, "add": { "x": 14, @@ -598,4 +608,4 @@ } if __name__ == "__main__": - print("\033[31;1mDo not execute this!\033[0m") + print("\033[31;1mDo not execute this!\033[0;1m") From 553c82f4231e5e4ed180be554209dde8003b71bb Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Fri, 14 Jun 2024 01:24:41 +0200 Subject: [PATCH 5/7] Formating, added pevm to roadmap and changed the blinking animation to use a blinker and not a thread --- pokete.py | 4 +- pokete_classes/roadmap.py | 202 +++++++++++++++++++++++--------------- 2 files changed, 127 insertions(+), 79 deletions(-) diff --git a/pokete.py b/pokete.py index 1102c6e3..c6c8725c 100755 --- a/pokete.py +++ b/pokete.py @@ -983,7 +983,7 @@ def teleport(poke): """Teleports the player to another towns pokecenter ARGS: poke: The Poke shown in the animation""" - if (obj := roadmap(mvp.movemap, choose=True)) is None: + if (obj := roadmap(mvp.movemap, None, choose=True)) is None: return if settings("animations").val: animations.transition(mvp.movemap, poke) @@ -1092,7 +1092,7 @@ def _game(_map): pevm = PeriodicEventManager(_map) inp_dict = { Action.DECK: [deck.deck, (mvp.movemap, 6, "Your deck")], - Action.MAP: [roadmap, (mvp.movemap,)], + Action.MAP: [roadmap, (mvp.movemap, pevm)], Action.INVENTORY: [inv, ()], Action.POKEDEX: [pokete_dex, ()], Action.CLOCK: [timer.clock, (mvp.movemap,)], diff --git a/pokete_classes/roadmap.py b/pokete_classes/roadmap.py index 6fad8b73..5dca824f 100644 --- a/pokete_classes/roadmap.py +++ b/pokete_classes/roadmap.py @@ -1,18 +1,17 @@ """Contains all classes relevant to show the roadmap""" -import scrap_engine as se -import pokete_data as p_data -import pokete_classes.ob_maps as obmp import time -import threading import random from os import environ +import scrap_engine as se + +import pokete_data as p_data +import pokete_classes.ob_maps as obmp from pokete_general_use_fns import liner from .hotkeys import ACTION_DIRECTIONS, Action, ActionList, get_action from .loops import std_loop, easy_exit_loop from .color import Color from .ui_elements import Box, InfoBox -from .tss import tss from . import movemap as mvp @@ -24,51 +23,60 @@ def __init__(self, _map): text = f"{_map} {_map.name} has no mapstation" super().__init__(text) + """A little hackaround""" + + class StationObject(se.Box): - + def __init__(self, text, width, height, ob_class=se.Object): super().__init__(height, width) self.ob_class = ob_class self.text = text self.ob_args = {} self.__create() - #if self.desc == "_LAKE": - #threading.Thread(target = self.animate_water, daemon = True).start() + # if self.desc == "_LAKE": + # threading.Thread(target = self.animate_water, daemon = True).start() def __create(self): for ry in range(self.height): for rx in range(self.width): - if len(self.text)==1: - r=0 + if len(self.text) == 1: + r = 0 else: - r=ry*self.width+rx + r = ry * self.width + rx self.add_ob( - self.ob_class( - self.text[r], "float", arg_proto=self.ob_args - ), - rx, ry + self.ob_class(self.text[r], "float", + arg_proto=self.ob_args), rx, ry ) def recolor(self, color): - r=0 + r = 0 for obj in self.obs: obj.rechar(color + self.text[r] + Color.reset) - if len(self.text)!=1: - r+=1 - + if len(self.text) != 1: + r += 1 + def animate_water(self): - #bruh i think this could be done better - water_colors = ["\033[38;5;38m", "\033[38;5;75m", "\033[38;5;39m", "\033[38;5;74m"] + # bruh i think this could be done better + water_colors = [ + "\033[38;5;38m", + "\033[38;5;75m", + "\033[38;5;39m", + "\033[38;5;74m", + ] while True: - r=0 + r = 0 for obj in self.obs: - obj.rechar(water_colors[random.randint(0, len(water_colors)-1)] + self.text[r] + Color.reset) - r+=1 + obj.rechar( + water_colors[random.randint(0, len(water_colors) - 1)] + + self.text[r] + + Color.reset + ) + r += 1 time.sleep(0.7) - class Station(StationObject): """Selectable station for Roadmap ARGS: @@ -80,16 +88,31 @@ class Station(StationObject): desc: The associated description char: Displayed char {w,a,s,d}_next: The next Station's name in a certain direction""" + choosen = None obs = [] - def __init__(self, roadmap, associate, additionals, width, height, desc, color="", colorTTY="", - text="#", w_next="", a_next="", s_next="", d_next=""): + def __init__( + self, + roadmap, + associate, + additionals, + width, + height, + desc, + color="", + colorTTY="", + text="#", + w_next="", + a_next="", + s_next="", + d_next="", + ): self.desc = desc self.roadmap = roadmap self.org_char = text self.associates = [associate] + [obmp.ob_maps[i] for i in additionals] - if colorTTY!="" and environ['TERM']=="linux": + if colorTTY != "" and environ["TERM"] == "linux": self.color = colorTTY else: self.color = color @@ -108,20 +131,17 @@ def choose(self): """Chooses and hightlights the station""" Station.choosen = self self.roadmap.rechar_info( - self.name if self.has_been_visited() else "???" - ) - threading.Thread(target = self.animate_blink, daemon = True).start() - + self.name if self.has_been_visited() else "???") + def unchoose(self): """Unchooses the station""" - self.recolor(self.color) + self.un_blink() + + def blink(self): + self.recolor(Color.red + Color.thicc) - def animate_blink(self): - while Station.choosen == self: - self.recolor(Color.red+Color.thicc) - time.sleep(0.8) - self.recolor(self.color) - time.sleep(0.5) + def un_blink(self): + self.recolor(self.color) def next(self, inp: ActionList): """Chooses the next station in a certain direction @@ -132,10 +152,10 @@ def next(self, inp: ActionList): inp = action break inp = { - Action.UP: 'w', - Action.DOWN: 's', - Action.LEFT: 'a', - Action.RIGHT: 'd', + Action.UP: "w", + Action.DOWN: "s", + Action.LEFT: "a", + Action.RIGHT: "d", }[inp] if (n_e := getattr(self, inp + "_next")) != "": self.unchoose() @@ -147,16 +167,17 @@ def has_been_visited(self): def is_city(self): """Returns if the station is a city""" - return "pokecenter" \ - in p_data.map_data[self.associates[0].name]["hard_obs"] + return "pokecenter" in p_data.map_data[self.associates[0].name][ + "hard_obs"] def hide_if_visited(self, choose=False): """Marks a station as visited""" if self.associates[0] is not None and not self.has_been_visited(): features = ["A", "P", "$", "C", "⌂", "#"] for ch in features: - self.text=self.text.replace(ch, " ") - + self.text = self.text.replace(ch, " ") + + class RoadMap: """Map you can see and navigate maps on ARGS: @@ -165,23 +186,20 @@ class RoadMap: def __init__(self, fig): self.fig = fig self.box = Box( - 17, 61, "Roadmap", - f"{Action.CANCEL.mapping}:close", + 17, 61, "Roadmap", f"{Action.CANCEL.mapping}:close", overview=mvp.movemap ) self.info_label = se.Text("", state="float") self.box.add_ob(self.info_label, self.box.width - 2, 0) for sta, _dict in p_data.decorations.items(): - obj = Station(self, None, **_dict['gen']) - self.box.add_ob(obj, **_dict['add']) + obj = Station(self, None, **_dict["gen"]) + self.box.add_ob(obj, **_dict["add"]) setattr(self, sta, obj) for sta, _dict in p_data.stations.items(): - obj = Station(self, obmp.ob_maps[sta], **_dict['gen']) - self.box.add_ob(obj, **_dict['add']) + obj = Station(self, obmp.ob_maps[sta], **_dict["gen"]) + self.box.add_ob(obj, **_dict["add"]) setattr(self, sta, obj) - - @property def sta(self): @@ -197,19 +215,25 @@ def rechar_info(self, name): self.info_label.rechar(name) self.box.add_ob(self.info_label, self.box.width - 2 - len(name), 0) - def __call__(self, _map, choose=False): + def __call__(self, _map: se.Submap, pevm, choose=False): """Shows the roadmap ARGS: _map: se.Map this is shown on choose: Bool whether or not this is done to choose a city""" for i in Station.obs: i.hide_if_visited(choose) - [i for i in Station.obs - if (self.fig.map - if self.fig.map not in [obmp.ob_maps[i] for i in - ("shopmap", "centermap")] - else self.fig.oldmap) - in i.associates][0].choose() + [ + i + for i in Station.obs + if ( + self.fig.map + if self.fig.map + not in [obmp.ob_maps[i] for i in ("shopmap", "centermap")] + else self.fig.oldmap + ) + in i.associates + ][0].choose() + blinker = Blinker() with self.box.center_add(_map): while True: action = get_action() @@ -217,30 +241,41 @@ def __call__(self, _map, choose=False): self.sta.next(action) elif action.triggers(Action.MAP, Action.CANCEL): break - elif (action.triggers(Action.ACCEPT) and choose - and self.sta.has_been_visited() - and self.sta.is_city()): + elif ( + action.triggers(Action.ACCEPT) + and choose + and self.sta.has_been_visited() + and self.sta.is_city() + ): return self.sta.associates[0] - elif (action.triggers(Action.ACCEPT) and not choose - and self.sta.has_been_visited()): - p_list = ", ".join(set(p_data.pokes[j]["name"] - for i in self.sta.associates - for j in - i.poke_args.get("pokes", []) - + i.w_poke_args.get("pokes", []))) + elif ( + action.triggers(Action.ACCEPT) + and not choose + and self.sta.has_been_visited() + ): + p_list = ", ".join( + set( + p_data.pokes[j]["name"] + for i in self.sta.associates + for j in i.poke_args.get("pokes", []) + + i.w_poke_args.get("pokes", []) + ) + ) with InfoBox( liner( self.sta.desc + "\n\n Here you can find: " + (p_list if p_list != "" else "Nothing"), - 30 + 30, ), self.sta.name, - _map=_map, overview=self.box + _map=_map, + overview=self.box, ) as box: easy_exit_loop(box=box) - std_loop(box=self.box) - _map.show() + std_loop(box=self.box, pevm=pevm) + blinker(self.sta) + _map.full_show() self.sta.unchoose() @staticmethod @@ -249,12 +284,25 @@ def check_maps(): all_road_maps = ["centermap", "shopmap"] for i, _dict in p_data.stations.items(): all_road_maps.append(i) - all_road_maps += _dict['gen']['additionals'] + all_road_maps += _dict["gen"]["additionals"] for _, _map in obmp.ob_maps.items(): if _map.name not in all_road_maps: raise RoadMapException(_map) +class Blinker: + def __init__(self): + self.idx = 0 + + def __call__(self, station: Station): + self.idx += 1 + if self.idx == 10: + station.blink() + if self.idx == 20: + station.un_blink() + self.idx = 0 + + if __name__ == "__main__": print("\033[31;1mDo not execute this!\033[0m") From f35ddd5f5c610b5e085898aec915a146ee211bf0 Mon Sep 17 00:00:00 2001 From: Janek Kermit Date: Sat, 15 Jun 2024 22:50:13 +0200 Subject: [PATCH 6/7] Fixed teleportation map and now color.py is used instead of raw escape codes in mapstations.py --- pokete_classes/color.py | 21 +++++++++- pokete_classes/roadmap.py | 34 ++++++++------- pokete_data/mapstations.py | 86 +++++++++++++++++--------------------- 3 files changed, 77 insertions(+), 64 deletions(-) diff --git a/pokete_classes/color.py b/pokete_classes/color.py index 04860eef..23707ea9 100644 --- a/pokete_classes/color.py +++ b/pokete_classes/color.py @@ -1,5 +1,5 @@ """Contains the color class""" - +from os import environ class Color: """Color class that provides all needed escape codes""" @@ -12,10 +12,27 @@ class Color: yellow = "\033[38;5;226m" lightblue = "\033[1;34m" blue = "\033[34m" - purple = "\033[1;38;5;141m" + purple = "\033[1;35m" cyan = "\033[1;36m" lightgrey = "\033[37m" white = "\033[1;37m" + + #extended color palette + brown="\033[38;5;88m" + lakeblue="\033[38;5;33m" + mediumgray="\033[38;5;238m" + brightyellow="\033[38;5;155m" + deepgreen="\033[38;5;35m" + lightgray="\033[38;5;246m" + brightgreen="\033[38;5;46m" + darkgreen="\033[38;5;29m" + gold="\033[38;5;94m" + cavegray="\033[38;5;236m" + + if environ["TERM"] == "linux": #this fixes some colors on TTY + gold="\033[38;5;9m" + cavegray="\033[38;5;7m" + if __name__ == "__main__": diff --git a/pokete_classes/roadmap.py b/pokete_classes/roadmap.py index 5dca824f..1885692f 100644 --- a/pokete_classes/roadmap.py +++ b/pokete_classes/roadmap.py @@ -2,7 +2,6 @@ import time import random -from os import environ import scrap_engine as se import pokete_data as p_data @@ -35,8 +34,7 @@ def __init__(self, text, width, height, ob_class=se.Object): self.text = text self.ob_args = {} self.__create() - # if self.desc == "_LAKE": - # threading.Thread(target = self.animate_water, daemon = True).start() + #TODO: if self.desc == "_LAKE" animate water def __create(self): for ry in range(self.height): @@ -101,7 +99,6 @@ def __init__( height, desc, color="", - colorTTY="", text="#", w_next="", a_next="", @@ -112,15 +109,12 @@ def __init__( self.roadmap = roadmap self.org_char = text self.associates = [associate] + [obmp.ob_maps[i] for i in additionals] - if colorTTY != "" and environ["TERM"] == "linux": - self.color = colorTTY - else: - self.color = color + self.color = getattr(Color, color, "\033[1;37m") if self.associates[0]: self.name = self.associates[0].pretty_name super().__init__(text, width, height) self.recolor(self.color) - self.hide_if_visited() + #self.hide_if_visited() self.w_next = w_next self.a_next = a_next self.s_next = s_next @@ -169,13 +163,25 @@ def is_city(self): """Returns if the station is a city""" return "pokecenter" in p_data.map_data[self.associates[0].name][ "hard_obs"] + + def is_cave(self): + #returns if the station is in a cave + if self.text[0] == "█": return True + return False def hide_if_visited(self, choose=False): - """Marks a station as visited""" - if self.associates[0] is not None and not self.has_been_visited(): - features = ["A", "P", "$", "C", "⌂", "#"] - for ch in features: - self.text = self.text.replace(ch, " ") + if self.associates[0] is not None: + if choose: + if self.is_city() and self.has_been_visited(): + self.recolor(Color.green + Color.thicc) + elif not self.is_cave(): + self.recolor(Color.white) + else: + self.recolor(self.color) + if not self.has_been_visited(): + features = ["A", "P", "$", "C", "⌂", "#"] + for ch in features: + self.text = self.text.replace(ch, " ") class RoadMap: diff --git a/pokete_data/mapstations.py b/pokete_data/mapstations.py index 10a93317..b0d3d533 100644 --- a/pokete_data/mapstations.py +++ b/pokete_data/mapstations.py @@ -7,7 +7,7 @@ "desc": "A small town.", "d_next": "playmap_51", "text": """ *P#├─── # #""", - "color": "\033[38;5;46m" + "color": "brightgreen" }, "add": { "x": 3, @@ -25,8 +25,7 @@ "a_next": "playmap_1", "w_next": "cave_1", "text": r"""└─┐──┘""", - "color": "\033[38;5;29m", - "colorTTY": "\033[38;5;22m" + "color": "darkgreen" }, "add": { "x": 7, @@ -42,8 +41,7 @@ "s_next": "playmap_51", "d_next": "playmap_2", "text": """███""", - "colorTTY": "\033[38;5;7m", - "color": "\033[38;5;236m" + "color": "cavegray" }, "add": { "x": 7, @@ -59,7 +57,7 @@ "a_next": "cave_1", "d_next": "playmap_3", "text": """────""", - "color": "\033[38;5;29m" + "color": "darkgreen" }, "add": { "x": 8, @@ -76,8 +74,7 @@ "w_next": "playmap_4", "s_next": "playmap_6", "text": """P│$─┤ #│#""", - "color": "\033[38;5;76;1m", - "colorTTY": "\033[38;5;22m" + "color": "brightgreen" }, "add": { "x": 12, @@ -93,7 +90,7 @@ "s_next": "playmap_3", "d_next": "playmap_28", "text": """├││""", - "color": "\033[38;5;29;1m" + "color": "darkgreen" }, "add": { "x": 13, @@ -111,7 +108,7 @@ "a_next": "playmap_7", "d_next": "playmap_8", "text": """│ │ ┴──""", - "color": "\033[38;5;46m" + "color": "deepgreen" }, "add": { "x": 13, @@ -126,8 +123,7 @@ "desc": "A dark and mysterious cave.", "d_next": "playmap_6", "text": """██""", - "colorTTY": "\033[38;5;7m", - "color": "\033[38;5;236m" + "color": "cavegray" }, "add": { "x": 11, @@ -144,7 +140,7 @@ "s_next": "playmap_11", "d_next": "playmap_12", "text": """# ─┬─""", - "color": "\033[38;5;10m" + "color": "brightyellow" }, "add": { "x": 16, @@ -159,7 +155,7 @@ "desc": "The shore of a lake near an olf fisher village.", "w_next": "playmap_8", "text": """│""", - "color": "\033[38;5;226m" + "color": "yellow" }, "add": { "x": 17, @@ -175,8 +171,7 @@ "a_next": "playmap_8", "w_next": "playmap_13", "text": """ │─┘""", - "color": "\033[38;5;88;1m", - "colorTTY": "\033[38;5;1m" + "color": "brown" }, "add": { "x": 19, @@ -193,8 +188,7 @@ "s_next": "playmap_12", "w_next": "playmap_15", "text": """#│A │ P│$""", - "color": "\033[38;5;94;1m", - "colorTTY": "\033[38;5;9m" + "color": "gold" }, "add": { "x": 19, @@ -210,8 +204,7 @@ "s_next": "playmap_13", "d_next": "playmap_16", "text": """┌──""", - "color": "\033[38;5;88;1m", - "colorTTY": "\033[38;5;1m" + "color": "brown" }, "add": { "x": 20, @@ -227,7 +220,7 @@ "a_next": "playmap_15", "d_next": "playmap_18", "text": """───""", - "color": "\033[38;5;154;1m" + "color": "brightyellow" }, "add": { "x": 23, @@ -243,7 +236,7 @@ "a_next": "playmap_16", "w_next": "playmap_19", "text": """──┘""", - "color": "\033[38;5;64;1m" + "color": "darkgreen" }, "add": { "x": 26, @@ -259,8 +252,7 @@ "s_next": "playmap_18", "w_next": "playmap_21", "text": """██""", - "colorTTY": "\033[38;5;7m", - "color": "\033[38;5;236;1m" + "color": "cavegray" }, "add": { "x": 28, @@ -281,7 +273,7 @@ "d_next": "playmap_33", "w_next": "playmap_40", "text": """P│ #┌┴──│#C """, - "color": "\033[38;5;246;1m" + "color": "lightgray" }, "add": { "x": 28, @@ -296,7 +288,7 @@ "desc": "A Great beach, with great weather, always.", "s_next": "playmap_21", "text": """│""", - "color": "\033[38;5;226m" + "color": "yellow" }, "add": { "x": 29, @@ -312,8 +304,7 @@ "a_next": "playmap_4", "d_next": "playmap_30", "text": """ ┌────┘ """, - "color": "\033[38;5;22;1m", - "colorTTY": "\033[38;5;22m" + "color": "brightgreen" }, "add": { "x": 14, @@ -330,7 +321,7 @@ of the most spectacular.", "a_next": "playmap_28", "text": """A$P ───┤# # """, - "color": "\033[38;5;34;1m" + "color": "deepgreen" }, "add": { "x": 19, @@ -346,7 +337,7 @@ "a_next": "playmap_21", "d_next": "playmap_35", "text": """──""", - "color": "\033[38;5;227;1m" + "color": "yellow" }, "add": { "x": 34, @@ -362,8 +353,7 @@ "a_next": "playmap_33", "s_next": "playmap_39", "text": """──┐┌─┘└─┐""", - "color": "\033[38;5;100m", - "colorTTY": "\033[38;5;3m" + "color": "brightyellow" }, "add": { "x": 36, @@ -385,7 +375,7 @@ "happiest and most delicious Mowcows anywhere to find!", "w_next": "playmap_35", "text": """ #│# P│A├─┘# $ #""", - "color": "\033[38;5;227;1m" + "color": "yellow" }, "add": { "x": 36, @@ -405,7 +395,7 @@ "height": 3, "desc": "", "text": """██ ████ ███""", - "color": "\033[38;5;238;1m" + "color": "mediumgray" }, "add": { "x": 8, @@ -420,7 +410,7 @@ "height": 3, "desc": "", "text": """█ ███ ███""", - "color": "\033[38;5;238;1m" + "color": "mediumgray" }, "add": { "x": 10, @@ -435,7 +425,7 @@ "height": 4, "desc": "", "text": """ ████████████ █""", - "color": "\033[38;5;238;1m" + "color": "mediumgray" }, "add": { "x": 1, @@ -450,7 +440,7 @@ "height": 2, "desc": "", "text": """████████""", - "color": "\033[38;5;238;1m" + "color": "mediumgray" }, "add": { "x": 23, @@ -465,7 +455,7 @@ "height": 5, "desc": "", "text": """ ███ ███ ███ ███ ██""", - "color": "\033[38;5;238;1m" + "color": "mediumgray" }, "add": { "x": 23, @@ -480,7 +470,7 @@ "height": 4, "desc": "", "text": """ ███████████ ██ """, - "color": "\033[38;5;238;1m" + "color": "mediumgray" }, "add": { "x": 29, @@ -494,7 +484,7 @@ "height": 1, "desc": "_LAKE", "text": """█""", - "color": "\033[38;5;33;1m" + "color": "lakeblue" }, "add": { "x": 29, @@ -508,8 +498,8 @@ "width": 6, "height": 3, "desc": "", - "text": """ ████ ███ ███ """, - "color": "\033[38;5;238;1m" + "text": """ ████ ████ ███ """, + "color": "mediumgray" }, "add": { "x": 31, @@ -520,11 +510,11 @@ "rockybeach": { "gen": { "additionals": [], - "width": 7, + "width": 5, "height": 1, "desc": "_LAKE", - "text": """█████ """, - "color": "\033[38;5;33;1m" + "text": """█████""", + "color": "lakeblue" }, "add": { "x": 27, @@ -540,7 +530,7 @@ "height": 1, "desc": "", "text": """██""", - "color": "\033[38;5;236;1m" + "color": "cavegray" }, "add": { "x": 32, @@ -568,7 +558,7 @@ "height": 1, "desc": "_LAKE", "text": """███""", - "color": "\033[38;5;33;1m" + "color": "lakeblue" }, "add": { "x": 12, @@ -583,7 +573,7 @@ "height": 1, "desc": "_LAKE", "text": """ ████ """, - "color": "\033[38;5;33;1m" + "color": "lakeblue" }, "add": { "x": 14, From c9a36a60bed806321c70a10b38deda039b513f8a Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Mon, 17 Jun 2024 17:31:19 +0200 Subject: [PATCH 7/7] feat(#275): Refactored roadmap make StationObject decend from se.Text --- pokete_classes/color.py | 33 +++-- pokete_classes/roadmap.py | 125 ++++++----------- pokete_data/__init__.py | 2 +- pokete_data/mapstations.py | 275 +++++++++++++------------------------ 4 files changed, 155 insertions(+), 280 deletions(-) diff --git a/pokete_classes/color.py b/pokete_classes/color.py index 23707ea9..3a8f8ef0 100644 --- a/pokete_classes/color.py +++ b/pokete_classes/color.py @@ -1,6 +1,7 @@ """Contains the color class""" from os import environ + class Color: """Color class that provides all needed escape codes""" reset = "\033[0m" @@ -16,23 +17,21 @@ class Color: cyan = "\033[1;36m" lightgrey = "\033[37m" white = "\033[1;37m" - - #extended color palette - brown="\033[38;5;88m" - lakeblue="\033[38;5;33m" - mediumgray="\033[38;5;238m" - brightyellow="\033[38;5;155m" - deepgreen="\033[38;5;35m" - lightgray="\033[38;5;246m" - brightgreen="\033[38;5;46m" - darkgreen="\033[38;5;29m" - gold="\033[38;5;94m" - cavegray="\033[38;5;236m" - - if environ["TERM"] == "linux": #this fixes some colors on TTY - gold="\033[38;5;9m" - cavegray="\033[38;5;7m" - + + # extended color palette + brown = "\033[38;5;88m" + lakeblue = "\033[38;5;33m" + mediumgrey = "\033[38;5;238m" + brightyellow = "\033[38;5;155m" + deepgreen = "\033[38;5;35m" + brightgreen = "\033[38;5;46m" + darkgreen = "\033[38;5;29m" + gold = "\033[38;5;94m" + cavegrey = "\033[38;5;236m" + + if environ["TERM"] == "linux": # this fixes some colors on TTY + gold = "\033[38;5;9m" + cavegrey = "\033[38;5;7m" if __name__ == "__main__": diff --git a/pokete_classes/roadmap.py b/pokete_classes/roadmap.py index 1885692f..a90cc96a 100644 --- a/pokete_classes/roadmap.py +++ b/pokete_classes/roadmap.py @@ -1,7 +1,4 @@ """Contains all classes relevant to show the roadmap""" - -import time -import random import scrap_engine as se import pokete_data as p_data @@ -23,56 +20,15 @@ def __init__(self, _map): super().__init__(text) -"""A little hackaround""" - - -class StationObject(se.Box): - - def __init__(self, text, width, height, ob_class=se.Object): - super().__init__(height, width) - self.ob_class = ob_class - self.text = text - self.ob_args = {} - self.__create() - #TODO: if self.desc == "_LAKE" animate water - - def __create(self): - for ry in range(self.height): - for rx in range(self.width): - if len(self.text) == 1: - r = 0 - else: - r = ry * self.width + rx - self.add_ob( - self.ob_class(self.text[r], "float", - arg_proto=self.ob_args), rx, ry - ) - - def recolor(self, color): - r = 0 - for obj in self.obs: - obj.rechar(color + self.text[r] + Color.reset) - if len(self.text) != 1: - r += 1 - - def animate_water(self): - # bruh i think this could be done better - water_colors = [ - "\033[38;5;38m", - "\033[38;5;75m", - "\033[38;5;39m", - "\033[38;5;74m", - ] - while True: - r = 0 - for obj in self.obs: - obj.rechar( - water_colors[random.randint(0, len(water_colors) - 1)] - + self.text[r] - + Color.reset - ) - r += 1 - time.sleep(0.7) +class StationObject(se.Text): + + def __init__(self, text, color): + super().__init__(text, esccode=color, state="float") + + +class Decoration(StationObject): + def __init__(self, text, color=""): + super().__init__(text, getattr(Color, color, Color.lightgrey)) class Station(StationObject): @@ -81,10 +37,7 @@ class Station(StationObject): roadmap: RoadMap object associate: Main PlayMap name the station belongs to additionals: List of PlayMap names the station also belongs to - width: The Station's width - height: The Station's height desc: The associated description - char: Displayed char {w,a,s,d}_next: The next Station's name in a certain direction""" choosen = None @@ -95,11 +48,9 @@ def __init__( roadmap, associate, additionals, - width, - height, desc, + text, color="", - text="#", w_next="", a_next="", s_next="", @@ -107,14 +58,13 @@ def __init__( ): self.desc = desc self.roadmap = roadmap - self.org_char = text - self.associates = [associate] + [obmp.ob_maps[i] for i in additionals] self.color = getattr(Color, color, "\033[1;37m") + self.base_color = self.color + self.base_text = text + self.associates = [associate] + [obmp.ob_maps[i] for i in additionals] if self.associates[0]: self.name = self.associates[0].pretty_name - super().__init__(text, width, height) - self.recolor(self.color) - #self.hide_if_visited() + super().__init__(text, self.color) self.w_next = w_next self.a_next = a_next self.s_next = s_next @@ -132,10 +82,10 @@ def unchoose(self): self.un_blink() def blink(self): - self.recolor(Color.red + Color.thicc) + self.rechar(self.text, Color.red + Color.thicc) def un_blink(self): - self.recolor(self.color) + self.rechar(self.text, self.color) def next(self, inp: ActionList): """Chooses the next station in a certain direction @@ -163,25 +113,21 @@ def is_city(self): """Returns if the station is a city""" return "pokecenter" in p_data.map_data[self.associates[0].name][ "hard_obs"] - - def is_cave(self): - #returns if the station is in a cave - if self.text[0] == "█": return True - return False def hide_if_visited(self, choose=False): - if self.associates[0] is not None: - if choose: - if self.is_city() and self.has_been_visited(): - self.recolor(Color.green + Color.thicc) - elif not self.is_cave(): - self.recolor(Color.white) + self.text = self.base_text + if not self.has_been_visited(): + self.color = Color.white + for ch in ["A", "P", "$", "C", "#"]: + self.text = self.text.replace(ch, " ") + elif choose: + if self.is_city(): + self.color = self.base_color else: - self.recolor(self.color) - if not self.has_been_visited(): - features = ["A", "P", "$", "C", "⌂", "#"] - for ch in features: - self.text = self.text.replace(ch, " ") + self.color = Color.white + else: + self.color = self.base_color + self.rechar(self.text, self.color) class RoadMap: @@ -195,10 +141,23 @@ def __init__(self, fig): 17, 61, "Roadmap", f"{Action.CANCEL.mapping}:close", overview=mvp.movemap ) + self.rose = se.Text(""" N + ▲ +W ◀ ▶ E + ▼ + S""", state="float") + self.legend = se.Text("""│ Legend: +│ P-Pokecenter +│ $-Shop +│ C-PoketeCare +│ A-Arena +└──────────────""", state="float") self.info_label = se.Text("", state="float") self.box.add_ob(self.info_label, self.box.width - 2, 0) + self.box.add_ob(self.rose, 53, 11) + self.box.add_ob(self.legend, 45, 1) for sta, _dict in p_data.decorations.items(): - obj = Station(self, None, **_dict["gen"]) + obj = Decoration(**_dict["gen"]) self.box.add_ob(obj, **_dict["add"]) setattr(self, sta, obj) diff --git a/pokete_data/__init__.py b/pokete_data/__init__.py index da726d53..e77f9983 100644 --- a/pokete_data/__init__.py +++ b/pokete_data/__init__.py @@ -93,7 +93,7 @@ def validate(): "soft_ob": ["x", "y", "txt"], "dor": ["x", "y", "args"], "ball": ["x", "y"], - "gen": ["additionals", "width", "height", "desc"], + "gen": ["additionals", "text", "desc"], "add": ["x", "y"], "poke_ico": ["txt", "esc"], "trainer": ["pokes", "args"] diff --git a/pokete_data/mapstations.py b/pokete_data/mapstations.py index b0d3d533..4a87921d 100644 --- a/pokete_data/mapstations.py +++ b/pokete_data/mapstations.py @@ -2,11 +2,11 @@ "playmap_1": { "gen": { "additionals": ["intromap"], - "width": 4, - "height": 3, "desc": "A small town.", "d_next": "playmap_51", - "text": """ *P#├─── # #""", + "text": """ *P# +├─── + # #""", "color": "brightgreen" }, "add": { @@ -17,14 +17,13 @@ "playmap_51": { "gen": { "additionals": [], - "width": 3, - "height": 2, "desc": "Some small patches of grass surrounded by forrest, near " "Nice Town.", "a_next": "playmap_1", "w_next": "cave_1", - "text": r"""└─┐──┘""", + "text": r"""└─┐ +──┘""", "color": "darkgreen" }, "add": { @@ -35,13 +34,13 @@ "cave_1": { "gen": { "additionals": [], - "width": 1, - "height": 3, "desc": "A dark cave full of batos.", "s_next": "playmap_51", "d_next": "playmap_2", - "text": """███""", - "color": "cavegray" + "text": """█ +█ +█""", + "color": "cavegrey" }, "add": { "x": 7, @@ -51,8 +50,6 @@ "playmap_2": { "gen": { "additionals": [], - "width": 4, - "height": 1, "desc": "Part of light areas near Sunny Dale.", "a_next": "cave_1", "d_next": "playmap_3", @@ -67,13 +64,13 @@ "playmap_3": { "gen": { "additionals": ["playmap_49"], - "width": 3, - "height": 3, "desc": "A small sunny village.", "a_next": "playmap_2", "w_next": "playmap_4", "s_next": "playmap_6", - "text": """P│$─┤ #│#""", + "text": """P│$ +─┤ +#│#""", "color": "brightgreen" }, "add": { @@ -84,12 +81,12 @@ "playmap_4": { "gen": { "additionals": ["playmap_5"], - "width": 1, - "height": 3, "desc": "The shores of the great Sunnydale lake.", "s_next": "playmap_3", "d_next": "playmap_28", - "text": """├││""", + "text": """├ +│ +│""", "color": "darkgreen" }, "add": { @@ -100,14 +97,14 @@ "playmap_6": { "gen": { "additionals": [], - "width": 3, - "height": 3, "desc": "The woodland edge at the foot of a great mountain full of \ caves.", "w_next": "playmap_3", "a_next": "playmap_7", "d_next": "playmap_8", - "text": """│ │ ┴──""", + "text": """│ +│ +┴──""", "color": "deepgreen" }, "add": { @@ -118,12 +115,10 @@ "playmap_7": { "gen": { "additionals": [], - "width": 2, - "height": 1, "desc": "A dark and mysterious cave.", "d_next": "playmap_6", "text": """██""", - "color": "cavegray" + "color": "cavegrey" }, "add": { "x": 11, @@ -133,13 +128,12 @@ "playmap_8": { "gen": { "additionals": ["playmap_10", "playmap_9"], - "width": 3, - "height": 2, "desc": "An abandoned fisher village.", "a_next": "playmap_6", "s_next": "playmap_11", "d_next": "playmap_12", - "text": """# ─┬─""", + "text": """# +─┬─""", "color": "brightyellow" }, "add": { @@ -150,8 +144,6 @@ "playmap_11": { "gen": { "additionals": [], - "width": 1, - "height": 1, "desc": "The shore of a lake near an olf fisher village.", "w_next": "playmap_8", "text": """│""", @@ -165,12 +157,11 @@ "playmap_12": { "gen": { "additionals": [], - "width": 2, - "height": 2, "desc": "A dense forest near Deepens forest.", "a_next": "playmap_8", "w_next": "playmap_13", - "text": """ │─┘""", + "text": """ │ +─┘""", "color": "brown" }, "add": { @@ -181,13 +172,14 @@ "playmap_13": { "gen": { "additionals": ["playmap_14", "playmap_20"], - "width": 3, - "height": 3, - "desc": "Deepens forest, a big town in the middle of the deepest \ -forest, populated by thousands of people and cultural center of the region.", + "desc": "Deepens forest, a big town in the middle of the deepest " + "forest, populated by thousands of people and cultural " + "center of the region.", "s_next": "playmap_12", "w_next": "playmap_15", - "text": """#│A │ P│$""", + "text": """#│A + │ +P│$""", "color": "gold" }, "add": { @@ -198,8 +190,6 @@ "playmap_15": { "gen": { "additionals": [], - "width": 3, - "height": 1, "desc": "A small clearing near Deepens forest.", "s_next": "playmap_13", "d_next": "playmap_16", @@ -214,8 +204,6 @@ "playmap_16": { "gen": { "additionals": ["playmap_17"], - "width": 3, - "height": 1, "desc": "A small 'village', that's not even worth talking about.", "a_next": "playmap_15", "d_next": "playmap_18", @@ -230,8 +218,6 @@ "playmap_18": { "gen": { "additionals": [], - "width": 3, - "height": 1, "desc": "A small see at the foot of the Big mountain.", "a_next": "playmap_16", "w_next": "playmap_19", @@ -246,13 +232,12 @@ "playmap_19": { "gen": { "additionals": [], - "width": 1, - "height": 2, "desc": "A dark and big cave in the Big mountain.", "s_next": "playmap_18", "w_next": "playmap_21", - "text": """██""", - "color": "cavegray" + "text": """█ +█""", + "color": "cavegrey" }, "add": { "x": 28, @@ -264,16 +249,16 @@ "additionals": ["playmap_22", "playmap_23", "playmap_24", "playmap_25", "playmap_26", "playmap_27", "playmap_29", "playmap_50"], - "width": 4, - "height": 3, - "desc": "The great Rock-ville is the biggest city in the region \ -around the Big mountain. With the Rocky hotel it's also a tourist \ -hotspot.", + "desc": "The great Rock-ville is the biggest city in the region " + "around the Big mountain. With the Rocky hotel it's " + "also a tourist hotspot.", "s_next": "playmap_19", "d_next": "playmap_33", "w_next": "playmap_40", - "text": """P│ #┌┴──│#C """, - "color": "lightgray" + "text": """P│ # +┌┴── +│#C """, + "color": "lightgrey" }, "add": { "x": 28, @@ -283,8 +268,6 @@ "playmap_40": { "gen": { "additionals": [], - "width": 1, - "height": 1, "desc": "A Great beach, with great weather, always.", "s_next": "playmap_21", "text": """│""", @@ -298,12 +281,11 @@ "playmap_28": { "gen": { "additionals": [], - "width": 5, - "height": 2, "desc": "A foggy place full of ghosts and plants.", "a_next": "playmap_4", "d_next": "playmap_30", - "text": """ ┌────┘ """, + "text": """ ┌── +──┘""", "color": "brightgreen" }, "add": { @@ -314,13 +296,13 @@ "playmap_30": { "gen": { "additionals": ["playmap_31", "playmap_32"], - "width": 4, - "height": 3, - "desc": "With its plant Poketes, Flowy Town may be the greenest \ -spot in the Pokete world and with the great git-tree it may also be one \ -of the most spectacular.", + "desc": "With its plant Poketes, Flowy Town may be the greenest " + "spot in the Pokete world and with the great git-tree it " + "may also be one of the most spectacular.", "a_next": "playmap_28", - "text": """A$P ───┤# # """, + "text": """A$P +───┤ +# # """, "color": "deepgreen" }, "add": { @@ -331,8 +313,6 @@ "playmap_33": { "gen": { "additionals": ["playmap_34"], - "width": 2, - "height": 1, "desc": "Part of the great agracultural landscape near Agrawos.", "a_next": "playmap_21", "d_next": "playmap_35", @@ -347,12 +327,12 @@ "playmap_35": { "gen": { "additionals": ["playmap_36", "playmap_37", "playmap_38"], - "width": 3, - "height": 3, "desc": "Part of the great agracultural landscape near Agrawos.", "a_next": "playmap_33", "s_next": "playmap_39", - "text": """──┐┌─┘└─┐""", + "text": """──┐ +┌─┘ +└─┐""", "color": "brightyellow" }, "add": { @@ -365,8 +345,6 @@ "additionals": ["playmap_41", "playmap_42", "playmap_43", "playmap_44", "playmap_45", "playmap_46", "playmap_47", "playmap_48"], - "width": 4, - "height": 4, "desc": "The great city of Agrawos, agricultural and cultural " "center of the whole region. It's famous for its great " "Pokete-Arena and its master trainer. Check out the " @@ -374,7 +352,10 @@ "juiciest and most delicious Mowcow-burgers, cut from the " "happiest and most delicious Mowcows anywhere to find!", "w_next": "playmap_35", - "text": """ #│# P│A├─┘# $ #""", + "text": """ #│# + P│A +├─┘# + $ #""", "color": "yellow" }, "add": { @@ -382,95 +363,84 @@ "y": 7 } }, - - - + } -decorations={ +decorations = { "cave3": { "gen": { - "additionals": [], - "width": 5, - "height": 3, - "desc": "", - "text": """██ ████ ███""", - "color": "mediumgray" + "text": """██ +████ + ███""", + "color": "mediumgrey" }, "add": { "x": 8, "y": 10 } }, - + "cave2": { "gen": { - "additionals": [], - "width": 4, - "height": 3, - "desc": "", - "text": """█ ███ ███""", - "color": "mediumgray" + "text": """█ +███ + ███""", + "color": "mediumgrey" }, "add": { "x": 10, "y": 13 } }, - + "cave1": { "gen": { - "additionals": [], - "width": 6, - "height": 4, - "desc": "", - "text": """ ████████████ █""", - "color": "mediumgray" + "text": """ +██████ +██████ + █""", + "color": "mediumgrey" }, "add": { "x": 1, "y": 8 } }, - + "cave4-1": { "gen": { - "additionals": [], - "width": 4, - "height": 2, - "desc": "", - "text": """████████""", - "color": "mediumgray" + "text": """████ +████""", + "color": "mediumgrey" }, "add": { "x": 23, "y": 1 } }, - + "cave4": { "gen": { - "additionals": [], - "width": 5, - "height": 5, - "desc": "", - "text": """ ███ ███ ███ ███ ██""", - "color": "mediumgray" + "text": """ ███ + ███ + ███ + ███ + ██""", + "color": "mediumgrey" }, "add": { "x": 23, "y": 3 } }, - + "cave5": { "gen": { - "additionals": [], - "width": 5, - "height": 4, - "desc": "", - "text": """ ███████████ ██ """, - "color": "mediumgray" + "text": """ ██ +█████ +████ + ██ """, + "color": "mediumgrey" }, "add": { "x": 29, @@ -479,10 +449,6 @@ }, "mountainsee": { "gen": { - "additionals": [], - "width": 1, - "height": 1, - "desc": "_LAKE", "text": """█""", "color": "lakeblue" }, @@ -491,28 +457,22 @@ "y": 8 } }, - + "cave7": { "gen": { - "additionals": [], - "width": 6, - "height": 3, - "desc": "", - "text": """ ████ ████ ███ """, - "color": "mediumgray" + "text": """ ████ + ████ + ███ """, + "color": "mediumgrey" }, "add": { "x": 31, "y": 1 } }, - + "rockybeach": { "gen": { - "additionals": [], - "width": 5, - "height": 1, - "desc": "_LAKE", "text": """█████""", "color": "lakeblue" }, @@ -521,42 +481,19 @@ "y": 1 } }, - - + "cave6": { "gen": { - "additionals": [], - "width": 2, - "height": 1, - "desc": "", "text": """██""", - "color": "cavegray" + "color": "cavegrey" }, "add": { "x": 32, "y": 4 } }, - - "rose": { - "gen": { - "additionals": [], - "width": 7, - "height": 5, - "desc": "", - "text": """ N ▲ W ◀ ▶ E ▼ S """ - }, - "add": { - "x": 53, - "y": 11 - } - }, "sunnylake": { "gen": { - "additionals": [], - "width": 3, - "height": 1, - "desc": "_LAKE", "text": """███""", "color": "lakeblue" }, @@ -565,13 +502,8 @@ "y": 4 } }, - "fisherlake": { "gen": { - "additionals": [], - "width": 6, - "height": 1, - "desc": "_LAKE", "text": """ ████ """, "color": "lakeblue" }, @@ -580,21 +512,6 @@ "y": 15 } }, - - "Legend": { - "gen": { - "additionals": [], - "width": 15, - "height": 6, - "desc": "", - "text": """│ Legend: │ P-Pokecenter │ $-Shop │ C-PoketeCare │ A-Arena └──────────────""" - #! - avaiable quests - }, - "add": { - "x": 45, - "y": 1 - } - }, } if __name__ == "__main__":