Skip to content

Commit

Permalink
Potion of foresight/Increasing stats allows you to choose some of the…
Browse files Browse the repository at this point in the history
…m to increase
  • Loading branch information
fungamer2-2 committed Jan 9, 2024
1 parent 665474c commit 272a782
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 45 deletions.
17 changes: 12 additions & 5 deletions effects.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[
{
"name": "Hasted",
"type": "good",
"apply_msg": "You feel your movements speed up as time appears to slow down.",
"extend_msg": "You feel that your speed will last longer.",
"remove_msg": "You feel yourself slow down to normal speed."
"name": "Hasted",
"type": "good",
"apply_msg": "You feel your movements speed up as time appears to slow down.",
"extend_msg": "You feel that your speed will last longer.",
"remove_msg": "You feel yourself slow down to normal speed."
},
{
"name": "Slowed",
Expand Down Expand Up @@ -47,6 +47,13 @@
"remove_msg": "Your fade into view once again.",
"mon_apply_msg": "<monster> fades out of view!",
"mon_remove_msg": "<monster> reappears!"
},
{
"name": "Foresight",
"type": "good",
"apply_msg": "You suddenly feel like you can see what's just about to happen.",
"extend_msg": "You feel even more perceptive about the near future.",
"remove_msg": "You no longer feel as certain about what's about to happen."
}

]
8 changes: 8 additions & 0 deletions entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ def has_clear_path(self, pos):
def display_color(self):
return 0

def is_aware(self):
return True

def do_turn(self):
pass

Expand Down Expand Up @@ -259,6 +262,11 @@ def stealth_mod(self):
def stealth_roll(self):
return gauss_roll(self.stealth_mod())

def get_perception(self):
per_mod = stat_mod(self.WIS)
perception = 10 + per_mod
return perception

def tick_status_effects(self, amount):
for name in list(self.status.keys()):
self.status[name] -= amount
Expand Down
21 changes: 11 additions & 10 deletions game_inst.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ def place_items(self):
[HealingPotion, 130],
[EnlargementPotion, 20],
[ShrinkingPotion, 20],
[SpeedPotion, 30]
[SpeedPotion, 30],
[ForesightPotion, 15]
]

for _ in range(rng(1, 5)):
Expand Down Expand Up @@ -323,11 +324,10 @@ def place_items(self):
pos = board.random_passable()
board.place_item_at(pos, Shield())

if one_in(2):
for _ in range(triangular_roll(1, 9)):
if one_in(2):
pos = board.random_passable()
board.place_item_at(pos, Dart())
num = rng(0, rng(0, 9))
for _ in range(num):
pos = board.random_passable()
board.place_item_at(pos, Dart())

def place_monsters(self):
eligible_types = {}
Expand Down Expand Up @@ -486,7 +486,6 @@ def do_turn(self):
player = self.get_player()
used = player.energy_used


if used <= 0:
return

Expand All @@ -500,7 +499,9 @@ def do_turn(self):

self.subtick_timer += used
player.energy += used
for m in self.monsters:

monsters = self.get_monsters()
for m in monsters:
m.energy += used

self.process_noise_events()
Expand All @@ -509,12 +510,12 @@ def do_turn(self):
self.subtick_timer -= 100
self.tick += 1
player.tick()
for m in self.monsters:
for m in monsters:
if m.is_alive():
m.tick()


remaining = self.monsters.copy()
remaining = monsters.copy()
random.shuffle(remaining)
remaining.sort(key=lambda m: m.energy, reverse=True)

Expand Down
6 changes: 5 additions & 1 deletion inventory_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def item_display_name(player, item):

if item is player.armor:
name += " (worn)"
elif item is player.weapon:
name += " (wielded)"
return name

def display_item(g, item):
Expand All @@ -31,7 +33,8 @@ def display_item(g, item):
menu.add_text("This is a finesse weapon.")
if item.heavy:
menu.add_text("This weapon is heavy; attacking with it takes a bit longer.")




use_text = "Use"
can_throw = False
Expand All @@ -40,6 +43,7 @@ def display_item(g, item):
can_throw = item.thrown != False
elif isinstance(item, ThrownItem):
can_throw = True

elif isinstance(item, Armor):
use_text = "Wear"

Expand Down
25 changes: 24 additions & 1 deletion items.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def use(self, player):
return ItemUseResult.CONSUMED

class SpeedPotion(Potion):
description = "A potion with a blue liquid that appears to have a slight glow. When consed, it grants a temporary speed boost."
description = "A potion with a blue liquid that appears to have a slight glow. When consumed, it grants a temporary speed boost."

def __init__(self):
super().__init__()
Expand Down Expand Up @@ -129,6 +129,26 @@ def use(self, player):
player.add_status("Invisible", dur)
return ItemUseResult.CONSUMED

class ForesightPotion(Potion):
description = "A potion with a clear liquid that appears to glow cyan when agitated. Anyone who drinks it gains the ability to see a few seconds into the future for a short duration, allowing you to anticipate your enemies' actions."

def __init__(self):
super().__init__()
self.name = "foresight potion"

def display_color(self):
return curses.color_pair(COLOR_CYAN)

def use(self, player):
player.add_msg("You drink the foresight potion.")
if player.has_status("Foresight"):
dur = rng(15, 40)
else:
dur = rng(30, 80)
player.use_energy(100)
player.add_status("Foresight", dur)
return ItemUseResult.CONSUMED

class Scroll(Item):
description = "A scroll that contains magical writing on it."

Expand Down Expand Up @@ -217,6 +237,7 @@ def __init__(self, name):
self.damage = Dice(1, 1)
self.finesse = False
self.thrown = [6, 18]
self.destroy_chance = 6

def roll_damage(self):
return self.damage.roll()
Expand All @@ -233,6 +254,8 @@ def __init__(self):
self.damage = Dice(1, 4)
self.finesse = True
self.symbol = ";"
self.destroy_chance = 3


def display_color(self):
return curses.color_pair(COLOR_DODGER_BLUE2) | curses.A_REVERSE
Expand Down
15 changes: 14 additions & 1 deletion json_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,20 @@ def load(cls, d):
obj.load_required(d, "potency", int)
obj.load_optional(d, "slowing", False, bool)
return obj


class AttackType(JSONObject):

def load(cls, d):
obj = cls()
obj.load_required(d, "name", str)
obj.load_required(d, "attack_cost", 100)

obj.load_optional(d, "use_dex", False, bool)
obj.load_optional(d, "reach", 1, int)

dam = obj.get_required(d, "base_damage", str)
obj.set_field("base_damage", Dice(*parse_dice(dam)))


speed_names = ["tiny", "small", "medium", "large", "huge", "gargantuan"]

Expand Down
30 changes: 23 additions & 7 deletions monster.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ def on_hear_noise(self, noise):
self.set_target(noise.pos)
self.soundf = duration

def get_perception(self):
return super().get_perception() + self.get_skill("perception")

def check_alerted(self):
if one_in(70):
return True
Expand All @@ -185,7 +188,7 @@ def check_alerted(self):
dist = self.distance(player)

per_mod = stat_mod(self.WIS)
perception = 10 + per_mod
perception = self.get_perception()
range = self.type.blindsight_range
if dist <= range:
perception += 5
Expand All @@ -194,7 +197,6 @@ def check_alerted(self):
#Player is invisible
perception -= 5

perception += self.get_skill("perception")

stealth_roll = player.stealth_roll()

Expand Down Expand Up @@ -420,9 +422,11 @@ def die(self):
self.use_energy(1000)
self.add_msg_if_u_see(self, f"{self.get_name(True)} dies!", "good")
board.erase_collision_cache(self.pos)
if self.weapon and one_in(3):
if self.weapon and one_in(4):
board.place_item_at(self.pos, self.weapon)

if self.shield and one_in(4):
board.place_item_at(self.pos, Shield())

def is_aware(self):
return self.state in ["AWARE", "TRACKING"]

Expand Down Expand Up @@ -561,6 +565,8 @@ def attack_pos(self, pos):
if acid > 0:
c.hit_with_acid(acid)
elif u_see_attacker:
if c.is_player() and c.has_status("Foresight") and one_in(3): #No need to tell them every time
self.add_msg(f"You anticipate {self.get_name()}'s attack and instinctively avoid it!", "good")
defender = c.get_name() if u_see_defender else "something"
self.add_msg_if_u_see(self, f"{self.get_name(True)}'s attack misses {defender}.")

Expand Down Expand Up @@ -596,14 +602,25 @@ def inflict_poison_to(self, c):
c.add_status("Paralyzed", rng(1, 5))
paralyzed = True
c.add_status("Slowed", rng(dmg, dmg*4), paralyzed)

def add_status(self, name, dur, silent=False):
super().add_status(name, dur)

g = self.g
if not silent:
eff_type = g.get_effect_type(name)
if self.has_status(name):
self.add_msg_if_u_see(self, eff_type.mon_extend_msg)
else:
self.add_msg_if_u_see(self, eff_type.mon_apply_msg)

def random_guess_invis(self):
g = self.g
board = g.get_board()
chance = 1
target = None
for pos in board.points_in_radius(self.pos, 3):
if self.sees_pos(pos) and one_in(chance):
if board.has_clear_path_to(self.pos, pos) and one_in(chance):
chance += 1
target = pos
if target:
Expand Down Expand Up @@ -635,8 +652,7 @@ def on_hit(self, ent):
if not self.is_ally(mon):
continue

if not one_in(3):
self.set_state("AWARE")
self.set_state("AWARE")

def move(self):
g = self.g
Expand Down
Loading

0 comments on commit 272a782

Please sign in to comment.