feat(game): race exit warnings in the turn report (#12)
Tests · Go / test (push) Successful in 2m29s
Tests · UI / test (push) Waiting to run
Tests · Go / test (pull_request) Successful in 2m17s
Tests · Integration / integration (pull_request) Successful in 1m53s
Tests · UI / test (pull_request) Successful in 3m37s

Surface the inactivity-removal countdown the rules promise but the
engine never reported. A race within five turns of being auto-removed
for inactivity gets a personal warning in its own report; every race
within three turns is listed publicly to all participants.

- model: Report.PersonalExitWarning + RacesLeavingSoon ([]RaceExitNotice)
- fbs: RaceExitNotice table + Report.personal_exit_warning /
  races_leaving_soon (regenerated Go + TS bindings)
- transcoder: encode/decode both fields
- engine: ReportExitWarnings fills the recipient's TTL (1..5) and lists
  other non-extinct races with TTL 1..3, excluding the recipient itself
- ui: danger-styled personal banner + "races leaving soon" section
  (hidden when empty), wired into the report view, EN/RU i18n
- docs: rules.txt report-section list, FUNCTIONAL.md 6.4 + RU mirror

Voluntary quit and idle timeout share the TTL countdown and are not
distinguished, per the agreed scope.
This commit is contained in:
Ilia Denisov
2026-05-31 10:34:50 +02:00
parent 9dce15c7bb
commit 9e9977d5f1
28 changed files with 908 additions and 22 deletions
+33
View File
@@ -129,6 +129,9 @@ func (c *Cache) ReportRace(ri int, rep *mr.Report, battles []*mr.BattleReport, b
rep.Player[i].Relation = "-"
}
// race exit warnings
c.ReportExitWarnings(ri, rep)
// sciences
c.ReportLocalScience(ri, rep)
c.ReportOtherScience(ri, rep)
@@ -177,6 +180,36 @@ func (c *Cache) ReportRace(ri int, rep *mr.Report, battles []*mr.BattleReport, b
c.ReportUnidentifiedGroup(ri, rep)
}
// ReportExitWarnings fills the inactivity-removal warnings. A race's TTL at
// report time equals the number of turns remaining before it is auto-removed
// (it is wiped at the start of turn T+TTL). The recipient gets a personal
// countdown once it is 5 turns out (rep.PersonalExitWarning); every other
// non-extinct race within 3 turns of removal is listed publicly
// (rep.RacesLeavingSoon). Voluntary quit and idle timeout share the TTL
// countdown and are intentionally not distinguished here.
func (c *Cache) ReportExitWarnings(ri int, rep *mr.Report) {
c.validateRaceIndex(ri)
rep.PersonalExitWarning = 0
if ttl := c.g.Race[ri].TTL; ttl > 0 && ttl <= 5 {
rep.PersonalExitWarning = ttl
}
rep.RacesLeavingSoon = rep.RacesLeavingSoon[:0]
for i := range c.g.Race {
r := &c.g.Race[i]
if i == ri || r.Extinct {
continue
}
if r.TTL > 0 && r.TTL <= 3 {
rep.RacesLeavingSoon = append(rep.RacesLeavingSoon, mr.RaceExitNotice{
Race: r.Name,
TurnsLeft: r.TTL,
})
}
}
}
func (c *Cache) ReportLocalScience(ri int, rep *mr.Report) {
c.validateRaceIndex(ri)
r := &c.g.Race[ri]
+31
View File
@@ -196,3 +196,34 @@ func TestReportIncomingGroupRemainingDistance(t *testing.T) {
// route would be sqrt(2) ≈ 1.414.
assert.InDelta(t, 5.657, rep.IncomingGroup[0].Distance.F(), 0.01)
}
// TestReportExitWarnings checks the inactivity-removal warnings: the recipient
// gets a personal countdown only at TTL 1..5, other non-extinct races within 3
// turns are listed publicly, the recipient is excluded from its own public
// list, and extinct races never appear.
func TestReportExitWarnings(t *testing.T) {
c, _ := newCache()
c.Race(Race_0_idx).TTL = 5
c.Race(Race_1_idx).TTL = 2
c.Race(2).TTL = 2 // Race_Extinct: extinct, must never appear publicly
// Race_0's report: personal countdown 5; only Race_1 (TTL 2) is public.
r0 := &report.Report{}
c.ReportExitWarnings(Race_0_idx, r0)
assert.Equal(t, uint(5), r0.PersonalExitWarning)
assert.Len(t, r0.RacesLeavingSoon, 1)
assert.Equal(t, Race_1.Name, r0.RacesLeavingSoon[0].Race)
assert.Equal(t, uint(2), r0.RacesLeavingSoon[0].TurnsLeft)
// Race_1's report: personal countdown 2; Race_0 (TTL 5 > 3) is not public.
r1 := &report.Report{}
c.ReportExitWarnings(Race_1_idx, r1)
assert.Equal(t, uint(2), r1.PersonalExitWarning)
assert.Empty(t, r1.RacesLeavingSoon)
// TTL above the 5-turn window → no personal warning.
c.Race(Race_0_idx).TTL = 6
r0b := &report.Report{}
c.ReportExitWarnings(Race_0_idx, r0b)
assert.Zero(t, r0b.PersonalExitWarning)
}
+8
View File
@@ -1152,6 +1152,14 @@ Freighter загруженный 15 ед. груза при технологии
- Размер галактики, количество планет галактики и количество оставшихся рас.
- Предупреждение о скором исключении Вашей расы из игры за неактивность,
если до удаления осталось не более 5 ходов: указывается количество
оставшихся ходов (механизм описан в разделе "Выход из игры").
- Расы, покидающие игру в ближайшее время: расы, до принудительного
исключения которых за неактивность осталось не более 3 ходов; этот
список виден всем участникам.
- Ваше общее количество голосов.
- Имя расы, которой Вы отдаете свои голоса.