Skip to content

Commit

Permalink
progress[major] - custom utilities creation (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
OcelotWalrus authored Jan 21, 2024
1 parent b3066c4 commit 068b724
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Bane-Of-Wargs.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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')],
Expand Down
1 change: 0 additions & 1 deletion compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
8 changes: 7 additions & 1 deletion data/items.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,13 @@ Healing Potion:
# Utilities
Map:
type: "Utility"
description: "It's a map of the dungeons! [Press 'M' to activate.]"
key: "M"
script name: 'map_item.py'
arguments:
- player
- zone
- map
description: "It's a map of the world! [Press 'M' to activate.]"
# Armors
Wolf Fur: &wolf_fur
display name: "Wolf Fur"
Expand Down
3 changes: 3 additions & 0 deletions schemas/items_Utility.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
type: str()
key: str()
script name: str()
description: str()
arguments: list(required=False)
2 changes: 1 addition & 1 deletion schemas/preferences.yaml
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
File renamed without changes.
106 changes: 91 additions & 15 deletions source/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import battle
import check_yaml
import train
import map_item
import term_menu
import mission_handling
import dialog_handling
Expand Down Expand Up @@ -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")

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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")

Expand Down Expand Up @@ -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"]:
Expand Down Expand Up @@ -2297,20 +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:
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}'")
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 = {}
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)
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(" ")
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)
Expand Down

0 comments on commit 068b724

Please sign in to comment.