ytdata.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package main
  2. import "time"
  3. type YTConfig struct {
  4. Sectors int `json:"sectors"`
  5. Turns int `json:"turns"`
  6. Holds int `json:"holds"`
  7. PortReset int `json:"reset"` // What is this? (Amount ports replenish per day?, )
  8. DaysExpire int `json:"expire"`
  9. Lottery int `json:"lotto"` // What is this? (Number of times players can play?, Lotto seed?)
  10. }
  11. type YTSectorType uint16
  12. type YTSector struct {
  13. Sector YTSectorType
  14. Planet bool `json:"planet"` // This could be calculated
  15. Port bool `json:"port"` // This could be calculated
  16. Fighters uint `json:"fighters"`
  17. FighterOwner int `json:"owner"`
  18. Mines uint `json:"mines"`
  19. Sectors []YTSectorType `json:"sectors"` // Warps
  20. Players []int `json:"players`
  21. }
  22. func (sector YTSector) HasPlanet() bool {
  23. _, has := YTPlanets[sector.Sector]
  24. return has
  25. }
  26. func (sector YTSector) HasPort() bool {
  27. //_, has := YTSectors[sector.Sector]
  28. //return YTSectors[sector.Sector].Port
  29. var has bool
  30. _, has = YTPortMap[sector.Sector]
  31. return has
  32. }
  33. var YTSectors []YTSector
  34. type YTPlayer struct {
  35. Sector YTSectorType
  36. Name string `json:"name"`
  37. LastPlayed time.Time `json:"last"`
  38. Turns int `json:"turns"`
  39. Credits uint `json:"credits"` // Money!
  40. Holds int `json:"holds"`
  41. Amounts [3]uint `json:"holding"` // FUEL, ORG, EQU
  42. Lotto uint8 `json:"lotto` // Number of lottos able to be played
  43. Cloak uint16 `json:"cloak` // Cloak Energy (Percent)
  44. Fighters uint `json:"figs"`
  45. Mines uint `json:"mines"`
  46. Missiles uint `json:"missiles"`
  47. Scanner bool `json:"scanner"` // Danger Scanner
  48. Shields uint `json:"shields"`
  49. Forces uint `json:"forces"` // Ground Forces
  50. PortsOwned uint `json:"ports"` // Number of ports owned by this player
  51. PlasmaBolts uint `json:"bolts"`
  52. }
  53. // or to database? DB would also handle concurrency...
  54. type YTPlayers struct {
  55. Players map[uint]YTPlayer `json:"players"`
  56. }
  57. const (
  58. PORT_EARTH = 0
  59. PORT_FUEL = 1
  60. PORT_ORG = 2
  61. PORT_EQU = 3
  62. PORT_SPACEPORT = 4 // Maybe!?
  63. )
  64. // Or database? DB would work better for player info
  65. // YT Ports: Sell one thing, buy the others.
  66. type YTPort struct {
  67. Name string `json:"name"`
  68. Owner int `json:"owner"`
  69. Credits uint64 `json:"credits"`
  70. Type uint8 `json:"type"`
  71. Amounts [3]uint32 `json:"amounts"`
  72. }
  73. var YTPortMap map[YTSectorType]YTPort
  74. // Spending $$$ increases production of planets (Need to gather information)
  75. //
  76. // Putting money in the planet's bank produces interest (free money earned per day, need to get the formula)
  77. //
  78. // Forces grow as there are more stationed on the planet, also affects attack and defenses of the planet (Need to gather information on attacks and how much they grow by)
  79. //
  80. // When a planet exceeds a particular amount it encounters a recession loosing production and some items along the way (need information)
  81. type YTPlanet struct {
  82. Name string `json:"name"`
  83. Owner int `json:"owner"`
  84. Production [3]uint `json:"products"` // FUEL, ORG, EQU (Production per day)
  85. Amounts [3]uint `json:"amounts"` // FUEL, ORG, EQU (Amount)
  86. Fighters [2]uint `json:"figs"` // Production, Amount
  87. Missiles [2]uint `json:"missiles"`
  88. Mines [2]uint `json:"mines"`
  89. Credits [2]uint `json:"credits"` // Money! (Interest, Amount)
  90. Forces [2]uint `json:"forces"` // Ground Forces (Population Growth, Population)
  91. PlasmaBolts [2]uint `json:"bolts"`
  92. }
  93. var YTPlanets map[YTSectorType]YTPlanet