-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
87 lines (80 loc) · 3.67 KB
/
main.py
File metadata and controls
87 lines (80 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import sys
import random
from player import Player
from game_data import get_shop_items, get_enemy_templates
from shop import shop_loop
from battle import battle_prep
from enemy import Enemy
class GameState:
def __init__(self):
self.player = Player()
self.current_enemy = None
self.shop_items = get_shop_items()
def create_enemy(self):
enemy_templates = get_enemy_templates()
enemy_template = random.choice(enemy_templates)
self.current_enemy = Enemy(enemy_template, self.player.level, self.player.bonus_agility)
self.player.current_health = self.player.get_effective_health()
def start(game_state):
print("Welcome to the shop what would you like to do?")
shop_loop(game_state)
def greet():
game_state = GameState()
name = input("What is your name? ").capitalize()
if name == "Dev":
game_state.player.coins = 999
ready = input("Hello, " + name + " are you ready to start? [Y/N] ").upper()
if ready == "Y":
start(game_state)
else:
print("Exiting...")
sys.exit(0)
def pre_battle(game_state):
game_state.player.update_trinket_bonuses()
pre_battle_choice = input("List inventory, equip item, check stats, or go to battle? ").lower()
if pre_battle_choice == "list inventory":
print(game_state.player.inventory)
pre_battle(game_state)
elif pre_battle_choice == "check stats":
equipped_names = game_state.player.equipment.get_equipped_names()
print("Your equipped sword is " + equipped_names["sword"] + "!")
print("Your equipped armor is " + equipped_names["armor"] + "!")
print(f"Your equipped charm is {equipped_names['charm']}!")
print(f"Your equipped amulet is {equipped_names['amulet']}!")
print(f"Your equipped ring is {equipped_names['ring']}!")
print("Your health without armor is " + str(game_state.player.base_health) + "!")
print("Your health with armor is " + str(game_state.player.get_effective_health()) + "!")
print("Your damage without sword is " + str(game_state.player.base_damage) + "!")
print("Your damage with sword is " + str(game_state.player.get_effective_damage()) + "!")
print(f"Your bonus agility is {game_state.player.bonus_agility}!")
pre_battle(game_state)
elif pre_battle_choice == "go to battle":
battle_prep(game_state)
elif pre_battle_choice == "equip item":
equip_item = input("Which item? ").title()
if equip_item in game_state.player.inventory:
all_items = (game_state.shop_items["swords"] +
game_state.shop_items["trinkets"] +
game_state.shop_items["armors"])
for item in all_items:
if item["name"] == equip_item:
if item["item_type"] == "sword":
print(f"{item['name']} equipped")
game_state.player.equipment.equip_sword(item)
pre_battle(game_state)
elif item["item_type"] == "armor":
print(f"{item['name']} equipped")
game_state.player.equipment.equip_armor(item)
pre_battle(game_state)
elif item["item_type"] == "trinket":
if game_state.player.equipment.equip_trinket(item):
print(f"{item['name']} equipped")
else:
print("You already have one of those equipped")
pre_battle(game_state)
else:
pre_battle(game_state)
if __name__ == "__main__":
greet()
print("Script end")
sys.exit(0)