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

Method getSpellCooldownSmoothTime

source/game/Player.cpp:196–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196float Player::getSpellCooldownSmoothTime(SpellType spellType) const
197{
198 uint32_t spellIndex = static_cast<uint32_t>(spellType);
199 if(spellIndex >= mSpellsCooldown.size())
200 {
201 OD_LOG_ERR("seatId=" + Helper::toString(getId()) + ", spellType=" + SpellManager::getSpellNameFromSpellType(spellType));
202 return 0;
203 }
204
205 const PlayerSpellData& cooldown = mSpellsCooldown.at(spellIndex);
206 uint32_t cooldownTurns = cooldown.mCooldownNbTurnPending;
207 if(cooldownTurns <= 0)
208 return 0.0f;
209
210 float cooldownTime = static_cast<float>(cooldownTurns - 1) / ODApplication::turnsPerSecond;
211 cooldownTime += cooldown.mCooldownTimePendingTurn;
212
213 return cooldownTime;
214}
215
216void Player::decreaseSpellCooldowns()
217{

Callers 1

checkSpellCastMethod · 0.80

Calls 1

toStringFunction · 0.70

Tested by

no test coverage detected