forked from alaingilbert/ogame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
id.go
277 lines (262 loc) · 6.49 KB
/
id.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
package ogame
import "strconv"
// ID represent an ogame id
type ID int64
// IsSet returns either or not the id is set to a value different than 0
func (o ID) IsSet() bool {
return o.Int64() != 0
}
// Int64 returns an integer value of the id
func (o ID) Int64() int64 {
return int64(o)
}
// Int returns an integer value of the id
// Deprecated: backward compatibility
func (o ID) Int() int64 {
return int64(o)
}
func (o ID) String() string {
res := ""
switch o {
case AllianceDepotID:
res += "AllianceDepot"
case RoboticsFactoryID:
res += "RoboticsFactory"
case ShipyardID:
res += "Shipyard"
case ResearchLabID:
res += "ResearchLab"
case MissileSiloID:
res += "MissileSilo"
case NaniteFactoryID:
res += "NaniteFactory"
case TerraformerID:
res += "Terraformer"
case SpaceDockID:
res += "SpaceDock"
case LunarBaseID:
res += "LunarBase"
case SensorPhalanxID:
res += "SensorPhalanx"
case JumpGateID:
res += "JumpGate"
case MetalMineID:
res += "MetalMine"
case CrystalMineID:
res += "CrystalMine"
case DeuteriumSynthesizerID:
res += "DeuteriumSynthesizer"
case SolarPlantID:
res += "SolarPlant"
case FusionReactorID:
res += "FusionReactor"
case MetalStorageID:
res += "MetalStorage"
case CrystalStorageID:
res += "CrystalStorage"
case DeuteriumTankID:
res += "DeuteriumTank"
case ShieldedMetalDenID:
res += "ShieldedMetalDen"
case UndergroundCrystalDenID:
res += "UndergroundCrystalDen"
case SeabedDeuteriumDenID:
res += "SeabedDeuteriumDen"
case RocketLauncherID:
res += "RocketLauncher"
case LightLaserID:
res += "LightLaser"
case HeavyLaserID:
res += "HeavyLaser"
case GaussCannonID:
res += "GaussCannon"
case IonCannonID:
res += "IonCannon"
case PlasmaTurretID:
res += "PlasmaTurret"
case SmallShieldDomeID:
res += "SmallShieldDome"
case LargeShieldDomeID:
res += "LargeShieldDome"
case AntiBallisticMissilesID:
res += "AntiBallisticMissiles"
case InterplanetaryMissilesID:
res += "InterplanetaryMissiles"
case SmallCargoID:
res += "SmallCargo"
case LargeCargoID:
res += "LargeCargo"
case LightFighterID:
res += "LightFighter"
case HeavyFighterID:
res += "HeavyFighter"
case CruiserID:
res += "Cruiser"
case BattleshipID:
res += "Battleship"
case ColonyShipID:
res += "ColonyShip"
case RecyclerID:
res += "Recycler"
case EspionageProbeID:
res += "EspionageProbe"
case BomberID:
res += "Bomber"
case SolarSatelliteID:
res += "SolarSatellite"
case DestroyerID:
res += "Destroyer"
case DeathstarID:
res += "Deathstar"
case BattlecruiserID:
res += "Battlecruiser"
case CrawlerID:
res += "Crawler"
case ReaperID:
res += "Reaper"
case PathfinderID:
res += "Pathfinder"
case EspionageTechnologyID:
res += "EspionageTechnology"
case ComputerTechnologyID:
res += "ComputerTechnology"
case WeaponsTechnologyID:
res += "WeaponsTechnology"
case ShieldingTechnologyID:
res += "ShieldingTechnology"
case ArmourTechnologyID:
res += "ArmourTechnology"
case EnergyTechnologyID:
res += "EnergyTechnology"
case HyperspaceTechnologyID:
res += "HyperspaceTechnology"
case CombustionDriveID:
res += "CombustionDrive"
case ImpulseDriveID:
res += "ImpulseDrive"
case HyperspaceDriveID:
res += "HyperspaceDrive"
case LaserTechnologyID:
res += "LaserTechnology"
case IonTechnologyID:
res += "IonTechnology"
case PlasmaTechnologyID:
res += "PlasmaTechnology"
case IntergalacticResearchNetworkID:
res += "IntergalacticResearchNetwork"
case AstrophysicsID:
res += "Astrophysics"
case GravitonTechnologyID:
res += "GravitonTechnology"
default:
res += "Invalid(" + strconv.FormatInt(int64(o), 10) + ")"
}
return res
}
// IsValid returns either or not the id is valid
func (o ID) IsValid() bool {
return o.IsDefense() || o.IsShip() || o.IsTech() || o.IsBuilding()
}
// IsFacility returns either or not the id is a facility
func (o ID) IsFacility() bool {
return o == AllianceDepotID ||
o == RoboticsFactoryID ||
o == ShipyardID ||
o == ResearchLabID ||
o == MissileSiloID ||
o == NaniteFactoryID ||
o == TerraformerID ||
o == SpaceDockID ||
o == LunarBaseID ||
o == SensorPhalanxID ||
o == JumpGateID
}
// IsResourceBuilding returns either or not the id is a resource building
func (o ID) IsResourceBuilding() bool {
return o == MetalMineID ||
o == CrystalMineID ||
o == DeuteriumSynthesizerID ||
o == SolarPlantID ||
o == FusionReactorID ||
o == MetalStorageID ||
o == CrystalStorageID ||
o == DeuteriumTankID ||
o == ShieldedMetalDenID ||
o == UndergroundCrystalDenID ||
o == SeabedDeuteriumDenID
}
// IsBuilding returns either or not the id is a building (facility, resource building)
func (o ID) IsBuilding() bool {
return o.IsResourceBuilding() || o.IsFacility()
}
// IsTech returns either or not the id is a technology
func (o ID) IsTech() bool {
return o == EspionageTechnologyID ||
o == ComputerTechnologyID ||
o == WeaponsTechnologyID ||
o == ShieldingTechnologyID ||
o == ArmourTechnologyID ||
o == EnergyTechnologyID ||
o == HyperspaceTechnologyID ||
o == CombustionDriveID ||
o == ImpulseDriveID ||
o == HyperspaceDriveID ||
o == LaserTechnologyID ||
o == IonTechnologyID ||
o == PlasmaTechnologyID ||
o == IntergalacticResearchNetworkID ||
o == AstrophysicsID ||
o == GravitonTechnologyID
}
// IsDefense returns either or not the id is a defense
func (o ID) IsDefense() bool {
return o == RocketLauncherID ||
o == LightLaserID ||
o == HeavyLaserID ||
o == GaussCannonID ||
o == IonCannonID ||
o == PlasmaTurretID ||
o == SmallShieldDomeID ||
o == LargeShieldDomeID ||
o == AntiBallisticMissilesID ||
o == InterplanetaryMissilesID
}
// IsShip returns either or not the id is a ship
func (o ID) IsShip() bool {
return o == SmallCargoID ||
o == LargeCargoID ||
o == LightFighterID ||
o == HeavyFighterID ||
o == CruiserID ||
o == BattleshipID ||
o == ColonyShipID ||
o == RecyclerID ||
o == EspionageProbeID ||
o == BomberID ||
o == SolarSatelliteID ||
o == DestroyerID ||
o == DeathstarID ||
o == BattlecruiserID ||
o == CrawlerID ||
o == ReaperID ||
o == PathfinderID
}
// IsFlyableShip returns either or not the id is a ship that can fly
func (o ID) IsFlyableShip() bool {
if o == SolarSatelliteID || o == CrawlerID {
return false
}
return o.IsShip()
}
// IsCombatShip ...
func (o ID) IsCombatShip() bool {
return o == LightFighterID ||
o == HeavyFighterID ||
o == CruiserID ||
o == BattleshipID ||
o == BomberID ||
o == DestroyerID ||
o == DeathstarID ||
o == BattlecruiserID ||
o == ReaperID
}