ee933491 by Barry

Added pankration changes for base damage calculation

1 parent 81ddab81
No preview for this file type
...@@ -156,7 +156,9 @@ class Pankration: ...@@ -156,7 +156,9 @@ class Pankration:
156 pass 156 pass
157 157
158 def start_battle(self, monster1, monster2, battle_type): 158 def start_battle(self, monster1, monster2, battle_type):
159 pass 159 battle = Battle(monster1, monster2, battle_type)
160 battle.start()
161 return battle
160 162
161 def list_zones(self): 163 def list_zones(self):
162 zone_list = [] 164 zone_list = []
...@@ -202,6 +204,7 @@ class Pankration: ...@@ -202,6 +204,7 @@ class Pankration:
202 def get_action(): 204 def get_action():
203 return "" 205 return ""
204 206
207
205 class Monster: 208 class Monster:
206 def __init__(self, family, level, main_job, support_job, innate_feral_skills, 209 def __init__(self, family, level, main_job, support_job, innate_feral_skills,
207 equipped_feral_skills, dicipline_level): 210 equipped_feral_skills, dicipline_level):
...@@ -216,6 +219,9 @@ class Monster: ...@@ -216,6 +219,9 @@ class Monster:
216 self.temperament_attitude = family['temperament_attitude']['initial_value'] 219 self.temperament_attitude = family['temperament_attitude']['initial_value']
217 self.pre_fight_command = {"temperament_posture": None, "temperament_attitude": None} 220 self.pre_fight_command = {"temperament_posture": None, "temperament_attitude": None}
218 self.exp = exp_to_level[level] + 1 221 self.exp = exp_to_level[level] + 1
222 # TODO: Setup something more interesting for each monster.
223 self.weapon_base_damage = 100
224 self.ammo_damage = 0
219 225
220 def __str__(self): 226 def __str__(self):
221 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) 227 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)
...@@ -254,6 +260,58 @@ class Monster: ...@@ -254,6 +260,58 @@ class Monster:
254 else: 260 else:
255 return "Obedient" 261 return "Obedient"
256 262
263 # Calculate the base damage against the provided defense
264 # attack_type can be 'ranged' or 'melee'
265 def get_physical_base_damage(self, defense, attack_type, level_difference):
266 # Calculate the attack/defense ratio
267 bd = float(self.weapon_base_damage)
268 if attack_type == 'ranged':
269 bd += self.ammo_damage
270 # NOTE: We are not using fStr1 or fStr2 since we are not keeping str / vit as data
271 if defense == 0:
272 ratio = 99
273 else:
274 ratio = bd / float(defense)
275 if attack_type == 'ranged':
276 cap = 3.0
277 else:
278 cap = 2.25
279 if ratio > cap:
280 ratio = cap
281 # Get the level correction ratio
282 if attack_type == 'ranged':
283 cRatio = ratio - 0.025 * level_difference
284 else:
285 cRatio = ratio - 0.050 * level_difference
286 if cRatio < 0:
287 cRatio = 0
288 if cRatio > 3.0:
289 cRatio = 3.0
290 # Calculate the pDif max as the max of our RNG
291 if cRatio <= 0.5:
292 pDif_max = 1+(10/9)*(cRatio-0.5)
293 elif 0.5 <= cRatio <= float(3/4):
294 pDif_max = 1
295 elif float(3/4) <= cRatio <= cap:
296 pDif_max = 1+(10/9)*(cRatio-float(3/4))
297
298 # Calculate the pDif max as the max of our RNG
299 if cRatio <= 0.5:
300 pDif_min = 1/6
301 elif 0.5 <= cRatio <= 1.25:
302 pDif_min = 1+(10/9)*(cRatio-1.25)
303 elif 1.25 <= cRatio <= 1.5:
304 pDif_min = 1
305 elif 1.5 <= cRatio <= cap:
306 pDif_min = 1+(10/9)*(cRatio-1.5)
307
308 print(pDif_min)
309 # Some fuckery since python doesn't let you do a rand between decimals
310 pDif_rand = float(random.randint(int(pDif_min*100000), int(pDif_max*100000))) / 100000.0
311
312 final_damage = bd * (pDif_rand * cRatio)
313 return final_damage
314
257 # This should ONLY be executed at the start of battle. 315 # This should ONLY be executed at the start of battle.
258 def set_strategy(self, temperament_posture, temperament_attitude): 316 def set_strategy(self, temperament_posture, temperament_attitude):
259 distance_from_nature = abs(self.temperament_posture - temperament_posture) 317 distance_from_nature = abs(self.temperament_posture - temperament_posture)
...@@ -275,8 +333,16 @@ class Monster: ...@@ -275,8 +333,16 @@ class Monster:
275 #if severe request then reduce dicipline_level 333 #if severe request then reduce dicipline_level
276 pass 334 pass
277 335
336
278 class Battle: 337 class Battle:
279 pass 338 def __init__(self, monster1, monster2, battle_type):
339 self.monster1 = monster1
340 self.monster2 = monster2
341 self.battle_type = battle_type
342
343 def perform_attack():
344 base_damage = get_physical_base_damage(monster2.defense, 'melee', 0)
345
280 346
281 class Arena: 347 class Arena:
282 pass 348 pass
...@@ -299,6 +365,8 @@ if hunt_response.result == HuntResponse.SUCCESS: ...@@ -299,6 +365,8 @@ if hunt_response.result == HuntResponse.SUCCESS:
299 print(monster.set_strategy(1, 1)) 365 print(monster.set_strategy(1, 1))
300 print(monster.set_strategy(1, 2)) 366 print(monster.set_strategy(1, 2))
301 monster.add_xp(2900) 367 monster.add_xp(2900)
368 phy_damage = monster.get_physical_base_damage(100, 'melee', -15)
369 print("Phys Attack: {}".format(phy_damage))
302 else: 370 else:
303 print(hunt_response.message) 371 print(hunt_response.message)
304 372
......