PlayerSide to determine Global Property

Wondering how to layout the traits for this issue:

The issue is if 4 players each pull down the same game piece (CAT)

For Instance:
CAT (Single Piece)

Player1 should use the Global Property - P1Cat
Player2 should use the Global Property - P2Cat
Player3 should use the Global Property - P3Cat
Player4 should use the Global Property - P4Cat

I would think that one of the traits should identify the $PlayerSide$
Then, upon identifying the $PlayerSide$, it would then assign the global property to use as P1Cat or P2Cat respectively.
I am thinking a Calculated Property, but how would that look?
Most IF statements are 1or two possibly results
IF($PlayerSide$==“Player1”, “P1Cat”, “P2Cat”)
But how would that work for 4 possible outcomes ?

Thanks!

just nest more IF statements so what you want is this:
IF($PlayerSide$==“Player1”, “P1Cat”, IF($PlayerSide$==“Player2”, “P2Cat”, IF($PlayerSide$==“Player3”, “P3Cat”, “P4Cat”)))
On Saturday, April 25, 2020, 02:35:09 PM CDT, KEslinger keslinger@gmail.com wrote:

[This message has been edited.]

Wondering how to layout the traits for this issue:

The issue is if 4 players each pull down the same game piece (CAT)

For Instance:
CAT (Single Piece)

Player1 should use the Global Property - P1Cat
Player2 should use the Global Property - P2Cat
Player3 should use the Global Property - P3Cat
Player4 should use the Global Property - P4Cat

I would think that one of the traits should identify the $PlayerSide$
Then, upon identifying the $PlayerSide$, it would then assign the global
property to use as P1Cat or P2Cat respectively.
I am thinking a Calculated Property, but how would that look?
Most IF statements are 1or two possibly results
IF($PlayerSide$==“Player1”, “P1Cat”, “P2Cat”)
But how would that work for 4 possible outcomes ?

Thanks!


Read this topic online here:
https://forum.vassalengine.org/t/playerside-to-determine-global-property/10466/1

gotcha, nested IF statements, cool i’ll try it!
Thanks!

Excellent, so the nested If statements are working,
However how do i assign a global property to be used based on that calculated property.

Such as, with Calculated Property a variable must be assigned to hold the result of the nested if’s
Calculated Property
PropertyName : CatVariable
$PlayerSide$==“Player1” so CatVariable = “P1Cat”

So now if I go to use the Set Global Property trait
Global Property Name: ???
Normally you would set a static variable here, but what if you wanted to assign the result from CatVariable from the Calculated Property?
I’ve tried {GetProperty(CatVariable)}

but this produces an error “Unable to locate Global Property named {GetProperty(GlobVar)}”

Thanks for your assistance!

Just as an aside, I would recommend changing the name of the Global Properties you use to align them with the names of the PlayerSides.

Instead of P1Cat, P2Cat, P3Cat, P4Cat use Player1Cat, Player2Cat, Player3Cat, and Player4Cat.

That then gets rid of the nested Ifs. You can get to the correct global property using {GetProperty(PlayerSide+“Cat”)}. In A set Global Property trait, you would then use just {PlayerSide+“Cat”} to set the matching global.

For

While larger nested ifs will work, they are just adding additional complication, complexity and processing overheads to your module.

Regards.

Brent is right. I am just presenting a logic you can use. I would yield to his know how

Thank you Both Tim and Brent! Both suggestions are excellent tips and information on expression building.
Both ideas are vital in my understanding. Greatly appreciate it!
Cheers to you both,

So, interestingly enough it looked like it was working, however when i tested with another computer connecting to my online game, it did not matter that both Player1 & Player2 were still using the same Global Property. I am sure it must be some sort of syntax that i am missing. Do either of you care to look at this sample test file ?

Create an online game
Pull the Card element into Player1 Hand
Connect via another computer
join as player 2 and pull the Card single piece into Player hand 2
NUM+ / NUM- effects both elements even though they should be pulling from their own PlayerSide global property
{PlayerSide+ModelName+“HP”}

Trying to understand, logically it should be working.
Thanks!

Are you sure you are connected them as different player sides? Did you you change your password in Preferences before joining with the second computer? Add a text label to a counter with the label $PlayerSide$ to see what the counter thinks the PlayerSide actually is.

Rgds.

yeah i made sure they were completely different accounts and passwords. It even specifically allows me to select a player.

Hmmm i wonder if the pieces are not being restricted or owned to specific PlayerSide.
For instance, as Player1 they will see and report all game pieces as Player1, and Player2 seeing all as Player2.

hmmm

Confirmed that is exactly what is happening.
For instance, a SinglePiece has a text trait to return a global variable
{GetProperty(PlayerSide+ModelName+“HP”)}

However, depending on your PlayerSide you will get that information, even if it was not a piece that you pulled

Each player sees the piece as their current PlayerSide variable.

Strange I would have thought that the player that pulled the piece would set that piece variable permanently .

It seems PlayerSide is a local variable that doesn’t assign itself to the single piece.

I solved it by simply having the players assign a color themselves red, green,blue,yellow once in the game. It’s not ideal and is an extra step but it works. Wish Vassal had an easier solution to this.
It’d still be interested to hear any other solutions. Always more than one solution

From the Vassal reference manual:

PlayerSide is a Global Property reporting what your Side is, it is not linked to the specific piece you are checking it on.

If you want to make this automatic, then I would do the following:

  • Add a ‘Key Command to apply to all units ending movement on this map’ to the map. Use a named Keystroke ‘Arrived’.
  • Add a Dynamic Property named PS to each unit. Add a Key command to the Dynamic Property to set it’s values to {PlayerSide} when it sees the Key Command ‘Update’.
  • Add a Trigger Action that looks for the Keystroke ‘Arrived’ and issue the KeyStroke ‘Update’ if {PS == “”}

Regards.