diff --git a/src/td/simulation/CommandApply.cpp b/src/td/simulation/CommandApply.cpp index 02a1beb..dd227af 100644 --- a/src/td/simulation/CommandApply.cpp +++ b/src/td/simulation/CommandApply.cpp @@ -6,9 +6,17 @@ namespace sim { CommandApply::CommandApply(const game::World& a_World, WorldSnapshot& a_Snapshot) : m_World(a_World), m_Snapshot(a_Snapshot) {} void CommandApply::Handle(const protocol::commands::EndCommand& a_End) {} + void CommandApply::Handle(const protocol::commands::PlaceTowerCommand& a_PlaceTower) { - m_World.CanPlaceBigTower({}, 0); + static game::TowerFactory factory; + + auto tower = std::shared_ptr(factory.CreateMessage(*a_PlaceTower->m_Type).release()); + tower->m_Builder = *a_PlaceTower->m_Placer; + tower->SetCenter(utils::shape::Point(a_PlaceTower->m_Position.x, a_PlaceTower->m_Position.y)); + + m_Snapshot.m_Towers.push_back(tower); } + void CommandApply::Handle(const protocol::commands::PlayerJoinCommand& a_PlayerJoin) {} void CommandApply::Handle(const protocol::commands::SpawnTroopCommand& a_SpawnTroop) {