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

Method checkSpellCast

source/spells/SpellCreatureHeal.cpp:75–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75void SpellCreatureHeal::checkSpellCast(GameMap* gameMap, const InputManager& inputManager, InputCommand& inputCommand)
76{
77 Player* player = gameMap->getLocalPlayer();
78 int32_t priceTotal = 0;
79 int32_t pricePerTarget = ConfigManager::getSingleton().getSpellConfigInt32("CreatureHealPrice");
80 int32_t playerMana = static_cast<int32_t>(player->getSeat()->getMana());
81 if(inputManager.mCommandState == InputCommandState::infoOnly)
82 {
83 if(playerMana < pricePerTarget)
84 {
85 std::string txt = formatCastSpell(SpellType::creatureHeal, pricePerTarget);
86 inputCommand.displayText(Ogre::ColourValue::Red, txt);
87 }
88 else
89 {
90 std::string txt = formatCastSpell(SpellType::creatureHeal, pricePerTarget);
91 inputCommand.displayText(Ogre::ColourValue::White, txt);
92 }
93 inputCommand.selectSquaredTiles(inputManager.mXPos, inputManager.mYPos, inputManager.mXPos,
94 inputManager.mYPos);
95 return;
96 }
97
98 if(inputManager.mCommandState == InputCommandState::building)
99 {
100 inputCommand.selectSquaredTiles(inputManager.mXPos, inputManager.mYPos, inputManager.mLStartDragX,
101 inputManager.mLStartDragY);
102 }
103
104 std::vector<GameEntity*> targets;
105 gameMap->playerSelects(targets, inputManager.mXPos, inputManager.mYPos, inputManager.mLStartDragX, inputManager.mLStartDragY,
106 SelectionTileAllowed::groundClaimedAllied, SelectionEntityWanted::creatureAliveOwnedHurt, player);
107
108 if(targets.empty())
109 {
110 // If we have no owned creature that can be heal, we look for enemy creatures in jail
111 gameMap->playerSelects(targets, inputManager.mXPos, inputManager.mYPos, inputManager.mLStartDragX, inputManager.mLStartDragY,
112 SelectionTileAllowed::groundClaimedAllied, SelectionEntityWanted::creatureAliveInOwnedPrisonHurt, player);
113 }
114 if(targets.empty())
115 {
116 std::string txt = formatCastSpell(SpellType::creatureHeal, 0);
117 inputCommand.displayText(Ogre::ColourValue::White, txt);
118 return;
119 }
120
121 std::random_shuffle(targets.begin(), targets.end());
122 std::vector<Creature*> creatures;
123 for(GameEntity* target : targets)
124 {
125 if(playerMana < pricePerTarget)
126 break;
127
128 if(target->getObjectType() != GameEntityType::creature)
129 {
130 static bool logMsg = false;
131 if(!logMsg)
132 {

Callers

nothing calls this directly

Calls 11

getLocalPlayerMethod · 0.80
getSpellConfigInt32Method · 0.80
getManaMethod · 0.80
playerSelectsMethod · 0.80
toStringFunction · 0.50
getSeatMethod · 0.45
displayTextMethod · 0.45
selectSquaredTilesMethod · 0.45
getObjectTypeMethod · 0.45
unselectAllTilesMethod · 0.45

Tested by

no test coverage detected