9e9977d5f1
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.
95 lines
3.5 KiB
Go
95 lines
3.5 KiB
Go
package report
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
u "galaxy/util"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Float float64
|
|
|
|
func F(v float64) Float {
|
|
return Float(u.Fixed3(v))
|
|
}
|
|
|
|
func (f Float) F() float64 {
|
|
return float64(f)
|
|
}
|
|
|
|
type Report struct {
|
|
Version uint `json:"version"`
|
|
Turn uint `json:"turn"`
|
|
Width uint32 `json:"mapWidth"`
|
|
Height uint32 `json:"mapHeight"`
|
|
PlanetCount uint32 `json:"mapPlanets"`
|
|
Race string `json:"race"`
|
|
RaceID uuid.UUID `json:"-"`
|
|
Votes Float `json:"votes"`
|
|
VoteFor string `json:"voteFor"`
|
|
Player []Player `json:"player"`
|
|
LocalScience []Science `json:"localScience,omitempty"`
|
|
OtherScience []OtherScience `json:"otherScience,omitempty"`
|
|
LocalShipClass []ShipClass `json:"localShipClass,omitempty"`
|
|
OtherShipClass []OthersShipClass `json:"otherShipClass,omitempty"`
|
|
Battle []BattleSummary `json:"battle,omitempty"`
|
|
Bombing []*Bombing `json:"bombing,omitempty"`
|
|
IncomingGroup []IncomingGroup `json:"incomingGroup,omitempty"`
|
|
LocalPlanet []LocalPlanet `json:"localPlanet,omitempty"`
|
|
ShipProduction []ShipProduction `json:"shipProduction,omitempty"`
|
|
Route []Route `json:"route,omitempty"`
|
|
OtherPlanet []OtherPlanet `json:"otherPlanet,omitempty"`
|
|
UninhabitedPlanet []UninhabitedPlanet `json:"uninhabitedPlanet,omitempty"`
|
|
UnidentifiedPlanet []UnidentifiedPlanet `json:"unidentifiedPlanet,omitempty"`
|
|
LocalFleet []LocalFleet `json:"localFleet,omitempty"`
|
|
LocalGroup []LocalGroup `json:"localGroup,omitempty"`
|
|
OtherGroup []OtherGroup `json:"otherGroup,omitempty"`
|
|
UnidentifiedGroup []UnidentifiedGroup `json:"unidentifiedGroup,omitempty"`
|
|
|
|
// Race exit warnings. PersonalExitWarning is the recipient race's own
|
|
// number of turns remaining before auto-removal for inactivity (set when
|
|
// it is 1..5, otherwise 0). RacesLeavingSoon lists other races within 3
|
|
// turns of removal and is shown to every recipient.
|
|
PersonalExitWarning uint `json:"personalExitWarning,omitempty"`
|
|
RacesLeavingSoon []RaceExitNotice `json:"racesLeavingSoon,omitempty"`
|
|
|
|
OnPlanetGroupCache map[uint][]int `json:"-"`
|
|
InSpaceGroupRangeCache map[int]map[uint]float64 `json:"-"`
|
|
}
|
|
|
|
type Route struct {
|
|
Planet uint `json:"planet"`
|
|
Route map[uint]string `json:"route"`
|
|
}
|
|
|
|
type Player struct {
|
|
ID uuid.UUID `json:"-"`
|
|
Name string `json:"name"`
|
|
Drive Float `json:"drive"`
|
|
Weapons Float `json:"weapons"`
|
|
Shields Float `json:"shields"`
|
|
Cargo Float `json:"cargo"`
|
|
Population Float `json:"population"`
|
|
Industry Float `json:"industry"`
|
|
Planets uint16 `json:"planets"`
|
|
Relation string `json:"relation"`
|
|
Votes Float `json:"votes"`
|
|
Extinct bool `json:"extinct"`
|
|
}
|
|
|
|
// RaceExitNotice is a public notice that a race is within a few turns of being
|
|
// auto-removed for inactivity; TurnsLeft is the number of turns until removal.
|
|
type RaceExitNotice struct {
|
|
Race string `json:"race"`
|
|
TurnsLeft uint `json:"turnsLeft"`
|
|
}
|
|
|
|
func (r Report) MarshalBinary() (data []byte, err error) {
|
|
return json.Marshal(&r)
|
|
}
|
|
|
|
func (r *Report) UnmarshalBinary(data []byte) error {
|
|
return json.Unmarshal(data, r)
|
|
}
|