Commit b2f5160
* refactor: Move `activePlayers` reset logic to reuseable function
This moves the logic that resets an empty `activePlayers` to next,
previous or `null` values into `UpdateActivePlayers`, so that it can be
called from an `EndStage` event and not just inside `ProcessMove`.
* feat: Add `startStage` and `endStage` events
* test: Fix failing tests with new events
* test: Write basic tests for `setStage` and `endStage`
* feat: Add hypothetical move limit logic
If `arg.moveLimit` could reach `UpdateStage` this logic would update
`ctx` appropriately.
* test: Add failing test for move limit with `setStage`
* feat: Bail out of `UpdateStage` early if `arg` is undefined
* feat: Allow `setStage` event to receive object argument
Supports `moveLimit` with an object argument: `setStage({ stage,
moveLimit })`
* test: Update `setStage` move limit test with object syntax
* test: Add test for `setStage` object syntax without move limit
* test: Test how `setStage` & `endStage` mutate `_activePlayersNumMoves`
* test: Add test for `endStage` with more than one currently active player
* refactor: Use `EndStage` to simplify `ProcessMove`
Allow a `playerID` to be passed to `EndStage` and `UpdateStage` so they
can be used to end/update any player in `activePlayers`. They default to
`ctx.currentPlayer` when called from the client, which could need
changing once any active player can call events.
* test: Increase `setStage`/`endStage` coverage
* refactor: Rename `UpdateActivePlayers` to `UpdateActivePlayersOnceEmpty`
* refactor: Don’t call no-op `UpdateStage` when `arg` is undefined
* group event defaults
* remove redundant statement
1 parent 53eb648 commit b2f5160
4 files changed
Lines changed: 308 additions & 55 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
338 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
339 | 344 | | |
340 | 345 | | |
341 | 346 | | |
| |||
355 | 360 | | |
356 | 361 | | |
357 | 362 | | |
| 363 | + | |
| 364 | + | |
358 | 365 | | |
359 | 366 | | |
360 | 367 | | |
| |||
367 | 374 | | |
368 | 375 | | |
369 | 376 | | |
| 377 | + | |
370 | 378 | | |
371 | 379 | | |
372 | 380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
211 | 216 | | |
212 | 217 | | |
213 | | - | |
214 | | - | |
215 | 218 | | |
216 | 219 | | |
217 | 220 | | |
| |||
498 | 501 | | |
499 | 502 | | |
500 | 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 | + | |
501 | 541 | | |
502 | 542 | | |
503 | 543 | | |
| |||
631 | 671 | | |
632 | 672 | | |
633 | 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 | + | |
634 | 731 | | |
635 | 732 | | |
636 | 733 | | |
| |||
683 | 780 | | |
684 | 781 | | |
685 | 782 | | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
| 783 | + | |
692 | 784 | | |
693 | 785 | | |
694 | 786 | | |
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 | | - | |
| 787 | + | |
737 | 788 | | |
738 | 789 | | |
739 | 790 | | |
| |||
744 | 795 | | |
745 | 796 | | |
746 | 797 | | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | 798 | | |
| 799 | + | |
752 | 800 | | |
753 | 801 | | |
754 | 802 | | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
755 | 810 | | |
756 | 811 | | |
757 | 812 | | |
| |||
772 | 827 | | |
773 | 828 | | |
774 | 829 | | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
775 | 838 | | |
776 | 839 | | |
777 | 840 | | |
| |||
802 | 865 | | |
803 | 866 | | |
804 | 867 | | |
| 868 | + | |
| 869 | + | |
805 | 870 | | |
806 | 871 | | |
807 | 872 | | |
| |||
823 | 888 | | |
824 | 889 | | |
825 | 890 | | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
826 | 895 | | |
827 | 896 | | |
828 | 897 | | |
| |||
0 commit comments