| 59 | { return ConfigManager::getSingleton().getRoomConfigInt32("TreasuryCostPerTile"); } |
| 60 | |
| 61 | void checkBuildRoom(GameMap* gameMap, const InputManager& inputManager, InputCommand& inputCommand) const override |
| 62 | { |
| 63 | Player* player = gameMap->getLocalPlayer(); |
| 64 | int nbTreasuries = player->getSeat()->getNbRooms(RoomTreasury::mRoomType); |
| 65 | int32_t pricePerTarget = RoomManager::costPerTile(RoomTreasury::mRoomType); |
| 66 | int32_t playerGold = static_cast<int32_t>(player->getSeat()->getGold()); |
| 67 | if(inputManager.mCommandState == InputCommandState::infoOnly) |
| 68 | { |
| 69 | // First treasury tile is free |
| 70 | if(nbTreasuries <= 0) |
| 71 | pricePerTarget = 0; |
| 72 | |
| 73 | if(playerGold < pricePerTarget) |
| 74 | { |
| 75 | std::string txt = formatBuildRoom(RoomTreasury::mRoomType, pricePerTarget); |
| 76 | inputCommand.displayText(Ogre::ColourValue::Red, txt); |
| 77 | } |
| 78 | else |
| 79 | { |
| 80 | std::string txt = formatBuildRoom(RoomTreasury::mRoomType, pricePerTarget); |
| 81 | inputCommand.displayText(Ogre::ColourValue::White, txt); |
| 82 | } |
| 83 | inputCommand.selectSquaredTiles(inputManager.mXPos, inputManager.mYPos, inputManager.mXPos, |
| 84 | inputManager.mYPos); |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | std::vector<Tile*> buildableTiles = gameMap->getBuildableTilesForPlayerInArea(inputManager.mXPos, |
| 89 | inputManager.mYPos, inputManager.mLStartDragX, inputManager.mLStartDragY, player); |
| 90 | |
| 91 | inputCommand.selectTiles(buildableTiles); |
| 92 | |
| 93 | if(buildableTiles.empty()) |
| 94 | { |
| 95 | std::string txt = formatBuildRoom(RoomTreasury::mRoomType, 0); |
| 96 | inputCommand.displayText(Ogre::ColourValue::White, txt); |
| 97 | return; |
| 98 | } |
| 99 | |
| 100 | int32_t priceTotal = static_cast<int32_t>(buildableTiles.size()) * pricePerTarget; |
| 101 | // First treasury tile is free |
| 102 | if(nbTreasuries <= 0) |
| 103 | priceTotal -= pricePerTarget; |
| 104 | |
| 105 | if(playerGold < priceTotal) |
| 106 | { |
| 107 | std::string txt = formatBuildRoom(RoomTreasury::mRoomType, priceTotal); |
| 108 | inputCommand.displayText(Ogre::ColourValue::Red, txt); |
| 109 | return; |
| 110 | } |
| 111 | |
| 112 | std::string txt = formatBuildRoom(RoomTreasury::mRoomType, priceTotal); |
| 113 | inputCommand.displayText(Ogre::ColourValue::White, txt); |
| 114 | |
| 115 | if(inputManager.mCommandState != InputCommandState::validated) |
| 116 | return; |
| 117 | |
| 118 | ClientNotification *clientNotification = RoomManager::createRoomClientNotification(RoomTreasury::mRoomType); |
nothing calls this directly
no test coverage detected