-
Notifications
You must be signed in to change notification settings - Fork 3
/
converter.go
961 lines (830 loc) · 29.2 KB
/
converter.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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
//go:generate go run github.com/jmattheis/goverter/cmd/goverter@v1.4.0 gen ./
package db
import (
"database/sql"
"time"
"github.com/sirgwain/craig-stars/cs"
)
// will be instanciated in ./converter.init.go
var c Converter
// goverter:converter
// goverter:output:package github.com/sirgwain/craig-stars/db
// goverter:output:file ./generated.go
// goverter:ignoreUnexported
// goverter:extend TimeToTime
// goverter:extend NullTimeToTime
// goverter:extend TimeToNullTime
// goverter:extend NullBoolToBool
// goverter:extend BoolToNullBool
// goverter:extend RulesToGameRules
// goverter:extend GameRulesToRules
// goverter:extend TagsToGameTags
// goverter:extend GameTagsToTags
// goverter:extend RaceSpecToGameRaceSpec
// goverter:extend GameRaceSpecToRaceSpec
// goverter:extend ProductionPlansToGameProductionPlans
// goverter:extend GameProductionPlansToProductionPlans
// goverter:extend BattlePlansToGameBattlePlans
// goverter:extend GameBattlePlansToBattlePlans
// goverter:extend TransportPlansToGameTransportPlans
// goverter:extend GameTransportPlansToTransportPlans
// goverter:extend PlayerRelationshipsToGamePlayerRelationships
// goverter:extend GamePlayerRelationshipsToPlayerRelationships
// goverter:extend PlayerMessagesToGamePlayerMessages
// goverter:extend GamePlayerMessagesToPlayerMessages
// goverter:extend PlayerScoresToGamePlayerScores
// goverter:extend GamePlayerScoresToPlayerScores
// goverter:extend BattleRecordsToGameBattleRecords
// goverter:extend GameBattleRecordsToBattleRecords
// goverter:extend PlayerIntelsToGamePlayerIntels
// goverter:extend GamePlayerIntelsToPlayerIntels
// goverter:extend ScoreIntelsToGameScoreIntels
// goverter:extend GameScoreIntelsToScoreIntels
// goverter:extend PlanetIntelsToGamePlanetIntels
// goverter:extend GamePlanetIntelsToPlanetIntels
// goverter:extend FleetIntelsToGameFleetIntels
// goverter:extend GameFleetIntelsToFleetIntels
// goverter:extend ShipDesignIntelsToGameShipDesignIntels
// goverter:extend GameShipDesignIntelsToShipDesignIntels
// goverter:extend MineralPacketIntelsToGameMineralPacketIntels
// goverter:extend GameMineralPacketIntelsToMineralPacketIntels
// goverter:extend SalvageIntelsToGameSalvageIntels
// goverter:extend GameSalvageIntelsToSalvageIntels
// goverter:extend MineFieldIntelsToGameMineFieldIntels
// goverter:extend GameMineFieldIntelsToMineFieldIntels
// goverter:extend WormholeIntelsToGameWormholeIntels
// goverter:extend GameWormholeIntelsToWormholeIntels
// goverter:extend MysteryTraderIntelsToGameMysteryTraderIntels
// goverter:extend GameMysteryTraderIntelsToMysteryTraderIntels
// goverter:extend GameRaceToPlayerRace
// goverter:extend PlayerRaceToGameRace
// goverter:extend PlayerSpecToGamePlayerSpec
// goverter:extend GamePlayerSpecToPlayerSpec
// goverter:extend PlayerStatsToGamePlayerStats
// goverter:extend GamePlayerStatsToPlayerStats
// goverter:name GameConverter
// goverter:extend PlanetSpecToGamePlanetSpec
// goverter:extend GamePlanetSpecToPlanetSpec
// goverter:extend ProductionQueueItemsToGameProductionQueueItems
// goverter:extend GameProductionQueueItemsToProductionQueueItems
// goverter:extend FleetSpecToGameFleetSpec
// goverter:extend GameFleetSpecToFleetSpec
// goverter:extend ShipTokensToGameShipTokens
// goverter:extend GameShipTokensToShipTokens
// goverter:extend WaypointsToGameWaypoints
// goverter:extend GameWaypointsToWaypoints
// goverter:extend MineFieldSpecToGameMineFieldSpec
// goverter:extend GameMineFieldSpecToMineFieldSpec
// goverter:extend ShipDesignSpecToGameShipDesignSpec
// goverter:extend GameShipDesignSpecToShipDesignSpec
// goverter:extend ShipDesignSlotsToGameShipDesignSlots
// goverter:extend GameShipDesignSlotsToShipDesignSlots
// goverter:extend WormholeSpecToGameWormholeSpec
// goverter:extend GameWormholeSpecToWormholeSpec
// goverter:extend MysteryTraderSpecToGameMysteryTraderSpec
// goverter:extend GameMysteryTraderSpecToMysteryTraderSpec
// goverter:enum no
type Converter interface {
// goverter:map . DBObject
ConvertUser(source User) cs.User
ConvertUsers(source []User) []cs.User
// goverter:autoMap DBObject
ConvertGameUser(source *cs.User) *User
// goverter:map . DBObject
// goverter:map . ResearchCost | ExtendResearchCost
// goverter:map . HabLow | ExtendHabLow
// goverter:map . HabHigh | ExtendHabHigh
ConvertRace(source Race) cs.Race
ConvertRaces(source []Race) []cs.Race
// goverter:autoMap DBObject
// goverter:map HabHigh.Grav HabHighGrav
// goverter:map HabHigh.Temp HabHighTemp
// goverter:map HabHigh.Rad HabHighRad
// goverter:map HabLow.Grav HabLowGrav
// goverter:map HabLow.Temp HabLowTemp
// goverter:map HabLow.Rad HabLowRad
// goverter:map ResearchCost.Energy ResearchCostEnergy
// goverter:map ResearchCost.Weapons ResearchCostWeapons
// goverter:map ResearchCost.Propulsion ResearchCostPropulsion
// goverter:map ResearchCost.Construction ResearchCostConstruction
// goverter:map ResearchCost.Electronics ResearchCostElectronics
// goverter:map ResearchCost.Biotechnology ResearchCostBiotechnology
ConvertGameRace(source *cs.Race) *Race
// goverter:map . DBObject
// goverter:map . VictoryConditions | ExtendVictoryConditions
// goverter:map . Area | ExtendArea
// goverter:map . Rules | ExtendDefaultRules
ConvertGame(source Game) cs.Game
ConvertGames(source []Game) []cs.Game
// goverter:autoMap DBObject
// goverter:map VictoryConditions.NumCriteriaRequired VictoryConditionsNumCriteriaRequired
// goverter:map VictoryConditions.YearsPassed VictoryConditionsYearsPassed
// goverter:map VictoryConditions.OwnPlanets VictoryConditionsOwnPlanets
// goverter:map VictoryConditions.AttainTechLevel VictoryConditionsAttainTechLevel
// goverter:map VictoryConditions.AttainTechLevelNumFields VictoryConditionsAttainTechLevelNumFields
// goverter:map VictoryConditions.ExceedsScore VictoryConditionsExceedsScore
// goverter:map VictoryConditions.ExceedsSecondPlaceScore VictoryConditionsExceedsSecondPlaceScore
// goverter:map VictoryConditions.ProductionCapacity VictoryConditionsProductionCapacity
// goverter:map VictoryConditions.OwnCapitalShips VictoryConditionsOwnCapitalShips
// goverter:map VictoryConditions.HighestScoreAfterYears VictoryConditionsHighestScoreAfterYears
// goverter:map VictoryConditions.Conditions VictoryConditionsConditions
// goverter:map Area.X AreaX
// goverter:map Area.Y AreaY
ConvertGameGame(source *cs.Game) *Game
// goverter:autoMap GameDBObject
// goverter:map TechLevels.Energy TechLevelsEnergy
// goverter:map TechLevels.Weapons TechLevelsWeapons
// goverter:map TechLevels.Propulsion TechLevelsPropulsion
// goverter:map TechLevels.Construction TechLevelsConstruction
// goverter:map TechLevels.Electronics TechLevelsElectronics
// goverter:map TechLevels.Biotechnology TechLevelsBiotechnology
// goverter:map TechLevelsSpent.Energy TechLevelsSpentEnergy
// goverter:map TechLevelsSpent.Weapons TechLevelsSpentWeapons
// goverter:map TechLevelsSpent.Propulsion TechLevelsSpentPropulsion
// goverter:map TechLevelsSpent.Construction TechLevelsSpentConstruction
// goverter:map TechLevelsSpent.Electronics TechLevelsSpentElectronics
// goverter:map TechLevelsSpent.Biotechnology TechLevelsSpentBiotechnology
// goverter:autoMap PlayerOrders
// goverter:map PlayerIntels.BattleRecords BattleRecords
// goverter:map PlayerIntels.PlayerIntels PlayerIntels
// goverter:map PlayerIntels.ScoreIntels ScoreIntels
// goverter:map PlayerIntels.PlanetIntels PlanetIntels
// goverter:map PlayerIntels.FleetIntels FleetIntels
// goverter:map PlayerIntels.StarbaseIntels StarbaseIntels
// goverter:map PlayerIntels.ShipDesignIntels ShipDesignIntels
// goverter:map PlayerIntels.MineralPacketIntels MineralPacketIntels
// goverter:map PlayerIntels.MineFieldIntels MineFieldIntels
// goverter:map PlayerIntels.WormholeIntels WormholeIntels
// goverter:map PlayerIntels.MysteryTraderIntels MysteryTraderIntels
// goverter:map PlayerIntels.SalvageIntels SalvageIntels
// goverter:autoMap PlayerPlans
ConvertGamePlayer(source *cs.Player) *Player
// goverter:map . GameDBObject
// goverter:map . TechLevels | ExtendTechLevels
// goverter:map . TechLevelsSpent | ExtendTechLevelsSpent
// goverter:map . PlayerOrders
// goverter:map . PlayerIntels
// goverter:map . PlayerPlans
// goverter:ignore Designs
ConvertPlayer(source Player) cs.Player
ConvertPlayers(source []Player) []cs.Player
// goverter:autoMap MapObject.GameDBObject
// goverter:autoMap MapObject.Position
// goverter:autoMap MapObject
// goverter:autoMap PlanetOrders
// goverter:autoMap Hab
// goverter:map BaseHab.Grav BaseGrav
// goverter:map BaseHab.Temp BaseTemp
// goverter:map BaseHab.Rad BaseRad
// goverter:map TerraformedAmount.Grav TerraformedAmountGrav
// goverter:map TerraformedAmount.Temp TerraformedAmountTemp
// goverter:map TerraformedAmount.Rad TerraformedAmountRad
// goverter:map MineralConcentration.Ironium MineralConcIronium
// goverter:map MineralConcentration.Boranium MineralConcBoranium
// goverter:map MineralConcentration.Germanium MineralConcGermanium
// goverter:map MineYears.Ironium MineYearsIronium
// goverter:map MineYears.Boranium MineYearsBoranium
// goverter:map MineYears.Germanium MineYearsGermanium
// goverter:autoMap Cargo
ConvertGamePlanet(source *cs.Planet) *Planet
// goverter:map . Hab
// goverter:map . BaseHab | ExtendBaseHab
// goverter:map . TerraformedAmount | ExtendTerraformedAmount
// goverter:map . MineralConcentration | ExtendMineralConcentration
// goverter:map . MineYears | ExtendMineYears
// goverter:map . Cargo
// goverter:map . MapObject | ExtendPlanetMapObject
// goverter:map . PlanetOrders
// goverter:ignore Starbase
ConvertPlanet(source *Planet) *cs.Planet
// goverter:autoMap MapObject.GameDBObject
// goverter:autoMap MapObject.Position
// goverter:autoMap MapObject
// goverter:autoMap FleetOrders
// goverter:map Heading.X HeadingX
// goverter:map Heading.Y HeadingY
// goverter:map PreviousPosition.X PreviousPositionX
// goverter:map PreviousPosition.Y PreviousPositionY
// goverter:autoMap Cargo
ConvertGameFleet(source *cs.Fleet) *Fleet
// goverter:map . Heading | ExtendFleetHeading
// goverter:map . PreviousPosition | ExtendFleetPreviousPosition
// goverter:map . Cargo
// goverter:map . MapObject | ExtendFleetMapObject
// goverter:map . FleetOrders | ExtendFleetFleetOrders
ConvertFleet(source *Fleet) *cs.Fleet
// goverter:autoMap GameDBObject
// goverter:ignore CanDelete
ConvertGameShipDesign(source *cs.ShipDesign) *ShipDesign
// goverter:ignore Dirty
// goverter:ignore Delete
// goverter:map . GameDBObject
ConvertShipDesign(source *ShipDesign) *cs.ShipDesign
// goverter:autoMap MapObject.GameDBObject
// goverter:autoMap MapObject.Position
// goverter:autoMap MapObject
ConvertGameWormhole(source *cs.Wormhole) *Wormhole
// goverter:map . MapObject
ConvertWormhole(source *Wormhole) *cs.Wormhole
// goverter:map . GameDBObject
// goverter:map . Position
// goverter:map Type | MapObjectTypeWormhole
// goverter:ignore Dirty
// goverter:ignore Delete
// goverter:ignore PlayerNum
wormHoleMapObject(source Wormhole) cs.MapObject
// goverter:autoMap MapObject.GameDBObject
// goverter:autoMap MapObject.Position
// goverter:autoMap MapObject
// goverter:map Heading.X HeadingX
// goverter:map Heading.Y HeadingY
ConvertGameMysteryTrader(source *cs.MysteryTrader) *MysteryTrader
// goverter:map . MapObject | ExtendMysteryTraderMapObject
// goverter:map . Heading | ExtendMysteryTraderHeading
ConvertMysteryTrader(source *MysteryTrader) *cs.MysteryTrader
// goverter:autoMap MapObject.GameDBObject
// goverter:autoMap MapObject.Position
// goverter:autoMap MapObject
// goverter:autoMap Cargo
ConvertGameSalvage(source *cs.Salvage) *Salvage
// goverter:map . MapObject | ExtendSalvageMapObject
// goverter:map . Cargo
ConvertSalvage(source *Salvage) *cs.Salvage
// goverter:autoMap MapObject.GameDBObject
// goverter:autoMap MapObject.Position
// goverter:autoMap MapObject
// goverter:map MineFieldOrders.Detonate Detonate
ConvertGameMineField(source *cs.MineField) *MineField
// goverter:map . MapObject | ExtendMineFieldMapObject
// goverter:map . MineFieldOrders
ConvertMineField(source *MineField) *cs.MineField
// goverter:autoMap MapObject.GameDBObject
// goverter:autoMap MapObject.Position
// goverter:autoMap MapObject
// goverter:autoMap Cargo
// goverter:map Cargo.Ironium Ironium
// goverter:map Cargo.Boranium Boranium
// goverter:map Cargo.Germanium Germanium
// goverter:map Heading.X HeadingX
// goverter:map Heading.Y HeadingY
ConvertGameMineralPacket(source *cs.MineralPacket) *MineralPacket
// goverter:map . MapObject | ExtendMineralPacketMapObject
// goverter:map . Cargo
// goverter:map . Heading | ExtendMineralPacketHeading
ConvertMineralPacket(source *MineralPacket) *cs.MineralPacket
// goverter:ignore Colonists
salvageCargo(source Salvage) cs.Cargo
// goverter:ignore Colonists
mineralPaketCargo(source MineralPacket) cs.Cargo
}
func MapObjectTypeWormhole() cs.MapObjectType {
return cs.MapObjectTypeWormhole
}
func TimeToTime(source time.Time) time.Time {
return source
}
func NullTimeToTime(source sql.NullTime) time.Time {
if source.Valid {
return source.Time
}
return time.Time{}
}
func TimeToNullTime(source time.Time) sql.NullTime {
return sql.NullTime{
Valid: true,
Time: source,
}
}
func NullBoolToBool(source sql.NullBool) bool {
if source.Valid {
return source.Bool
}
return false
}
func BoolToNullBool(source bool) sql.NullBool {
return sql.NullBool{
Valid: true,
Bool: source,
}
}
func RulesToGameRules(source *Rules) cs.Rules {
return cs.Rules(*source)
}
func GameRulesToRules(source cs.Rules) *Rules {
return (*Rules)(&source)
}
func RaceSpecToGameRaceSpec(source *RaceSpec) cs.RaceSpec {
return (cs.RaceSpec)(*source)
}
func GameRaceSpecToRaceSpec(source cs.RaceSpec) *RaceSpec {
return (*RaceSpec)(&source)
}
func TagsToGameTags(source *Tags) cs.Tags {
if source == nil {
return cs.Tags{}
}
return (cs.Tags)(*source)
}
func GameTagsToTags(source cs.Tags) *Tags {
return (*Tags)(&source)
}
func BattlePlansToGameBattlePlans(source *BattlePlans) []cs.BattlePlan {
// return an empty slice for nil
if source == nil {
return []cs.BattlePlan{}
}
return ([]cs.BattlePlan)(*source)
}
func GameBattlePlansToBattlePlans(source []cs.BattlePlan) *BattlePlans {
return (*BattlePlans)(&source)
}
func ProductionPlansToGameProductionPlans(source *ProductionPlans) []cs.ProductionPlan {
// return an empty slice for nil
if source == nil {
return []cs.ProductionPlan{}
}
return ([]cs.ProductionPlan)(*source)
}
func GameProductionPlansToProductionPlans(source []cs.ProductionPlan) *ProductionPlans {
return (*ProductionPlans)(&source)
}
func TransportPlansToGameTransportPlans(source *TransportPlans) []cs.TransportPlan {
// return an empty slice for nil
if source == nil {
return []cs.TransportPlan{}
}
return ([]cs.TransportPlan)(*source)
}
func GameTransportPlansToTransportPlans(source []cs.TransportPlan) *TransportPlans {
return (*TransportPlans)(&source)
}
func PlayerRelationshipsToGamePlayerRelationships(source *PlayerRelationships) []cs.PlayerRelationship {
// return an empty slice for nil
if source == nil {
return []cs.PlayerRelationship{}
}
return ([]cs.PlayerRelationship)(*source)
}
func GamePlayerRelationshipsToPlayerRelationships(source []cs.PlayerRelationship) *PlayerRelationships {
return (*PlayerRelationships)(&source)
}
func PlayerMessagesToGamePlayerMessages(source *PlayerMessages) []cs.PlayerMessage {
// return an empty slice for nil
if source == nil {
return []cs.PlayerMessage{}
}
return ([]cs.PlayerMessage)(*source)
}
func GamePlayerMessagesToPlayerMessages(source []cs.PlayerMessage) *PlayerMessages {
return (*PlayerMessages)(&source)
}
func PlayerScoresToGamePlayerScores(source *PlayerScores) []cs.PlayerScore {
// return an empty slice for nil
if source == nil {
return []cs.PlayerScore{}
}
return ([]cs.PlayerScore)(*source)
}
func GamePlayerScoresToPlayerScores(source []cs.PlayerScore) *PlayerScores {
return (*PlayerScores)(&source)
}
func BattleRecordsToGameBattleRecords(source *BattleRecords) []cs.BattleRecord {
// return an empty slice for nil
if source == nil {
return []cs.BattleRecord{}
}
return ([]cs.BattleRecord)(*source)
}
func GameBattleRecordsToBattleRecords(source []cs.BattleRecord) *BattleRecords {
return (*BattleRecords)(&source)
}
func PlayerIntelsToGamePlayerIntels(source *PlayerIntels) []cs.PlayerIntel {
// return an empty slice for nil
if source == nil {
return []cs.PlayerIntel{}
}
return ([]cs.PlayerIntel)(*source)
}
func GamePlayerIntelsToPlayerIntels(source []cs.PlayerIntel) *PlayerIntels {
return (*PlayerIntels)(&source)
}
func ScoreIntelsToGameScoreIntels(source *ScoreIntels) []cs.ScoreIntel {
// return an empty slice for nil
if source == nil {
return []cs.ScoreIntel{}
}
return ([]cs.ScoreIntel)(*source)
}
func GameScoreIntelsToScoreIntels(source []cs.ScoreIntel) *ScoreIntels {
return (*ScoreIntels)(&source)
}
func PlanetIntelsToGamePlanetIntels(source *PlanetIntels) []cs.PlanetIntel {
// return an empty slice for nil
if source == nil {
return []cs.PlanetIntel{}
}
return ([]cs.PlanetIntel)(*source)
}
func GamePlanetIntelsToPlanetIntels(source []cs.PlanetIntel) *PlanetIntels {
return (*PlanetIntels)(&source)
}
func FleetIntelsToGameFleetIntels(source *FleetIntels) []cs.FleetIntel {
// return an empty slice for nil
if source == nil {
return []cs.FleetIntel{}
}
return ([]cs.FleetIntel)(*source)
}
func GameFleetIntelsToFleetIntels(source []cs.FleetIntel) *FleetIntels {
return (*FleetIntels)(&source)
}
func ShipDesignIntelsToGameShipDesignIntels(source *ShipDesignIntels) []cs.ShipDesignIntel {
// return an empty slice for nil
if source == nil {
return []cs.ShipDesignIntel{}
}
return ([]cs.ShipDesignIntel)(*source)
}
func GameShipDesignIntelsToShipDesignIntels(source []cs.ShipDesignIntel) *ShipDesignIntels {
return (*ShipDesignIntels)(&source)
}
func MineralPacketIntelsToGameMineralPacketIntels(source *MineralPacketIntels) []cs.MineralPacketIntel {
// return an empty slice for nil
if source == nil {
return []cs.MineralPacketIntel{}
}
return ([]cs.MineralPacketIntel)(*source)
}
func GameMineralPacketIntelsToMineralPacketIntels(source []cs.MineralPacketIntel) *MineralPacketIntels {
return (*MineralPacketIntels)(&source)
}
func SalvageIntelsToGameSalvageIntels(source *SalvageIntels) []cs.SalvageIntel {
// return an empty slice for nil
if source == nil {
return []cs.SalvageIntel{}
}
return ([]cs.SalvageIntel)(*source)
}
func GameSalvageIntelsToSalvageIntels(source []cs.SalvageIntel) *SalvageIntels {
return (*SalvageIntels)(&source)
}
func MineFieldIntelsToGameMineFieldIntels(source *MineFieldIntels) []cs.MineFieldIntel {
// return an empty slice for nil
if source == nil {
return []cs.MineFieldIntel{}
}
return ([]cs.MineFieldIntel)(*source)
}
func GameMineFieldIntelsToMineFieldIntels(source []cs.MineFieldIntel) *MineFieldIntels {
return (*MineFieldIntels)(&source)
}
func WormholeIntelsToGameWormholeIntels(source *WormholeIntels) []cs.WormholeIntel {
// return an empty slice for nil
if source == nil {
return []cs.WormholeIntel{}
}
return ([]cs.WormholeIntel)(*source)
}
func GameWormholeIntelsToWormholeIntels(source []cs.WormholeIntel) *WormholeIntels {
return (*WormholeIntels)(&source)
}
func MysteryTraderIntelsToGameMysteryTraderIntels(source *MysteryTraderIntels) []cs.MysteryTraderIntel {
// return an empty slice for nil
if source == nil {
return []cs.MysteryTraderIntel{}
}
return ([]cs.MysteryTraderIntel)(*source)
}
func GameMysteryTraderIntelsToMysteryTraderIntels(source []cs.MysteryTraderIntel) *MysteryTraderIntels {
return (*MysteryTraderIntels)(&source)
}
func PlayerRaceToGameRace(source *PlayerRace) cs.Race {
// return an empty object for nil to support partial loads
if source == nil {
return cs.Race{}
}
return cs.Race(*source)
}
func GameRaceToPlayerRace(source cs.Race) *PlayerRace {
return (*PlayerRace)(&source)
}
func PlayerSpecToGamePlayerSpec(source *PlayerSpec) cs.PlayerSpec {
// return an empty object for nil to support partial loads
if source == nil {
return cs.PlayerSpec{}
}
return (cs.PlayerSpec)(*source)
}
func GamePlayerSpecToPlayerSpec(source cs.PlayerSpec) *PlayerSpec {
return (*PlayerSpec)(&source)
}
func PlayerStatsToGamePlayerStats(source *PlayerStats) *cs.PlayerStats {
return (*cs.PlayerStats)(source)
}
func GamePlayerStatsToPlayerStats(source *cs.PlayerStats) *PlayerStats {
return (*PlayerStats)(source)
}
func PlanetSpecToGamePlanetSpec(source *PlanetSpec) cs.PlanetSpec {
return (cs.PlanetSpec)(*source)
}
func GamePlanetSpecToPlanetSpec(source cs.PlanetSpec) *PlanetSpec {
return (*PlanetSpec)(&source)
}
func ProductionQueueItemsToGameProductionQueueItems(source *ProductionQueueItems) []cs.ProductionQueueItem {
return ([]cs.ProductionQueueItem)(*source)
}
func GameProductionQueueItemsToProductionQueueItems(source []cs.ProductionQueueItem) *ProductionQueueItems {
return (*ProductionQueueItems)(&source)
}
func FleetSpecToGameFleetSpec(source *FleetSpec) cs.FleetSpec {
return (cs.FleetSpec)(*source)
}
func GameFleetSpecToFleetSpec(source cs.FleetSpec) *FleetSpec {
return (*FleetSpec)(&source)
}
func ShipTokensToGameShipTokens(source *ShipTokens) []cs.ShipToken {
return ([]cs.ShipToken)(*source)
}
func GameShipTokensToShipTokens(source []cs.ShipToken) *ShipTokens {
return (*ShipTokens)(&source)
}
func WaypointsToGameWaypoints(source *Waypoints) []cs.Waypoint {
return ([]cs.Waypoint)(*source)
}
func GameWaypointsToWaypoints(source []cs.Waypoint) *Waypoints {
return (*Waypoints)(&source)
}
func MineFieldSpecToGameMineFieldSpec(source *MineFieldSpec) cs.MineFieldSpec {
return (cs.MineFieldSpec)(*source)
}
func GameMineFieldSpecToMineFieldSpec(source cs.MineFieldSpec) *MineFieldSpec {
return (*MineFieldSpec)(&source)
}
func ShipDesignSpecToGameShipDesignSpec(source *ShipDesignSpec) cs.ShipDesignSpec {
return (cs.ShipDesignSpec)(*source)
}
func GameShipDesignSpecToShipDesignSpec(source cs.ShipDesignSpec) *ShipDesignSpec {
return (*ShipDesignSpec)(&source)
}
func ShipDesignSlotsToGameShipDesignSlots(source *ShipDesignSlots) []cs.ShipDesignSlot {
return ([]cs.ShipDesignSlot)(*source)
}
func GameShipDesignSlotsToShipDesignSlots(source []cs.ShipDesignSlot) *ShipDesignSlots {
return (*ShipDesignSlots)(&source)
}
func WormholeSpecToGameWormholeSpec(source *WormholeSpec) cs.WormholeSpec {
return (cs.WormholeSpec)(*source)
}
func GameWormholeSpecToWormholeSpec(source cs.WormholeSpec) *WormholeSpec {
return (*WormholeSpec)(&source)
}
func MysteryTraderSpecToGameMysteryTraderSpec(source *MysteryTraderSpec) cs.MysteryTraderSpec {
return (cs.MysteryTraderSpec)(*source)
}
func GameMysteryTraderSpecToMysteryTraderSpec(source cs.MysteryTraderSpec) *MysteryTraderSpec {
return (*MysteryTraderSpec)(&source)
}
func ExtendResearchCost(source Race) cs.ResearchCost {
return cs.ResearchCost{
Energy: source.ResearchCostEnergy,
Weapons: source.ResearchCostWeapons,
Propulsion: source.ResearchCostPropulsion,
Construction: source.ResearchCostConstruction,
Electronics: source.ResearchCostElectronics,
Biotechnology: source.ResearchCostBiotechnology,
}
}
func ExtendHabLow(source Race) cs.Hab {
return cs.Hab{
Grav: source.HabLowGrav,
Temp: source.HabLowTemp,
Rad: source.HabLowRad,
}
}
func ExtendHabHigh(source Race) cs.Hab {
return cs.Hab{
Grav: source.HabHighGrav,
Temp: source.HabHighTemp,
Rad: source.HabHighRad,
}
}
func ExtendVictoryConditions(source Game) cs.VictoryConditions {
return cs.VictoryConditions{
Conditions: source.VictoryConditionsConditions,
NumCriteriaRequired: source.VictoryConditionsNumCriteriaRequired,
YearsPassed: source.VictoryConditionsYearsPassed,
OwnPlanets: source.VictoryConditionsOwnPlanets,
AttainTechLevel: source.VictoryConditionsAttainTechLevel,
AttainTechLevelNumFields: source.VictoryConditionsAttainTechLevelNumFields,
ExceedsScore: source.VictoryConditionsExceedsScore,
ExceedsSecondPlaceScore: source.VictoryConditionsExceedsSecondPlaceScore,
ProductionCapacity: source.VictoryConditionsProductionCapacity,
OwnCapitalShips: source.VictoryConditionsOwnCapitalShips,
HighestScoreAfterYears: source.VictoryConditionsHighestScoreAfterYears,
}
}
func ExtendArea(source Game) cs.Vector {
return cs.Vector{
X: source.AreaX,
Y: source.AreaY,
}
}
func ExtendDefaultRules(source Game) cs.Rules {
return cs.NewRules()
}
func ExtendTechLevels(source Player) cs.TechLevel {
return cs.TechLevel{
Energy: source.TechLevelsEnergy,
Weapons: source.TechLevelsWeapons,
Propulsion: source.TechLevelsPropulsion,
Construction: source.TechLevelsConstruction,
Electronics: source.TechLevelsElectronics,
Biotechnology: source.TechLevelsBiotechnology,
}
}
func ExtendTechLevelsSpent(source Player) cs.TechLevel {
return cs.TechLevel{
Energy: source.TechLevelsSpentEnergy,
Weapons: source.TechLevelsSpentWeapons,
Propulsion: source.TechLevelsSpentPropulsion,
Construction: source.TechLevelsSpentConstruction,
Electronics: source.TechLevelsSpentElectronics,
Biotechnology: source.TechLevelsSpentBiotechnology,
}
}
func ExtendPlanetMapObject(source Planet) cs.MapObject {
return cs.MapObject{
GameDBObject: cs.GameDBObject{
ID: source.ID,
GameID: source.GameID,
CreatedAt: source.CreatedAt,
UpdatedAt: source.UpdatedAt,
},
Type: cs.MapObjectTypePlanet,
Position: cs.Vector{
X: source.X,
Y: source.Y,
},
Name: source.Name,
Num: source.Num,
PlayerNum: source.PlayerNum,
Tags: TagsToGameTags(source.Tags),
}
}
func ExtendBaseHab(source Planet) cs.Hab {
return cs.Hab{
Grav: source.BaseGrav,
Temp: source.BaseTemp,
Rad: source.BaseRad,
}
}
func ExtendTerraformedAmount(source Planet) cs.Hab {
return cs.Hab{
Grav: source.TerraformedAmountGrav,
Temp: source.TerraformedAmountTemp,
Rad: source.TerraformedAmountRad,
}
}
func ExtendMineralConcentration(source Planet) cs.Mineral {
return cs.Mineral{
Ironium: source.MineralConcIronium,
Boranium: source.MineralConcBoranium,
Germanium: source.MineralConcGermanium,
}
}
func ExtendMineYears(source Planet) cs.Mineral {
return cs.Mineral{
Ironium: source.MineYearsIronium,
Boranium: source.MineYearsBoranium,
Germanium: source.MineYearsGermanium,
}
}
func ExtendFleetMapObject(source Fleet) cs.MapObject {
return cs.MapObject{
GameDBObject: cs.GameDBObject{
ID: source.ID,
GameID: source.GameID,
CreatedAt: source.CreatedAt,
UpdatedAt: source.UpdatedAt,
},
Type: cs.MapObjectTypeFleet,
Position: cs.Vector{
X: source.X,
Y: source.Y,
},
Name: source.Name,
Num: source.Num,
PlayerNum: source.PlayerNum,
Tags: TagsToGameTags(source.Tags),
}
}
func ExtendFleetFleetOrders(source Fleet) cs.FleetOrders {
return cs.FleetOrders{
BattlePlanNum: source.BattlePlanNum,
Waypoints: *source.Waypoints,
RepeatOrders: source.RepeatOrders,
Purpose: source.Purpose,
}
}
func ExtendFleetHeading(source Fleet) cs.Vector {
return cs.Vector{
X: source.HeadingX,
Y: source.HeadingY,
}
}
func ExtendFleetPreviousPosition(source Fleet) *cs.Vector {
if source.PreviousPositionX == nil || source.PreviousPositionY == nil {
return nil
}
return &cs.Vector{
X: *source.PreviousPositionX,
Y: *source.PreviousPositionY,
}
}
func ExtendMysteryTraderMapObject(source MysteryTrader) cs.MapObject {
return cs.MapObject{
GameDBObject: cs.GameDBObject{
ID: source.ID,
GameID: source.GameID,
CreatedAt: source.CreatedAt,
UpdatedAt: source.UpdatedAt,
},
Type: cs.MapObjectTypeMysteryTrader,
Position: cs.Vector{
X: source.X,
Y: source.Y,
},
Name: source.Name,
Num: source.Num,
Tags: TagsToGameTags(source.Tags),
}
}
func ExtendMysteryTraderHeading(source MysteryTrader) cs.Vector {
return cs.Vector{
X: source.HeadingX,
Y: source.HeadingY,
}
}
func ExtendSalvageMapObject(source Salvage) cs.MapObject {
return cs.MapObject{
GameDBObject: cs.GameDBObject{
ID: source.ID,
GameID: source.GameID,
CreatedAt: source.CreatedAt,
UpdatedAt: source.UpdatedAt,
},
Type: cs.MapObjectTypeSalvage,
Position: cs.Vector{
X: source.X,
Y: source.Y,
},
Name: source.Name,
Num: source.Num,
PlayerNum: source.PlayerNum,
Tags: TagsToGameTags(source.Tags),
}
}
func ExtendMineFieldMapObject(source MineField) cs.MapObject {
return cs.MapObject{
GameDBObject: cs.GameDBObject{
ID: source.ID,
GameID: source.GameID,
CreatedAt: source.CreatedAt,
UpdatedAt: source.UpdatedAt,
},
Type: cs.MapObjectTypeMineField,
Position: cs.Vector{
X: source.X,
Y: source.Y,
},
Name: source.Name,
Num: source.Num,
PlayerNum: source.PlayerNum,
Tags: TagsToGameTags(source.Tags),
}
}
func ExtendMineralPacketHeading(source MineralPacket) cs.Vector {
return cs.Vector{
X: source.HeadingX,
Y: source.HeadingY,
}
}
func ExtendMineralPacketMapObject(source MineralPacket) cs.MapObject {
return cs.MapObject{
GameDBObject: cs.GameDBObject{
ID: source.ID,
GameID: source.GameID,
CreatedAt: source.CreatedAt,
UpdatedAt: source.UpdatedAt,
},
Type: cs.MapObjectTypeMineralPacket,
Position: cs.Vector{
X: source.X,
Y: source.Y,
},
Name: source.Name,
Num: source.Num,
PlayerNum: source.PlayerNum,
Tags: TagsToGameTags(source.Tags),
}
}