forked from tdauth/dmdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStruct Force.j
970 lines (883 loc) · 25.2 KB
/
Struct Force.j
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
962
963
964
965
966
967
968
969
970
library AStructCoreGeneralForce requires AStructCoreGeneralVector
/**
* Some kind of wrapper structure for native JASS type \ref force.
* Simplifies member access by providing an instance of \ref APlayerVector which holds all force members.
* Additionally it provides various methods which provide same functionality as native and BJ functions.
* \sa AGroup
* \sa wrappers
*/
struct AForce
// members
private APlayerVector m_players
// members
public method players takes nothing returns APlayerVector
return this.m_players
endmethod
// methods
/**
* Fills force \p whichForce with all belonging players.
*/
public method fillForce takes force whichForce returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call ForceAddPlayer(whichForce, this.m_players[i])
set i = i + 1
endloop
endmethod
/**
* Creates a new Warcraft-3-like force from the force.
* \return Returns a newly created force.
*/
public method force takes nothing returns force
local force whichForce = CreateForce()
call this.fillForce(whichForce)
return whichForce
endmethod
/**
* Simple forEach wrapper (equal to players.forEach).
* \sa ForForce()
*/
public method forForce takes APlayerVectorUnaryFunction forFunction returns nothing
call this.m_players.forEach(forFunction)
endmethod
/**
* Adds all units of force \p whichForce to the force.
* \param destroy If this value is true force \p whichForce will be destroyed after it has been added.
* \param clear If this value is true force \p whichForce will be cleared after it has been added. This value has no effect if \p destroy is already true. If both parameters are false force \p whichForce won't change. Unfortunately the method has to check all players (limited Warcraft 3 natives).
*/
public method addForce takes force whichForce, boolean destroy, boolean clear returns nothing
local integer i = 0
loop
exitwhen (i == bj_MAX_PLAYER_SLOTS)
if (IsPlayerInForce(Player(i), whichForce)) then
call this.m_players.pushBack(Player(i))
endif
set i = i + 1
endloop
if (destroy) then
call DestroyForce(whichForce)
set whichForce = null
elseif (clear) then
call ForceClear(whichForce)
endif
endmethod
/**
* \sa ForceEnumPlayers()
*/
public method addPlayers takes boolexpr filter returns nothing
local force whichForce = CreateForce()
call ForceEnumPlayers(whichForce, filter)
call this.addForce(whichForce, true, false)
set whichForce = null
endmethod
/**
* \sa ForceEnumPlayersCounted()
*/
public method addPlayersCounted takes boolexpr filter, integer countLimit returns nothing
local force whichForce = CreateForce()
call ForceEnumPlayersCounted(whichForce, filter, countLimit)
call this.addForce(whichForce, true, false)
set whichForce = null
endmethod
/**
* \sa ForceEnumAllies()
*/
public method addAllies takes player whichPlayer, boolexpr filter returns nothing
local force whichForce = CreateForce()
call ForceEnumAllies(whichForce, whichPlayer, filter)
call this.addForce(whichForce, true, false)
set whichForce = null
endmethod
/**
* \sa ForceEnumEnemies()
*/
public method addEnemies takes player whichPlayer, boolexpr filter returns nothing
local force whichForce = CreateForce()
call ForceEnumEnemies(whichForce, whichPlayer, filter)
call this.addForce(whichForce, true, false)
set whichForce = null
endmethod
/**
* \sa GetPlayersByMapControl()
*/
public method addPlayersByMapControl takes mapcontrol whichControl returns nothing
local integer i = 0
loop
exitwhen (i == bj_MAX_PLAYER_SLOTS)
if (GetPlayerController(Player(i)) == whichControl) then
call this.m_players.pushBack(Player(i))
endif
set i = i + 1
endloop
endmethod
/**
* \sa SetForceAllianceStateBJ()
*/
public method setAllianceState takes AForce targetForce, integer allianceState returns nothing
local integer targetIndex
local integer sourceIndex = 0
loop
exitwhen (sourceIndex == this.m_players.size())
set targetIndex = 0
loop
exitwhen (targetIndex == targetForce.m_players.size())
call SetPlayerAllianceStateBJ(this.m_players[sourceIndex], targetForce.m_players[targetIndex], allianceState)
set targetIndex = targetIndex + 1
endloop
set sourceIndex = sourceIndex + 1
endloop
endmethod
/**
* \sa GetPlayerTeam()
*/
public method hasTeam takes integer team returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (GetPlayerTeam(this.m_players[i]) != team) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa GetPlayerStartLocation()
*/
public method hasStartLocation takes integer startLocation returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (GetPlayerStartLocation(this.m_players[i]) != startLocation) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa GetPlayerColor()
*/
public method hasColor takes playercolor color returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (GetPlayerColor(this.m_players[i]) != color) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa GetPlayerSelectable
*/
public method isSelectable takes nothing returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not GetPlayerSelectable(this.m_players[i])) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa GetPlayerController
*/
public method hasController takes mapcontrol controller returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (GetPlayerController(this.m_players[i]) != controller) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa GetPlayerSlotState
*/
public method hasSlotState takes playerslotstate playerSlotState returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (GetPlayerSlotState(this.m_players[i]) != playerSlotState) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa GetPlayerTaxRate
*/
public method hasTaxRate takes player otherPlayer, playerstate whichResource, integer taxRate returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (GetPlayerTaxRate(this.m_players[i], otherPlayer, whichResource) != taxRate) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa SetPlayerRacePreference
* \sa thistype#hasRacePreferenceSet
*/
public method setRacePreference takes racepreference preference returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call SetPlayerRacePreference(this.m_players[i], preference)
set i = i + 1
endloop
endmethod
/**
* \return Returns true if all belonging players have race preference \p preference.
* \sa IsPlayerRacePrefSet
* \sa thistype#setRacePreference
* \sa isSetHuman
* \sa isSetOrc
* \sa isSetNightelf
* \sa isSetUndead
* \sa isSetDemon
* \sa isSetRandom
* \sa isSetUserSelectable
*/
public method hasRacePreferenceSet takes racepreference preference returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsPlayerRacePrefSet(this.m_players[i], preference)) then
return false
endif
set i = i + 1
endloop
return true
endmethod
public method isSetHuman takes nothing returns boolean
return this.hasRacePreferenceSet(RACE_PREF_HUMAN)
endmethod
public method isSetOrc takes nothing returns boolean
return this.hasRacePreferenceSet(RACE_PREF_ORC)
endmethod
public method isSetNightelf takes nothing returns boolean
return this.hasRacePreferenceSet(RACE_PREF_NIGHTELF)
endmethod
public method isSetUndead takes nothing returns boolean
return this.hasRacePreferenceSet(RACE_PREF_UNDEAD)
endmethod
public method isSetDemon takes nothing returns boolean
return this.hasRacePreferenceSet(RACE_PREF_DEMON)
endmethod
public method isSetRandom takes nothing returns boolean
return this.hasRacePreferenceSet(RACE_PREF_RANDOM)
endmethod
public method isSetUserSelectable takes nothing returns boolean
return this.hasRacePreferenceSet(RACE_PREF_USER_SELECTABLE)
endmethod
/**
* Sets the name of every player in the force to \p name.
* \sa SetPlayerName
*/
public method setName takes string name returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call SetPlayerName(this.m_players[i], name)
set i = i + 1
endloop
endmethod
/**
* \return Returns true if all players in the force have the name \p name. Otherwise it returns false.
* \sa GetPlayerName
*/
public method hasName takes string name returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (GetPlayerName(this.m_players[i]) != name) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \return Returns true if the whole force is allied to player \p whichPlayer. Otherwise it returns false.
* \sa IsPlayerAlly
*/
public method isAlliedToPlayer takes player whichPlayer returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsPlayerAlly(this.m_players[i], whichPlayer)) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \return Returns true if the whole force is hostile to player \p whichPlayer. Otherwise it returns false.
* \sa IsPlayerEnemy
*/
public method isHostileToPlayer takes player whichPlayer returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsPlayerEnemy(this.m_players[i], whichPlayer)) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa IsPlayerInForce
*/
public method isInForce takes force whichForce returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsPlayerInForce(this.m_players[i], whichForce)) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa IsPlayerObserver
*/
public method isObserver takes nothing returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsPlayerObserver(this.m_players[i])) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa IsVisibleToPlayer
*/
public method isVisibleTo takes real x, real y returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsVisibleToPlayer(x, y, this.m_players[i])) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa IsLocationVisibleToPlayer
*/
public method isLocationVisibleTo takes location whichLocation returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsLocationVisibleToPlayer(whichLocation, this.m_players[i])) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa IsFoggedToPlayer
*/
public method isFoggedTo takes real x, real y returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsFoggedToPlayer(x, y, this.m_players[i])) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa IsLocationFoggedToPlayer
*/
public method isLocationFoggedTo takes location whichLocation returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsLocationFoggedToPlayer(whichLocation, this.m_players[i])) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa IsMaskedToPlayer
*/
public method isMaskedTo takes real x, real y returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsMaskedToPlayer(x, y, this.m_players[i])) then
return false
endif
set i = i + 1
endloop
return false
endmethod
/**
* \sa IsLocationMaskedToPlayer
*/
public method isLocationMaskedTo takes location whichLocation returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsLocationMaskedToPlayer(whichLocation, this.m_players[i])) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \return Returns true all players in the force have the race \p whichRace. Otherwise it returns false.
* \sa GetPlayerRace
*/
public method hasRace takes race whichRace returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (GetPlayerRace(this.m_players[i]) != whichRace) then
return false
endif
set i = i + 1
endloop
return true
endmethod
public method isHuman takes nothing returns boolean
return this.hasRace(RACE_HUMAN)
endmethod
public method isOrc takes nothing returns boolean
return this.hasRace(RACE_ORC)
endmethod
public method isUndead takes nothing returns boolean
return this.hasRace(RACE_UNDEAD)
endmethod
public method isNightelf takes nothing returns boolean
return this.hasRace(RACE_NIGHTELF)
endmethod
public method isDemon takes nothing returns boolean
return this.hasRace(RACE_DEMON)
endmethod
public method isOther takes nothing returns boolean
return this.hasRace(RACE_OTHER)
endmethod
/**
* \return Returns true if all players in the force have the ID \p id. Otherwise it returns false.
* \sa GetPlayerId
*/
public method hasId takes integer id returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (GetPlayerId(this.m_players[i]) != id) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \return Returns the sum of all players unit counts.
* \sa GetPlayerUnitCount
* \sa thistype#unitTypedCount()
* \sa thistype#structureCount()
*/
public method unitCount takes boolean includeIncomplete returns integer
local integer result = 0
local integer i = 0
loop
exitwhen (i == this.m_players.size())
set result = result + GetPlayerUnitCount(this.m_players[i], includeIncomplete)
set i = i + 1
endloop
return result
endmethod
/**
* \return Returns the sum of all players typed unit counts.
* \sa GetPlayerTypedUnitCount
* \sa thistype#unitCount()
* \sa thistype#structureCount()
*/
public method unitTypedCount takes string unitName, boolean includeIncomplete, boolean includeUpgrades returns integer
local integer result = 0
local integer i = 0
loop
exitwhen (i == this.m_players.size())
set result = result + GetPlayerTypedUnitCount(this.m_players[i], unitName, includeIncomplete, includeUpgrades)
set i = i + 1
endloop
return result
endmethod
/**
* \return Returns the sum of all players structure counts.
* \sa GetPlayerStructureCount
* \sa thistype#unitCount()
* \sa thistype#unitTypedCount()
*/
public method structureCount takes boolean includeIncomplete returns integer
local integer result = 0
local integer i = 0
loop
exitwhen (i == this.m_players.size())
set result = result + GetPlayerStructureCount(this.m_players[i], includeIncomplete)
set i = i + 1
endloop
return result
endmethod
/**
* Sets state \p whichPlayerState for all belonging players to \p value.
* \sa SetPlayerState
* \sa thistype#state()
*/
public method setState takes playerstate whichPlayerState, integer value returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call SetPlayerState(this.m_players[i], whichPlayerState, value)
set i = i + 1
endloop
endmethod
/**
* \return Returns the sum of all player state values of state \p whichPlayerState.
* \sa GetPlayerState
* \sa thistype#setState()
*/
public method state takes playerstate whichPlayerState returns integer
local integer result = 0
local integer i = 0
loop
exitwhen (i == this.m_players.size())
set result = result + GetPlayerState(this.m_players[i], whichPlayerState)
set i = i + 1
endloop
return result
endmethod
/**
* \return Returns the sum of all players score of type \p whichPlayerScore.
* \sa GetPlayerScore
*/
public method score takes playerscore whichPlayerScore returns integer
local integer result = 0
local integer i = 0
loop
exitwhen (i == this.m_players.size())
set result = result + GetPlayerScore(this.m_players[i], whichPlayerScore)
set i = i + 1
endloop
return result
endmethod
/**
* \return Only returns true if alliance type \p whichAllianceSetting is true for all belonging players to player \p otherPlayer. Otherwise it returns false.
* \sa GetPlayerAlliance
*/
public method alliance takes player otherPlayer, alliancetype whichAllianceSetting returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not GetPlayerAlliance(this.m_players[i], otherPlayer, whichAllianceSetting)) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa SetPlayerHandicap
*/
public method setHandicap takes real handicap returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call SetPlayerHandicap(this.m_players[i], handicap)
set i = i + 1
endloop
endmethod
/**
* \sa GetPlayerHandicap
*/
public method handicap takes nothing returns real
local real result = 0.0
local integer i = 0
loop
exitwhen (i == this.m_players.size())
set result = result + GetPlayerHandicap(this.m_players[i])
set i = i + 1
endloop
return result
endmethod
/**
* \sa SetPlayerHandicapXP
*/
public method setHandicapXP takes real handicap returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call SetPlayerHandicapXP(this.m_players[i], handicap)
set i = i + 1
endloop
endmethod
/**
* \sa GetPlayerHandicapXP
*/
public method handicapXP takes nothing returns real
local real result = 0.0
local integer i = 0
loop
exitwhen (i == this.m_players.size())
set result = result + GetPlayerHandicapXP(this.m_players[i])
set i = i + 1
endloop
return result
endmethod
/**
* \sa SetPlayerTechMaxAllowed
*/
public method setTechMaxAllowed takes integer techid, integer maximum returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call SetPlayerTechMaxAllowed(this.m_players[i], techid, maximum)
set i = i + 1
endloop
endmethod
/**
* \sa GetPlayerTechMaxAllowed
*/
public method techMaxAllowed takes integer techid returns integer
local integer result = 0
local integer i = 0
loop
exitwhen (i == this.m_players.size())
set result = result + GetPlayerTechMaxAllowed(this.m_players[i], techid)
set i = i + 1
endloop
return result
endmethod
/**
* \sa AddPlayerTechResearched
*/
public method addTechResearched takes integer techid, integer levels returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call AddPlayerTechResearched(this.m_players[i], techid, levels)
set i = i + 1
endloop
endmethod
/**
* \sa SetPlayerTechResearched
*/
public method setTechResearched takes integer techid, integer setToLevel returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call SetPlayerTechResearched(this.m_players[i], techid, setToLevel)
set i = i + 1
endloop
endmethod
/**
* \sa GetPlayerTechResearched
*/
public method techResearched takes integer techid, boolean specificonly returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not GetPlayerTechResearched(this.m_players[i], techid, specificonly)) then
return false
endif
set i = i + 1
endloop
return true
endmethod
/**
* \sa GetPlayerTechCount
*/
public method techCount takes integer techid, boolean specificonly returns integer
local integer result = 0
local integer i = 0
loop
exitwhen (i == this.m_players.size())
set result = result + GetPlayerTechCount(this.m_players[i], techid, specificonly)
set i = i + 1
endloop
return result
endmethod
/**
* \sa SetPlayerUnitsOwner
*/
public method setUnitsOwner takes integer newOwner returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call SetPlayerUnitsOwner(this.m_players[i], newOwner)
set i = i + 1
endloop
endmethod
/**
* \sa CripplePlayer
*/
public method cripple takes force toWhichPlayers, boolean flag returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call CripplePlayer(this.m_players[i], toWhichPlayers, flag)
set i = i + 1
endloop
endmethod
/**
* \sa SetPlayerAbilityAvailable
*/
public method setAbilityAvailable takes integer abilityId, boolean available returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
call SetPlayerAbilityAvailable(this.m_players[i], abilityId, available)
set i = i + 1
endloop
endmethod
public method hasUnitsOfPlayer takes player whichPlayer returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (this.m_players[i] == whichPlayer) then
return true
endif
set i = i + 1
endloop
return false
endmethod
public method removeUnitsOfPlayer takes player whichPlayer returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (this.m_players[i] == whichPlayer) then
call this.m_players.erase(i)
else
set i = i + 1
endif
endloop
endmethod
public method hasAlliesOfPlayer takes player whichPlayer returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (IsPlayerAlly(this.m_players[i], whichPlayer)) then
return true
endif
set i = i + 1
endloop
return false
endmethod
public method hasAlliesOfUnit takes unit whichUnit returns boolean
local player owner = GetOwningPlayer(whichUnit)
local boolean result = this.hasAlliesOfPlayer(owner)
set owner = null
return result
endmethod
public method removeAlliesOfPlayer takes player whichPlayer returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (IsPlayerAlly(this.m_players[i], whichPlayer)) then
call this.m_players.erase(i)
else
set i = i + 1
endif
endloop
endmethod
public method removeAlliesOfUnit takes unit whichUnit returns nothing
local player owner = GetOwningPlayer(whichUnit)
call this.removeAlliesOfPlayer(owner)
set owner = null
endmethod
public method hasEnemiesOfPlayer takes player whichPlayer returns boolean
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsPlayerAlly(this.m_players[i], whichPlayer)) then
return true
endif
set i = i + 1
endloop
return false
endmethod
public method hasEnemiesOfUnit takes unit whichUnit returns boolean
local player owner = GetOwningPlayer(whichUnit)
local boolean result = this.hasEnemiesOfPlayer(owner)
set owner = null
return result
endmethod
public method removeEnemiesOfPlayer takes player whichPlayer returns nothing
local integer i = 0
loop
exitwhen (i == this.m_players.size())
if (not IsPlayerAlly(this.m_players[i], whichPlayer)) then
call this.m_players.erase(i)
else
set i = i + 1
endif
endloop
endmethod
public method removeEnemiesOfUnit takes unit whichUnit returns nothing
local player owner = GetOwningPlayer(whichUnit)
call this.removeEnemiesOfPlayer(owner)
set owner = null
endmethod
public static method create takes nothing returns thistype
local thistype this = thistype.allocate()
// members
set this.m_players = APlayerVector.create()
return this
endmethod
public static method createWithForce takes force whichForce, boolean destroy, boolean clear returns thistype
local thistype this = thistype.create()
call this.addForce(whichForce, destroy, clear)
return this
endmethod
public static method createWithAll takes nothing returns thistype
local thistype this = thistype.allocate()
local integer i = 0
// members
set this.m_players = APlayerVector.createWithSize(bj_MAX_PLAYERS, null)
loop
exitwhen (i == bj_MAX_PLAYERS)
set this.m_players[i] = Player(i)
set i = i + 1
endloop
return this
endmethod
public static method createWithPlayer takes player whichPlayer returns thistype
local thistype this = thistype.allocate()
// members
set this.m_players = APlayerVector.createWithSize(1, whichPlayer)
return this
endmethod
public method onDestroy takes nothing returns nothing
// members
call this.m_players.destroy()
endmethod
endstruct
endlibrary