From 13e4f3e3908220d484b01b9fb6dc4375ab28a16e Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 3 Dec 2022 01:01:39 +0100 Subject: Extracted Scenario and related things into own campaign module --- campaign/CMakeLists.txt | 14 +++++++++ campaign/include/kurator/campaign/Scenario.h | 24 ++++++++++++++ campaign/include/kurator/campaign/ShipConfig.h | 22 +++++++++++++ campaign/include/kurator/campaign/scenarios.h | 19 ++++++++++++ campaign/src/Scenario.cpp | 23 ++++++++++++++ campaign/src/scenarios.cpp | 43 ++++++++++++++++++++++++++ 6 files changed, 145 insertions(+) create mode 100644 campaign/CMakeLists.txt create mode 100644 campaign/include/kurator/campaign/Scenario.h create mode 100644 campaign/include/kurator/campaign/ShipConfig.h create mode 100644 campaign/include/kurator/campaign/scenarios.h create mode 100644 campaign/src/Scenario.cpp create mode 100644 campaign/src/scenarios.cpp (limited to 'campaign') diff --git a/campaign/CMakeLists.txt b/campaign/CMakeLists.txt new file mode 100644 index 0000000..ca2663a --- /dev/null +++ b/campaign/CMakeLists.txt @@ -0,0 +1,14 @@ +project(campaign) +add_library( + ${PROJECT_NAME} + src/Scenario.cpp + src/scenarios.cpp +) +target_include_directories( + ${PROJECT_NAME} + PUBLIC include +) +target_link_libraries( + ${PROJECT_NAME} + PUBLIC universe +) diff --git a/campaign/include/kurator/campaign/Scenario.h b/campaign/include/kurator/campaign/Scenario.h new file mode 100644 index 0000000..23647fc --- /dev/null +++ b/campaign/include/kurator/campaign/Scenario.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +#include "ShipConfig.h" + + +namespace kurator +{ +namespace campaign +{ + + +struct Scenario +{ + std::string name; + std::vector ships; + int total_teams() const; +}; + + +} // namespace campaign +} // namespace kurator diff --git a/campaign/include/kurator/campaign/ShipConfig.h b/campaign/include/kurator/campaign/ShipConfig.h new file mode 100644 index 0000000..cb5ca48 --- /dev/null +++ b/campaign/include/kurator/campaign/ShipConfig.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + + +namespace kurator +{ +namespace campaign +{ + + +struct ShipConfig +{ + int team; + std::string type; + std::vector turrets; +}; + + +} // namespace campaign +} // namespace kurator diff --git a/campaign/include/kurator/campaign/scenarios.h b/campaign/include/kurator/campaign/scenarios.h new file mode 100644 index 0000000..cdc1e19 --- /dev/null +++ b/campaign/include/kurator/campaign/scenarios.h @@ -0,0 +1,19 @@ +#pragma once + +#include "Scenario.h" + + +namespace kurator +{ +namespace campaign +{ +namespace scenarios +{ + + +Scenario example(); + + +} // namespace scenarios +} // namespace campaign +} // namespace kurator diff --git a/campaign/src/Scenario.cpp b/campaign/src/Scenario.cpp new file mode 100644 index 0000000..cd5a1c6 --- /dev/null +++ b/campaign/src/Scenario.cpp @@ -0,0 +1,23 @@ +#include + + +namespace kurator +{ +namespace campaign +{ + + +int +Scenario::total_teams() const +{ + int last_team = 0; + for (const auto& ship : ships) { + if (ship.team > last_team) + last_team = ship.team; + } + return last_team + 1; +} + + +} // namespace campaign +} // namespace kurator diff --git a/campaign/src/scenarios.cpp b/campaign/src/scenarios.cpp new file mode 100644 index 0000000..06b4659 --- /dev/null +++ b/campaign/src/scenarios.cpp @@ -0,0 +1,43 @@ +#include + +#include + + +namespace kurator +{ +namespace campaign +{ +namespace scenarios +{ + + +Scenario +example() +{ + return { + "Example", + { + {0, "Anvil", {"ChargeLaser", "ChargeLaser"}}, + {0, "Anvil", {"ChargeLaser", "ChargeLaser"}}, + {0, "Anvil", {"ChargeLaser", "ChargeLaser"}}, + {0, "Warbringer", {"ChargeLaser"}}, + {0, "Warbringer", {"ChargeLaser"}}, + {0, "Eclipse", {"ChargeLaser"}}, + {0, "Eclipse", {"ChargeLaser"}}, + {0, "Eclipse", {"ChargeLaser"}}, + {1, "Anvil", {"ChargeLaser", "ChargeLaser"}}, + {1, "Anvil", {"ChargeLaser", "ChargeLaser"}}, + {1, "Anvil", {"ChargeLaser", "ChargeLaser"}}, + {1, "Warbringer", {"ChargeLaser"}}, + {1, "Warbringer", {"ChargeLaser"}}, + {1, "Eclipse", {"ChargeLaser"}}, + {1, "Eclipse", {"ChargeLaser"}}, + {1, "Eclipse", {"ChargeLaser"}}, + }, + }; +} + + +} // namespace scenarios +} // namespace campaign +} // namespace kurator -- cgit v1.1