Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROGRESS: Mission Data Type & More #26

Merged
merged 11 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 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 --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 source/enemy_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 --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 source/enemy_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 --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 source/enemy_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 Expand Up @@ -165,7 +165,7 @@ jobs:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: ${{ github.workspace }}
path: ${{ github.workspace }}
- name: Add ${{ env.OUTPUT_LINUX }} to release tag
continue-on-error: true
run: |
Expand Down
3 changes: 3 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ 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 \
--add-data yamale/VERSION:yamale \
--collect-submodules fsspec \
--collect-submodules appdirs \
Expand Down
1 change: 0 additions & 1 deletion data/dialog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
phrases:
- "Hey! Welcome to this cool and beautiful game $name! I hope you'll have fun playing it."
- "Find villages, fight monsters, equip and upgrade yourself with looted items and protect people from monsters!"
- "Also, don't forget to explore the map! It is very big. If you're too annoyed with the vanilla plot and items, you can try to find plugins and install them!"

Check warning on line 5 in data/dialog.yaml

View workflow job for this annotation

GitHub Actions / Validate Yaml

5:121 [line-length] line too long (161 > 120 characters)
- "Or even create your own plugin and be creative!"
use actions: False
scene: Title1
Expand All @@ -11,7 +11,7 @@
phrases:
- "You enter the village, but you cannot find any one in the streets."
- "You keep looking for people when you hear some noise and try to approach where it comes from."
- "You enter the village center place and you see every one of the village forming a circle. You look in the center and you see an angry warg."

Check warning on line 14 in data/dialog.yaml

View workflow job for this annotation

GitHub Actions / Validate Yaml

14:121 [line-length] line too long (145 > 120 characters)
- "One guy see you and shout out:\n `Hey guys! There's a knight to help' us!`"
- "You guess you can't get back now, you have to fight the warg."
scene: Warg
Expand All @@ -25,7 +25,7 @@
player attributes:
- "seen warg attacking village"
phrases:
- "Hey! Aren't you the courageous knight who fought the Warg yesterday? Please accept these 7 gold coins and this tissue bag."

Check warning on line 28 in data/dialog.yaml

View workflow job for this annotation

GitHub Actions / Validate Yaml

28:121 [line-length] line too long (128 > 120 characters)
- "I want you now that you are welcome in this village!"
use actions: True
actions:
Expand All @@ -45,7 +45,7 @@
find another old rusted key in case:
to display:
player attributes:
- met jerry the junk seller

Check warning on line 48 in data/dialog.yaml

View workflow job for this annotation

GitHub Actions / Validate Yaml

48:7 [indentation] wrong indentation: expected 4 but found 6
use actions: True
phrases:
- "You find another old rusted key on the ground. Looks exactly like the one Jerry The Junk Seller was talking about."
Expand All @@ -60,4 +60,3 @@
- "There is a strong steel gate blocking anyone wanting to go further east."
- "You must find the key to open it!"
scene: Steel Gate

12 changes: 9 additions & 3 deletions data/mission.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Hunt Down Yrch Covet:
name: "Hunt Down Yrch Covet"
description: ""
First Mission:
name: "First Mission"
description: "Go to $destination"
source: 0
destination: 5
on offer:
dialog: "first mission"
on complete:
dialog: "first mission"
5 changes: 3 additions & 2 deletions data/start.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ elapsed time seconds: 1
elapsed time game days: .25
attributes:
- None
active missions:
- None
active missions: []
done missions:
- None
offered missions:
Expand Down Expand Up @@ -58,3 +57,5 @@ defeated enemies:
- None
met npcs:
- None
missions:
None: none
3 changes: 3 additions & 0 deletions docs/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ 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 \
--add-data yamale/VERSION:yamale \
--collect-submodules fsspec \
--collect-submodules appdirs \
Expand Down
14 changes: 14 additions & 0 deletions schemas/missions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: str()
description: str()
invisible: bool()
deadline: int(required=False)
stopovers: list(int(), required=False)
to offer: any(required=False)
to complete: any(required=False)
to fail: any(required=False)
source: int()
destination: int()
on offer: any(required=False)
on complete: any(required=False)
on fail: any(required=False)
enemies: any(required=False)
1 change: 1 addition & 0 deletions schemas/start.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ map zone: str()
taken items: list(int(), str(equals=None))
defeated enemies: list(int(), str(equals=None))
met npcs: list(int(), str(equals=None))
missions: any()
6 changes: 3 additions & 3 deletions source/battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def encounter_text_show(player, item, enemy, map, map_location, enemies_remainin
print_separator(text)

print(" ")
startup_action = input("> ")
startup_action = input(COLOR_GREEN + COLOR_STYLE_BRIGHT + "> " + COLOR_RESET_ALL)
print("")

text = '='
Expand All @@ -294,7 +294,7 @@ def encounter_text_show(player, item, enemy, map, map_location, enemies_remainin
player_inventory = player_inventory.replace(", ", '\n -')
print("INVENTORY:")
print(player_inventory)
item_input = input("> ")
item_input = input(COLOR_GREEN + COLOR_STYLE_BRIGHT + "> " + COLOR_RESET_ALL)
# use item
if item_input in player["inventory"]:
if item[item_input]["type"] == "Consumable" or item[item_input]["type"] == "Food":
Expand Down Expand Up @@ -457,7 +457,7 @@ def fight(player, item, enemy, map, map_location, enemies_remaining, lists):
print_separator(text)
print("INVENTORY:")
print(player_inventory)
item_input = input("> ")
item_input = input(COLOR_GREEN + COLOR_STYLE_BRIGHT + "> " + COLOR_RESET_ALL)
# use item
if item_input in player["inventory"]:
if item[item_input]["type"] == "Consumable" or item[item_input]["type"] == "Food":
Expand Down
4 changes: 3 additions & 1 deletion source/check_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ def check_yaml(file_path):
file_type = 'npcs'
elif file_path.endswith('start.yaml'):
file_type = 'start'
elif file_path.endswith('mission.yaml'):
file_type = 'missions'
elif file_path.endswith('zone.yaml'):
file_type = 'zones'
elif file_path.endswith('preferences.yaml'):
file_type = 'preferences'
elif file_path.startswith('saves/'):
file_type = 'saves'
file_schema = str(f'{program_dir}/game/schemas/{file_type}.yaml')
if file_type == 'drinks' or file_type == 'mounts' or file_type == 'map' or file_type == 'lists' or file_type == 'npcs' or file_type == 'enemies' or file_type == 'dialogs':
if file_type == 'drinks' or file_type == 'mounts' or file_type == 'map' or file_type == 'lists' or file_type == 'npcs' or file_type == 'enemies' or file_type == 'dialogs' or file_type == 'missions':
count = 0
file_len = int(len(list(file)))
while count < file_len:
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
Loading