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

Method checkSpellCast

source/spells/SpellEyeEvil.cpp:98–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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