Skip to content
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
dist/
build/
**/*.egg-info
.DS_Store

.idea
scrap_engine.py
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
POKETE_SERVER_CLIENT_VERSION="0.10.0-rc3"
POKETE_SERVER_CLIENT_VERSION="0.10.0-rc4"
POKETE_SERVER_HOST="localhost"
POKETE_SERVER_PORT="9988"
POKETE_API_PORT="9989"
Expand Down
25 changes: 12 additions & 13 deletions src/pokete/base/ui/views/choose_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ def __init__(
self.elems: list[HasArea] = []
self.up_down_switch = UpDownSwitch(self)
self.__special_ret: Optional[T] = None
self.add_ob(
self.up_down_switch,
self.width - 3 - self.up_down_switch.width,
self.height - 1,
)
self.__add_up_down_switch()

def __add_up_down_switch(self):
if len(self.elems) / (self.height - 2) > 1:
self.add_ob(
self.up_down_switch,
self.width - 3 - self.up_down_switch.width,
self.height - 1,
)

@override
def get_partial_interactors(self) -> list[MouseInteractor]:
Expand Down Expand Up @@ -145,19 +149,13 @@ def add_elems(self):
@abstractmethod
def new_size(self) -> tuple[int, int]: ...

def resize(self, height, width):
super().resize(height, width)
self.add_ob(
self.up_down_switch,
self.width - 3 - self.up_down_switch.width,
self.height - 1,
)

def resize_view(self):
"""Manages recursive view resizing"""
self.remove()
self.overview.resize_view()
self.rem_ob(self.up_down_switch)
self.resize(*self.new_size())
self.__add_up_down_switch()
self.rem_elems()
self.add_elems()
if len(self.c_obs) == 0:
Expand Down Expand Up @@ -193,6 +191,7 @@ def change_page(self, add_page, n_idx):
def __call__(self, ctx: Context) -> Optional[T]:
self.set_ctx(ctx)
ctx = change_ctx(ctx, self)
self.__add_up_down_switch()

while True:
action, _ = get_action()
Expand Down
13 changes: 10 additions & 3 deletions src/pokete/classes/animations.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def transition(_map, poke):


def fight_intro(height, width):
"""Intro animation for fight
"""Intro animation for fight with enhanced visual effect
ARGS:
height: Height of the animation
width: Width of the animation"""
Expand All @@ -57,17 +57,24 @@ def fight_intro(height, width):
for i in vec_list:
i.add(fancymap, int(width / 2), int((height - 1) / 2))
fancymap.show()

chars = ["-", "=", "-"]
char_idx = 0
for i, _l in zip(
list(zip(*[j.obs for j in vec_list])),
list(zip(*[list(2 * " ") + k for k in [j.obs for j in vec_list]])),
):
for j in i:
j.rechar("-")
j.rechar(chars[char_idx % len(chars)])
for j in _l:
if j != " ":
j.rechar(" ")
char_idx += 1
fancymap.show()
time.sleep(SPEED_OF_TIME * 0.005)
time.sleep(SPEED_OF_TIME * 0.008)

time.sleep(SPEED_OF_TIME * 0.15)

for i in vec_list:
i.remove()
del fancymap
Expand Down
10 changes: 8 additions & 2 deletions src/pokete/classes/health_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,20 @@ def make(self, oldhp):
self.rechar(bar_num * "#", esccode)

def update(self, oldhp):
"""Updates the healthbar in steps
"""Updates the healthbar in steps with easing effect
ARGS:
oldhp: The pokes former hp"""
diff = abs(oldhp - self.poke.hp)
step = 0
while oldhp != self.poke.hp and oldhp > 0:
oldhp += -1 if oldhp > self.poke.hp else 1
step += 1
self.poke.text_hp.rechar(f"HP:{oldhp}", esccode=Color.yellow)
self.make(oldhp)
time.sleep(SPEED_OF_TIME * 0.1)
# Easing: starts fast, slows down towards end
progress = step / max(diff, 1)
delay = 0.03 + (0.12 * progress * progress)
time.sleep(SPEED_OF_TIME * delay)
self.poke.ico.map.show()
self.poke.text_hp.rechar(f"HP:{oldhp}")
time.sleep(SPEED_OF_TIME * 0.1)
Expand Down
19 changes: 11 additions & 8 deletions src/pokete/classes/interactions/multi_text_choose_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .. import movemap as mvp


class MultiTextChooseBox(ChooseBoxView[str]):
class MultiTextChooseBox(ChooseBoxView[tuple[int, str]]):
"""ChooseBox wrapper for multitext conversations"""

def __init__(self, keys: list[str], name: str):
Expand All @@ -26,13 +26,13 @@ def __init__(self, keys: list[str], name: str):
def new_size(self) -> tuple[int, int]:
return self.height, self.width

def choose(self, ctx: Context, idx: int) -> Optional[str]:
def choose(self, ctx: Context, idx: int) -> Optional[tuple[int, str]]:
if idx >= 0:
return self.keys[idx]
return idx, self.keys[idx]
else:
return None

def add(self, _map, x, y):
def add_relative(self, _map, x, y):
assert self.fig
mvp.movemap.assure_distance(
self.fig.x, self.fig.y, self.width + 2, self.height + 2
Expand All @@ -41,9 +41,12 @@ def add(self, _map, x, y):
_map, self.fig.x - mvp.movemap.x, self.fig.y - mvp.movemap.y + 1
)

def __call__(self, ctx: Context) -> Optional[str]:
def __call__(self, ctx: Context) -> tuple[int, str]:
self.fig = ctx.figure
self.add_elems()
ret: Optional[tuple[int, str]] = None

with self.add(ctx.map, -1, -1):
return super().__call__(ctx)
while ret is None:
self.add_elems()
with self.add_relative(ctx.map, -1, -1):
ret = super().__call__(ctx)
return ret
77 changes: 60 additions & 17 deletions src/pokete/classes/map_additions/center.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import random
import time

import scrap_engine as se

from pokete.base import loops
from pokete.base.input import Action, _ev, get_action
from pokete.base.input import _ev
from pokete.classes import deck
from pokete.classes import movemap as mvp
from pokete.classes.classes import PlayMap
from pokete.classes.doors import CenterDoor
from pokete.classes.interactions.multi_text_choose_box import MultiTextChooseBox
from pokete.classes.inv import buy
from pokete.classes.landscape import MapInteract
from pokete.release import SPEED_OF_TIME

CUDDLE_MESSAGES = [
"{name} nuzzles against you affectionately!",
"{name} nuzzles against you lovingly!",
"{name} nuzzles against you happily!",
"{name} purrs contentedly in your arms!",
"{name} looks up at you with adoring eyes!",
"{name} snuggles closer to you!",
]


class CenterMap(PlayMap):
"""Contains all relevant objects for centermap
Expand Down Expand Up @@ -87,6 +97,22 @@ def __init__(self, _he, _wi):
class CenterInteract(se.Object, MapInteract):
"""Triggers a conversation in the Pokete center"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.menu = MultiTextChooseBox(
[
"See your full deck",
"Heal all your Poketes",
"Cuddle with the Poketes",
"Quit",
],
"Select",
)

def __normalize_pokes(self, ob):
while "__fallback__" in [p.identifier for p in ob.pokes]:
ob.pokes.pop([p.identifier for p in ob.pokes].index("__fallback__"))

def action(self, ob):
"""Triggers the interaction in the Pokete center
ARGS:
Expand All @@ -100,21 +126,15 @@ def action(self, ob):
[
"Welcome to the Pokete-Center",
"What do you want to do?",
"1: See your full deck\n 2: Heal all your Poketes\n 3: Cuddle with the Poketes",
],
passthrough=True,
)
while True:
action, _ = get_action()
if action.triggers(Action.ACT_1):
while "__fallback__" in [p.identifier for p in ob.pokes]:
ob.pokes.pop(
[p.identifier for p in ob.pokes].index("__fallback__")
)

match self.menu(self.ctx)[0]:
case 0:
self.__normalize_pokes(ob)
ob.balls_label_rechar()
deck.deck(self.ctx, len(ob.pokes))
break
elif action.triggers(Action.ACT_2):
case 1:
ob.heal()
time.sleep(SPEED_OF_TIME * 0.5)
mvp.movemap.text(
Expand All @@ -123,10 +143,33 @@ def action(self, ob):
3,
["...", "Your Poketes are now healed!"],
)
break
elif action.triggers(Action.CANCEL, Action.ACT_3):
break
loops.std(self.ctx)
case 2:
self.__normalize_pokes(ob)
if ob.pokes:
selected_idx = deck.deck(
self.ctx,
len(ob.pokes),
label="Choose a Pokete to cuddle",
in_fight=True,
)
if selected_idx is not None:
poke = ob.pokes[selected_idx]
message = random.choice(CUDDLE_MESSAGES).format(
name=poke.name
)
mvp.movemap.text(
self.ctx,
mvp.movemap.bmap.inner.x - mvp.movemap.x + 8,
3,
["...", message],
)
else:
mvp.movemap.text(
self.ctx,
mvp.movemap.bmap.inner.x - mvp.movemap.x + 8,
3,
["You don't have any Poketes to cuddle with!"],
)
mvp.movemap.full_show(init=True)


Expand Down
7 changes: 3 additions & 4 deletions src/pokete/classes/movemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def assure_distance(self, _x: int, _y: int, width: int, height: int):
self.show()
time.sleep(SPEED_OF_TIME * 0.045)

def text(self, ctx: Context, _x, _y, inp_arr, passthrough=False):
def text(self, ctx: Context, _x, _y, inp_arr):
"""Shows dialog text on movemap
ARGS:
_x: The message's X
Expand Down Expand Up @@ -129,12 +129,11 @@ def text(self, ctx: Context, _x, _y, inp_arr, passthrough=False):
self.multitext.outp(
liner(text, self.width - (_x - self.x + 1), " ")
)
while _ev.get() == "":
while _ev.get() is None:
loops.std(ctx.with_overview(self))
self.full_show()
self.multitext.remove()
if not passthrough:
_ev.clear()
_ev.clear()

def resize_view(self):
"""Manages recursive view resizing"""
Expand Down
Loading