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

Method castSpell

source/spells/SpellCallToWar.cpp:149–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149bool SpellCallToWar::castSpell(GameMap* gameMap, Player* player, ODPacket& packet)
150{
151 Tile* tile = gameMap->tileFromPacket(packet);
152 if(tile == nullptr)
153 return false;
154
155 int32_t playerMana = static_cast<int32_t>(player->getSeat()->getMana());
156 int32_t manaCost = ConfigManager::getSingleton().getSpellConfigInt32("CallToWarPrice");
157 if(playerMana < manaCost)
158 return false;
159
160 if(!player->getSeat()->takeMana(manaCost))
161 return false;
162
163 SpellCallToWar* spell = new SpellCallToWar(gameMap);
164 spell->setSeat(player->getSeat());
165 spell->addToGameMap();
166 Ogre::Vector3 spawnPosition(static_cast<Ogre::Real>(tile->getX()),
167 static_cast<Ogre::Real>(tile->getY()),
168 static_cast<Ogre::Real>(0.0));
169 spell->createMesh();
170 spell->setPosition(spawnPosition);
171
172 return true;
173}
174
175Spell* SpellCallToWar::getSpellFromStream(GameMap* gameMap, std::istream &is)
176{

Callers

nothing calls this directly

Calls 11

tileFromPacketMethod · 0.80
getManaMethod · 0.80
getSpellConfigInt32Method · 0.80
takeManaMethod · 0.80
setSeatMethod · 0.80
createMeshMethod · 0.80
getSeatMethod · 0.45
addToGameMapMethod · 0.45
getXMethod · 0.45
getYMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected