Created
April 30, 2016 06:41
-
-
Save milesrout/6337b98e64b921499c179930bec93c8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc(roll, miss, crit, dodge, parry, hit): | |
roll += hit | |
roll -= parry | |
if roll < 0.0: | |
return 'parry' | |
roll -= dodge | |
if roll < 0.0: | |
return 'dodge' | |
roll -= miss | |
if roll < 0.0: | |
return 'miss' | |
if roll < crit: | |
return 'crit' | |
return 'hit' | |
attacker = { | |
"skills": { | |
"defence": 75, | |
"swords": 75, | |
}, | |
"crit_rating": 500, | |
"hit_rating": 500, | |
} | |
defender = { | |
"skills": { | |
"defence": 75, | |
}, | |
"parry_rating": 400, | |
"dodge_rating": 400, | |
} | |
base_miss_chance = 0.20 | |
base_crit_chance = 0.05 | |
base_dodge_chance = 0.175 | |
base_parry_chance = 0.175 | |
miss_chance = base_miss_chance + (defender["skills"]["defence"] / 1000.0) | |
crit_chance = base_crit_chance + (attacker["crit_rating"] / 10000.0) | |
dodge_chance = base_dodge_chance + (defender["dodge_rating"] / 10000.0) | |
parry_chance = base_parry_chance + (defender["parry_rating"] / 10000.0) | |
bonus_hit = (attacker["skills"]["swords"] / 1000.0) | |
print('miss_chance', miss_chance) | |
print('crit_chance', crit_chance) | |
print('dodge_chance', dodge_chance) | |
print('parry_chance', parry_chance) | |
print('bonus_hit', bonus_hit) | |
from random import random as rand | |
atk1, atk2, atk3 = rand(), rand(), rand() | |
for atk in (atk1, atk2, atk3): | |
res = calc(atk, miss_chance, crit_chance, dodge_chance, parry_chance, bonus_hit) | |
print(atk, res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment