summaryrefslogtreecommitdiff
path: root/graphs/cpp/caste_or_cast/queen.cc
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
commitc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch)
tree3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/cpp/caste_or_cast/queen.cc
add: graphs et rushs
Diffstat (limited to 'graphs/cpp/caste_or_cast/queen.cc')
-rw-r--r--graphs/cpp/caste_or_cast/queen.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/graphs/cpp/caste_or_cast/queen.cc b/graphs/cpp/caste_or_cast/queen.cc
new file mode 100644
index 0000000..d1a998f
--- /dev/null
+++ b/graphs/cpp/caste_or_cast/queen.cc
@@ -0,0 +1,30 @@
+#include "queen.hh"
+
+#include <iostream>
+
+#include "colony.hh"
+#include "nurturer.hh"
+#include "provider.hh"
+
+void Queen::layEgg()
+{
+ std::cout << "Queen is laying an Egg.\n";
+ // if the queen tries to lay an egg without enough food_level
+ // it loses a health point
+ if (food_level_ < 0)
+ hp_ -= 1;
+ // checking if the colony_ attribute is not expired
+ std::shared_ptr<Colony> colony = check_colony_access();
+ // either create a new Provider or a new Nurturer
+ static bool choose = false;
+ if (choose)
+ eggs_queue_.emplace(std::make_shared<Provider>(
+ colony, food_level_ * 0.5 + 0.2, DevelopmentStage::EGG));
+ else
+ eggs_queue_.emplace(std::make_shared<Nurturer>(
+ colony, food_level_ * 0.1 + 0.13, DevelopmentStage::EGG));
+ choose = !choose;
+ // consequences of laying an egg
+ colony->cleanliness -= 0.6;
+ food_level_ -= 5.7;
+}