-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()) {
- planet.GetSimulation().Log() << "no more creatures, game over" << std::endl;
- state.GetCreaturePanel().Hide();
- while (app.HasState()) {
- app.PopState();
- }
- } else {
- for (auto a : planet.Creatures()) {
- if (a != &c) {
- state.GetCreaturePanel().Show(*a);
- a->WhenDead([&](creature::Creature &b) { (*this)(b); });
- break;
- }
- }
- }
- }
-
- world::Planet &planet;
- app::Application &app;
- app::MasterState &state;
-};
-}
-