Add reconstructed and demolished house counters

This commit is contained in:
dP
2020-06-18 16:47:28 +03:00
parent f8095884a3
commit 1212bec10b
4 changed files with 71 additions and 12 deletions

View File

@@ -15,6 +15,11 @@ Game::Game() {
t->cm.cs_total_prev = t->cm.cs_total;
t->cm.hr_last_month = t->cm.hr_total - t->cm.hr_total_prev;
t->cm.hr_total_prev = t->cm.hr_total;
t->cm.houses_reconstructed_last_month = t->cm.houses_reconstructed_this_month;
t->cm.houses_reconstructed_this_month = 0;
t->cm.houses_demolished_last_month = t->cm.houses_demolished_this_month;
t->cm.houses_demolished_this_month = 0;
}
});
this->events.listen<event::TownGrowthTick>([this] (const event::TownGrowthTick &event) {
@@ -26,6 +31,19 @@ Game::Game() {
event.town->cm.cs_total++;
}
});
this->events.listen<event::HouseRebuilt>([this] (const event::HouseRebuilt &event) {
if (event.was_successful) {
event.town->cm.houses_reconstructed_this_month++;
} else {
event.town->cm.houses_demolished_this_month++;
}
});
this->events.listen<event::HouseBuilt>([this] (const event::HouseBuilt &event) {
event.town->cm.houses_constructing++;
});
this->events.listen<event::HouseCompleted>([this] (const event::HouseCompleted &event) {
event.town->cm.houses_constructing--;
});
}
} // namespace citymania