feat: place towers

This commit is contained in:
2021-09-19 19:20:08 +02:00
parent 3f53d32e44
commit 10a1fac992
6 changed files with 69 additions and 18 deletions

View File

@@ -146,7 +146,7 @@ void ServerConnexion::initConnection() {
void ServerConnexion::HandlePacket(protocol::PlaceTowerPacket* packet) {
game::TowerType towerType = packet->getTowerType();
const game::TowerInfo& towerInfo = game::getTowerInfo(towerType);
const game::World* world = m_Server->getGame().getWorld();
game::World* world = m_Server->getGame().getWorld();
if (towerInfo.isBigTower()) {
if (!world->CanPlaceBigTower({ packet->getTowerX(), packet->getTowerY() }))
return;
@@ -154,6 +154,9 @@ void ServerConnexion::HandlePacket(protocol::PlaceTowerPacket* packet) {
if (!world->CanPlaceLittleTower({ packet->getTowerX(), packet->getTowerY() }))
return;
}
world->placeTowerAt(towerType, packet->getTowerX(), packet->getTowerY(), m_ID);
protocol::WorldAddTowerPacket addTowerPacket(packet->getTowerX(), packet->getTowerY(), packet->getTowerType(), m_ID);
m_Server->broadcastPacket(&addTowerPacket);
}