Engine, adapter and tools without game data
This commit is contained in:
commit
e2ede736f3
3500 changed files with 1640229 additions and 0 deletions
103
engine/minigame/chocolate.h
Normal file
103
engine/minigame/chocolate.h
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace choco::minigame {
|
||||
|
||||
struct Point { float x=0,y=0; };
|
||||
enum class FactoryPhase { Initial, Countdown, Playing, Ending, Aborted, Over };
|
||||
|
||||
// Snapshot of original Lua product/category fields. The caller resolves product overrides.
|
||||
struct ChocolateConfig {
|
||||
std::vector<std::string> recipe;
|
||||
std::vector<Point> trayPath;
|
||||
std::vector<Point> conveyorPath;
|
||||
uint32_t trayCount=7;
|
||||
uint32_t conveyorCount=5;
|
||||
uint32_t trayTimeMs=30000;
|
||||
uint32_t conveyorTimeMs=1200;
|
||||
uint32_t gunTimeMs=250;
|
||||
uint32_t productTimeMs=3000;
|
||||
uint32_t countdownMs=3000;
|
||||
uint32_t gameTimeMs=60000;
|
||||
uint32_t warningMs=10000;
|
||||
uint32_t endingMs=1000;
|
||||
uint32_t missLimit=8;
|
||||
float hitRadius=34;
|
||||
uint32_t colorCount=1,ringTimeMs=500,recyclerTimeMs=5000;
|
||||
bool rainbow=false,recycler=false;
|
||||
std::vector<Point> recyclerPath;
|
||||
float speedup=1.1f,maxSpeed=8.f;
|
||||
};
|
||||
|
||||
struct TrayView {
|
||||
Point position;
|
||||
std::vector<std::string> slots; // empty string means unfilled
|
||||
bool full=false;
|
||||
int color=-1;
|
||||
std::vector<int> slotColors;
|
||||
};
|
||||
struct ShotView { Point start,target,current; std::string ingredient; int color=-1; };
|
||||
struct RingView { Point position; int color=-1; uint32_t remainingMs=0; };
|
||||
struct ChocolateView {
|
||||
FactoryPhase phase=FactoryPhase::Initial;
|
||||
uint32_t countdownRemainingMs=0,playRemainingMs=0;
|
||||
bool warning=false;
|
||||
uint32_t score=0,misses=0;
|
||||
std::vector<std::string> conveyor;
|
||||
std::vector<int> conveyorColors;
|
||||
std::vector<TrayView> trays;
|
||||
std::vector<ShotView> shots;
|
||||
std::vector<RingView> rings;
|
||||
bool recyclerActive=false;
|
||||
Point recyclerPosition;
|
||||
uint32_t recycled=0,bonusCount=0;
|
||||
float traySpeed=1.f;
|
||||
};
|
||||
|
||||
// Deterministic fixed-input simulation; future CoffeeGrid uses the same tick/fire boundary.
|
||||
class ChocolateGame {
|
||||
public:
|
||||
bool configure(ChocolateConfig config,std::string* error=nullptr);
|
||||
void start();
|
||||
void pause(bool paused);
|
||||
void abort();
|
||||
void tick(uint32_t elapsedMs);
|
||||
bool fire(Point target);
|
||||
ChocolateView view() const;
|
||||
FactoryPhase phase() const { return phase_; }
|
||||
uint32_t score() const { return score_; }
|
||||
uint32_t misses() const { return misses_; }
|
||||
bool paused() const { return paused_; }
|
||||
private:
|
||||
struct Tray { std::vector<std::string> slots; std::vector<int> colors; int color=-1; bool full=false; };
|
||||
struct Ingredient { std::string name; int color=0; };
|
||||
struct Shot { Point start,target; std::string ingredient; int color=0; uint32_t age=0; };
|
||||
struct Product { uint32_t remaining=0; size_t tray=0; };
|
||||
void advancePlaying(uint32_t ms);
|
||||
void resolveShot(const Shot& shot);
|
||||
void miss();
|
||||
Point trayPosition(size_t index) const;
|
||||
void replenish();
|
||||
void complete(size_t tray,bool bonus);
|
||||
ChocolateConfig config_;
|
||||
FactoryPhase phase_=FactoryPhase::Initial;
|
||||
bool configured_=false,paused_=false;
|
||||
uint32_t countdown_=0,remaining_=0,ending_=0,conveyorClock_=0;
|
||||
uint32_t conveyorReadyMs_=0;
|
||||
uint64_t playElapsed_=0;
|
||||
uint32_t score_=0,misses_=0;
|
||||
uint32_t recycled_=0,bonusCount_=0;
|
||||
float traySpeed_=1.f;
|
||||
double trayPhase_=0;
|
||||
size_t nextIngredient_=0;
|
||||
std::deque<Ingredient> conveyor_;
|
||||
std::vector<Tray> trays_;
|
||||
std::vector<Shot> shots_;
|
||||
std::vector<Product> products_;
|
||||
std::vector<RingView> rings_;
|
||||
};
|
||||
|
||||
} // namespace choco::minigame
|
||||
Loading…
Add table
Add a link
Reference in a new issue