-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_ide_helper.php
More file actions
3296 lines (2952 loc) · 116 KB
/
Copy path_ide_helper.php
File metadata and controls
3296 lines (2952 loc) · 116 KB
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
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/** @noinspection PhpDocRedundantThrowsInspection */
/** @noinspection PhpInconsistentReturnPointsInspection */
/** @noinspection PhpUnreachableStatementInspection */
namespace Bga\GameFramework\Actions {
#[\Attribute]
class CheckAction {
public function __construct(
public bool $enabled = true,
) {}
}
#[\Attribute]
class Debug {
public function __construct(
public bool $reload = false,
) {}
}
}
namespace Bga\GameFramework\Actions\Types {
#[\Attribute]
class IntParam {
public function __construct(
?string $name = null,
public ?int $min = null,
public ?int $max = null,
) {}
public function getValue(string $paramName): int { return 0; }
}
#[\Attribute]
class BoolParam {
public function __construct(
?string $name = null,
) {}
public function getValue(string $paramName): bool { return false; }
}
#[\Attribute]
class FloatParam {
public function __construct(
?string $name = null,
public ?float $min = null,
public ?float $max = null,
) {}
public function getValue(string $paramName): float { return 0; }
}
#[\Attribute]
class IntArrayParam {
public function __construct(
?string $name = null,
public ?int $min = null,
public ?int $max = null,
) {}
public function getValue(string $paramName): array { return []; }
}
#[\Attribute]
class StringParam {
public function __construct(
?string $name = null,
public ?bool $alphanum = false,
public ?bool $alphanum_dash = false,
public ?bool $base64 = false,
public ?array $enum = null,
) {}
public function getValue(string $paramName): string { return ''; }
}
#[\Attribute]
class JsonParam {
public function __construct(
?string $name = null,
public ?bool $associative = true,
public ?bool $alphanum = true,
public ?string $class = null,
) {}
public function getValue(string $paramName): mixed { return []; }
}
}
namespace Bga\GameFramework\States {
#[\Attribute]
class PossibleAction {}
abstract class GameState
{
public \Bga\GameFramework\Bga $bga;
public \Bga\GameFramework\Db\Globals $globals;
public \Bga\GameFramework\Notify $notify;
public \Bga\GameFramework\Legacy $legacy;
public \Bga\GameFramework\TableOptions $tableOptions;
public \Bga\GameFramework\UserPreferences $userPreferences;
public \Bga\GameFramework\TableStats $tableStats;
public \Bga\GameFramework\PlayerStats $playerStats;
public \Bga\GameFramework\Components\DeckFactory $deckFactory;
public \Bga\GameFramework\Components\Counters\CounterFactory $counterFactory;
public \Bga\GameFramework\Components\Counters\PlayerCounter $playerScore;
public \Bga\GameFramework\Components\Counters\PlayerCounter $playerScoreAux;
public ?\Bga\GameFramework\GameStateMachine $gamestate = null;
/**
* @param int|class-string<\Bga\GameFramework\States\GameState>|null $initialPrivate
*/
public function __construct(
/*protected*/ \Bga\GameFramework\Table $game,
public int $id,
public \Bga\GameFramework\StateType $type,
public ?string $name = null,
public string $description = '',
public string $descriptionMyTurn = '',
public array $transitions = [],
public bool $updateGameProgression = false,
public int|string|null $initialPrivate = null,
) {
}
/**
* Returns a random choice from an array of possible choices, for Zombie Mode level 1.
*
* @param array $choices an of $choiceKey
* @return mixed a random $choiceKey
*/
public function getRandomZombieChoice(array $choices): mixed {
return null;
}
/**
* Returns a random top choice from an array of possible choices, for Zombie Mode level 2
*
* @param array $choices an associative array of $choiceKey => $associatedPoints.
* @param bool $reversed if the least points would be the best answer, instead of the top points
* @return mixed the best $choiceKey
*/
public function getBestZombieChoice(array $choices, bool $reversed = false): mixed {
return null;
}
}
}
namespace Bga\GameFramework {
enum StateType: string
{
case ACTIVE_PLAYER = 'activeplayer';
case MULTIPLE_ACTIVE_PLAYER = 'multipleactiveplayer';
case PRIVATE = 'private';
case GAME = 'game';
case MANAGER = 'manager';
}
/**
* A builder for game states.
* To be called with `[game state id] => GameStateBuilder::create()->...[set all necessary properties]->build()`
* in the states.inc.php file.
*/
final class GameStateBuilder
{
/**
* Create a new GameStateBuilder.
*/
public static function create(): self
{
return new self();
}
/**
* Return the game setup state (should have id 1).
* To be called with `[game state id] => GameStateBuilder::gameSetup(10)->build()` if your first game state is 10.
* If not set in the $machinestates array, it will be automatically created with a transition to state 2.
*
* @param int|class-string<\Bga\GameFramework\States\GameState> $nextStateId the first real game state, just after the setup (default 2).
*/
public static function gameSetup(int|string $nextStateId = 2): self
{
return self::create();
}
/**
* Return the game end score state (usually, id 98).
* This is a common state used for end game scores & stats computation.
* If the game dev uses it, they must define the function `stEndScore` with a call to `$this->gamestate->nextState();` at the end.
*/
public static function endScore(): self
{
return self::create();
}
/**
* Return the game end state (should have id 99).
* If not set in the $machinestates array, it will be automatically created.
*/
public static function gameEnd(): self
{
return self::create();
}
/**
* The name of the state.
*/
public function name(string $name): self
{
return $this;
}
/**
* The type of the state. MANAGER should not be used, except for setup and end game states.
*/
public function type(StateType $type): self
{
return $this;
}
/**
* The description for inactive players. Should be `clienttranslate('...')` if not empty.
*/
public function description(string $description): self
{
return $this;
}
/**
* The description for active players. Should be `clienttranslate('...')` if not empty.
*/
public function descriptionMyTurn(string $descriptionMyTurn): self
{
return $this;
}
/**
* The PHP function to call when entering the state.
* Usually prefixed by `st`.
*/
public function action(string $action): self
{
return $this;
}
/**
* The PHP function returning the arguments to send to the front when entering the state.
* Usually prefixed by `arg`.
*/
public function args(string $args): self
{
return $this;
}
/**
* The list of possible actions in the state.
* Usually prefixed by `act`.
*/
public function possibleActions(array $possibleActions): self
{
return $this;
}
/**
* The list of transitions to other states. The key is the transition name and the value is the state to transition to.
* Example: `['endTurn' => ST_END_TURN]`.
*/
public function transitions(array $transitions): self
{
return $this;
}
/**
* Set to true if the game progression has changed (to be recalculated with `getGameProgression`)
*/
public function updateGameProgression(bool $update): self
{
return $this;
}
/**
* For multi active states with inner private states, the initial state to go to.
*/
public function initialPrivate(int $initial): self
{
return $this;
}
/**
* Export the built GameState.
*/
public function build(): GameState
{
return new class extends GameState{}();
}
}
/**
* Object to regroup all framework subobjects.
*/
abstract class Bga {
public Db\Globals $globals;
public Notify $notify;
public Logs $logs;
public Legacy $legacy;
public Tournament $tournament;
public TableOptions $tableOptions;
public UserPreferences $userPreferences;
public TableStats $tableStats;
public PlayerStats $playerStats;
public Components\DeckFactory $deckFactory;
public Components\Counters\CounterFactory $counterFactory;
public Debug $debug;
public Components\Counters\PlayerCounter $playerScore;
public Components\Counters\PlayerCounter $playerScoreAux;
}
abstract class Notify {
/**
* Add a decorator function, to be applied on args when a notif function is called.
*
* @param callable $fn The decorator function. Expected signature: `function(string $message, array $args): array`
* @return void
*/
public function addDecorator(callable $fn): void {
//
}
/**
* Tell if notification targets will be player no (true) or player id (false).
*/
public function setUseNo(bool $useNo): void {
//
}
/**
* Send a notification to a single player of the game.
*
* @param int $playerIdOrNo the player ID (or no if useNo: true) to send the notification to.
* @param string $notifName a comprehensive string code that explain what is the notification for.
* @param (string | NotificationMessage) $message some text that can be displayed on player's log window (should be surrounded by clienttranslate if not empty).
* @param array $args notification arguments.
*/
public function player(int $playerIdOrNo, string $notifName, string | NotificationMessage $message = '', array $args = []): void {
//
}
/**
* Send a notification to all players of the game and spectators (public).
*
* @param string $notifName a comprehensive string code that explain what is the notification for.
* @param (string | NotificationMessage) $message some text that can be displayed on player's log window (should be surrounded by clienttranslate if not empty).
* @param array $args notification arguments.
*/
public function all(string $notifName, string | NotificationMessage $message = '', array $args = []): void {
//
}
/**
* If called, all _private informations sent to the front will be merged to the args (if not called, they will stay into args._private).
* If you want to only merge some _private, add `_merge_private => true` to the relevant args instead.
*/
public function alwaysMergePrivate(): void {}
}
abstract class Logs {
/**
* Returns the current move id, when doing an action, that should be stored along informations to undo.
*
* @return int the current move id
*/
function getCurrentMoveId(): int {
return 0;
}
/**
* Remove all logs from a move id that was stored during an action using `getCurrentMoveId()`.
* The game should be in the exact same point as it was before the stored action.
*/
function remove(int $startMoveId): void {
}
}
abstract class Legacy {
/**
* Get data associated with $key for the current game.
*
* This data is common to ALL tables from the same game for this player, and persist from one table to another.
*
* Note: calling this function has an important cost => please call it few times (possibly: only ONCE) for each player for 1 game if possible
*
* @param string $key the key of the legacy data to get
* @param int $playerId the player id (or 0 for data shared on all tables)
* @param mixed $defaultValue the value to return if the key doesn't exist in the legacy data for this player
*/
public function get(string $key, int $playerId, mixed $defaultValue = null): mixed {
return null;
}
/**
* Store some data associated with $key for the given user / current game
* In the opposite of all other game data, this data will PERSIST after the end of this table, and can be re-used in a future table with the same game.
*
* ⚠️ The only possible place where you can use this method is when the game is over at your table (last game action). Otherwise, there is a risk of conflicts between ongoing games.
*
* In any way, the total data (= all keys) you can store for a given user+game is 64k
*
* NOTICE: You can store some persistant data across all tables from your game using the specific player_id 0 which is unused. In such case, it's even more important to manage correctly the size of your data to avoid any exception or issue while storing updated data (ie. you can use this for some kind of leaderbord for solo game or contest)
*
*
* @param string $key the key of the legacy data to save
* @param int $playerId the player id (or 0 for data shared on all tables)
* @param mixed $value the value to save as the legacy data for this player
* @param int $ttl time-to-live: the maximum, and default, is 365 days.
*/
public function set(string $key, int $playerId, mixed $value, int $ttl = 365): void {
}
/**
* Remove some legacy data with the given key
*
* @param string $key the key of the legacy data to remove
* @param int $playerId the player id (or 0 for data shared on all tables)
*/
public function delete(string $key, int $playerId): void {
}
/**
* Get data associated with the team for the current game.
*
* This data is common to ALL tables from the same game for this team, and persist from one table to another.
*
* Note: calling this function has an important cost => please call it few times (possibly: only ONCE) for 1 game if possible
*
* @param mixed $defaultValue the value to return if the legacy data doesn't exist or is null for this team
*/
public function getTeam(mixed $defaultValue = null): mixed {
return null;
}
/**
* Store some data associated to the team of the current table (all players at the table) / current game
* In the opposite of all other game data, this data will PERSIST after the end of this table, and can be re-used in a future table with the same game.
*
* ⚠️ The only possible place where you can use this method is when the game is over at your table (last game action). Otherwise, there is a risk of conflicts between ongoing games.
*
* In any way, the total data you can store for a given team+game is 64k
*
* @param mixed $value the value to save as the legacy data for this team
* @param int $ttl time-to-live: the maximum, and default, is 365 days.
*/
public function setTeam(mixed $value, int $ttl = 365): void {
}
/**
* Remove the legacy data for a team
*/
public function deleteTeam(): void {
}
}
abstract class Tournament
{
/**
* Returns true if this table is a tournament encounter.
*/
public function isTournament(): bool
{
return false;
}
/**
* Retrieve tournament seeds for deterministic randomness.
*
* Returns an empty array when the table is not part of a tournament.
*
* Note: `parent_tournament` refer to the main tournament of Groups Stage tournaments (tournaments of either of the two stages, will reference the same "parent")
*
* @return array{
* tournament_seed?: int,
* step_seed?: int,
* parent_tournament_seed?: int
* }
*/
public function getSeedInfo(): array
{
return [];
}
/**
* Store player game data associated with the given key for a tournament (of which the table must be a part of).
*
* The cumulative size of the data you can store for a given player for a tournament is 64 KiB.
*
* Note: As with every game framework API that interacts with the BGA mainsite, please use it thoughtfully.
*
* @param int $playerId
* @param string $key
* @param mixed $data
*/
public function storePlayerGameData(int $playerId, string $key, mixed $data): void
{
//
}
/**
* Get player game data associated with the given key for a tournament.
*
* You can use '%' in the key to retrieve multiple values at once matching a pattern.
*
* If '%' is used the return value will be an array of key-value pairs (or [], if no match is found).
* Otherwise, a single value is returned (or null, if no match is found).
*
* Returned values are decoded from JSON.
*
* @param int $playerId
* @param string $key
*
* @return null|string|array<string,string>
*/
public function retrievePlayerGameData(int $playerId, string $key): null|string|array
{
return null;
}
/**
* Remove player game data associated with the given key for a tournament.
*
* In any case, all data related to a tournament is removed when the tournament is finished.
*
* @param int $playerId
* @param string $key
*/
public function removePlayerGameData(int $playerId, string $key): void
{
//
}
}
abstract class TableOptions {
/**
* Get the value of a table option.
*
* @param int $optionId the option id as in the gameoptions.json file
* @return int|null the option value, or null if the option doesn't exist (for example on a table created before a new option was added).
*/
public function get(int $optionId): ?int {
return 0;
}
/**
* Indicates if the table is Turn-based.
*
* @return bool if the table is Turn-based.
*/
function isTurnBased(): bool {
return false;
}
/**
* Indicates if the table is Real-time.
*
* @return bool if the table is Real-time.
*/
function isRealTime(): bool {
return false;
}
}
abstract class UserPreferences {
/**
* Gets the value of a user preference for a player (cached in game DB).
*
* @param int $playerId the player id
* @param int $prefId the preference id, as described in the gamepreferences.json file
* @return int|null the user preference value, or null if unset
*/
function get(int $playerId, int $prefId): ?int
{
return null;
}
}
abstract class TableStats {
/**
* Create a statistic entry with a default value.
*
* @param string|array $nameOrNames Statistic identifier(s) defined in `stats.json`.
* @param int|float|bool $value Default value to register.
*/
public function init(string|array $nameOrNames, int|float|bool $value): void {
}
/**
* Update a table statistic to the provided value.
*
* @param string $name Statistic identifier defined in `stats.json`.
* @param int|float|bool $value Value to persist.
*/
public function set(string $name, int|float|bool $value): void {
}
/**
* Increment a table statistic by the given delta.
*
* @param string $name Statistic identifier defined in `stats.json`.
* @param int|float $delta Signed difference to apply.
*/
public function inc(string $name, int|float $delta): void {
}
/**
* Fetch a table statistic.
*
* @param string $name Statistic identifier defined in `stats.json`.
*
* @return int|float|bool The statistic value.
*/
public function get(string $name): int|float|bool {
return 0;
}
}
abstract class PlayerStats {
/**
* Create a statistic entry with a default value.
*
* @param string|array $nameOrNames Statistic identifier(s) defined in `stats.json`.
* @param int|float|bool $value Default value to register.
* @param bool $updateTableStat if there is a table stat of the same name to init at the same time (for example, for a turnNumber counter that would store the turns played by each player but also the total of turns for the table)
*/
public function init(string|array $nameOrNames, int|float|bool $value, bool $updateTableStat = false): void {
}
/**
* Update a player statistic to the provided value.
*
* @param string $name Statistic identifier defined in `stats.json`.
* @param int|float|bool $value Value to persist.
* @param int $player_id Target player id.
*/
public function set(string $name, int|float|bool $value, int $player_id): void {
}
/**
* Apply the same value to a player statistic for every player.
*
* @param string $name Statistic identifier defined in `stats.json`.
* @param int|float|bool $value Value to persist for all players.
*/
public function setAll(string $name, int|float|bool $value): void {
}
/**
* Increment a player statistic by the given delta.
*
* @param string $name Statistic identifier defined in `stats.json`.
* @param int|float $delta Signed difference to apply.
* @param int $player_id Target player id.
* @param bool $updateTableStat if there is a table stat of the same name to update at the same time (for example, for a turnNumber counter that would store the turns played by each player but also the total of turns for the table)
*/
public function inc(string $name, int|float $delta, int $player_id, bool $updateTableStat = false): void {
}
/**
* Increment a statistic for every player.
*
* @param string $name Statistic identifier defined in `stats.json`.
* @param int|float $delta Signed difference to apply.
*/
public function incAll(string $name, int|float $delta): void {
}
/**
* Fetch a player statistic.
*
* @param string $name Statistic identifier defined in `stats.json`.
* @param int $player_id Target player id.
*
* @return int|float|bool The statistic value.
*/
public function get(string $name, int $player_id): int|float|bool {
return 0;
}
/**
* Retrieve the statistic for all players, keyed by player id.
*
* @param string $name Statistic identifier defined in `stats.json`.
*
* @return array<int, int|float|bool> Player id keyed map of the statistic values.
*/
public function getAll(string $name): array {
return [];
}
}
abstract class GameState
{
public ?string $name = null;
public ?StateType $type = null;
public ?string $description = '';
public ?string $descriptionMyTurn = '';
public ?string $action = null;
public ?string $args = null;
public ?array $possibleActions = null;
public ?array $transitions = null;
public ?bool $updateGameProgression = false;
public ?int $initialPrivate = null;
public function toArray(): array
{
return [];
}
}
abstract class GamestateMachine
{
/**
* You can call this method to make any player active.
*
* NOTE: you must transition to a state in the action triggering this call, so the change of active player is notified to the front.
*
* @param int $playerId the new active player.
*/
final public function changeActivePlayer(int $playerId): void
{
//
}
/**
* This works exactly like `Table::checkAction()`, except that it does NOT check if the current player is
* active.
*
* @param string $action_name the current state information
*/
final public function checkPossibleAction(string $action_name): void
{
//
}
/**
* With this method you can retrieve the list of the active player at any time.
*
* - During a "game" type game state, it will return a void array.
* - During an "activeplayer" type game state, it will return an array with one value (the active player id).
* - During a "multipleactiveplayer" type game state, it will return an array of the active players' id.
*
* NOTE: You should only use this method in the latter case.
*
* @return string[] The list of active players (ids typed as strings).
*/
final public function getActivePlayerList(): array
{
return [];
}
/**
* This return the private state or null if not initialized or not in private state.
*
* @deprecated use getCurrentState($playerId)
*
* @param int $playerId the current player id
* @return array the current private state for the player as an array
*/
final public function getPrivateState(int $playerId): array
{
return [];
}
/**
* Player with the specified id is entering a first private state defined in the master state initial private
* parameter.
*
* Everytime you need to start a private parallel states you need to call this or similar methods above
*
* - Note: player needs to be active (see above) and current game state must be a multiactive state with initial
* private parameter defined
* - Note: initial private parameter of master state should be set to the id of the first private state. This
* private state needs to be defined in states.php with the type set to 'private'.
* - Note: this method is usually preceded with activating that player
* - Note: initializing private state can run action or args methods of the initial private state
*
* @param int $playerId
*/
final public function initializePrivateState(int $playerId): void
{
//
}
/**
* All active players in a multiactive state are entering a first private state defined in the master state's
* initialprivate parameter.
*
* Every time you need to start a private parallel states you need to call this or similar methods below.
*
* - Note: at least one player needs to be active (see above) and current game state must be a multiactive state
* with initialprivate parameter defined
* - Note: initialprivate parameter of master state should be set to the id of the first private state. This
* private state needs to be defined in states.php with the type set to 'private'.
* - Note: this method is usually preceded with activating some or all players
* - Note: initializing private state can run action or args methods of the initial private state
*/
final public function initializePrivateStateForAllActivePlayers(): void
{
//
}
/**
* Players with specified ids are entering a first private state defined in the master state initialprivate
* parameter.
*
* @param array<int> $playerIds
*/
final public function initializePrivateStateForPlayers(array $playerIds): void
{
//
}
/**
* Return true if we are in multipleactiveplayer state, false otherwise.
*
* @deprecated use isMultiactiveState
*/
final public function isMutiactiveState(): bool
{
return false;
}
/**
* Return true if we are in multipleactiveplayer state, false otherwise.
*
* @return bool if the main state is MULTIPLE_ACTIVE_PLAYER.
*/
final public function isMultiactiveState(): bool
{
return false;
}
/**
* Return true if specified player is active right now.
*
* This method take into account game state type, ie nobody is active if game state is "game" and several
* players can be active if game state is "multiplayer".
*
* @param int $player_id the player id
* @return bool if this player is active.
*/
final public function isPlayerActive(int $player_id): bool
{
return false;
}
/**
* Change current state to a new state. ⚠️ the $nextState parameter is the key of the state, not the state name.
*
* NOTE: This is very advanced method, it should not be used in normal cases. Specific advanced cases
* include - jumping to specific state from "do_anytime" actions, jumping to dispatcher state or jumping to
* recovery state from zombie player function.
*
* @param int|class-string<\Bga\GameFramework\States\GameState> $next_state the state id, or class name if using Class states
*/
final public function jumpToState(int|string $next_state): void
{
//
}
/**
* Player with specified id will transition to next private state specified by provided transition.
*
* - Note: game needs to be in a master state which allows private parallel states
* - Note: transition should lead to another private state (i.e. a state with type defined as 'private'
* - Note: transition should be defined in private state in which the players currently are.
* - Note: this method can run action or args methods of the target state for specified player
* - Note: this is usually used after some player actions to move to next private state
*
* @param int $playerId the player id
* @param string|int|class-string<\Bga\GameFramework\States\GameState> $transition the transition name, or state id, or class name if using Class states
*/
final public function nextPrivateState(int $playerId, int|string $transition): void
{
//
}
/**
* All active players will transition to next private state by specified transition.
*
* - Note: game needs to be in a master state which allows private parallel states
* - Note: transition should lead to another private state (i.e. a state with type defined as 'private'
* - Note: transition should be defined in private state in which the players currently are.
* - Note: this method can run action or args methods of the target state
* - Note: this is usually used after initializing the private state to move players to specific private state
* according to the game logic
*
* @param string|int|class-string<\Bga\GameFramework\States\GameState> $transition the transition name, or state id, or class name if using Class states
*/
final public function nextPrivateStateForAllActivePlayers(int|string $transition): void
{
//
}
/**
* Players with specified ids will transition to next private state specified by provided transition.
* Same considerations apply as for the method above.
*
*
* @param array<int> $playerIds the player ids to transition
* @param string|int|class-string<\Bga\GameFramework\States\GameState> $transition the transition name, or state id, or class name if using Class states
*/
final public function nextPrivateStateForPlayers(array $playerIds, int|string $transition): void
{
//
}
/**
* Change current state to a new state.
*
* NOTE: the `$transition` parameter is the name of the transition, and NOT the name of the target game state.
*
* @see states.inc.php
*
* @param string $transition the transition name
*/
final public function nextState(string $transition = ''): void
{
//
}
/**
* Reload the current state.
*
* @return array the result of gamstate->state()
*/
final public function reloadState(): array
{
return [];
}
/**
* All playing players are made active. Update notification is sent to all players (this will trigger
* `onUpdateActionButtons`).
*
* Usually, you use this method at the beginning of a game state (e.g., `stGameState`) which transitions to a
* `multipleactiveplayer` state in which multiple players have to perform some action. Do not use this method if
* you're going to make some more changes in the active player list. (I.e., if you want to take away
* `multipleactiveplayer` status immediately afterward, use `setPlayersMultiactive` instead).
*/
final public function setAllPlayersMultiactive(): void
{
//
}
/**
* All playing players are made inactive. Transition to next state.
*
* @param string|int|class-string<\Bga\GameFramework\States\GameState> $next_state the transition name, or state id, or class name if using Class states
*/
final public function setAllPlayersNonMultiactive(string $next_state): bool
{
return false;
}
/**
* During a multi-active game state, make the specified player inactive.
*
* Usually, you call this method during a multi-active game state after a player did his action. It is also
* possible to call it directly from multiplayer action handler. If this player was the last active player, the
* method trigger the "next_state" transition to go to the next game state.
*
* @param int $player the player to make inactive
* @param string|int|class-string<\Bga\GameFramework\States\GameState>|callable $nextState the transition name, or state id, or class name if using Class states
* @return bool if the call moved to the next state
*/
final public function setPlayerNonMultiactive(int $player, int|string|callable $nextState): bool
{
return false;
}
/**
* Make a specific list of players active during a multiactive game state. Update notification is sent to all
* players whose state changed.
*
* - "players" is the array of player id that should be made active. If "players" is not empty the value of
* "next_state" will be ignored (you can put whatever you want).
* - If "bExclusive" parameter is not set or false it doesn't deactivate other previously active players. If
* it's set to true, the players who will be multiactive at the end are only these in "$players" array.
* - In case "players" is empty, the method trigger the "next_state" transition to go to the next game state.
*
* @param int[] $players the players to activate
* @param string|int|class-string<\Bga\GameFramework\States\GameState>|callable $nextState the transition name, or state id, or class name if using Class states