forked from alaingilbert/ogame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathespionageReport.go
226 lines (216 loc) · 7.88 KB
/
espionageReport.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
package ogame
import "time"
// EspionageReport detailed espionage report
type EspionageReport struct {
Resources
ID int64
Username string
LastActivity int64
CounterEspionage int64
APIKey string
HasFleetInformation bool // Either or not we sent enough probes to get the fleet information
HasDefensesInformation bool // Either or not we sent enough probes to get the defenses information
HasBuildingsInformation bool // Either or not we sent enough probes to get the buildings information
HasResearchesInformation bool // Either or not we sent enough probes to get the researches information
HonorableTarget bool
IsBandit bool
IsStarlord bool
IsInactive bool
IsLongInactive bool
MetalMine *int64 // ResourcesBuildings
CrystalMine *int64
DeuteriumSynthesizer *int64
SolarPlant *int64
FusionReactor *int64
SolarSatellite *int64
MetalStorage *int64
CrystalStorage *int64
DeuteriumTank *int64
RoboticsFactory *int64 // Facilities
Shipyard *int64
ResearchLab *int64
AllianceDepot *int64
MissileSilo *int64
NaniteFactory *int64
Terraformer *int64
SpaceDock *int64
LunarBase *int64
SensorPhalanx *int64
JumpGate *int64
EnergyTechnology *int64 // Researches
LaserTechnology *int64
IonTechnology *int64
HyperspaceTechnology *int64
PlasmaTechnology *int64
CombustionDrive *int64
ImpulseDrive *int64
HyperspaceDrive *int64
EspionageTechnology *int64
ComputerTechnology *int64
Astrophysics *int64
IntergalacticResearchNetwork *int64
GravitonTechnology *int64
WeaponsTechnology *int64
ShieldingTechnology *int64
ArmourTechnology *int64
RocketLauncher *int64 // Defenses
LightLaser *int64
HeavyLaser *int64
GaussCannon *int64
IonCannon *int64
PlasmaTurret *int64
SmallShieldDome *int64
LargeShieldDome *int64
AntiBallisticMissiles *int64
InterplanetaryMissiles *int64
LightFighter *int64 // Fleets
HeavyFighter *int64
Cruiser *int64
Battleship *int64
Battlecruiser *int64
Bomber *int64
Destroyer *int64
Deathstar *int64
SmallCargo *int64
LargeCargo *int64
ColonyShip *int64
Recycler *int64
EspionageProbe *int64
Crawler *int64
Reaper *int64
Pathfinder *int64
Coordinate Coordinate
Type EspionageReportType
Date time.Time
}
func i64(v *int64) int64 {
if v == nil {
return 0
}
return *v
}
// ResourcesBuildings returns a ResourcesBuildings struct from the espionage report
func (r EspionageReport) ResourcesBuildings() *ResourcesBuildings {
if !r.HasBuildingsInformation {
return nil
}
return &ResourcesBuildings{
MetalMine: i64(r.MetalMine),
CrystalMine: i64(r.CrystalMine),
DeuteriumSynthesizer: i64(r.DeuteriumSynthesizer),
SolarPlant: i64(r.SolarPlant),
FusionReactor: i64(r.FusionReactor),
SolarSatellite: i64(r.SolarSatellite),
MetalStorage: i64(r.MetalStorage),
CrystalStorage: i64(r.CrystalStorage),
DeuteriumTank: i64(r.DeuteriumTank),
}
}
// Facilities returns a Facilities struct from the espionage report
func (r EspionageReport) Facilities() *Facilities {
if !r.HasBuildingsInformation {
return nil
}
return &Facilities{
RoboticsFactory: i64(r.RoboticsFactory),
Shipyard: i64(r.Shipyard),
ResearchLab: i64(r.ResearchLab),
AllianceDepot: i64(r.AllianceDepot),
MissileSilo: i64(r.MissileSilo),
NaniteFactory: i64(r.NaniteFactory),
Terraformer: i64(r.Terraformer),
SpaceDock: i64(r.SpaceDock),
LunarBase: i64(r.LunarBase),
SensorPhalanx: i64(r.SensorPhalanx),
JumpGate: i64(r.JumpGate),
}
}
// Researches returns a Researches struct from the espionage report
func (r EspionageReport) Researches() *Researches {
if !r.HasResearchesInformation {
return nil
}
return &Researches{
EnergyTechnology: i64(r.EnergyTechnology),
LaserTechnology: i64(r.LaserTechnology),
IonTechnology: i64(r.IonTechnology),
HyperspaceTechnology: i64(r.HyperspaceTechnology),
PlasmaTechnology: i64(r.PlasmaTechnology),
CombustionDrive: i64(r.CombustionDrive),
ImpulseDrive: i64(r.ImpulseDrive),
HyperspaceDrive: i64(r.HyperspaceDrive),
EspionageTechnology: i64(r.EspionageTechnology),
ComputerTechnology: i64(r.ComputerTechnology),
Astrophysics: i64(r.Astrophysics),
IntergalacticResearchNetwork: i64(r.IntergalacticResearchNetwork),
GravitonTechnology: i64(r.GravitonTechnology),
WeaponsTechnology: i64(r.WeaponsTechnology),
ShieldingTechnology: i64(r.ShieldingTechnology),
ArmourTechnology: i64(r.ArmourTechnology),
}
}
// ShipsInfos returns a ShipsInfos struct from the espionage report
func (r EspionageReport) ShipsInfos() *ShipsInfos {
if !r.HasFleetInformation {
return nil
}
return &ShipsInfos{
LightFighter: i64(r.LightFighter),
HeavyFighter: i64(r.HeavyFighter),
Cruiser: i64(r.Cruiser),
Battleship: i64(r.Battleship),
Battlecruiser: i64(r.Battlecruiser),
Bomber: i64(r.Bomber),
Destroyer: i64(r.Destroyer),
Deathstar: i64(r.Deathstar),
SmallCargo: i64(r.SmallCargo),
LargeCargo: i64(r.LargeCargo),
ColonyShip: i64(r.ColonyShip),
Recycler: i64(r.Recycler),
EspionageProbe: i64(r.EspionageProbe),
SolarSatellite: i64(r.SolarSatellite),
Crawler: i64(r.Crawler),
Reaper: i64(r.Reaper),
Pathfinder: i64(r.Pathfinder),
}
}
// DefensesInfos returns a DefensesInfos struct from the espionage report
func (r EspionageReport) DefensesInfos() *DefensesInfos {
if !r.HasDefensesInformation {
return nil
}
return &DefensesInfos{
RocketLauncher: i64(r.RocketLauncher),
LightLaser: i64(r.LightLaser),
HeavyLaser: i64(r.HeavyLaser),
GaussCannon: i64(r.GaussCannon),
IonCannon: i64(r.IonCannon),
PlasmaTurret: i64(r.PlasmaTurret),
SmallShieldDome: i64(r.SmallShieldDome),
LargeShieldDome: i64(r.LargeShieldDome),
AntiBallisticMissiles: i64(r.AntiBallisticMissiles),
InterplanetaryMissiles: i64(r.InterplanetaryMissiles),
}
}
// PlunderRatio returns the plunder ratio
func (r EspionageReport) PlunderRatio(characterClass CharacterClass) float64 {
plunderRatio := 0.5
if r.IsInactive && characterClass == Discoverer {
plunderRatio = 0.75
}
if r.IsBandit {
plunderRatio = 1
} else if !r.IsInactive && r.IsStarlord {
plunderRatio = 0.75
}
return plunderRatio
}
// Loot returns the possible loot
func (r EspionageReport) Loot(characterClass CharacterClass) Resources {
plunderRatio := r.PlunderRatio(characterClass)
return Resources{
Metal: int64(float64(r.Metal) * plunderRatio),
Crystal: int64(float64(r.Crystal) * plunderRatio),
Deuterium: int64(float64(r.Deuterium) * plunderRatio),
}
}