From 377e778f3c56a020ea9fed41f3a203623b9b8c5e Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 28 Dec 2022 03:52:28 +0100 Subject: Implemented very naive campaign encounter generation --- kurator/src/Campaign.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- kurator/src/Campaign.h | 6 ++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/kurator/src/Campaign.cpp b/kurator/src/Campaign.cpp index c109f63..a3f788e 100644 --- a/kurator/src/Campaign.cpp +++ b/kurator/src/Campaign.cpp @@ -4,22 +4,61 @@ #include #include +#include +#include +#include + +#include "Battle.h" #include "Session.h" + namespace kurator { Campaign::Campaign(std::shared_ptr _session) : - session {std::move(_session)} + session {std::move(_session)}, + ships {}, + team {0}, + level {0}, + id {0} { + auto scenario = campaign::scenarios::example(); + for (auto& ship : scenario.ships) { + if (ship.team == team) { + ship.identifier.id = id++; + ships.push_back(std::move(ship)); + } + } } void Campaign::update(const float) { + if (ImGui::Begin("Campaign")) { + ImGui::Text("Level %d, ships left:", level); + for (const auto& ship : ships) { + if (ship.team == team) + ImGui::Text("%s", ship.type.c_str()); + } + if (ImGui::Button("Start")) { + campaign::Scenario scenario {"encounter", 12000, {}}; + scenario.ships.insert(scenario.ships.cend(), ships.begin(), ships.end()); + auto generator = campaign::scenarios::example(); + for (auto& ship : generator.ships) { + if (ship.team != team) { + ship.identifier.id = id++; + scenario.ships.push_back(std::move(ship)); + } + } + session->push(std::make_shared(session, std::move(scenario))); + } + if (ImGui::Button("Back")) + session->pop(); + } + ImGui::End(); } diff --git a/kurator/src/Campaign.h b/kurator/src/Campaign.h index 80d1506..f7beed5 100644 --- a/kurator/src/Campaign.h +++ b/kurator/src/Campaign.h @@ -2,6 +2,8 @@ #include +#include + #include "Scene.h" #include "Session.h" @@ -18,6 +20,10 @@ public: void draw() const override; private: std::shared_ptr session; + std::vector ships; + int team; + int level; + int id; }; -- cgit v1.1