feat(game): race exit warnings in the turn report (#12)
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:
@@ -26,6 +26,7 @@ import {
|
||||
OtherScience,
|
||||
OthersShipClass,
|
||||
Player,
|
||||
RaceExitNotice,
|
||||
Report,
|
||||
Route,
|
||||
RouteEntry,
|
||||
@@ -139,6 +140,11 @@ export interface ShipProductionFixture {
|
||||
free?: number;
|
||||
}
|
||||
|
||||
export interface RaceExitNoticeFixture {
|
||||
race: string;
|
||||
turnsLeft: number;
|
||||
}
|
||||
|
||||
export interface ReportFixture {
|
||||
turn: number;
|
||||
mapWidth?: number;
|
||||
@@ -159,6 +165,8 @@ export interface ReportFixture {
|
||||
battles?: BattleSummaryFixture[];
|
||||
bombings?: BombingFixture[];
|
||||
shipProductions?: ShipProductionFixture[];
|
||||
personalExitWarning?: number;
|
||||
racesLeavingSoon?: RaceExitNoticeFixture[];
|
||||
}
|
||||
|
||||
export function buildReportPayload(fixture: ReportFixture): Uint8Array {
|
||||
@@ -356,6 +364,14 @@ export function buildReportPayload(fixture: ReportFixture): Uint8Array {
|
||||
return ShipProduction.endShipProduction(builder);
|
||||
});
|
||||
|
||||
const racesLeavingSoonOffsets = (fixture.racesLeavingSoon ?? []).map((n) => {
|
||||
const race = builder.createString(n.race);
|
||||
RaceExitNotice.startRaceExitNotice(builder);
|
||||
RaceExitNotice.addRace(builder, race);
|
||||
RaceExitNotice.addTurnsLeft(builder, n.turnsLeft);
|
||||
return RaceExitNotice.endRaceExitNotice(builder);
|
||||
});
|
||||
|
||||
const localVec =
|
||||
localOffsets.length === 0
|
||||
? null
|
||||
@@ -404,6 +420,10 @@ export function buildReportPayload(fixture: ReportFixture): Uint8Array {
|
||||
shipProductionOffsets.length === 0
|
||||
? null
|
||||
: Report.createShipProductionVector(builder, shipProductionOffsets);
|
||||
const racesLeavingSoonVec =
|
||||
racesLeavingSoonOffsets.length === 0
|
||||
? null
|
||||
: Report.createRacesLeavingSoonVector(builder, racesLeavingSoonOffsets);
|
||||
// Phase 27 — `battle` carries `BattleSummary` tables, each with
|
||||
// an inline `id:UUID` struct plus `planet` and `shots` slots.
|
||||
const battleVec = (() => {
|
||||
@@ -462,6 +482,10 @@ export function buildReportPayload(fixture: ReportFixture): Uint8Array {
|
||||
if (bombingVec !== null) Report.addBombing(builder, bombingVec);
|
||||
if (shipProductionVec !== null)
|
||||
Report.addShipProduction(builder, shipProductionVec);
|
||||
if (fixture.personalExitWarning !== undefined)
|
||||
Report.addPersonalExitWarning(builder, fixture.personalExitWarning);
|
||||
if (racesLeavingSoonVec !== null)
|
||||
Report.addRacesLeavingSoon(builder, racesLeavingSoonVec);
|
||||
const reportOff = Report.endReport(builder);
|
||||
builder.finish(reportOff);
|
||||
return builder.asUint8Array();
|
||||
|
||||
Reference in New Issue
Block a user