Follow-up for the unresolved chatgpt-codex-connector review threads left on merged PR #78 ([02.1][M0.1] Load SpellPower costs and deduct cast power). Keep this as a focused SpellPower correctness PR, separate from #73 CombatRatings.
Context
PR #78 landed SpellPower cost loading and represented power deduction, but these review threads are still unresolved and not outdated:
C++ anchors
Spell::CheckCast / Spell::CheckPower / Spell::TakePower: /home/server/woltk-trinity-legacy/src/server/game/Spells/Spell.cpp
Player::GetPowerIndex and DB2Manager::GetPowerIndexByClass: /home/server/woltk-trinity-legacy/src/server/game/Entities/Unit/StatSystem.cpp, /home/server/woltk-trinity-legacy/src/server/game/DataStores/DB2Stores.cpp
Player::SaveToDB / CHAR_UPD_CHARACTER power fields (power1..power10): /home/server/woltk-trinity-legacy/src/server/game/Entities/Player/Player.cpp, characters prepared statements
Do
- Split represented power handling into C++-like check vs take phases:
CheckPower should fail before cast start/execution when current power is insufficient.
TakePower should deduct only after represented cast-failure gates pass, before SMSG_SPELL_GO, matching C++.
- Queued casts must run the same check/take path at execution time.
- Fix canonical player power index setup so non-mana primary power classes do not keep stale
POWER_MANA -> slot 0 mapping.
- Login self
UpdateObject should represent the saved current slot-0 power, not the max value, when DB current power is lower.
- Logout/disconnect persistence should write represented current powers (
power1..power10) back to characters where Rust has authoritative canonical/session power state.
Tests
Add focused positive/negative tests for:
- no power =>
CastFailed(NoPower) and no deduction.
- represented later cast failure => no deduction.
- queued cast => no free cast; checks and deducts when executed.
- non-mana class with mana-cost spell does not spend rage/energy/runic power as mana.
- login current power below max is sent/represented correctly.
- logout/disconnect save snapshots include updated power fields.
Validation
Use the usual issue workflow:
PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world <focused tests> --lib
PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo check -p world-server
cargo fmt --all -- --check
git diff --check
Done means tests + live validation of a spell power spend/relogin flow against the running server, with C++ behavior rechecked before implementation.
Follow-up for the unresolved
chatgpt-codex-connectorreview threads left on merged PR #78 ([02.1][M0.1] Load SpellPower costs and deduct cast power). Keep this as a focused SpellPower correctness PR, separate from #73 CombatRatings.Context
PR #78 landed SpellPower cost loading and represented power deduction, but these review threads are still unresolved and not outdated:
C++ anchors
Spell::CheckCast/Spell::CheckPower/Spell::TakePower:/home/server/woltk-trinity-legacy/src/server/game/Spells/Spell.cppPlayer::GetPowerIndexandDB2Manager::GetPowerIndexByClass:/home/server/woltk-trinity-legacy/src/server/game/Entities/Unit/StatSystem.cpp,/home/server/woltk-trinity-legacy/src/server/game/DataStores/DB2Stores.cppPlayer::SaveToDB/CHAR_UPD_CHARACTERpower fields (power1..power10):/home/server/woltk-trinity-legacy/src/server/game/Entities/Player/Player.cpp,charactersprepared statementsDo
CheckPowershould fail before cast start/execution when current power is insufficient.TakePowershould deduct only after represented cast-failure gates pass, beforeSMSG_SPELL_GO, matching C++.POWER_MANA -> slot 0mapping.UpdateObjectshould represent the saved current slot-0 power, not the max value, when DB current power is lower.power1..power10) back tocharacterswhere Rust has authoritative canonical/session power state.Tests
Add focused positive/negative tests for:
CastFailed(NoPower)and no deduction.Validation
Use the usual issue workflow:
Done means tests + live validation of a spell power spend/relogin flow against the running server, with C++ behavior rechecked before implementation.