mirror of
https://github.com/nacabaro/nacapet.git
synced 2026-01-27 16:05:32 +00:00
Cositas:
- Habia un problema a la hora de los temporizadores del hambre y la fuerza - Se me ha vuelto a romper la pantalla, asi que meti un mini hack para que funcione una pantalla de menor resolucion - Añadida la mecanica del overfeed (la tengo que probar, no se siva) - Añadida la mecanica de interrupción de suelo (esta, si que debería de funcionar, pero hasta que no consiga funcionar el cambio de bicho aqui no se prueba na) COMO CAMARÓN
This commit is contained in:
parent
b35ff2d1b2
commit
43c10d02f5
@ -69,19 +69,19 @@ def process_npet_file(origFp, eggFp, outputName):
|
|||||||
charaReductionTime = int(matches[0][11], 16)
|
charaReductionTime = int(matches[0][11], 16)
|
||||||
charaMinWeight = int(matches[0][12], 16)
|
charaMinWeight = int(matches[0][12], 16)
|
||||||
|
|
||||||
destFp.write(charaId.to_bytes(1, "big"))
|
destFp.write(charaId.to_bytes(1, "little"))
|
||||||
destFp.write(charaName)
|
destFp.write(charaName)
|
||||||
destFp.write(charaHp.to_bytes(1, "big"))
|
destFp.write(charaHp.to_bytes(1, "little"))
|
||||||
destFp.write(charaBp.to_bytes(1, "big"))
|
destFp.write(charaBp.to_bytes(1, "little"))
|
||||||
destFp.write(charaAp.to_bytes(1, "big"))
|
destFp.write(charaAp.to_bytes(1, "little"))
|
||||||
destFp.write(charaStage.to_bytes(1, "big"))
|
destFp.write(charaStage.to_bytes(1, "little"))
|
||||||
destFp.write(charaAttribute.to_bytes(1, "big"))
|
destFp.write(charaAttribute.to_bytes(1, "little"))
|
||||||
destFp.write(charaAttackSprite.to_bytes(1, "big"))
|
destFp.write(charaAttackSprite.to_bytes(1, "little"))
|
||||||
destFp.write(charaSleepTime.to_bytes(4, "big"))
|
destFp.write(charaSleepTime.to_bytes(4, "little"))
|
||||||
destFp.write(charaWakeupTime.to_bytes(4, "big"))
|
destFp.write(charaWakeupTime.to_bytes(4, "little"))
|
||||||
destFp.write(charaEvolutionTime.to_bytes(4, "big"))
|
destFp.write(charaEvolutionTime.to_bytes(4, "little"))
|
||||||
destFp.write(charaReductionTime.to_bytes(2, "big"))
|
destFp.write(charaReductionTime.to_bytes(2, "little"))
|
||||||
destFp.write(charaMinWeight.to_bytes(1, "big"))
|
destFp.write(charaMinWeight.to_bytes(1, "little"))
|
||||||
|
|
||||||
logging.info(f"Añadiendo nueva entrada con nombre {matches[0][1]}")
|
logging.info(f"Añadiendo nueva entrada con nombre {matches[0][1]}")
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,18 @@ uint8_t buttons_getPressedButtons() {
|
|||||||
(k4_prev == HIGH && k4_current == LOW)
|
(k4_prev == HIGH && k4_current == LOW)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (retV == K4_PRESSED) {
|
||||||
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
xPos++;
|
||||||
|
if (xPos > 1) {
|
||||||
|
yPos++;
|
||||||
|
xPos = 0;
|
||||||
|
if (yPos > 1) {
|
||||||
|
yPos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (retV != 0) {
|
if (retV != 0) {
|
||||||
tone(SPK_PIN, BEEP_FREQ_HZ, BEEP_LEN_MS);
|
tone(SPK_PIN, BEEP_FREQ_HZ, BEEP_LEN_MS);
|
||||||
lastPressedButtonTime = esp_timer_get_time();
|
lastPressedButtonTime = esp_timer_get_time();
|
||||||
@ -51,7 +63,5 @@ uint8_t buttons_getPressedButtons() {
|
|||||||
k3_prev = k3_current;
|
k3_prev = k3_current;
|
||||||
k4_prev = k4_current;
|
k4_prev = k4_current;
|
||||||
|
|
||||||
delay(15);
|
|
||||||
|
|
||||||
return retV;
|
return retV;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,10 +15,11 @@ struct CharacterData {
|
|||||||
uint8_t age;
|
uint8_t age;
|
||||||
uint8_t poopNumber;
|
uint8_t poopNumber;
|
||||||
|
|
||||||
uint8_t careMistakes;
|
uint8_t careMistakes = 0;
|
||||||
uint8_t effort;
|
uint8_t effort = 0;
|
||||||
uint8_t overfeed;
|
uint8_t overfeed = 0;
|
||||||
uint8_t sleepDisturbances;
|
uint8_t sleepDisturbances = 0;
|
||||||
|
uint8_t injuries = 0;
|
||||||
|
|
||||||
uint16_t stageTotalBattled;
|
uint16_t stageTotalBattled;
|
||||||
uint16_t stageTotalWon;
|
uint16_t stageTotalWon;
|
||||||
@ -27,7 +28,7 @@ struct CharacterData {
|
|||||||
uint16_t charaTotalWon;
|
uint16_t charaTotalWon;
|
||||||
|
|
||||||
int32_t sleepCareMistakeCounter = 0;
|
int32_t sleepCareMistakeCounter = 0;
|
||||||
int32_t evoLeftTimer;
|
int32_t changeTimerLeft;
|
||||||
int16_t hungerCareMistakeTimer;
|
int16_t hungerCareMistakeTimer;
|
||||||
int16_t strengthCareMistakeTimer;
|
int16_t strengthCareMistakeTimer;
|
||||||
|
|
||||||
@ -38,12 +39,18 @@ struct CharacterData {
|
|||||||
bool careMistakeCallLight = false;
|
bool careMistakeCallLight = false;
|
||||||
bool overfeedHappened = false;
|
bool overfeedHappened = false;
|
||||||
|
|
||||||
|
uint32_t sleepTime;
|
||||||
|
uint32_t wakeupTime;
|
||||||
|
|
||||||
bool sleepy = false;
|
bool sleepy = false;
|
||||||
bool asleep = false;
|
bool asleep = false;
|
||||||
bool injured = false;
|
bool injured = false;
|
||||||
bool dead = false;
|
bool dead = false;
|
||||||
bool traited = true;
|
bool traited = true;
|
||||||
|
|
||||||
|
// Usado para recalcular cuantos dias van a tardar en recuperarse, max 5 pls
|
||||||
|
uint8_t dynamicSleepDists;
|
||||||
|
|
||||||
// Obtained from structure
|
// Obtained from structure
|
||||||
uint8_t idChara;
|
uint8_t idChara;
|
||||||
|
|
||||||
@ -56,10 +63,10 @@ struct CharacterData {
|
|||||||
uint8_t stage;
|
uint8_t stage;
|
||||||
uint8_t attribute;
|
uint8_t attribute;
|
||||||
|
|
||||||
uint32_t sleepTime;
|
uint32_t initialSleepTime;
|
||||||
uint32_t wakeupTime;
|
uint32_t initialWakeupTime;
|
||||||
|
|
||||||
uint32_t evoTime;
|
uint32_t initialChangeTimer;
|
||||||
|
|
||||||
uint16_t initialStatsReductionTime = 600;
|
uint16_t initialStatsReductionTime = 600;
|
||||||
uint8_t minWeight;
|
uint8_t minWeight;
|
||||||
|
|||||||
@ -113,6 +113,8 @@
|
|||||||
#define EMPTY_HEART_ICON 10
|
#define EMPTY_HEART_ICON 10
|
||||||
#define CLEANER_ICON 11
|
#define CLEANER_ICON 11
|
||||||
|
|
||||||
|
#define SECONDS_IN_DAY 86400
|
||||||
|
|
||||||
// STANDARD VPET PARAMETER (CARE MISTAKES)
|
// STANDARD VPET PARAMETER (CARE MISTAKES)
|
||||||
#define CARE_MISTAKE_COUNTER_MAX 60
|
#define CARE_MISTAKE_COUNTER_MAX 60
|
||||||
#define SLEEP_CARE_MISTAKE_COUNTER_MAX 60
|
#define SLEEP_CARE_MISTAKE_COUNTER_MAX 60
|
||||||
@ -132,6 +134,8 @@
|
|||||||
#define K4_PRESSED 1
|
#define K4_PRESSED 1
|
||||||
#define NONE_PRESSED 0
|
#define NONE_PRESSED 0
|
||||||
|
|
||||||
|
#define SCALE_FACTOR 3
|
||||||
|
|
||||||
#define CHARA_COUNT_IN_DEVICE 5
|
#define CHARA_COUNT_IN_DEVICE 5
|
||||||
|
|
||||||
extern int screenKey;
|
extern int screenKey;
|
||||||
@ -179,4 +183,12 @@ extern Line_t** currentLine;
|
|||||||
|
|
||||||
extern struct SpriteData mainCharacterSprites;
|
extern struct SpriteData mainCharacterSprites;
|
||||||
|
|
||||||
|
// ALTAMENTE TEMPORAL
|
||||||
|
extern int xPos;
|
||||||
|
extern int yPos;
|
||||||
|
|
||||||
|
#include <TFT_eSPI.h>
|
||||||
|
|
||||||
|
extern TFT_eSPI tft;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1,8 +1,11 @@
|
|||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
|
int xPos = 0;
|
||||||
|
int yPos = 0;
|
||||||
|
|
||||||
void tft_initDisplay(TFT_eSPI &tft, uint16_t color) {
|
void tft_initDisplay(TFT_eSPI &tft, uint16_t color) {
|
||||||
tft.init();
|
tft.init();
|
||||||
tft.setRotation(0);
|
tft.setRotation(1);
|
||||||
tft.fillScreen(color);
|
tft.fillScreen(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,7 +18,7 @@ void tft_initScreenBuffer(TFT_eSprite &buffer, uint16_t color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void tft_drawBuffer(TFT_eSprite &buffer) {
|
void tft_drawBuffer(TFT_eSprite &buffer) {
|
||||||
buffer.pushSprite(0, 0);
|
buffer.pushSprite(xPos * -80, yPos * -112);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tft_clearBuffer(TFT_eSprite &buffer, uint16_t color) {
|
void tft_clearBuffer(TFT_eSprite &buffer, uint16_t color) {
|
||||||
|
|||||||
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
#include "defs/sprite_data.h"
|
#include "defs/sprite_data.h"
|
||||||
|
|
||||||
|
#define BUFFER_X 239
|
||||||
|
#define BUFFER_Y 239
|
||||||
|
|
||||||
const char* TAG_D = "[DRAW]";
|
const char* TAG_D = "[DRAW]";
|
||||||
|
|
||||||
void draw_drawSprite(
|
void draw_drawSprite(
|
||||||
@ -39,10 +42,10 @@ void draw_drawSpriteCentered(
|
|||||||
TFT_eSprite &buffer, TFT_eSprite &spr,
|
TFT_eSprite &buffer, TFT_eSprite &spr,
|
||||||
struct SpriteData* spriteData, uint8_t spriteNumber, uint8_t factor, bool flipped, int y
|
struct SpriteData* spriteData, uint8_t spriteNumber, uint8_t factor, bool flipped, int y
|
||||||
) {
|
) {
|
||||||
int x = (TFT_WIDTH - (spriteData->spriteWidth * factor)) / 2;
|
int x = (BUFFER_X - (spriteData->spriteWidth * factor)) / 2;
|
||||||
int new_y;
|
int new_y;
|
||||||
if (y == -1) {
|
if (y == -1) {
|
||||||
new_y = (TFT_HEIGHT - (spriteData->spriteHeight * factor)) / 2;
|
new_y = (BUFFER_Y - (spriteData->spriteHeight * factor)) / 2;
|
||||||
} else {
|
} else {
|
||||||
new_y = y;
|
new_y = y;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,9 +59,11 @@ uint8_t eggNumber = 0;
|
|||||||
|
|
||||||
// Tasks
|
// Tasks
|
||||||
TaskHandle_t secondLoop = NULL;
|
TaskHandle_t secondLoop = NULL;
|
||||||
|
TaskHandle_t readSteps = NULL;
|
||||||
|
|
||||||
void loop2();
|
void loop2();
|
||||||
void secondCoreTask(void*);
|
void secondCoreTask(void*);
|
||||||
|
void loop_readSteps(void*);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
@ -175,15 +177,18 @@ void loop() {
|
|||||||
menu_drawDeathScreen(composite, bg, sprite, &menuElementsData, &uiElementsData);
|
menu_drawDeathScreen(composite, bg, sprite, &menuElementsData, &uiElementsData);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (screenKey == IDLE_SCREEN || screenKey == OFF_SCREEN) {
|
||||||
|
steps_countSteps();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop2() {
|
void loop2() {
|
||||||
steps_countSteps();
|
|
||||||
buttons_checkInactivity();
|
buttons_checkInactivity();
|
||||||
vpet_runVpetTasks();
|
vpet_runVpetTasks();
|
||||||
|
|
||||||
getLocalTime(&timeInfo, 50);
|
getLocalTime(&timeInfo, 50);
|
||||||
dayUnixTime = mktime(&timeInfo) % 86400;
|
dayUnixTime = mktime(&timeInfo) % SECONDS_IN_DAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void secondCoreTask(void*) {
|
void secondCoreTask(void*) {
|
||||||
|
|||||||
@ -53,7 +53,7 @@ void menu_drawClockEdit(TFT_eSprite &composite, TFT_eSprite &bg) {
|
|||||||
// Es un dia random, nada significativo, ya pondre mas adelante que tenga dia del año
|
// Es un dia random, nada significativo, ya pondre mas adelante que tenga dia del año
|
||||||
rtc.setTime(0, clockMinuteCount, clockHourCount, 1, 11, 2024);
|
rtc.setTime(0, clockMinuteCount, clockHourCount, 1, 11, 2024);
|
||||||
getLocalTime(&timeInfo, 50);
|
getLocalTime(&timeInfo, 50);
|
||||||
dayUnixTime = mktime(&timeInfo) % 86400;
|
dayUnixTime = mktime(&timeInfo) % SECONDS_IN_DAY;
|
||||||
|
|
||||||
coldBoot = false;
|
coldBoot = false;
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,8 @@ void menu_reloadEggs(uint8_t selectedEgg) {
|
|||||||
|
|
||||||
lines_freeEggList();
|
lines_freeEggList();
|
||||||
|
|
||||||
|
printf("[DEBUG] fileName=%s\n", fileName);
|
||||||
|
|
||||||
lines_getSingleLine(fileName);
|
lines_getSingleLine(fileName);
|
||||||
lines_getLineCareMistakes(fileName);
|
lines_getLineCareMistakes(fileName);
|
||||||
|
|
||||||
|
|||||||
@ -11,19 +11,6 @@ void menu_feedingScreen(
|
|||||||
static int currentAnimationFrame = 0;
|
static int currentAnimationFrame = 0;
|
||||||
|
|
||||||
uint64_t currentTime = esp_timer_get_time();
|
uint64_t currentTime = esp_timer_get_time();
|
||||||
uint8_t pressedButtons = buttons_getPressedButtons();
|
|
||||||
switch (pressedButtons) {
|
|
||||||
case 8:
|
|
||||||
case 4:
|
|
||||||
screenKey = FOOD_SCREEN;
|
|
||||||
currentAnimationFrame = 0;
|
|
||||||
lastPressedButtonTime = currentTime;
|
|
||||||
submenuKey = -1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentTime - lastUpdateTime > ANIMATION_THRESHOLD_TIME_US) {
|
if (currentTime - lastUpdateTime > ANIMATION_THRESHOLD_TIME_US) {
|
||||||
draw_drawBackground(composite, bg, 90, 90, 3);
|
draw_drawBackground(composite, bg, 90, 90, 3);
|
||||||
@ -46,4 +33,18 @@ void menu_feedingScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
tft_drawBuffer(composite);
|
tft_drawBuffer(composite);
|
||||||
|
|
||||||
|
uint8_t pressedButtons = buttons_getPressedButtons();
|
||||||
|
switch (pressedButtons) {
|
||||||
|
case 8:
|
||||||
|
case 4:
|
||||||
|
screenKey = FOOD_SCREEN;
|
||||||
|
currentAnimationFrame = 0;
|
||||||
|
lastPressedButtonTime = currentTime;
|
||||||
|
submenuKey = -1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -32,12 +32,14 @@ void menu_foodScreen(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSprite &mainC
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pressedButtons == 4) {
|
if (pressedButtons == 4) {
|
||||||
|
lastUpdateTime = 0;
|
||||||
switch(arrowPosition) {
|
switch(arrowPosition) {
|
||||||
case 0:
|
case 0:
|
||||||
if (charaData.hunger < 8) {
|
if (charaData.hunger < 8) {
|
||||||
|
charaData.hungerCareMistakeTimer = charaData.initialStatsReductionTime;
|
||||||
|
charaData.hungerCareMistakeObtained = false;
|
||||||
charaData.weight++;
|
charaData.weight++;
|
||||||
charaData.hunger++;
|
charaData.hunger++;
|
||||||
charaData.hungerCareMistakeTimer = charaData.initialStatsReductionTime;
|
|
||||||
screenKey = FEEDING_SCREEN;
|
screenKey = FEEDING_SCREEN;
|
||||||
submenuKey = FOOD_ICON;
|
submenuKey = FOOD_ICON;
|
||||||
} else {
|
} else {
|
||||||
@ -47,18 +49,20 @@ void menu_foodScreen(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSprite &mainC
|
|||||||
charaData.overfeedHappened = true;
|
charaData.overfeedHappened = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (charaData.strength < 8) {
|
if (charaData.strength < 8) {
|
||||||
|
charaData.strengthCareMistakeTimer = charaData.initialStatsReductionTime;
|
||||||
charaData.strength++;
|
charaData.strength++;
|
||||||
charaData.weight += 2;
|
charaData.weight += 2;
|
||||||
charaData.strengthCareMistakeTimer = charaData.initialStatsReductionTime;
|
|
||||||
screenKey = FEEDING_SCREEN;
|
screenKey = FEEDING_SCREEN;
|
||||||
submenuKey = PILL_ICON;
|
submenuKey = PILL_ICON;
|
||||||
} else {
|
} else {
|
||||||
screenKey = REFUSING_SCREEN;
|
screenKey = REFUSING_SCREEN;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -45,4 +45,7 @@ void menu_eggHatchScreen(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSprite &s
|
|||||||
void menu_reloadEggs(uint8_t selectedEgg);
|
void menu_reloadEggs(uint8_t selectedEgg);
|
||||||
void menu_drawDeathScreen(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* uiBigSprite, struct SpriteData* uiSmallSprite);
|
void menu_drawDeathScreen(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* uiBigSprite, struct SpriteData* uiSmallSprite);
|
||||||
|
|
||||||
|
void menu_sleepScreen_sleepAction();
|
||||||
|
void menu_sleepScreen_recalculateSleep();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -17,11 +17,11 @@ void menu_drawCurrentMenuOption(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSp
|
|||||||
uint8_t pressedButtons = buttons_getPressedButtons();
|
uint8_t pressedButtons = buttons_getPressedButtons();
|
||||||
|
|
||||||
switch (pressedButtons) {
|
switch (pressedButtons) {
|
||||||
case 8:
|
case K1_PRESSED:
|
||||||
menuKey++;
|
menuKey++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case K3_PRESSED:
|
||||||
screenKey = IDLE_SCREEN;
|
screenKey = IDLE_SCREEN;
|
||||||
menuKey = STATUS_SCREEN_MENU;
|
menuKey = STATUS_SCREEN_MENU;
|
||||||
return;
|
return;
|
||||||
@ -31,7 +31,8 @@ void menu_drawCurrentMenuOption(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSp
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pressedButtons == 4) {
|
// Separaíto mas guapito
|
||||||
|
if (pressedButtons == K2_PRESSED) {
|
||||||
switch (menuKey) {
|
switch (menuKey) {
|
||||||
case STATUS_SCREEN_MENU:
|
case STATUS_SCREEN_MENU:
|
||||||
screenKey = STATUS_SCREEN;
|
screenKey = STATUS_SCREEN;
|
||||||
@ -42,10 +43,7 @@ void menu_drawCurrentMenuOption(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSp
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SLEEP_SCREEN_MENU:
|
case SLEEP_SCREEN_MENU:
|
||||||
charaData.asleep = true;
|
menu_sleepScreen_sleepAction();
|
||||||
vpet_computeCallLight();
|
|
||||||
menuKey = STATUS_SCREEN;
|
|
||||||
screenKey = SLEEP_SCREEN;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case POOP_SCREEN_MENU:
|
case POOP_SCREEN_MENU:
|
||||||
@ -107,3 +105,35 @@ void menu_drawCurrentMenuOption(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSp
|
|||||||
|
|
||||||
tft_drawBuffer(composite);
|
tft_drawBuffer(composite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void menu_sleepScreen_sleepAction() {
|
||||||
|
if (charaData.asleep && charaData.sleepy) {
|
||||||
|
menu_sleepScreen_recalculateSleep();
|
||||||
|
|
||||||
|
charaData.sleepy = false;
|
||||||
|
charaData.asleep = false;
|
||||||
|
|
||||||
|
charaData.sleepDisturbances++;
|
||||||
|
|
||||||
|
menuKey = STATUS_SCREEN;
|
||||||
|
screenKey = IDLE_SCREEN;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
charaData.asleep = true;
|
||||||
|
|
||||||
|
vpet_computeCallLight(); // Lo hago por cortesia, no me gusta
|
||||||
|
|
||||||
|
menuKey = STATUS_SCREEN;
|
||||||
|
screenKey = SLEEP_SCREEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void menu_sleepScreen_recalculateSleep() {
|
||||||
|
uint32_t newSleepTime = (dayUnixTime + 3600) % SECONDS_IN_DAY;
|
||||||
|
uint32_t newWakeUpTime = charaData.wakeupTime + 3600;
|
||||||
|
|
||||||
|
charaData.sleepTime = newSleepTime;
|
||||||
|
charaData.wakeupTime = newWakeUpTime;
|
||||||
|
|
||||||
|
charaData.dynamicSleepDists++;
|
||||||
|
}
|
||||||
@ -14,6 +14,7 @@ void lines_onHatchComplete() {
|
|||||||
|
|
||||||
storage_readFile(spriteFileName, &mainCharacterSprites);
|
storage_readFile(spriteFileName, &mainCharacterSprites);
|
||||||
|
|
||||||
|
// Primero los datos del bicho actual en nuestra estructura de datos de confianza
|
||||||
charaData.hp = currentLine[currentCharacter]->characters[0].hp;
|
charaData.hp = currentLine[currentCharacter]->characters[0].hp;
|
||||||
charaData.bp = currentLine[currentCharacter]->characters[0].bp;
|
charaData.bp = currentLine[currentCharacter]->characters[0].bp;
|
||||||
charaData.ap = currentLine[currentCharacter]->characters[0].ap;
|
charaData.ap = currentLine[currentCharacter]->characters[0].ap;
|
||||||
@ -21,16 +22,16 @@ void lines_onHatchComplete() {
|
|||||||
charaData.stage = currentLine[currentCharacter]->characters[0].stage;
|
charaData.stage = currentLine[currentCharacter]->characters[0].stage;
|
||||||
charaData.attribute = currentLine[currentCharacter]->characters[0].attribute;
|
charaData.attribute = currentLine[currentCharacter]->characters[0].attribute;
|
||||||
|
|
||||||
charaData.sleepTime = currentLine[currentCharacter]->characters[0].sleepTime;
|
charaData.sleepTime = charaData.initialSleepTime = currentLine[currentCharacter]->characters[0].sleepTime;
|
||||||
charaData.wakeupTime = currentLine[currentCharacter]->characters[0].wakeTime;
|
charaData.wakeupTime = charaData.initialWakeupTime = currentLine[currentCharacter]->characters[0].wakeTime;
|
||||||
charaData.evoLeftTimer = currentLine[currentCharacter]->characters[0].changeTime;
|
charaData.initialChangeTimer = charaData.changeTimerLeft = currentLine[currentCharacter]->characters[0].changeTime;
|
||||||
charaData.evoTime = currentLine[currentCharacter]->characters[0].changeTime;
|
|
||||||
|
|
||||||
charaData.hungerCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
|
||||||
charaData.strengthCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
|
||||||
|
|
||||||
charaData.initialStatsReductionTime = currentLine[currentCharacter]->characters[0].depleteTime;
|
charaData.initialStatsReductionTime = currentLine[currentCharacter]->characters[0].depleteTime;
|
||||||
charaData.minWeight = currentLine[currentCharacter]->characters[0].minWeight;
|
charaData.minWeight = currentLine[currentCharacter]->characters[0].minWeight;
|
||||||
|
|
||||||
|
// Luego le obligamos a que nazca con hambre
|
||||||
|
charaData.hungerCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
||||||
|
charaData.strengthCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
||||||
|
|
||||||
charaData.hatched = true;
|
charaData.hatched = true;
|
||||||
}
|
}
|
||||||
@ -2,8 +2,8 @@
|
|||||||
#include "defs/defs.h"
|
#include "defs/defs.h"
|
||||||
|
|
||||||
float gravity = 0.0;
|
float gravity = 0.0;
|
||||||
const float alpha = 0.99;
|
const float alpha = 0.95;
|
||||||
const float thresh = 0.80;
|
const float thresh = 0.40;
|
||||||
uint64_t lastStepTime = esp_timer_get_time();
|
uint64_t lastStepTime = esp_timer_get_time();
|
||||||
|
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ void steps_countSteps() {
|
|||||||
float dyn = mag - gravity;
|
float dyn = mag - gravity;
|
||||||
|
|
||||||
unsigned long now = esp_timer_get_time();
|
unsigned long now = esp_timer_get_time();
|
||||||
if (dyn > thresh && (now - lastStepTime) > 500000) {
|
if (dyn > thresh && (now - lastStepTime) > 250000) {
|
||||||
stepCounter++;
|
stepCounter++;
|
||||||
lastStepTime = now;
|
lastStepTime = now;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,13 +38,22 @@ bool vpet_evalSleep() {
|
|||||||
charaData.sleepy = false;
|
charaData.sleepy = false;
|
||||||
charaData.asleep = false;
|
charaData.asleep = false;
|
||||||
|
|
||||||
|
if (charaData.dynamicSleepDists > 0) {
|
||||||
|
// Primero, el sleep time ahora está reventado, hay que restaurarlo
|
||||||
|
// fácil, simplemente recalcula a la hora de despertar
|
||||||
|
charaData.dynamicSleepDists--;
|
||||||
|
|
||||||
|
charaData.sleepTime = (charaData.initialSleepTime + (charaData.dynamicSleepDists * 3600)) % SECONDS_IN_DAY;
|
||||||
|
charaData.wakeupTime = (charaData.initialWakeupTime + (charaData.dynamicSleepDists * 3600)) % SECONDS_IN_DAY;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
dayUnixTime < charaData.sleepTime &&
|
dayUnixTime < charaData.sleepTime &&
|
||||||
dayUnixTime > charaData.wakeupTime &&
|
dayUnixTime > charaData.wakeupTime &&
|
||||||
charaData.asleep &&
|
charaData.asleep &&
|
||||||
charaData.sleepCareMistakeCounter < 60
|
charaData.sleepCareMistakeCounter < SLEEP_COUNTER_MAX
|
||||||
// Esto se ejecuta cuando mandamos a dormir al personaje
|
// Esto se ejecuta cuando mandamos a dormir al personaje
|
||||||
// durante el dia.
|
// durante el dia.
|
||||||
// Resultado, el personaje deberia de dormir una siesta
|
// Resultado, el personaje deberia de dormir una siesta
|
||||||
@ -57,7 +66,7 @@ bool vpet_evalSleep() {
|
|||||||
dayUnixTime < charaData.sleepTime &&
|
dayUnixTime < charaData.sleepTime &&
|
||||||
dayUnixTime > charaData.wakeupTime &&
|
dayUnixTime > charaData.wakeupTime &&
|
||||||
charaData.asleep &&
|
charaData.asleep &&
|
||||||
charaData.sleepCareMistakeCounter >= 60
|
charaData.sleepCareMistakeCounter >= SLEEP_COUNTER_MAX
|
||||||
// Esto se ejecuta cuando la siesta del personaje acaba
|
// Esto se ejecuta cuando la siesta del personaje acaba
|
||||||
// Resultado, el personaje se despierta
|
// Resultado, el personaje se despierta
|
||||||
) {
|
) {
|
||||||
@ -88,7 +97,7 @@ bool vpet_evalSleep() {
|
|||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
charaData.sleepy && !charaData.asleep &&
|
charaData.sleepy && !charaData.asleep &&
|
||||||
charaData.sleepCareMistakeCounter < 60 &&
|
charaData.sleepCareMistakeCounter < SLEEP_COUNTER_MAX &&
|
||||||
!charaData.sleepCareMistakeObtained
|
!charaData.sleepCareMistakeObtained
|
||||||
// Esto se ejecuta cuando el personaje debería de estar durmiendo
|
// Esto se ejecuta cuando el personaje debería de estar durmiendo
|
||||||
// pero no se le ha mandado a dormir, empieza a contar para pasar
|
// pero no se le ha mandado a dormir, empieza a contar para pasar
|
||||||
@ -100,7 +109,7 @@ bool vpet_evalSleep() {
|
|||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
charaData.sleepy && !charaData.asleep &&
|
charaData.sleepy && !charaData.asleep &&
|
||||||
charaData.sleepCareMistakeCounter >= 60 &&
|
charaData.sleepCareMistakeCounter >= SLEEP_COUNTER_MAX &&
|
||||||
!charaData.sleepCareMistakeObtained
|
!charaData.sleepCareMistakeObtained
|
||||||
// Esto se ejecuta cuando el personaje deberia de estar durmiendo
|
// Esto se ejecuta cuando el personaje deberia de estar durmiendo
|
||||||
// pero no se le ha mandado a dormir, y el contador ya ha llegado
|
// pero no se le ha mandado a dormir, y el contador ya ha llegado
|
||||||
@ -135,74 +144,78 @@ bool vpet_evalSleep() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void vpet_evalTimers() {
|
void vpet_evalTimers() {
|
||||||
if (charaData.hungerCareMistakeTimer >= 0) {
|
vpet_evalHungerTimer();
|
||||||
charaData.hungerCareMistakeTimer -= 1;
|
vpet_evalStrengthTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (charaData.strengthCareMistakeTimer >= 0) {
|
void vpet_evalHungerTimer() {
|
||||||
charaData.strengthCareMistakeTimer -= 1;
|
if (charaData.hungerCareMistakeTimer > 0) {
|
||||||
}
|
charaData.hungerCareMistakeTimer--;
|
||||||
|
|
||||||
if (
|
} else if (
|
||||||
charaData.hungerCareMistakeTimer < 0 ||
|
charaData.hungerCareMistakeTimer <= 0 &&
|
||||||
charaData.strengthCareMistakeTimer < 0
|
charaData.hunger > 0
|
||||||
) {
|
) {
|
||||||
if (charaData.hunger > 0) {
|
|
||||||
charaData.hunger--;
|
charaData.hunger--;
|
||||||
screenKey = TIMER_FINISHED_SCREEN;
|
|
||||||
interruptKey = POOPING_SCREEN;
|
|
||||||
charaData.poopNumber++;
|
|
||||||
if (charaData.hunger < 4 && charaData.overfeedHappened) {
|
|
||||||
charaData.overfeedHappened = false;
|
|
||||||
}
|
|
||||||
if (charaData.hunger > 0) {
|
if (charaData.hunger > 0) {
|
||||||
charaData.hungerCareMistakeTimer = charaData.initialStatsReductionTime;
|
charaData.hungerCareMistakeTimer = charaData.initialStatsReductionTime;
|
||||||
|
screenKey = TIMER_FINISHED_SCREEN;
|
||||||
|
interruptKey = POOPING_SCREEN;
|
||||||
} else {
|
} else {
|
||||||
charaData.hungerCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
charaData.hungerCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!charaData.hungerCareMistakeObtained) {
|
|
||||||
if (
|
|
||||||
charaData.hunger == 0 &&
|
|
||||||
charaData.hungerCareMistakeTimer < 0
|
|
||||||
) {
|
|
||||||
charaData.careMistakes++;
|
|
||||||
charaData.hungerCareMistakeObtained = true;
|
|
||||||
|
|
||||||
} else if (charaData.hunger == 0) {
|
|
||||||
interruptKey = POOPING_SCREEN;
|
|
||||||
screenKey = TIMER_FINISHED_SCREEN;
|
screenKey = TIMER_FINISHED_SCREEN;
|
||||||
|
interruptKey = CARE_MISTAKE_SCREEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (charaData.poopNumber < 8) {
|
||||||
charaData.poopNumber++;
|
charaData.poopNumber++;
|
||||||
|
} else {
|
||||||
|
charaData.injured = true;
|
||||||
|
charaData.injuries++;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (
|
||||||
|
charaData.hungerCareMistakeTimer <= 0 &&
|
||||||
|
charaData.hunger == 0 &&
|
||||||
|
!charaData.hungerCareMistakeObtained
|
||||||
|
) {
|
||||||
|
charaData.hungerCareMistakeObtained = true;
|
||||||
|
charaData.careMistakes++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (charaData.strength > 0) {
|
void vpet_evalStrengthTimer() {
|
||||||
|
if (charaData.strengthCareMistakeTimer > 0) {
|
||||||
|
charaData.strengthCareMistakeTimer--;
|
||||||
|
|
||||||
|
} else if (
|
||||||
|
charaData.strengthCareMistakeTimer <= 0 &&
|
||||||
|
charaData.strength > 0
|
||||||
|
) {
|
||||||
charaData.strength--;
|
charaData.strength--;
|
||||||
if (charaData.strength > 0) {
|
if (charaData.strength > 0) {
|
||||||
charaData.strengthCareMistakeTimer = charaData.initialStatsReductionTime;
|
charaData.strengthCareMistakeTimer = charaData.initialStatsReductionTime;
|
||||||
} else {
|
} else {
|
||||||
charaData.strengthCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
charaData.strengthCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!charaData.strengthCareMistakeObtained) {
|
|
||||||
if (
|
|
||||||
charaData.strength == 0 &&
|
|
||||||
charaData.strengthCareMistakeTimer < 0
|
|
||||||
) {
|
|
||||||
charaData.careMistakes++;
|
|
||||||
charaData.strengthCareMistakeObtained = true;
|
|
||||||
|
|
||||||
} else if(charaData.strength == 0) {
|
|
||||||
if (interruptKey != POOPING_SCREEN) {
|
if (interruptKey != POOPING_SCREEN) {
|
||||||
interruptKey = CARE_MISTAKE_SCREEN;
|
interruptKey = CARE_MISTAKE_SCREEN;
|
||||||
screenKey = TIMER_FINISHED_SCREEN;
|
screenKey = TIMER_FINISHED_SCREEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (
|
||||||
|
charaData.strengthCareMistakeTimer <= 0 &&
|
||||||
|
charaData.strength == 0 &&
|
||||||
|
!charaData.strengthCareMistakeObtained
|
||||||
|
) {
|
||||||
|
charaData.strengthCareMistakeObtained = true;
|
||||||
|
charaData.careMistakes++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void IRAM_ATTR onActionTimerDelta() {
|
void IRAM_ATTR onActionTimerDelta() {
|
||||||
runVpetTasks = true;
|
runVpetTasks = true;
|
||||||
@ -214,15 +227,17 @@ void vpet_runVpetTasks() {
|
|||||||
if (!vpet_evalSleep()) {
|
if (!vpet_evalSleep()) {
|
||||||
vpet_evalTimers();
|
vpet_evalTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[MAIN]: Hunger timer %d, hunger %d\n", charaData.hungerCareMistakeTimer, charaData.hunger);
|
printf("[MAIN]: Hunger timer %d, hunger %d\n", charaData.hungerCareMistakeTimer, charaData.hunger);
|
||||||
printf("[MAIN]: Strength timer %d, strength %d\n", charaData.strengthCareMistakeTimer, charaData.strength);
|
printf("[MAIN]: Strength timer %d, strength %d\n", charaData.strengthCareMistakeTimer, charaData.strength);
|
||||||
printf("[MAIN]: Evo timer %d\n", charaData.evoLeftTimer);
|
printf("[MAIN]: Change timer %d\n", charaData.changeTimerLeft);
|
||||||
printf("[MAIN]: RTC time is %d\n", dayUnixTime);
|
printf("[MAIN]: RTC time is %d\n", dayUnixTime);
|
||||||
printf("[MAIN]: Sleep counter is %d\n", charaData.sleepCareMistakeCounter);
|
printf("[MAIN]: Sleep counter is %d\n", charaData.sleepCareMistakeCounter);
|
||||||
printf("[MAIN]: Care mistake count is %d\n", charaData.careMistakes);
|
printf("[MAIN]: Care mistake count is %d\n", charaData.careMistakes);
|
||||||
printf("[MAIN]: Is sleep care mistake tripped? %d\n", charaData.sleepCareMistakeObtained);
|
printf("[MAIN]: Is sleep care mistake tripped? %d\n", charaData.sleepCareMistakeObtained);
|
||||||
|
|
||||||
runVpetTasks = false;
|
runVpetTasks = false;
|
||||||
|
|
||||||
} else if (runVpetTasks && !charaData.hatched && charaData.hatching) {
|
} else if (runVpetTasks && !charaData.hatched && charaData.hatching) {
|
||||||
charaData.hatchTimer++;
|
charaData.hatchTimer++;
|
||||||
printf("[DEBUG] hatchTimer=%i out of hatchTimer=%i\n", charaData.hatchTimer, currentLine[currentCharacter]->hatchTime);
|
printf("[DEBUG] hatchTimer=%i out of hatchTimer=%i\n", charaData.hatchTimer, currentLine[currentCharacter]->hatchTime);
|
||||||
|
|||||||
@ -9,5 +9,7 @@ void vpet_computeCallLight();
|
|||||||
bool vpet_evalSleep();
|
bool vpet_evalSleep();
|
||||||
void vpet_evalTimers();
|
void vpet_evalTimers();
|
||||||
void vpet_runVpetTasks();
|
void vpet_runVpetTasks();
|
||||||
|
void vpet_evalHungerTimer();
|
||||||
|
void vpet_evalStrengthTimer();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loading…
x
Reference in New Issue
Block a user