pankration.py
12.2 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
import random
import time
import pickle
FIND_PERCENTAGE = 100
SKILL_PERCENT = 80
class HuntResponse:
ERROR = -1
FAILURE = 0
SUCCESS = 1
def __init__(self, result, message, monster):
self.result = result
self.message = message
self.monster = monster
exp_to_level = [500, 1250, 2250, 3500, 5000, 6750, 8750, 10950, 13350, 15950, 18750, 21750, 24950, 28350, 31950, 35750, 39750, 43950, 48350, 52950, 57750, 62750, 67850, 73050, 78350, 83750, 89250, 94850, 100550, 106350, 112250, 118250, 124350, 130550, 136850, 143250, 149750, 156350, 163050, 169850, 176750, 183750, 190850, 198050, 205350, 212750, 220250, 227850, 235550]
class Jobs:
WAR = 1
MNK = 2
BLM = 3
WHM = 4
THF = 5
RDM = 6
PLD = 7
DRK = 8
BST = 9
BRD = 10
RNG = 11
SAM = 12
NIN = 13
DRG = 14
SMN = 15
BLU = 16
COR = 17
PUP = 18
DNC = 19
SCH = 20
GEO = 21
RUN = 22
TemperamentPosture = {
4: {"name": "Very Agressive", "message": "Show no mercy!", "value": 4},
3: {"name": "Somewhat Agressive", "message": "Give em' a little more bite!", "value": 3},
2: {"name": "Somewhat Defensive", "message": "Back off a bit!", "value": 2},
1: {"name": "Very Defensive", "message": "Guard! Block! Parry! Hold!", "value": 1}
}
TemperamentAttitude = {
4: {"name": "Very Wild", "message": "Don't think, kill!", "value": 4},
3: {"name": "Somewhat Wild", "message": "Less thinking, more striking!", "value": 3},
2: {"name": "Somewhat Tame", "message": "Watch your opponent, then attack!", "value": 2},
1: {"name": "Very Tame", "message": "Think, and think again!", "value": 1}
}
PhysicalDamageTypes = {
'blunt': ['Hand-to-Hand', 'Club', 'Staff', 'Harlequin Frame', 'Stormwaker Frame', 'Sharpshot Frame'],
'slashing': ['Axe', 'Great Axe', 'Great Sword', 'Sword', 'Scythe', 'Katana', 'Great Katana', 'Valoredge Frame'],
'piercing': ['Dagger', 'Polearm', 'Archery', 'Marksmanship', 'Shuriken', 'Boomerang']
}
FeralSkills = {
'Airy Shield': {'fp_cost': 0, 'type': 'Enhancing', 'sub_type': 'arrow shield', 'shadows': 'ignore', 'range': None, 'aoe': False, 'spell': 'arrow shield'},
'Binding Wave': {'type': 'Enfeebling', 'shadows': 'ignore', 'range': 15, 'aoe': True, 'spell': 'bind'},
'Dire Straight': {'type': 'Physical', 'shadows': 'wipe', 'range': None, 'aoe': False},
'Dismemberment': {'type': 'Piercing', 'shadows': 'absorb', 'range': None, 'aoe': False}, # causes the monster to lose a body part
'Earthshatter': {'type': 'Piercing', 'shadows': 'wipe', 'range': None, 'aoe': True},
'Eyes On Me': {'type': 'Magical', 'sub_type': 'Dark', 'mp_cost': 112, 'shadows': 'absorb', 'range': 13, 'aoe': False},
'Hypnosis': {'type': 'Enfeebling', 'sub_type': 'sleep', 'shadows': 'ignore', 'range': 'gaze', 'aoe': True},
'Magic Barrier': {'type': 'Magical', 'sub_type': 'Dark', 'mp_cost': 29, 'shadows': 'absorb', 'range': None, 'aoe': True},
'Sinker Drill': {'type': 'Physical', 'sub_type': 'Piercing', 'shadows': 'absorb', 'range': None, 'aoe': False},
}
Families = {
'acrolith': {
'base_fp': 50,
'fp_per_level': 0.1,
'max_fp': 55,
'available_main_job': [Jobs.WAR, Jobs.DRG, Jobs.DRK, Jobs.PLD],
'available_support_job': [Jobs.WAR, Jobs.DRG, Jobs.DRK, Jobs.PLD],
'innate_feral_skills': ['Sinker Drill', 'Dire Straight', 'Dismemberment', 'Earthshatter'],
'type': 'Arcana',
'strong_vs': ['Dark'],
'charmable': False,
'aspir': False,
'drain': False,
'temperament_attitude': {
'initial_value': 4,
'actions': {
4: {'use_tp_chance': 100, 'ws': ['Sinker Drill'], 'side_attack_chance': 0, 'range_chance': 0},
3: {'use_tp_chance': 75, 'ws': ['Eyes On Me'], 'side_attack_chance': 70, 'range_chance': 10},
2: {'use_tp_chance': 50, 'ws': ['Binding Wave', 'Hypnosis'], 'side_attack_chance': 25, 'range_chance': 70},
1: {'use_tp_chance': 70, 'ws': ['Binding Wave', 'Hypnosis', 'Magic Barrier', 'Airy Shield'], 'side_attack_chance': 25, 'range_chance': 70}
}
},
'temperament_posture': {
'initial_value': 4,
'actions': {
4: {'use_tp_chance': 100, 'ws': ['Eyes On Me'], 'side_attack_chance': 0, 'range_chance': 0},
3: {'use_tp_chance': 75, 'ws': ['Eyes On Me'], 'side_attack_chance': 70, 'range_chance': 10},
2: {'use_tp_chance': 50, 'ws': ['Binding Wave', 'Hypnosis'], 'side_attack_chance': 25, 'range_chance': 70},
1: {'use_tp_chance': 70, 'ws': ['Magic Barrier', 'Airy Shield'], 'side_attack_chance': 25, 'range_chance': 100}
}
}
},
'ahriman': {
'base_fp': 65,
'fp_per_level': 0.3,
'max_fp': 80,
'available_main_job': [Jobs.BLM, Jobs.RDM, Jobs.WAR],
'available_support_job': [Jobs.BLM, Jobs.RDM, Jobs.WAR],
'innate_feral_skills': ['Binding Wave', 'Magic Barrier', 'Hypnosis', 'Eyes On Me', 'Airy Shield'],
'type': 'Demon',
'traits': ['magic defence bonus +25%'],
'charmable': False,
'aspir': True,
'drain': True,
'temperament_attitude': {
'initial_value': 4,
'actions': {
4: {'use_tp_chance': 100, 'ws': ['Eyes On Me'], 'side_attack_chance': 0, 'range_chance': 0},
3: {'use_tp_chance': 75, 'ws': ['Eyes On Me'], 'side_attack_chance': 70, 'range_chance': 10},
2: {'use_tp_chance': 50, 'ws': ['Binding Wave', 'Hypnosis'], 'side_attack_chance': 25, 'range_chance': 70},
1: {'use_tp_chance': 70, 'ws': ['Binding Wave', 'Hypnosis', 'Magic Barrier', 'Airy Shield'], 'side_attack_chance': 25, 'range_chance': 70}
}
},
'temperament_posture': {
'initial_value': 4,
'actions': {
4: {'use_tp_chance': 100, 'ws': ['Eyes On Me'], 'side_attack_chance': 0, 'range_chance': 0},
3: {'use_tp_chance': 75, 'ws': ['Eyes On Me'], 'side_attack_chance': 70, 'range_chance': 10},
2: {'use_tp_chance': 50, 'ws': ['Binding Wave', 'Hypnosis'], 'side_attack_chance': 25, 'range_chance': 70},
1: {'use_tp_chance': 70, 'ws': ['Magic Barrier', 'Airy Shield'], 'side_attack_chance': 25, 'range_chance': 100}
}
}
}
}
Monsters = {
'Mechanical Menace': {
'initial_level': 9,
'family': 'acrolith',
'zone': 'Abyssea - Uleguerand'
},
'Floating Eye': {
'initial_level': 3,
'family': 'ahriman',
'zone': 'Ranguemont Pass'
}
}
class Pankration:
def __init__(self):
pass
def start_battle(self, monster1, monster2, battle_type):
pass
def list_zones(self):
zone_list = []
for monster in Monsters.itervalues():
if monster['zone'] not in zone_list:
zone_list.append(monster['zone'])
return zone_list
def get_monsters(self, zone):
monster_list = []
for monster_name, monster in Monsters.iteritems():
if monster['zone'] == zone:
monster_list.append(monster_name)
return monster_list
def hunt_monster(self, zone):
if random.randint(1, 100) < FIND_PERCENTAGE:
monster_data = Monsters[random.choice(self.get_monsters(zone))]
print(monster_data)
family_name = monster_data['family']
level = monster_data['initial_level']
family = Families[family_name]
main_job = random.choice(family['available_main_job'])
support_job = random.choice(family['available_support_job'])
feral_skills = []
skills = random.sample(family['innate_feral_skills'], 3)
if random.randint(1, 100) < SKILL_PERCENT:
feral_skills.append(skills[0])
if random.randint(1, 100) < SKILL_PERCENT:
feral_skills.append(skills[1])
if random.randint(1, 100) < SKILL_PERCENT:
feral_skills.append(skills[2])
dicipline_level = 1
monster = Monster(family, level, main_job, support_job, feral_skills,
[], dicipline_level)
return HuntResponse(HuntResponse.SUCCESS, "You captured the monster!",
monster)
else:
return HuntResponse(HuntResponse.FAILURE, "You were unable to capture a monster's soul.",
None)
def get_action():
return ""
class Monster:
def __init__(self, family, level, main_job, support_job, innate_feral_skills,
equipped_feral_skills, dicipline_level):
self.family = family
self.level = level
self.main_job = main_job
self.support_job = support_job
self.innate_feral_skills = innate_feral_skills
self.equipped_feral_skills = equipped_feral_skills
self.discipline_level = dicipline_level
self.temperament_posture = family['temperament_posture']['initial_value']
self.temperament_attitude = family['temperament_attitude']['initial_value']
self.pre_fight_command = {"temperament_posture": None, "temperament_attitude": None}
self.exp = exp_to_level[level] + 1
def __str__(self):
return "Family: {}\nLevel: {}\nMain Job: {}\nSupport Job: {}\nInnate Feral Skills: {}\nEquipped Feral Skills: {}\nDicipline Level: {}\nTemperament...".format(self.family, self.level, self.main_job, self.support_job, self.innate_feral_skills, self.equipped_feral_skills, self.discipline_level)
def get_fp(self):
return int(self.level / self.family['fp_per_level'])
def add_xp(self, exp_to_add):
self.exp += exp_to_add
for i in range(self.level, 50):
if self.exp > exp_to_level[i]:
if i > self.level:
# We leveled up!
print("Start level: {} New Level: {}".format(self.level, i))
else:
print("Just another brick in the wall...")
else:
break
# calc level based on xp
# stop at 50
pass
def get_current_posture(self):
return TemperamentPosture(self.temperament_posture)
def get_current_attitude(self):
return TemperamentAttitude(self.temperament_attitude)
def get_dicipline_level(self):
if self.dicipline_level < 2:
return "Defiant"
elif self.dicipline_level < 5:
return "Disrespectful"
elif self.dicipline_level < 7:
return "Disobedient"
else:
return "Obedient"
# This should ONLY be executed at the start of battle.
def set_strategy(self, temperament_posture, temperament_attitude):
distance_from_nature = abs(self.temperament_posture - temperament_posture)
distance_from_nature += abs(self.temperament_attitude - temperament_attitude)
if distance_from_nature == 0:
chance_of_listening = self.discipline_level
else:
chance_of_listening = float(float(self.discipline_level) / (float(distance_from_nature)/10))
chance_of_listening = abs(float((float(chance_of_listening)-1)/(20-1)))
if random.randint(1, 100) > chance_of_listening * 100:
print("DO ACTION:")
# adjust dicipline_level
# move temperament
else:
#continue action
#if severe request then reduce dicipline_level
pass
class Battle:
pass
class Arena:
pass
#print Families
p = Pankration()
print("Zones: \n\n{}".format('\n'.join(p.list_zones())))
hunt_zone = p.list_zones()[0]
print("Hunting for monster in zone: {}\n".format(hunt_zone))
hunt_response = p.hunt_monster(hunt_zone)
print("hunt_response")
print(str(hunt_response.result))
time.sleep(0.5)
if hunt_response.result == HuntResponse.SUCCESS:
print(hunt_response.message)
monster = hunt_response.monster
print("The Soul Plate Shows: \n\n{}".format(monster))
print(monster.set_strategy(4, 3))
print(monster.set_strategy(1, 1))
print(monster.set_strategy(1, 2))
monster.add_xp(2900)
else:
print(hunt_response.message)