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

FEATURE: Traveling Rework & Mounts Stats Addition #74

Merged
merged 4 commits into from
Mar 8, 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
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ Here are the main code style conventions:
- You shouldn't worry about that checks too much

## Merging Pull Requests
When you merge a pull request, please `Squash Merge`, remove commit listing, use the [naming convention](#naming-conventions), and add extra details if necessary. You do not have to use the name of a PR in the commit name. Note that before merging, every github action checks must be passing.
When you merge a pull request, please `Squash Merge`, remove commit listing, use the [naming convention](#naming-conventions), and add extra details if necessary. You do not have to use the name of a PR in the commit name. Note that before merging, every github action checks must be passing. If the PR you're merging updates the `GAME_SOURCE_CODE_VERSION` and `GAME_DATA_VERSION` constants in the `main.py` class, please specify it in the commit description.
16 changes: 16 additions & 0 deletions data/mounts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Warg:
name: Warg
plural: Wargs
gold: 59.36
mph: 24
feed:
food:
- Beef
Expand All @@ -19,11 +20,13 @@ Warg:
level stat additions:
agility addition: .025
resistance addition: .015
mph addition: .25
description: "Wargs are at first Yrch mounts but they can be tamed and then used to fight against Yrch. Wargs are fast and agile mounts."
White Warg:
name: White Warg
plural: White Wargs
gold: 320.34
mph: 29
feed:
food:
- Beef
Expand All @@ -41,11 +44,13 @@ White Warg:
level stat additions:
agility addition: .015
resistance addition: .01
mph addition: .2
description: "Wargs are at first Yrch mounts but they can be tamed and then used to fight against Yrch. Wargs are fast and agile mounts."
Bear:
name: Bear
plural: Bears
gold: 79.58
mph: 15
feed:
food:
- Beef
Expand All @@ -62,11 +67,13 @@ Bear:
level stat additions:
agility addition: .015
resistance addition: .15
mph addition: .2
description: "Bears are very big and powerful animals that are very hard to train; they required lot of work."
Horse:
name: Horse
plural: Horses
gold: 54.23
mph: 17
feed:
food:
- Carrot
Expand All @@ -84,11 +91,13 @@ Horse:
level stat additions:
agility addition: .015
resistance addition: .005
mph addition: .25
description: "There are many different species of horses that you can find in the Kathallion Plains. This is a generic horse that you can find almost anywhere in the Kathallion Plains."
Friesian Horse:
name: Friesian Horse
plural: Friesian Horses
gold: 74.35
mph: 18
feed:
food:
- Hay Bale
Expand All @@ -105,11 +114,13 @@ Friesian Horse:
level stat additions:
agility addition: .016
resistance addition: .007
mph addition: .26
description: "Friesian Horses are breeds who are known for their docile ,energetic and swift high-stepping trot. They are often used by knights."
Shire Horse:
name: Shire Horse
plural: Shire Horses
gold: 63.35
mph: 16
feed:
food:
- Hay Bale
Expand All @@ -126,11 +137,13 @@ Shire Horse:
level stat additions:
agility addition: .015
resistance addition: .02
mph addition: .15
description: "Shire Horses are tall horses that are often used by farmers to labor their lands. Despite that, they are also great horses for knights. "
Camel:
name: Camel
plural: Camels
gold: 76.42
mph: 10
feed:
food:
- Wheat
Expand All @@ -149,13 +162,15 @@ Camel:
level stat additions:
agility addition: .011
resistance addition: .023
mph addition: .1
description: >
Camels are mounts used by the merchants of the Gerud Valleys, who often need to cross the whole Gerud Desert
and sometimes the Badlands to get to their destination.
Donkey:
name: Donkey
plural: Donkeys
gold: 84.58
mph: 11
feed:
food:
- Carrot
Expand All @@ -172,6 +187,7 @@ Donkey:
level stat additions:
agility addition: .01
resistance addition: .021
mph addition: .13
description: >
Donkeys are not from the Stall Island, but some explorer brought them a few centuries ago and they're now often used by
merchants that want to cross the difficult Goro Mounts or the wild Mangrove Wastes.
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ Here are the main code style conventions:
- You shouldn't worry about that checks too much

## Merging Pull Requests
When you merge a pull request, please `Squash Merge`, remove commit listing, use the [naming convention](#naming-conventions), and add extra details if necessary. You do not have to use the name of a PR in the commit name. Note that before merging, every github action checks must be passing.
When you merge a pull request, please `Squash Merge`, remove commit listing, use the [naming convention](#naming-conventions), and add extra details if necessary. You do not have to use the name of a PR in the commit name. Note that before merging, every github action checks must be passing. If the PR you're merging updates the `GAME_SOURCE_CODE_VERSION` and `GAME_DATA_VERSION` constants in the `main.py` class, please specify it in the commit description.
2 changes: 2 additions & 0 deletions schemas/mounts.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: str()
plural: str()
gold: num()
mph: int()
feed:
food: list(str())
feed needs: num()
Expand All @@ -15,4 +16,5 @@ levels:
level stat additions:
agility addition: num()
resistance addition: num()
mph addition: num()
description: str()
41 changes: 39 additions & 2 deletions source/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def print_title():
program_dir = str(appdirs.user_config_dir(appname='Bane-Of-Wargs'))
first_start = False
if not os.path.exists(program_dir):
GAME_DATA_VERSION = 0.15
GAME_DATA_VERSION = 0.16
os.mkdir(program_dir)
# Open default config file and store the text into
# a variable to write it into the user config file
Expand Down Expand Up @@ -155,7 +155,7 @@ def print_title():
logger_sys.log_message("INFO: Checking if game source code is up to date")
global latest_version
latest_version = None # placeholder
SOURCE_CODE_VERSION = 0.15
SOURCE_CODE_VERSION = 0.16
latest_main_class = io.StringIO(data_handling.temporary_git_file_download(
'source/main.py', 'https://github.com/Dungeons-of-Kathallion/Bane-Of-Wargs.git'
)).readlines()
Expand Down Expand Up @@ -871,6 +871,13 @@ def run(play):
"level stat additions"
]["resistance addition"] * (round(current_mount_data["level"]) - 1)), 3
)
player["mounts"][
str(player["current mount"])
]["mph"] = (
mounts[current_mount_type]["mph"] + mounts[current_mount_type]["levels"][
"level stat additions"
]["mph addition"] * round(current_mount_data["level"] - 1)
)

logger_sys.log_message("INFO: Verifying player equipped equipment is in the player's inventory")
# verify if player worn equipment are in his inventory
Expand Down Expand Up @@ -1094,6 +1101,19 @@ def run(play):
else:
enemies_damage_coefficient = 1.5

# Calculating traveling coefficient, depending
# on the player inventory size and its mounts
# stats, if he has one
global traveling_coefficient
traveling_coefficient = 1

player_inventory_weight = len(player["inventory"]) / 100
traveling_coefficient += player_inventory_weight

if player["current mount"] != " ":
mount_mph = player["mounts"][player["current mount"]]["mph"]
traveling_coefficient -= mount_mph / 100

# All the checks for the player active effects
# are done here
#
Expand Down Expand Up @@ -1634,6 +1654,11 @@ def run(play):
utilities_list.append(i)
logger_sys.log_message(f"INFO: Found utilities items: '{utilities_list}'")

# Saving oldest coordinates
global player_x_old, player_y_old
player_x_old = player["x"]
player_y_old = player["y"]

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}'")
continued_command = False
Expand Down Expand Up @@ -2650,6 +2675,10 @@ def run(play):
" RESISTANCE ADDITION: " + COLOR_CYAN + COLOR_STYLE_BRIGHT +
str(which_mount_data["stats"]["resistance addition"]) + COLOR_RESET_ALL
)
cout(
" MPH: " + COLOR_BACK_BLUE + COLOR_STYLE_BRIGHT +
str(round(which_mount_data["mph"], 1)) + COLOR_RESET_ALL
)
cout(" ")

# get player possible feeding items
Expand Down Expand Up @@ -2845,6 +2874,14 @@ def run(play):
time.sleep(2)
cout(" ")

# Checking if the player has traveled, if
# yes, run a traveling wait
if (
player["x"] != player_x_old or
player["y"] != player_y_old
):
time_handling.traveling_wait(traveling_coefficient)

# get end time
end_time = time.time()
logger_sys.log_message(f"INFO: Getting end time: '{end_time}'")
Expand Down
29 changes: 29 additions & 0 deletions source/time_handling.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# source imports
import logger_sys
from colors import *
from terminal_handling import cout
# external imports
import calendar
import time
from datetime import datetime, timedelta


# Constants
COEFFICIENT = (1 / 720)
TRAVELING_WAIT = (1 / 7.3)

# Handling Functions

Expand All @@ -15,6 +19,7 @@ def addition_to_date(date, addition):
# Get month, day and year and then
# calculate the addition and return
# the value
logger_sys.log_message(f"INFO: Calculating addition of {addition} days to date {date}")
separated_date = date.split('-', 2)
month = separated_date[0]
day = separated_date[1]
Expand All @@ -30,13 +35,15 @@ def addition_to_date(date, addition):
new_year = future_date[0]

future_date = f"{new_month}-{new_day}-{new_year}"
logger_sys.log_message(f"INFO: Calculated addition of {addition} days to date {date} --> {future_date}")

return future_date


def date_prettifier(date):
# Get month, day and year and then
# prettify them and return the value
logger_sys.log_message(f"INFO: Prettifying date {date}")
separated_date = date.split('-', 2)
month = calendar.month_name[int(separated_date[0])]
day = separated_date[1]
Expand All @@ -62,6 +69,7 @@ def date_prettifier(date):
if day.startswith("0"):
day = day.replace("0", "")
formatted_date = f"{day} {month}, year {year}"
logger_sys.log_message(f"INFO: Prettified data {date} -- > {formatted_date}")

return formatted_date

Expand All @@ -79,11 +87,32 @@ def get_day_time(game_days):
day_time = COLOR_GREEN + COLOR_STYLE_BRIGHT + "☼ DAY" + COLOR_RESET_ALL
elif day_time_decimal > .75 and day_time_decimal:
day_time = COLOR_YELLOW + COLOR_STYLE_BRIGHT + "▼ EVENING" + COLOR_RESET_ALL
logger_sys.log_message(f"INFO: Calculated day time of game day decimal '{game_days}' --> '{day_time}'")

return day_time


def return_game_day_from_seconds(seconds, time_elapsing_coefficient):
logger_sys.log_message(
f"INFO: Calculating in-game days from seconds '{seconds}', with coefficient '{
time_elapsing_coefficient * COEFFICIENT
}'"
)
game_days = seconds * COEFFICIENT * time_elapsing_coefficient # 12 minutes irl = one whole game day (1=720*x)

return game_days


def traveling_wait(traveling_coefficient):
traveling_time = traveling_coefficient * TRAVELING_WAIT
logger_sys.log_message(f"INFO: Running traveling waiting time: {traveling_time * 5} seconds of wait")
cout("...", end="\r")
time.sleep(traveling_time)
cout("ø..", end="\r")
time.sleep(traveling_time)
cout(".ø.", end="\r")
time.sleep(traveling_time)
cout("..ø", end="\r")
time.sleep(traveling_time)
cout("...")
time.sleep(traveling_time)
3 changes: 2 additions & 1 deletion source/zone_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ def interaction_stable(map_zone, zone, player, item, drinks, mounts, map_locatio
"location": "point" + str(map_location),
"mount": str(which_mount),
"name": str(new_mount_name),
"stats": mount_stats
"stats": mount_stats,
"mph": mounts[which_mount]["mph"]
}
logger_sys.log_message(f"INFO: Created new mount stats: '{mount_dict}'")
player["mounts"][generated_mount_uuid] = mount_dict
Expand Down
Loading