书写实验报告 调整开始界面 修复逃跑后重新进入战斗的问题

This commit is contained in:
2026-06-03 18:27:46 +08:00
parent ed7bb908cb
commit e0e9b5d7af
11 changed files with 268 additions and 43 deletions
+47
View File
@@ -0,0 +1,47 @@
#define main mana_pet_world_real_main
#include "../../src/app/main.cpp"
#undef main
#include <cassert>
#include <cmath>
#include <filesystem>
namespace {
void StartBattleHidesTriggeredMonster()
{
const std::filesystem::path savePath = std::filesystem::temp_directory_path() / "mana_pet_world_battle_encounter_test_save.txt";
std::filesystem::remove(savePath);
Runtime rt;
rt.currentMapName = "TestMap";
rt.savePath = savePath;
Entity wild;
wild.name = "TestMonster";
wild.objectKey = "TestMap#monster#1";
wild.pet = MakePet("Lulea", 20, 7);
wild.active = true;
wild.moving = true;
wild.respawnDelay = 42.0f;
rt.wildPets.push_back(wild);
StartBattle(rt, 0);
assert(rt.mode == Mode::Battle);
assert(rt.battlePetIndex == 0);
assert(!rt.wildPets[0].active);
assert(!rt.wildPets[0].moving);
assert(std::fabs(rt.wildPets[0].respawnTimer - wild.respawnDelay) < 0.001f);
assert(rt.monsterRespawnUntil.find(wild.objectKey) != rt.monsterRespawnUntil.end());
std::filesystem::remove(savePath);
}
} // namespace
int main()
{
StartBattleHidesTriggeredMonster();
return 0;
}