Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
fungamer2-2 committed Dec 9, 2023
1 parent 3adb700 commit 99cd14c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def __init__(self):
self.HP = self.MAX_HP = 10
self.pos = Point()
self.energy = 100
self.poison = 0
self.status = {}

def has_status(self, name):
Expand Down
1 change: 1 addition & 0 deletions json_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def load(cls, d):
obj.load_required(d, "level", int)
obj.load_required(d, "diff", int)
obj.load_required(d, "to_hit", int)
obj.load_optional(d, "armor", 0, int)
obj.load_optional(d, "speed", 100, int)
obj.load_optional(d, "size", "medium", str)
obj.load_optional(d, "attack_msg", "<monster> attacks <target>", str)
Expand Down
1 change: 1 addition & 0 deletions monsters.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"to_hit": 4,
"level": 5,
"diff": 3,
"armor": 1,
"use_dex_melee": true,
"size": "small",
"speed": 90,
Expand Down
8 changes: 5 additions & 3 deletions player.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def calc_evasion(self):
bonus *= 0.7
elif self.has_status("Reduced"):
bonus *= 1.3

return bonus + 5

def add_to_inventory(self, item):
Expand Down Expand Up @@ -63,8 +62,7 @@ def gain_xp(self, amount):
self.xp -= self.xp_to_next_level()
self.xp_level += 1
self.recalc_max_hp()



if self.xp_level % 3 == 0:
num += 1

Expand Down Expand Up @@ -327,6 +325,10 @@ def do_turn(self):
while self.regen_tick >= 1:
self.regen_tick -= 1
self.heal(1)

if self.poison > 0:
amount = 1 + div_rand(self.poison, 12)
dmg = mult_rand_frac(amount, used, 100)

for name in list(self.status.keys()):
self.status[name] -= used
Expand Down
7 changes: 7 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def div_rand(x, y):
y = abs(y)
mod = x % y
return sign * (x//y + (rng(1, y) <= mod))

def mult_rand_frac(val, x, y):
return div_rand(val * x, y)

def random_weighted(entries):
values, weights = list(zip(*entries))
Expand Down Expand Up @@ -78,6 +81,10 @@ def display_bar(val, max, width):
bars += " "*(width-len(bars))
return f"[{bars}]"

def apply_armor(damage, armor):
prot = rng(0, armor) + rng(0, armor)
return max(damage - prot, 0)

class Dice:

def __init__(self, num, sides, mod):
Expand Down

0 comments on commit 99cd14c

Please sign in to comment.