Skip to content

Commit

Permalink
progression[major] - added logging system + many enhancements/fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
OcelotWalrus committed Jan 6, 2024
1 parent a7c67ce commit e1de745
Show file tree
Hide file tree
Showing 10 changed files with 505 additions and 35 deletions.
2 changes: 1 addition & 1 deletion data/dialog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ first village enter warg attack:
add attributes:
- "seen warg attacking village"

guy saw you fighting gives you money:
guy saw you fighting gives you gold:
to display:
player attributes:
- "seen warg attacking village"
Expand Down
9 changes: 8 additions & 1 deletion data/drinks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ Suspicious Stew:
gold: 12.5
healing level: 16
description: "Why not try to drink this?"

Coffee:
gold: 7.4
healing level: 7
description: "A warm coffee, perfect to relax."
Hot Chocolate:
gold: 7.6
healing level: 8
description: "A tasty beverage for any adventurer willing to rest."
3 changes: 3 additions & 0 deletions data/mission.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hunt Down Yrch Covet:
name: "Hunt Down Yrch Covet"
description: ""
6 changes: 6 additions & 0 deletions data/start.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ elapsed time seconds: 1
elapsed time game days: .25
attributes:
- None
active missions:
- None
done missions:
- None
offered missions:
- None
orders:
None: none
mounts:
Expand Down
12 changes: 6 additions & 6 deletions data/zone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Cocorico Village:
news:
- "Hey! Did you ever heard about tamed Wargs? Seems crazy right?"
- "You should checkout the hostel in the village! They sell items for great prices!"
- "Please, give money so we can build a church! We need a church to protect the village from monsters at night time!"
- "Please, give gold so we can build a church! We need a church to protect the village from monsters at night time!"
- "Would you help me defend the village? I'll need help tonight. Just circles near the village entry and watch out for monsters."
- "..."
- "Hey I'm Joshu... Ooh, You don't care..."
Expand Down Expand Up @@ -57,7 +57,7 @@ Woodstack Hostel:
news:
- "Hey! Did you ever heard about tamed Wargs? Seems crazy right?"
- "You should checkout the hostel in the village! They sell items for great prices!"
- "Please, give money so we can build a church! We need a church to protect the village from monsters at night time!"
- "Please, give gold so we can build a church! We need a church to protect the village from monsters at night time!"
- "Would you help me defend the village? I'll need help tonight. Just circles near the village entry and watch out for monsters."
- "..."
- "Hey I'm Joshu... Ooh, You don't care..."
Expand Down Expand Up @@ -96,7 +96,7 @@ Pickaxe Forge:
news:
- "Hey! Did you ever heard about tamed Wargs? Seems crazy right?"
- "You should checkout the hostel in the village! They sell items for great prices!"
- "Please, give money so we can build a church! We need a church to protect the village from monsters at night time!"
- "Please, give gold so we can build a church! We need a church to protect the village from monsters at night time!"
- "Would you help me defend the village? I'll need help tonight. Just circles near the village entry and watch out for monsters."
- "..."
- "Hey I'm Jo... Ooh, You don't care..."
Expand Down Expand Up @@ -130,11 +130,11 @@ James Blacksmith:
type: blacksmith
cost value: 1
location: 42
description: "Welcome to James Blacksmith! You can here sell metals to make money, but metals and order many type of swords!"
description: "Welcome to James Blacksmith! You can here sell metals to make gold, but metals and order many type of swords!"
news:
- "Hey! Did you ever heard about tamed Wargs? Seems crazy right?"
- "You should checkout the hostel in the village! They sell items for great prices!"
- "Please, give money so we can build a church! We need a church to protect the village from monsters at night time!"
- "Please, give gold so we can build a church! We need a church to protect the village from monsters at night time!"
- "Would you help me defend the village? I'll need help tonight. Just circles near the village entry and watch out for monsters."
- "..."
- "Hey I'm Jo... Ooh, You don't care..."
Expand Down Expand Up @@ -208,7 +208,7 @@ Clarc Warg Stable:
news:
- "Hey! Did you ever heard about tamed Wargs? Seems crazy right?"
- "You should checkout the hostel in the village! They sell items for great prices!"
- "Please, give money so we can build a church! We need a church to protect the village from monsters at night time!"
- "Please, give gold so we can build a church! We need a church to protect the village from monsters at night time!"
- "Would you help me defend the village? I'll need help tonight. Just circles near the village entry and watch out for monsters."
- "..."
- "Hey I'm Jo... Ooh, You don't care..."
Expand Down
3 changes: 3 additions & 0 deletions schemas/saves.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ defeated enemies: list(int(), str(equals=None))
elapsed time game days: num()
elapsed time seconds: num()
enemies list: list(str())
active missions: list(str())
done missions: list(str())
offered missions: list(str())
gold: num()
health: int()
heard dialogs: list(int(), str(equals=None))
Expand Down
3 changes: 3 additions & 0 deletions schemas/start.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ inventory slots remaining: int()
elapsed time seconds: num()
elapsed time game days: num()
attributes: list(str())
active missions: list(str())
done missions: list(str())
offered missions: list(str())
orders: any()
mounts: any()
start dialog:
Expand Down
6 changes: 6 additions & 0 deletions source/check_yaml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import yamale
import yaml
import appdirs
import logger_sys
from colors import *
from colorama import Fore, Back, Style, init, deinit

Expand Down Expand Up @@ -49,12 +50,14 @@ def check_yaml(file_path):

schema = yamale.make_schema(file_schema)
data = yamale.make_data(content=str(current_object_data))
logger_sys.log_message(f"INFO: Validating file '{file_path}' data: '{current_object_data}' with schema '{file_schema}'")
yamale.validate(schema, data)

count += 1
elif file_type == 'start':
schema = yamale.make_schema(file_schema)
data = yamale.make_data(file_path)
logger_sys.log_message(f"INFO: Validating file '{file_path}' data: '{data}' with schema '{file_schema}'")
yamale.validate(schema, data)
elif file_type == 'zones' or file_type == 'items':
count = 0
Expand All @@ -66,18 +69,21 @@ def check_yaml(file_path):

schema = yamale.make_schema(str(file_schema))
data = yamale.make_data(content=str(current_object_data))
logger_sys.log_message(f"INFO: Validating file '{file_path}' data: '{current_object_data}' with schema '{file_schema}'")
yamale.validate(schema, data)

count += 1
elif file_type == 'preferences' or file_type == 'saves':
file_schema = f'{program_dir}/game/schemas/{file_type}.yaml'
schema = yamale.make_schema(file_schema)
data = yamale.make_data(file_path)
logger_sys.log_message(f"INFO: Validating file '{file_path}' data: '{data}' with schema '{file_schema}'")
yamale.validate(schema, data)

def examine(file_path):
try:
check_yaml(str(file_path))
except Exception as error:
print(COLOR_RED + "ERROR: " + COLOR_RESET_ALL + COLOR_RED + COLOR_STYLE_BRIGHT + "A parsing error in a yaml file has been detected:\n" + COLOR_RESET_ALL + str(error))
logger_sys.log_message(f"ERROR: A parsing error in a yaml file has been detected:\n{error}")
exit(1)
18 changes: 18 additions & 0 deletions source/logger_sys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import logging
import appdirs
from datetime import date

def log_message(message):
program_dir = str(appdirs.user_config_dir(appname='Bane-Of-Wargs'))

# Create and configure logger
logging.basicConfig(filename=f'{program_dir}/logs/{date.today()}.log',
format='%(asctime)s %(message)s',
filemode='w'
)


# Let us create an object
logger = logging.getLogger()

logger.warning(message)
Loading

0 comments on commit e1de745

Please sign in to comment.