feat: pogoda, poprawki w wyświetlaniu. Clean Architecture

This commit is contained in:
2026-06-05 16:36:43 +02:00
parent 7ba9c55e27
commit 856990f232
17 changed files with 1517 additions and 634 deletions
+57
View File
@@ -0,0 +1,57 @@
#include "TamaLogic.h"
void initTama(TamaState &t, uint32_t now)
{
t.hunger = 10;
t.happiness = 80;
t.hygiene = 90;
t.nextHungerTick = now + 120000UL;
t.nextHappyTick = now + 180000UL;
t.nextHygieneTick = now + 240000UL;
}
Mood updateTama(TamaState &t, const BuddyState &b, uint32_t now)
{
// Tick needs over time
if (now >= t.nextHungerTick) {
t.nextHungerTick = now + 120000UL;
if (t.hunger < 100) t.hunger++;
}
if (now >= t.nextHappyTick) {
t.nextHappyTick = now + 180000UL;
if (t.happiness > 0) t.happiness--;
}
if (now >= t.nextHygieneTick) {
t.nextHygieneTick = now + 240000UL;
if (t.hygiene > 0) t.hygiene--;
}
// Return mood override based on critical needs.
// Guard: skip when buddy has a timed mood or is in non-overridable state.
if (b.revertAt == 0 && b.mood != MOOD_SLEEPY &&
b.mood != MOOD_WINK_L && b.mood != MOOD_WINK_R)
{
if (t.hunger >= 80) return MOOD_HUNGRY;
if (t.hygiene <= 20) return MOOD_DIRTY;
if (t.happiness <= 20) return MOOD_PLAYFUL;
// Needs satisfied — signal "reset to normal" (caller handles if buddy is in need-mood)
}
return MOOD_NORMAL;
}
void tamaFeed(TamaState &t)
{
t.hunger = (t.hunger >= 30) ? t.hunger - 30 : 0;
}
void tamaPlay(TamaState &t)
{
uint16_t v = (uint16_t)t.happiness + 25;
t.happiness = (v > 100) ? 100 : (uint8_t)v;
}
void tamaClean(TamaState &t)
{
uint16_t v = (uint16_t)t.hygiene + 40;
t.hygiene = (v > 100) ? 100 : (uint8_t)v;
}