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 b046049 commit 3adb700
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 22 deletions.
11 changes: 10 additions & 1 deletion entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@ def calc_evasion(self):
if not self.is_alive():
dex = 0
return 10 + (dex - 10) / 2

def base_speed(self):
return 100

def get_speed(self):
return 100
return round(self.base_speed() * self.speed_mult())

def speed_mult(self):
mult = 1
if self.has_status("Slowed"):
mult = 0.5
return mult

@abstractmethod
def get_name(self, capitalize=False):
Expand Down
14 changes: 9 additions & 5 deletions game_inst.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,17 @@ def generate_level(self):
def place_items(self):
board = self.get_board()

potions = [
[HealingPotion, 120],
[EnlargementPotion, 25],
[ShrinkingPotion, 25],
[SpeedPotion, 35]
]

for _ in range(rng(1, 5)):
pos = board.random_passable()

typ = HealingPotion
if one_in(3):
typ = random.choice([EnlargementPotion, ShrinkingPotion, SpeedPotion])
typ = random_weighted(potions)
board.place_item_at(pos, typ())

def place_monsters(self):
Expand Down Expand Up @@ -249,7 +254,6 @@ def do_turn(self):
return

self.refresh_mon_pos_cache()

player.do_turn()

self.subtick_timer += used
Expand All @@ -258,12 +262,12 @@ def do_turn(self):
m.energy += used

self.process_noise_events()

while self.subtick_timer >= 100:
self.subtick_timer -= 100
self.tick += 1
for m in self.monsters:
m.tick()


remaining = self.monsters.copy()
random.shuffle(remaining)
Expand Down
2 changes: 1 addition & 1 deletion monster.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_skill(self, name):
skills = self.type.skills
return skills.get("name", 0)

def get_speed(self):
def base_speed(self):
return self.type.speed

def get_diff_level(self):
Expand Down
20 changes: 20 additions & 0 deletions monsters.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,25 @@
"pack_travel": true,
"flags": [ "KEEN_SMELL" ],
"attack_msg": "<monster> bites <target>"
},
{
"id": "giant_centipede",
"name": "giant centipede",
"symbol": "m",
"STR": 5,
"DEX": 14,
"CON": 12,
"INT": 1,
"WIS": 7,
"CHA": 3,
"HP": 5,
"to_hit": 4,
"level": 5,
"diff": 3,
"use_dex_melee": true,
"size": "small",
"speed": 90,
"base_damage": "1d4",
"attack_msg": "<monster> bites <target>"
}
]
27 changes: 12 additions & 15 deletions player.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ def calc_evasion(self):
if self.has_status("Hasted"):
bonus += 2
if self.has_status("Enlarged"):
bonus *= 0.75
bonus *= 0.7
elif self.has_status("Reduced"):
bonus *= 1.25
bonus *= 1.3


return bonus
return bonus + 5

def add_to_inventory(self, item):
self.inventory.append(item)
Expand Down Expand Up @@ -122,11 +121,11 @@ def visible_monsters(self):
if (m := g.monster_at(pos)):
yield m

def get_speed(self):
speed = 100
def speed_mult(self):
mult = super().speed_mult()
if self.has_status("Hasted"):
speed *= 2
return speed
mult *= 2
return mult

def get_name(self, capitalize=False):
return "You" if capitalize else "you"
Expand All @@ -140,7 +139,7 @@ def calc_to_hit_bonus(self, mon):
mod += 5

if self.has_status("Reduced"):
mod += 1
mod += 1.5
return mod

def regen_rate(self):
Expand All @@ -154,7 +153,7 @@ def recalc_max_hp(self):
if self.has_status("Enlarged"):
val *= 1.5
elif self.has_status("Reduced"):
val *= 0.75
val *= 0.7

oldhp = self.MAX_HP
self.MAX_HP = round(val)
Expand Down Expand Up @@ -192,7 +191,6 @@ def use_item(self):
item = g.select_use_item()
if not item:
return False
self.add_msg(f"You have selected {item.name}")
used = item.use(self)
if used:
self.inventory.remove(item)
Expand Down Expand Up @@ -261,7 +259,7 @@ def attack_pos(self, pos):

damage = dice(1, 6) + div_rand(self.STR - 10, 2)
if self.has_status("Enlarged"):
damage += dice(1, 4)
damage += dice(1, 6)
elif self.has_status("Reduced"):
damage = (damage + 1) // 2
damage = max(damage, 1)
Expand All @@ -277,7 +275,6 @@ def attack_pos(self, pos):
noise = div_rand(noise, 2)

self.make_noise(noise)
self.add_msg(f"Made combat sound of {noise}")
self.add_msg(f"You hit {mon.get_name()} for {damage} damage.")

mon.take_damage(damage)
Expand Down Expand Up @@ -349,7 +346,7 @@ def do_turn(self):
def stealth_roll(self):
stealth = (self.DEX-10)/2
if self.has_status("Reduced"):
stealth += 2
stealth += 3
elif self.has_status("Enlarged"):
stealth -= 2
stealth -= 3
return gauss_roll(stealth)
3 changes: 3 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def div_rand(x, y):
mod = x % y
return sign * (x//y + (rng(1, y) <= mod))

def random_weighted(entries):
values, weights = list(zip(*entries))
return random.choices(values, weights=weights)[0]

def dice(num, sides):
if sides == 1:
Expand Down

0 comments on commit 3adb700

Please sign in to comment.