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

Method checkSpellCast

source/spells/SpellManager.cpp:119–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119void SpellManager::checkSpellCast(GameMap* gameMap, SpellType type, const InputManager& inputManager, InputCommand& inputCommand)
120{
121 Player* player = gameMap->getLocalPlayer();
122 float cooldown = player->getSpellCooldownSmoothTime(type);
123 if(cooldown > 0)
124 {
125 std::string errorStr = getSpellNameFromSpellType(type)
126 + " (" + Helper::toString(cooldown, 2)+ " s)";
127
128 inputCommand.displayText(Ogre::ColourValue::Red, errorStr);
129 return;
130 }
131
132 std::vector<const SpellFactory*>& factories = getFactories();
133 uint32_t index = static_cast<uint32_t>(type);
134 if(index >= factories.size())
135 {
136 OD_LOG_ERR("type=" + Helper::toString(index) + ", factories.size=" + Helper::toString(factories.size()));
137 return;
138 }
139
140 const SpellFactory& factory = *factories[index];
141 factory.checkSpellCast(gameMap, inputManager, inputCommand);
142}
143
144bool SpellManager::castSpell(GameMap* gameMap, SpellType type, Player* player, ODPacket& packet)
145{

Callers

nothing calls this directly

Calls 4

getLocalPlayerMethod · 0.80
toStringFunction · 0.50
displayTextMethod · 0.45

Tested by

no test coverage detected