+namespace {
+
+struct SwitchPanel {
+ SwitchPanel(world::Planet &p, app::Application &app, app::MasterState &state)
+ : planet(p), app(app), state(state) { }
+
+ void operator ()(creature::Creature &c) {
+ if (planet.Creatures().empty()) {
+ std::cout << "no more creatures, game over" << std::endl;
+ while (app.HasState()) {
+ app.PopState();
+ }
+ } else {
+ for (auto a : planet.Creatures()) {
+ if (a != &c) {
+ state.GetCreaturePanel().Show(*a);
+ a->OnDeath([&](creature::Creature &b) { (*this)(b); });
+ break;
+ }
+ }
+ }
+ }
+
+ world::Planet &planet;
+ app::Application &app;
+ app::MasterState &state;
+};
+}
+