Expose battle-start hero vigor correctly (#8639)

This commit is contained in:
2026-07-16 08:45:05 -07:00
committed by GitHub
parent afbf4c226c
commit 08f7e4ebfc
2 changed files with 6 additions and 2 deletions
@@ -67,7 +67,7 @@ using net::eagle0::shardok::api::HeroView;
stats->set_vigor(hero.vigor());
if (belongsToAsker) {
stats->set_starting_vigor(hero.vigor());
stats->set_starting_vigor(hero.starting_vigor());
HeroView::StatXp *statXp = filtered.mutable_stat_xp();
statXp->set_strength_xp(hero.strength_xp());
@@ -80,4 +80,4 @@ using net::eagle0::shardok::api::HeroView;
return filtered;
}
} // namespace shardok
} // namespace shardok
@@ -34,6 +34,8 @@ TEST_F(WatcherFilterTest, AlliedParticipantHeroStatsVisibleToWatcher) {
vector<Unit> attackerUnits;
attackerUnits.push_back(GetUnitT1());
attackerUnits.back().mutable_location() = Coords(4, 0);
attackerUnits.back().mutable_attached_hero().mutate_vigor(42);
attackerUnits.back().mutable_attached_hero().mutate_starting_vigor(88);
vector<Unit> defenderUnits;
defenderUnits.push_back(GetUnitT2());
@@ -58,6 +60,8 @@ TEST_F(WatcherFilterTest, AlliedParticipantHeroStatsVisibleToWatcher) {
for (const auto& uv : watcherView.units()) {
if (uv.player_id() == 0 && uv.has_attached_hero() && uv.attached_hero().has_stats()) {
foundAllyWithHeroStats = true;
EXPECT_DOUBLE_EQ(42, uv.attached_hero().stats().vigor());
EXPECT_DOUBLE_EQ(88, uv.attached_hero().stats().starting_vigor());
// Ally battalion stats also revealed.
EXPECT_TRUE(uv.battalion().has_armament());
EXPECT_TRUE(uv.battalion().has_morale());