From 622f05f9cd1772907993e80e29d085b9154ac784 Mon Sep 17 00:00:00 2001 From: Cromha Date: Sun, 21 Jan 2024 08:57:36 +0100 Subject: [PATCH 1/5] progress[major] - main engine --- .github/workflows/cd.yaml | 6 +- .github/workflows/ci.yaml | 6 +- Bane-Of-Wargs.spec | 2 +- compile.sh | 1 - data/items.yaml | 6 ++ schemas/items_Utility.yaml | 3 + schemas/preferences.yaml | 2 +- {source => scripts}/map_item.py | 0 source/main.py | 110 ++++++++++++++++++++++++++------ 9 files changed, 108 insertions(+), 28 deletions(-) rename {source => scripts}/map_item.py (100%) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index e6f30e5..867c3f8 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -42,7 +42,7 @@ jobs: pip install -r requirements.txt pip install PyInstaller - python -m PyInstaller --console --onefile --name Bane-Of-Wargs source/main.py source/battle.py source/check_yaml.py source/colors.py source/map_item.py source/train.py source/logger_sys.py source/mission_handling.py source/dialog_handling.py source/enemy_handling.py source/data_handling.py source/npc_handling.py source/text_handling.py source/zone_handling.py source/uuid_handling.py source/weapon_upgrade_handling.py --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs --hidden-import fsspec + python -m PyInstaller Bane-Of-Wargs.spec mv dist/Bane-Of-Wargs Bane-Of-Wargs-Linux - name: Upload artifact uses: actions/upload-artifact@v3 @@ -77,7 +77,7 @@ jobs: pip install -r requirements.txt pip install PyInstaller - python -m PyInstaller --console --onefile --name Bane-Of-Wargs source/main.py source/battle.py source/check_yaml.py source/colors.py source/map_item.py source/train.py source/logger_sys.py source/mission_handling.py source/dialog_handling.py source/enemy_handling.py source/data_handling.py source/npc_handling.py source/text_handling.py source/zone_handling.py source/uuid_handling.py source/weapon_upgrade_handling.py --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs + python -m PyInstaller Bane-Of-Wargs.spec mv dist/Bane-Of-Wargs Bane-Of-Wargs-Mac - name: Upload artifact uses: actions/upload-artifact@v3 @@ -112,7 +112,7 @@ jobs: pip install -r requirements.txt pip install windows-curses PyInstaller - python -m PyInstaller --console --onefile --name Bane-Of-Wargs source/main.py source/battle.py source/check_yaml.py source/colors.py source/map_item.py source/train.py source/logger_sys.py source/mission_handling.py source/dialog_handling.py source/enemy_handling.py source/data_handling.py source/npc_handling.py source/text_handling.py source/zone_handling.py source/uuid_handling.py source/weapon_upgrade_handling.py --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs --hidden-import fsspec + python -m PyInstaller Bane-Of-Wargs.spec mv dist/Bane-Of-Wargs.exe Bane-Of-Wargs.exe - name: Upload artifact uses: actions/upload-artifact@v3 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b38616d..9d48394 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,7 +43,7 @@ jobs: pip install -r requirements.txt pip install PyInstaller - python -m PyInstaller --console --onefile --name Bane-Of-Wargs source/main.py source/battle.py source/check_yaml.py source/colors.py source/map_item.py source/train.py source/logger_sys.py source/mission_handling.py source/dialog_handling.py source/enemy_handling.py source/data_handling.py source/npc_handling.py source/text_handling.py source/zone_handling.py source/uuid_handling.py source/weapon_upgrade_handling.py --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs --hidden-import fsspec + python -m PyInstaller Bane-Of-Wargs.spec mv dist/Bane-Of-Wargs Bane-Of-Wargs-Linux - name: Upload artifact uses: actions/upload-artifact@v3 @@ -77,7 +77,7 @@ jobs: pip install -r requirements.txt pip install PyInstaller - python -m PyInstaller --console --onefile --name Bane-Of-Wargs source/main.py source/battle.py source/check_yaml.py source/colors.py source/map_item.py source/train.py source/logger_sys.py source/mission_handling.py source/dialog_handling.py source/enemy_handling.py source/data_handling.py source/npc_handling.py source/text_handling.py source/zone_handling.py source/uuid_handling.py source/weapon_upgrade_handling.py --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs + python -m PyInstaller Bane-Of-Wargs.spec mv dist/Bane-Of-Wargs Bane-Of-Wargs-Mac - name: Upload artifact uses: actions/upload-artifact@v3 @@ -111,7 +111,7 @@ jobs: pip install -r requirements.txt pip install windows-curses PyInstaller - python -m PyInstaller --console --onefile --name Bane-Of-Wargs source/main.py source/battle.py source/check_yaml.py source/colors.py source/map_item.py source/train.py source/logger_sys.py source/mission_handling.py source/dialog_handling.py source/enemy_handling.py source/data_handling.py source/npc_handling.py source/text_handling.py source/zone_handling.py source/uuid_handling.py source/weapon_upgrade_handling.py --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs --hidden-import fsspec + python -m PyInstaller Bane-Of-Wargs.spec mv dist/Bane-Of-Wargs.exe Bane-Of-Wargs.exe - name: Upload artifact uses: actions/upload-artifact@v3 diff --git a/Bane-Of-Wargs.spec b/Bane-Of-Wargs.spec index 295bf35..a7801b4 100644 --- a/Bane-Of-Wargs.spec +++ b/Bane-Of-Wargs.spec @@ -7,7 +7,7 @@ hiddenimports += collect_submodules('appdirs') a = Analysis( - ['source/main.py', 'source/battle.py', 'source/check_yaml.py', 'source/colors.py', 'source/map_item.py', 'source/train.py', 'source/logger_sys.py', 'source/term_menu.py', 'source/mission_handling.py', 'source/dialog_handling.py', 'source/enemy_handling.py', 'source/data_handling.py', 'source/npc_handling.py', 'source/text_handling.py', 'source/zone_handling.py', 'source/uuid_handling.py', 'source/weapon_upgrade_handling.py'], + ['source/main.py', 'source/battle.py', 'source/check_yaml.py', 'source/colors.py', 'source/train.py', 'source/logger_sys.py', 'source/term_menu.py', 'source/mission_handling.py', 'source/dialog_handling.py', 'source/enemy_handling.py', 'source/data_handling.py', 'source/npc_handling.py', 'source/text_handling.py', 'source/zone_handling.py', 'source/uuid_handling.py', 'source/weapon_upgrade_handling.py'], pathex=[], binaries=[], datas=[('yamale/VERSION', 'yamale')], diff --git a/compile.sh b/compile.sh index d2c881e..008c405 100755 --- a/compile.sh +++ b/compile.sh @@ -8,7 +8,6 @@ source/main.py \ source/battle.py \ source/check_yaml.py \ source/colors.py \ -source/map_item.py \ source/train.py \ source/logger_sys.py \ source/term_menu.py \ diff --git a/data/items.yaml b/data/items.yaml index f98aad1..9dabe11 100644 --- a/data/items.yaml +++ b/data/items.yaml @@ -259,6 +259,12 @@ Healing Potion: # Utilities Map: type: "Utility" + key: "M" + script name: 'map_item.py' + arguments: + - player + - zone + - map description: "It's a map of the dungeons! [Press 'M' to activate.]" # Armors Wolf Fur: &wolf_fur diff --git a/schemas/items_Utility.yaml b/schemas/items_Utility.yaml index af961b0..288b367 100644 --- a/schemas/items_Utility.yaml +++ b/schemas/items_Utility.yaml @@ -1,2 +1,5 @@ type: str() +key: str() +script name: str() description: str() +arguments: list(required=False) diff --git a/schemas/preferences.yaml b/schemas/preferences.yaml index 024fc5c..80ca962 100644 --- a/schemas/preferences.yaml +++ b/schemas/preferences.yaml @@ -1,7 +1,7 @@ latest preset: plugin: str() save: str() - type: str() + type: str(equals='plugin', equals='vanilla') speed up: bool() theme: str() title style: int(max=2, min=1) diff --git a/source/map_item.py b/scripts/map_item.py similarity index 100% rename from source/map_item.py rename to scripts/map_item.py diff --git a/source/main.py b/source/main.py index ad84ef7..0b349f5 100644 --- a/source/main.py +++ b/source/main.py @@ -3,7 +3,6 @@ import battle import check_yaml import train -import map_item import term_menu import mission_handling import dialog_handling @@ -124,7 +123,7 @@ def print_title(): logger_sys.log_message("INFO: Downloading game data to update it") print("Download game data...") print("This may take a few seconds, sorry for the waiting.") - print("0/3", end="\r") + print("0/4", end="\r") logger_sys.log_message("INFO: Downloading game yaml schemas files from github") @@ -144,7 +143,7 @@ def print_title(): print(COLOR_YELLOW + str(error) + COLOR_RESET_ALL) time.sleep(.5) - print("1/3", end="\r") + print("1/4", end="\r") logger_sys.log_message("INFO: Downloading game data files from github") # Download data files @@ -163,7 +162,7 @@ def print_title(): print(COLOR_YELLOW + str(error) + COLOR_RESET_ALL) time.sleep(.5) - print("2/3", end="\r") + print("2/4", end="\r") logger_sys.log_message("INFO: Downloading game images .txt files from github") # Download images .txt files @@ -182,7 +181,26 @@ def print_title(): print(COLOR_YELLOW + str(error) + COLOR_RESET_ALL) time.sleep(.5) - print("3/3") + print("3/4", end="\r") + + logger_sys.log_message("INFO: Downloading game scripts .py files from github") + # Download images .txt files + try: + destination = program_dir + '/game/scripts' + fs = fsspec.filesystem("github", org="Dungeons-Of-Kathallion", repo="Bane-Of-Wargs") + fs.get(fs.ls("scripts/"), destination) + except Exception as error: + print( + COLOR_YELLOW + COLOR_STYLE_BRIGHT + "WARNING:" + + COLOR_RESET_ALL + " an error occurred when trying to download game data to '" + + destination + "'." + ) + logger_sys.log_message(f"WARNING: An error occurred when downloading game data to '{destination}'.") + logger_sys.log_message("DEBUG: " + str(error)) + print(COLOR_YELLOW + str(error) + COLOR_RESET_ALL) + time.sleep(.5) + + print("4/4") print("Done") logger_sys.log_message("INFO: Process of downloading game data to update it completed") @@ -1337,6 +1355,16 @@ def run(play): ) command = input(COLOR_GREEN + COLOR_STYLE_BRIGHT + "> " + COLOR_RESET_ALL) print(" ") + + logger_sys.log_message(f"INFO: Checking for utilities type items in '{item}' dictionary") + # Check for utilities keys + utilities_list = [] + for i in list(item): + current_item = item[i] + if current_item["type"] == 'Utility': + utilities_list.append(i) + logger_sys.log_message(f"INFO: Found utilities items: '{utilities_list}'") + logger_sys.log_message(f"INFO: Player ran command '{command}'") logger_sys.log_message(f"INFO: Checking if a ground item is present at map point 'point{map_location}'") if "item" in map["point" + str(map_location)] and command in map["point" + str(map_location)]["item"]: @@ -2297,24 +2325,68 @@ def run(play): logger_sys.log_message(f"INFO: Canceling mount examining process --> player doesn't own any mounts") print(COLOR_YELLOW + "It seems you don't own any mounts." + COLOR_RESET_ALL) time.sleep(1.5) - elif command.lower().startswith('m'): - if "Map" in player["inventory"]: - logger_sys.log_message("INFO: Player is examining map") - map_item.print_map(player, map, zone) - else: - logger_sys.log_message("INFO: Canceling map examining process --> doesn't have 'Map' item") - print("You do not have a map.") - print(" ") - finished = input(" ") - elif command == "q" or command == "Q": + elif command.lower().startswith('q'): logger_sys.log_message("INFO: Closing & Saving game") print(separator) play = 0 else: - logger_sys.log_message(f"INFO: chosen command '{command}' is not a valid command") - print("'" + command + "' is not a valid command") - time.sleep(2) - print(" ") + continued = False + for i in utilities_list: + continued = True + current_utility = i + if command == item[current_utility]["key"] and current_utility in player["inventory"]: + logger_sys.log_message(f"INFO: Player is using utility item '{current_utility}'") + if preferences["latest preset"]["type"] == 'plugin': + with open( + program_dir + '/plugins/' + preferences["latest preset"]["plugin"] + '/scripts/' + item[current_utility]["script name"] + ) as f: + global_arguments = {} + arguments = item[current_utility]['arguments'] + if "player" in arguments: + global_arguments["player"] = player + if "map" in arguments: + global_arguments["map"] = map + if "item" in arguments: + global_arguments["item"] = item + if "drinks" in arguments: + global_arguments["drinks"] = drinks + if "enemy" in arguments: + global_arguments["enemy"] = enemy + if "npcs" in arguments: + global_arguments["npcs"] = npcs + if "start_player" in arguments: + global_arguments["start_player"] = start_player + if "lists" in arguments: + global_arguments["lists"] = lists + if "zone" in arguments: + global_arguments["zone"] = zone + if "dialog" in arguments: + global_arguments["dialog"] = dialog + if "mission" in arguments: + global_arguments["mission"] = mission + if "mounts" in arguments: + global_arguments["mounts"] = mounts + exec(f.read(), global_arguments) + else: + pass + # map_item.print_map(player, map, zone) + finished = input(" ") + elif current_utility not in player["inventory"]: + logger_sys.log_message("INFO: Canceling map examining process --> doesn't have 'Map' item") + print(f"You do not have a '{current_utility}'.") + print(" ") + finished = input(" ") + else: + logger_sys.log_message(f"INFO: chosen command '{command}' is not a valid command") + print("'" + command + "' is not a valid command") + time.sleep(2) + print(" ") + + if not continued: + logger_sys.log_message(f"INFO: chosen command '{command}' is not a valid command") + print("'" + command + "' is not a valid command") + time.sleep(2) + print(" ") # get end time end_time = time.time() logger_sys.log_message(f"INFO: Getting end time: '{end_time}'") From 673a9efa1b6167d12f635a8cfd5c49f0cd525b02 Mon Sep 17 00:00:00 2001 From: Cromha Date: Sun, 21 Jan 2024 09:13:51 +0100 Subject: [PATCH 2/5] fix - fixed code style checks error --- data/items.yaml | 2 +- source/main.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/data/items.yaml b/data/items.yaml index 9dabe11..7c035d8 100644 --- a/data/items.yaml +++ b/data/items.yaml @@ -265,7 +265,7 @@ Map: - player - zone - map - description: "It's a map of the dungeons! [Press 'M' to activate.]" + description: "It's a map of the world! [Press 'M' to activate.]" # Armors Wolf Fur: &wolf_fur display name: "Wolf Fur" diff --git a/source/main.py b/source/main.py index 0b349f5..935bc72 100644 --- a/source/main.py +++ b/source/main.py @@ -2338,7 +2338,8 @@ def run(play): logger_sys.log_message(f"INFO: Player is using utility item '{current_utility}'") if preferences["latest preset"]["type"] == 'plugin': with open( - program_dir + '/plugins/' + preferences["latest preset"]["plugin"] + '/scripts/' + item[current_utility]["script name"] + program_dir + '/plugins/' + preferences["latest preset"]["plugin"] + + '/scripts/' + item[current_utility]["script name"] ) as f: global_arguments = {} arguments = item[current_utility]['arguments'] From 73cac52e67d939f934b7ad2d4c3997c0188ace09 Mon Sep 17 00:00:00 2001 From: Cromha Date: Sun, 21 Jan 2024 09:22:04 +0100 Subject: [PATCH 3/5] bugfix - fixed possible bugs --- source/main.py | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/source/main.py b/source/main.py index 935bc72..02af501 100644 --- a/source/main.py +++ b/source/main.py @@ -2342,31 +2342,32 @@ def run(play): '/scripts/' + item[current_utility]["script name"] ) as f: global_arguments = {} - arguments = item[current_utility]['arguments'] - if "player" in arguments: - global_arguments["player"] = player - if "map" in arguments: - global_arguments["map"] = map - if "item" in arguments: - global_arguments["item"] = item - if "drinks" in arguments: - global_arguments["drinks"] = drinks - if "enemy" in arguments: - global_arguments["enemy"] = enemy - if "npcs" in arguments: - global_arguments["npcs"] = npcs - if "start_player" in arguments: - global_arguments["start_player"] = start_player - if "lists" in arguments: - global_arguments["lists"] = lists - if "zone" in arguments: - global_arguments["zone"] = zone - if "dialog" in arguments: - global_arguments["dialog"] = dialog - if "mission" in arguments: - global_arguments["mission"] = mission - if "mounts" in arguments: - global_arguments["mounts"] = mounts + if "arguments" in item[current_utility]: + arguments = item[current_utility]['arguments'] + if "player" in arguments: + global_arguments["player"] = player + if "map" in arguments: + global_arguments["map"] = map + if "item" in arguments: + global_arguments["item"] = item + if "drinks" in arguments: + global_arguments["drinks"] = drinks + if "enemy" in arguments: + global_arguments["enemy"] = enemy + if "npcs" in arguments: + global_arguments["npcs"] = npcs + if "start_player" in arguments: + global_arguments["start_player"] = start_player + if "lists" in arguments: + global_arguments["lists"] = lists + if "zone" in arguments: + global_arguments["zone"] = zone + if "dialog" in arguments: + global_arguments["dialog"] = dialog + if "mission" in arguments: + global_arguments["mission"] = mission + if "mounts" in arguments: + global_arguments["mounts"] = mounts exec(f.read(), global_arguments) else: pass From 99e03d72ac7e614e1b09b94ad94e622030d9f5ac Mon Sep 17 00:00:00 2001 From: Cromha Date: Sun, 21 Jan 2024 09:39:08 +0100 Subject: [PATCH 4/5] tweak - tweaked some stuff --- source/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/source/main.py b/source/main.py index 02af501..7141f66 100644 --- a/source/main.py +++ b/source/main.py @@ -2371,7 +2371,6 @@ def run(play): exec(f.read(), global_arguments) else: pass - # map_item.print_map(player, map, zone) finished = input(" ") elif current_utility not in player["inventory"]: logger_sys.log_message("INFO: Canceling map examining process --> doesn't have 'Map' item") From 526a4f6bc16282b4218697acd869335eedf282c5 Mon Sep 17 00:00:00 2001 From: Cromha Date: Sun, 21 Jan 2024 09:42:41 +0100 Subject: [PATCH 5/5] fix - fixed visual bug --- source/main.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/main.py b/source/main.py index 7141f66..43af09e 100644 --- a/source/main.py +++ b/source/main.py @@ -2333,6 +2333,7 @@ def run(play): continued = False for i in utilities_list: continued = True + continued2 = False current_utility = i if command == item[current_utility]["key"] and current_utility in player["inventory"]: logger_sys.log_message(f"INFO: Player is using utility item '{current_utility}'") @@ -2369,25 +2370,27 @@ def run(play): if "mounts" in arguments: global_arguments["mounts"] = mounts exec(f.read(), global_arguments) + continued2 = True else: pass finished = input(" ") elif current_utility not in player["inventory"]: + continued2 = True logger_sys.log_message("INFO: Canceling map examining process --> doesn't have 'Map' item") print(f"You do not have a '{current_utility}'.") print(" ") finished = input(" ") - else: - logger_sys.log_message(f"INFO: chosen command '{command}' is not a valid command") - print("'" + command + "' is not a valid command") - time.sleep(2) - print(" ") - - if not continued: + if not continued2: logger_sys.log_message(f"INFO: chosen command '{command}' is not a valid command") print("'" + command + "' is not a valid command") time.sleep(2) print(" ") + + if not continued: + logger_sys.log_message(f"INFO: chosen command '{command}' is not a valid command") + print("'" + command + "' is not a valid command") + time.sleep(2) + print(" ") # get end time end_time = time.time() logger_sys.log_message(f"INFO: Getting end time: '{end_time}'")