how to count property of cards in player window / hand

In Pax Renaissance card bear different values / traits–some of these traits may be counted toward victory. I want to collate a report that would display who has how many points counting toward victory. Without loss of generality let’s assume there is just one such trait and let’s call it Z.

Cards will be placed in player window (called tableau). Player would purchase cards from the market, by right clicking on them, sending them to his tableau. Player could also discard a card from his tableau, moving it to discard pile. Again, this would be a new action in right-button menu. The tableau would be a free movement window–i.e. no grid, no resrtrictions on how card can be placed / moved. The placement of the cards in Pax Renaissance is liquid: the may be placed next to each other, or below, or can be rotated and placed one on the other–while it can be implemented into Vassal, the benefit is too little for the effort.

Each player has access to other players’ tableaus. It can open it and discard his / her cards–as one of the actions he can take during his turn.

I know how to calculate total Zs of all the cards in the player tableau. I know how to calculate total of Zs when a card is discarded. (There would be a number of Global Properties, one for each player, P1, P2, P3, P4, called PnZ, where n is the number of the player; I would updated the PnZ accordingly–that is fine).

How do I update the PnZ when the player MANUALLY moves the card from his tableau to the discard pile? Even if a discard pile would be a deck on the main map, and I would somehow capture all the cards ending the movement in the discard pile, a card can be moved first to the map and only then dragged to the discard pile.

My approach would as follows: there would be a dynamic property called “owner” which would indicate owner of the card i.e. to which tableu it belongs currently (Pn). If empty, than there is no owner.

I would implement a set of triggers to cover following conditions (under the same key command):

  1. owner=="" && CurrentMap~Pn => set owner to Pn, increase PnZ (for each n);
  2. owner==“Pn” && CurrentMap==“Pa”, where a!=n => decrease PnZ, set owner to Pa, increase PaZ;
  3. owner==“Pn” && CurrentMap!=“P1” && CurrentMap!=“P2” && CurrentMap!=“P3” && CurrentMap!=“P4” => set owner to “”, decrease PnZ.

I think that would work. Your comments?

Hi, I threw a similar version of this out in an earlier post, so I’ll repost it… maybe it’ll work as an alternative for you. I’m not sure it actually works as is though (I used some $$ short-cuts), so if you try it and it’s broken, you can let me know. I’d make a copy of your module beforehand, so you can quickly revert back to your current version if it’s not working for you (nothing like having to undo or redo stuff when you code yourself into a dead-end).

You’d have your four global properties: P1Z, P2Z, P3Z, P4Z, as you stated. Then you’d use use “end movement” map level GKCs to tally those properties onto and off the player boards, rather than any right-click actions (so remove all right-click tallying actions, as you don’t want them tallying twice). You can have separate key commands for these map level GKCs, or all the same, I don’t think it really matters as long as you list the relevant ones in the trigger actions below. Let’s assume all your maps have the same one though: MapGKC (so MapGKC is the ‘ends movement’ gkc property for any map in your module, just to be clear on that: main map, player hand, whatever).

The arrival trigger action would have a matching property of:
CurrentMap=~P1|P2|P3|P4&&Oldmap!=$CurrentMap$
It would watch for MapGKC, and then increment by 1 the global property trait named: $CurrentMap$Z.

The primary removal trigger action would have a matching property of:
CurrentMap!=$OldMap$&&OldMap=~P1|P2|P3|P4
It would watch for MapGKC, and then increment by -1 the global property trait named: $OldMap$Z.

Seems like that would work for either a right-click or manual discards (and by any player), but I could easily be wrong. Anyway, you’re welcome to let me know of any problems. Good luck either way!

Just reread it and saw a typo:

CurrentMap=~P1|P2|P3|P4&&Oldmap!=$CurrentMap$

should be:

CurrentMap=~P1|P2|P3|P4&&OldMap!=$CurrentMap$

So at least one problem with it solved. :smiley:

Hey, rrvs.

Yours is definitely simpler and more easy to follow / implement. My approach was based on one of the tutorials [1], where it says:

IMPORTANT WARNING: In other tutorials or forums you might suggested to use values named OldMap, OldZone or any other variable started with “Old”! I insist you don’t do that! That’s why: 1) these variables valid only when you drag pieces by mouse, they do not work when you move piece via command such as SendToLocation and ReturnToDeck; 2) using Dynamic Property “Counted” is more error proof method.

[1]. vassalengine.org/wiki/How_to … tion/state.

I can see no difference :slight_smile:

Hm, I just ran a quick test with return to deck… having a map level gkc print out the $OldMap$ when it hits the deck/board… and $OldMap$ seemed to work okay for me. Maybe I’m missing something regarding it with my quick test, or perhaps that warning was based on an earlier vassal version. I don’t know.

Re the typo, it’s the OldMap spelling (Oldmap). :smiley:

@rrvs: it works. If anyone is interested, I can share the module. Thank you much.