Skip to content

Commit

Permalink
progress - progressed in the mission handling offering part
Browse files Browse the repository at this point in the history
  • Loading branch information
OcelotWalrus committed Jan 14, 2024
1 parent 6c3c11a commit d9d13fb
Show file tree
Hide file tree
Showing 7 changed files with 277 additions and 186 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 --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs --hidden-import fsspec
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 --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs --hidden-import fsspec
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 --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs
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 --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs
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 --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs --hidden-import fsspec
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 --add-data yamale/VERSION:yamale --collect-submodules fsspec --collect-submodules appdirs --hidden-import appdirs --hidden-import fsspec
mv dist/Bane-Of-Wargs.exe Bane-Of-Wargs.exe
- name: Upload artifact
uses: actions/upload-artifact@v3
Expand Down
1 change: 1 addition & 0 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ source/train.py \
source/logger_sys.py \
source/term_menu.py \
source/mission_handling.py \
source/dialog_handling.py \
--add-data yamale/VERSION:yamale \
--collect-submodules fsspec \
--collect-submodules appdirs \
Expand Down
5 changes: 0 additions & 5 deletions data/dialog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,3 @@ generic steel gate blocking east:
- "There is a strong steel gate blocking anyone wanting to go further east."
- "You must find the key to open it!"
scene: Steel Gate

first mission:
use actions: False
phrases:
- "First mission! yay!"
1 change: 1 addition & 0 deletions docs/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ source/train.py \
source/logger_sys.py \
source/term_menu.py \
source/mission_handling.py \
source/dialog_handling.py \
--add-data yamale/VERSION:yamale \
--collect-submodules fsspec \
--collect-submodules appdirs \
Expand Down
204 changes: 204 additions & 0 deletions source/dialog_handling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
import logger_sys
import appdirs
import sys
import time
import random
from colorama import Fore, Back, Style, deinit, init
from colors import *

# Initialize colorama
init()

# Get program directory
program_dir = str(appdirs.user_config_dir(appname='Bane-Of-Wargs'))

# Functions to handle dialogs
def print_speech_text_effect(text, preferences):
text = str(text) + "\n"
new_input = ""
for i, letter in enumerate(text):
if i % 54 == 0:
new_input += '\n'
new_input += letter
if preferences["speed up"] == False:
for character in new_input:
sys.stdout.write(character)
sys.stdout.flush()
time.sleep(round(random.uniform(.05, .1), 2))
else:
for character in new_input:
sys.stdout.write(character)
sys.stdout.flush()
time.sleep(.02)

def print_dialog(current_dialog, dialog, preferences, text_replacements_generic, player, drinks):
current_dialog_name = current_dialog
logger_sys.log_message(f"INFO: Printing dialog '{current_dialog_name}'")
current_dialog = dialog[str(current_dialog)]
dialog_len = len(current_dialog["phrases"])
if "scene" in current_dialog:
current_dialog_scene = str(current_dialog["scene"])
logger_sys.log_message(f"INFO: Printing dialog '{current_dialog_name}' scene at '{program_dir}/game/imgs/{current_dialog_scene}.txt'")
if preferences["latest preset"]["type"] == 'vanilla':
with open(program_dir + '/game/imgs/' + str(current_dialog["scene"]) + '.txt') as f:
to_print = str(f.read())
to_print = to_print.replace('$RED', '\033[0;31m')
to_print = to_print.replace('$GREEN', '\033[0;32m')
to_print = to_print.replace('$YELLOW', '\033[0;33m')
to_print = to_print.replace('$BLUE', '\033[0;34m')
to_print = to_print.replace('$PURPLE', '\033[0;34m')
to_print = to_print.replace('$CYAN', '\033[0;36m')
to_print = to_print.replace('$WHITE', '\033[0;37m')
to_print = to_print.replace('$BLACK', '\033[0;30m')
to_print = to_print.replace('$BROWN', '\033[0;33m')
to_print = to_print.replace('$GRAY', '\033[1;30m')
print(to_print)
else:
current_plugin = str(preferences["latest preset"]["plugin"])
logger_sys.log_message(f"INFO: Printing dialog '{current_dialog_name}' scene at '{program_dir}/plugins/{current_plugin}/imgs/{current_dialog_scene}.txt'")
with open(program_dir + '/plugins/' + str(preferences["latest preset"]["plugin"]) + '/imgs/' + str(current_dialog["scene"]) + '.txt') as f:
to_print = str(f.read())
to_print = to_print.replace('$RED', '\033[0;31m')
to_print = to_print.replace('$GREEN', '\033[0;32m')
to_print = to_print.replace('$YELLOW', '\033[0;33m')
to_print = to_print.replace('$BLUE', '\033[0;34m')
to_print = to_print.replace('$PURPLE', '\033[0;34m')
to_print = to_print.replace('$CYAN', '\033[0;36m')
to_print = to_print.replace('$WHITE', '\033[0;37m')
to_print = to_print.replace('$BLACK', '\033[0;30m')
to_print = to_print.replace('$BROWN', '\033[0;33m')
to_print = to_print.replace('$GRAY', '\033[1;30m')
print(to_print)
count = 0
logger_sys.log_message(f"INFO: Printing dialog '{current_dialog_name}' phrases")
while count < dialog_len:
text = str(current_dialog["phrases"][int(count)])
count = 0
while count < len(list(text_replacements_generic)):
current_text_replacement = str(list(text_replacements_generic)[count])
text = text.replace(current_text_replacement, str(text_replacements_generic[current_text_replacement]))
count += 1
print_speech_text_effect(text, preferences)
count += 1
if current_dialog["use actions"] == True:
logger_sys.log_message(f"INFO: Executing dialog '{current_dialog_name}' actions on the player")
actions = current_dialog["actions"]
if "give item" in actions:
given_items = actions["give item"]
given_items_len = len(given_items)
count = 0
logger_sys.log_message(f"INFO: Giving to the player items '{given_items}'")
while count < given_items_len:
selected_item = given_items[count]
player["inventory"].append(selected_item)
count += 1
if "add attributes" in actions:
count = 0
added_attributes = actions["add attributes"]
added_attributes_len = len(added_attributes)
logger_sys.log_message(f"INFO: Adding attributes '{added_attributes}' to the player")
while count < added_attributes_len:
selected_attribute = added_attributes[count]
player["attributes"].append(selected_attribute)
count += 1
if "health modification" in actions:
if "diminution" in actions["health modification"]:
logger_sys.log_message("INFO: Removing " + actions["health modification"]["diminution"] + " hp from the player's health")
player["health"] -= actions["health modification"]["diminution"]
if "augmentation" in actions["health modification"]:
logger_sys.log_message("INFO: Adding " + actions["health modification"]["augmentation"] + " hp from the player's health")
player["health"] += actions["health modification"]["augmentation"]
if "max health" in actions["health modification"]:
if "diminution" in actions["health modification"]["max health"]:
logger_sys.log_message("INFO: Removing " + actions["health modification"]["max health"]["diminution"] + " hp from the player's max health")
player["max health"] -= actions["health modification"]["max health"]["diminution"]
if "augmentation" in actions["health modification"]["max health"]:
logger_sys.log_message("INFO: Adding " + actions["health modification"]["max health"]["augmentation"] + " hp from the player's max health")
player["max health"] += actions["health modification"]["max health"]["augmentation"]
if "gold modification" in actions:
if "diminution" in actions["gold modification"]:
logger_sys.log_message("INFO: Removing " + actions["gold modification"]["diminution"] + " gold to the player")
player["gold"] -= actions["gold modification"]["diminution"]
if "augmentation" in actions["gold modification"]:
logger_sys.log_message("INFO: Adding " + actions["gold modification"]["diminution"] + " gold to the player")
player["gold"] += actions["gold modification"]["augmentation"]
if "remove item" in actions:
removed_items = actions["remove item"]
removed_items_len = len(removed_items)
count = 0
logger_sys.log_message(f"INFO: Removing items '{removed_items}' from player's inventory")
while count < removed_items_len:
selected_item = removed_items[count]
player["inventory"].remove(selected_item)
count += 1
if "add to diary" in actions:
if "known zones" in actions["add to diary"]:
added_visited_zones = actions["add to diary"]["known zones"]
added_visited_zones_len = len(added_visited_zones)
count = 0
logger_sys.log_message(f"INFO: Adding zones '{added_visited_zones}' to player's visited zones")
while count < added_visited_zones_len:
selected_zone = added_visited_zones[count]
player["visited zones"].append(selected_zone)
count += 1
if "known enemies" in actions["add to diary"]:
added_known_enemies = actions["add to diary"]["known enemies"]
added_known_enemies_len = len(added_known_enemies)
count = 0
logger_sys.log_message(f"INFO: Adding enemies '{added_known_enemies}' to player's known enemies")
while count < added_known_enemies_len:
selected_enemy = added_known_enemies[count]
player["enemies list"].append(selected_enemy)
count += 1
if "known npcs" in actions["add to diary"]:
added_known_npcs = actions["add to diary"]["known npcs"]
added_known_npcs_len = len(added_known_npcs)
count = 0
logger_sys.log_message(f"INFO: Adding npcs '{added_known_npcs}' to player's known npcs")
while count < added_known_npcs_len:
selected_npc = added_known_npcs[count]
player["met npcs name"].append(selected_npc)
count += 1
if "remove to diary" in actions:
if "known zones" in actions["remove to diary"]:
removed_visited_zones = actions["remove to diary"]["known zones"]
removed_visited_zones_len = len(removed_visited_zones)
count = 0
logger_sys.log_message(f"INFO: Removing zones '{added_visited_zones}' to player's visited zones")
while count < removed_visited_zones_len:
selected_zone = removed_visited_zones[count]
player["visited zones"].remove(selected_zone)
count += 1
if "known enemies" in actions["remove to diary"]:
removed_known_enemies = actions["remove to diary"]["known enemies"]
removed_known_enemies_len = len(removed_known_enemies)
count = 0
logger_sys.log_message(f"INFO: Removing enemies '{added_known_enemies}' to player's known enemies")
while count < removed_known_enemies_len:
selected_enemy = removed_known_npcs[count]
player["enemies list"].remove(selected_enemy)
count += 1
if "known npcs" in actions["remove to diary"]:
removed_known_npcs = actions["remove to diary"]["known npcs"]
removed_known_npcs_len = len(removed_known_npcs)
count = 0
logger_sys.log_message(f"INFO: Removing npcs '{added_known_npcs}' to player's known npcs")
while count < removed_known_npcs_len:
selected_npc = removed_known_npcs[count]
player["met npcs name"].append(selected_npc)
count += 1
if "use drink" in actions:
used_drinks = actions["use drink"]
used_drinks_len = len(used_drinks)
count = 0
logger_sys.log_message(f"INFO: Using drinks '{used_drinks}'")
while count < used_drinks_len:
selected_drink = used_drinks_len[count]
if drinks[selected_drink]["healing level"] == 999:
player["health"] = player["max health"]
else:
player["health"] += drinks[selected_drink]["healing level"]


# Deinitialize colorama
deinit()
Loading

0 comments on commit d9d13fb

Please sign in to comment.