fix: saving equipped items

This commit is contained in:
Matyáš Caras 2022-05-24 09:40:21 +02:00 committed by GitHub
parent b8ffa7871d
commit 6e55242fb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -44,10 +44,10 @@ class FightHandler:
def show(self):
system("cls||clear")
p = math.trunc(self.hp/self.max*10)
h = "🟥"*p
h = f"{Fore.RED}{Fore.RESET}"*p
j = math.trunc(self.my/30*10)
a = "🟩"*j
a = f"{Fore.GREEN}{Fore.RESET}"*j
if str(p).endswith(".5"):
h += ""
if str(a).endswith(".5"):
@ -113,7 +113,11 @@ class FightHandler:
name = list(self.attacks[p].keys())[0]
enemyAtk = self.attacks[p][name]["atk"]
enemyDef = self.enemyDef
playerAtk = 0
playerDef = 0
if self.equipped["weapon"] is not None:
playerAtk = self.equipped["weapon"].attack
if self.equipped["armor"] is not None:
playerDef = self.equipped["armor"].defense
c = enemyAtk - playerDef
@ -131,6 +135,7 @@ class FightHandler:
class FightMenu(MenuManager): # Upravené menu, které nemá input na konci, protože to jinak buguje
def __init__(self,selections:list,additional:str):
keyboard.remove_all_hotkeys()
self.selected = 0
self.selections = selections
self.additional = additional

View file

@ -169,6 +169,7 @@ class Game: # Hlavní třída, uchovává údaje o hře
elif (sel == len(actions_desc)-1): # Uložit a ukončit
self.save.currentPrompt = self.current
self.save.inventory = self.inventory
self.save.equipped = self.equipped
self.save.save()
exit(0)
else:
@ -219,7 +220,7 @@ class Game: # Hlavní třída, uchovává údaje o hře
return newText
def load(file_path,lang): # Načte hru z YAML souboru
with open(file_path) as f:
with open(file_path, encoding="utf-8") as f:
data = yaml.load(f,Loader=SafeLoader)
g = Game(data,lang)
return g