forked from hmccormak/Finalproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skeleton_of_CIRA.py
157 lines (123 loc) · 4.54 KB
/
skeleton_of_CIRA.py
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
from pygame import mixer
from time import sleep
import csv
def main():
name = input("What is your name?: ")
sleep(1)
print(f"{name} steps into the Hornblake dungeons, ready to break the curse of CIRA once and for all!")
sleep(2)
battle()
def attack(p_poke, o_poke):
"""Deals damages based off of poke stats,
uses strength() to determine advantage between poke types
Args:
p_poke: player poke
o_poke: opponent poke
Returns:
string reporting attack and (int?/float?) damage value
"""
starting_power = 1
p_poke = starting_power
o_poke = starting_power
class Poke():
"""poke object, will be used to make a list of them,
attacks and its power will be added into a dictionary, eg (attack: power)
three types: fire, water, magic
water crits fire, fire crits magic, magic crits water
Attributes: name, type, atk, hp, def, speed
"""
def __init__(self, fpath):
with open(fpath, "r", encoding="utf-8")as f:
self.pokemon = {}
line = csv.reader(f)
for line in f:
name = line[0]
type = line[1]
atk = line[2]
hp = line[3]
deffense = line[4]
speed = line[5] #might needed to be changed, unawere of speed in poke csv file
self.pokemon[line[0]] = atk, hp
class ItemCatalog():
"""Creates dictionary of items from csv file, items can either heal
or boost attack/defense. Item name will be the key, its value and it's
a/d/h label will be in a tuple
Attributes:
item: dictionary of items
"""
def __init__(self, fpath):
"""Method that opens a csv file and catergorizes the items by its name,
stat and type of item
Args:
fpath (string): the path to the csv file
Side effects:
self.item is populated with items in csv file
"""
with open(fpath, "r", encoding="utf-8") as f:
self.item = {}
line = csv.reader(f)
for line in f:
name = line[0]
type = line[2]
self.item[line[0]] = type, name
def get_item(self, item_name):
"""Gets item info from catalog and creates item object
Args:
item_name (str): name of item
Returns:
Item object
"""
for item_name in self.item:
if item_name[2] == "a":
return self.item #unaweare exaclty how we wanted to use the items, so this commit is where to change return statements
if item_name[2] == "d":
return self.item
if item_name[2] == "h":
return self.item
class Item(ItemCatalog):
"""item object
Attributes:
name (str): name of item
stat (int): points assigned to item
type (char): char of a/d/h to denote type
"""
def __init__(self, name, stat, type):
self.name = name
self.stat = stat
self.type = type
def advantage(self, item):
self.item = item
class Player():
"""create player object, given preset poke and item list,
CPU players will not have items
"""
def __init__(self, player):
self.player = player
def battle():
mixer.init()
mixer.music.load("MEGALOVANIA.mp3")
mixer.music.play(loops=-1)
atk_list = ["punch", "kick"]
item_list = ["brain food lunch", "rare candy"]
print("\n\n--++==## THE FIGHT BEGINS ##==++--\n")
print(f"opponent sends out op_poke_name!\n")
print(f"Player sends out poke_name!\n")
choice_flag = False
while choice_flag == False:
choice = input("<Attack or Item?>: ")
if choice.lower() == "attack":
a_choice = input(f"<Select item>: {atk_list}: ")
choice_flag = bool(check_select(a_choice, atk_list, choice_flag))
elif choice.lower() == "item":
i_choice = input(f"<Select item>: {item_list}: ")
choice_flag = bool(check_select(i_choice, item_list, choice_flag))
else:
print("~~> Pick an option, dingus.")
def check_select(choice, list, choice_flag):
if str(choice) in list:
print(f"~~> used {choice}!")
choice_flag = True
return (choice_flag)
else:
print("~~> Pick an option, dingus.")
main()