1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package main
- import "time"
- type YTConfig struct {
- Sectors int `json:"sectors"`
- Turns int `json:"turns"`
- Holds int `json:"holds"`
- PortReset int `json:"reset"`
- DaysExpire int `json:"expire"`
- Lottery int `json:"lotto"`
- }
- type YTSectorType uint16
- type YTSector struct {
- Sector YTSectorType
- Planet bool `json:"planet"` // This could be calculated
- Port bool `json:"port"` // This could be calculated
- Fighters uint `json:"fighters"`
- FighterOwner int `json:"owner"`
- Mines uint `json:"mines"`
- Sectors []YTSectorType `json:"sectors"`
- Players []int `json:"players`
- }
- func (sector YTSector) HasPlanet() bool {
- _, has := YTPlanets[sector.Sector]
- return has
- }
- func (sector YTSector) HasPort() bool {
- //_, has := YTSectors[sector.Sector]
- //return YTSectors[sector.Sector].Port
- var has bool
- _, has = YTPortMap[sector.Sector]
- return has
- }
- var YTSectors []YTSector
- type YTPlayer struct {
- Sector YTSectorType
- Name string `json:"name"`
- LastPlayed time.Time `json:"last"`
- Turns int `json:"turns"`
- Holds int `json:"holds"`
- Lotto int `json:"lotto`
- Cloak uint16 `json:"cloak` // Cloak Energy
- }
- // or to database? DB would also handle concurrency...
- type YTPlayers struct {
- Players map[uint]YTPlayer `json:"players"`
- }
- const (
- PORT_EARTH = 0
- PORT_FUEL = 1
- PORT_ORG = 2
- PORT_EQU = 3
- PORT_SPACEPORT = 4 // Maybe!?
- )
- // Or database? DB would work better for player info
- // YT Ports: Sell one thing, buy the others.
- type YTPort struct {
- Name string `json:"name"`
- Owner int `json:"owner"`
- Credits uint64 `json:"credits"`
- Type uint8 `json:"type"`
- Amounts [3]uint32 `json:"amounts"`
- }
- var YTPortMap map[YTSectorType]YTPort
- type YTPlanet struct {
- Name string `json:"name"`
- Owner int `json:"owner"`
- }
- var YTPlanets map[YTSectorType]YTPlanet
|