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

Method castSpell

source/spells/SpellEyeEvil.cpp:143–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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