| 102 | } |
| 103 | |
| 104 | void SpellCallToWar::checkSpellCast(GameMap* gameMap, const InputManager& inputManager, InputCommand& inputCommand) |
| 105 | { |
| 106 | Player* player = gameMap->getLocalPlayer(); |
| 107 | |
| 108 | Tile* tile = gameMap->getTile(inputManager.mXPos, inputManager.mYPos); |
| 109 | if(tile == nullptr) |
| 110 | return; |
| 111 | |
| 112 | int32_t playerMana = static_cast<int32_t>(player->getSeat()->getMana()); |
| 113 | int32_t price = ConfigManager::getSingleton().getSpellConfigInt32("CallToWarPrice"); |
| 114 | if(inputManager.mCommandState == InputCommandState::infoOnly) |
| 115 | { |
| 116 | if(playerMana < price) |
| 117 | { |
| 118 | std::string txt = formatCastSpell(SpellType::callToWar, price); |
| 119 | inputCommand.displayText(Ogre::ColourValue::Red, txt); |
| 120 | } |
| 121 | else |
| 122 | { |
| 123 | std::string txt = formatCastSpell(SpellType::callToWar, price); |
| 124 | inputCommand.displayText(Ogre::ColourValue::White, txt); |
| 125 | } |
| 126 | inputCommand.selectSquaredTiles(inputManager.mXPos, inputManager.mYPos, inputManager.mXPos, |
| 127 | inputManager.mYPos); |
| 128 | return; |
| 129 | } |
| 130 | |
| 131 | if(inputManager.mCommandState == InputCommandState::building) |
| 132 | { |
| 133 | std::string txt = formatCastSpell(SpellType::callToWar, price); |
| 134 | inputCommand.displayText(Ogre::ColourValue::White, txt); |
| 135 | std::vector<Tile*> tiles; |
| 136 | tiles.push_back(tile); |
| 137 | inputCommand.selectTiles(tiles); |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | inputCommand.unselectAllTiles(); |
| 142 | |
| 143 | ClientNotification *clientNotification = SpellManager::createSpellClientNotification(SpellType::callToWar); |
| 144 | gameMap->tileToPacket(clientNotification->mPacket, tile); |
| 145 | |
| 146 | ODClient::getSingleton().queueClientNotification(clientNotification); |
| 147 | } |
| 148 | |
| 149 | bool SpellCallToWar::castSpell(GameMap* gameMap, Player* player, ODPacket& packet) |
| 150 | { |
nothing calls this directly
no test coverage detected