Skip to content

Add Startup GKC for when a player joins, retires, or changes sides V2#13904

Open
rlament wants to merge 2 commits into
vassalengine:masterfrom
rlament:13903-PlayerJoinGkc
Open

Add Startup GKC for when a player joins, retires, or changes sides V2#13904
rlament wants to merge 2 commits into
vassalengine:masterfrom
rlament:13903-PlayerJoinGkc

Conversation

@rlament

@rlament rlament commented Mar 19, 2025

Copy link
Copy Markdown
Contributor

This is different from the existing Startup GKC in that it does not fire on start of fresh game. This GKC fires as players join at startup via the wizard and anytime during the game when any player(s) retires, joins or changes side. Closes #13903

I neglected to add a reference to the original PR for Startup GKC on fresh game or player join/retire #11918

This is different from the existing GKC in that it does not fire
on start of fresh game.
Includes modifications to both code and documentation.
@riverwanderer riverwanderer added the enhancement New feature or request label Aug 11, 2025
@riverwanderer riverwanderer added this to the 3.8.0 milestone Aug 11, 2025
@riverwanderer riverwanderer added the Ready for Review Ready to be reviewed for Merging label Aug 11, 2025
@Cattlesquat

Copy link
Copy Markdown
Collaborator

Does this seem to work when you test it in multiplayer and in log-based play? I don't see the part that makes sure that it gets called if someone joins mid-stream - or maybe that already existed, I can't remember? The PR itself seems simple enough I just recommend testing all the edge cases, to make sure it gives timely notifs:
(1) At beginning of the game (does it send one GKC per player? Does it correctly do this AFTER sending any for the game itself being started?)
(2) When someone joins in multiplayer is it sending the GKC?
(3) When someone is added into a log-based game is it sending the GKC?
(4) And one different type of question -- do you really WANT the GKC when someone joins as "observer", and/or is there a way to detect those and ignore them if module wants to?

Add a sideChange listener to the startup GKC commands.
The listener saves state for the apply action.
@rlament

rlament commented Sep 3, 2025

Copy link
Copy Markdown
Contributor Author

Good points. I had to rework things particularly for point 3.

Does this seem to work when you test it in multiplayer and in log-based play?

Yes, I tested both scenarios. I created a test module that reports on all 5 Startup GKCs. Tested modules with and without sides. When there are no sides, this Startup GKC never fires. The latest change adds a fireSideChange event to the finish step of the wizard. I looked at all the listeners and didn't spot any nasty side effects.

(1) At beginning of the game (does it send one GKC per player? Does it correctly do this AFTER sending any for the game itself being started?)

Yes, one GKC per player at the beginning. It can be before or after any other startup GKC. That depends on the relative placement within the module editor. Startup GKCs are fired in order from top down, when the corresponding condition is satisfied.

(2) When someone joins in multiplayer is it sending the GKC?

Yes

(3) When someone is added into a log-based game is it sending the GKC?

Yes, it sends the GKC and logs it if logging is active.

(4) And one different type of question -- do you really WANT the GKC when someone joins as "observer"...

This GKC is modelled after APPLY_START_GAME_OR_SIDE_CHANGE. The exception being one GKC per player at start instead of just one GKC for just the first player (or game start). This GKC works the same as APPLY_START_GAME_OR_SIDE_CHANGE which also reports switching to "observer". A module can check {PlayerSide} to ignore specific "sides". Although upon testing, sometimes it would be nice to know the side from which the player left {PreviousSide?}. Perhaps a TBD?

@riverwanderer

Copy link
Copy Markdown
Collaborator

Absent this feature, a technique that I use is to wrap the built-in Retire component's hotkey in an Action button. i.e. the Retire component's button is assigned a null image and is replaced by the Action button.

Here is a simple example where "RETIRE" is hotkey for the built-in retire or join prompt:
image

validSideSwitch in this example is a feature to ensure that valid side is selected. It would be determined within the POST_JOIN_OR_RETIRE action.

hideHand is simply closing open window(s), if any.

To ensure that the Startup player is covered, I call POST_JOIN_OR_RETIRE from a Startup GKC.

@rlament is this different from the new feature that you are developing here ?

@rlament

rlament commented Sep 4, 2025

Copy link
Copy Markdown
Contributor Author

is this different from the new feature that you are developing here ?

Great tip on handling the pre-retirement to clear out the previous side. Tried it and it works really well.

This feature deals with side selection via the wizard. The retire button functionality just falls into place. This feature fires a Startup GKC as each player joins using the wizard user interface.

The existing "At Start of Fresh Game or Player join/Side-Change" Startup GKC only fires once from the wizard regardless of how many players join the game. So the first player gets preferential treatment and the others are left out.

@riverwanderer I'm wondering which Startup GKC you use and how you deal with side selection from the wizard for the second and each subsequent player?

@riverwanderer

Copy link
Copy Markdown
Collaborator

I'm wondering which Startup GKC you use and how you deal with side selection from the wizard for the second and each subsequent player?

The module from which the example was derived uses this SGKC to trigger, which sounds like it is problematic. So I could try the "Every Game Launch/Load of Session" instead, that's what I was using for this before V3.7:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Ready for Review Ready to be reviewed for Merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Startup GKC that fires when player joins or changes sides V2

3 participants