Files
tamagotchi-multiplayer/systems.py
T
2026-10-02 22:07:25 +03:00

42 lines
1.2 KiB
Python

from components import Health, Hydration, Hygiene, Satiety
from ecs import World
class SatietySystem:
@classmethod
def process(cls, world: World):
for _, component_map in world.query(Satiety):
health: Health = component_map[Health]
hunger: Satiety = component_map[Satiety]
if hunger.value <= 0:
health.value -= 1
hunger.value = 0
else:
hunger.value -= 1
class HydrationSystem:
@classmethod
def process(cls, world: World):
for _, component_map in world.query(Hydration):
health: Health = component_map[Health]
hydration: Hydration = component_map[Hydration]
if hydration.value <= 0:
health.value -= 1
hydration.value = 0
else:
hydration.value -= 1
class HygieneSystem:
@classmethod
def process(cls, world: World):
for _, component_map in world.query(Hygiene):
health: Health = component_map[Health]
hygiene: Hygiene = component_map[Hygiene]
if hygiene.value <= 0:
health.value -= 1
hygiene.value = 0
else:
hygiene.value -= 1