MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / checkSpellCast

Method checkSpellCast

source/spells/SpellCallToWar.cpp:104–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104void 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
149bool SpellCallToWar::castSpell(GameMap* gameMap, Player* player, ODPacket& packet)
150{

Callers

nothing calls this directly

Calls 11

getLocalPlayerMethod · 0.80
getManaMethod · 0.80
getSpellConfigInt32Method · 0.80
tileToPacketMethod · 0.80
getTileMethod · 0.45
getSeatMethod · 0.45
displayTextMethod · 0.45
selectSquaredTilesMethod · 0.45
selectTilesMethod · 0.45
unselectAllTilesMethod · 0.45

Tested by

no test coverage detected