TextLabel for Sum of Calculated Properties

Ok. I’ve been banging my head on this for days and finally came up with a solution that I don’t really like. Guess there is no way to have a Text Label automatically update when there is a Calculated Property that involves an IF statement. They do not play nice together. It continuously crashes my Vassal program. So, I had to resort to using the silly “right-click menu” option. Which really kinda defeats the purpose of an auto-update. But, that’s just me. :smiley: So, after my frustrations I wanted to share with you my problem and my solution, in case there are others out there trying to do the same thing.

I created a module for “Legendary: A Marvel Deck Building Game”. In this Semi-Cooperative card game, players win by defeating the Mastermind Villain. But, there is also an overall winner by accumulating Victory Points. So, I wanted a Counter Piece that automatically totaled up the VPs in a player’s Victory Pile. Well, if all the cards were worth “X” number of points, it would have been simple. Just do a Calculated Property to add the Counting Properties from each deck. However, some of the cards have conditional variables. For instance, Supreme Hydra says “This card worth 3 VP for each -other- Hydra in that player’s Victory Pile.” Well, like I said earlier, Text Labels and IF statements do not play well together.

So, here is what I did. I created a Global Property called “P1HydraScore”. Then on the Piece that displays Player 1’s total VP, I have the following:

Basic Piece (which can be blank - but I created a nice little box piece to hold the player’s score)

Set Global Property -
Description: Update Player’s Hydra Score
Global Property Name: P1HydraScore
Is Numeric?: Yes
Menu Command: Update Hydra Score
Key Command: CTRL SHIFT 1
Type: Set Value Directly
New Value: {($VPDeckPlayer1_Hydra$3)$VPDeckPlayer1_SupHydra$}

Calculated Property -
Property Name: Player1TotVP
Expression: VPDeckPlayer1_VP1+(VPDeckPlayer1_VP22)+(VPDeckPlayer1_VP33)+
(VPDeckPlayer1_VP44)+VPDeckPlayer1_VP55)+P1HydraScore

Text Label -
Text: $Player1TotVP$

On the Victory Pile I created Counting Properties for Markers for all the Cards that are Hydra Cards. The Supreme Commander, although technically a Hydra, I gave him a Marker of SupHydra, so he’s wasn’t included in the total above. Now, at the end of the game, or whenever a player wants, he can right-click on his Victory Pile and choose “Update Hydra Score” and it will recalculate the VPs depending on if he has the Supreme Commander and any Hydra cards. Otherwise, the VPs are automatically updating for all the other VPs.

So, until they can get the IF statement to play nicely with Text Label, this was the only solution I could figure out. If you have a better one, that I am missing, please let me know. No seemed to have a better answer when I asked. I wanted to post this in here for future programmers, in case they have games like mine. Thanks!

try reversing your text label and calculated property

Not sure what you mean. If you are talking about everything I typed up above, all of that works. That was my work around. If you mean the issue I was having with the Text Label not working with a Calculated IF Property, that was one of many things I tried. I even tried having the Calculated IF Property process on another piece and update a Global Property, but as soon as I used the Global Property in a Text Label, Vassal crashed. Personally, I think Text Labels are racists against IFs. :wink:

In what way did vassal ‘crash’? Did you submit a bug report?
Thanks,
Brent.

Yes. Well, the one time it crashed. I didn’t think you needed every time it did it since it seemed to be the same error information. You should have got it from wooterslw at gmail.

Ah, ok. Found it. This is actually a known bug that (hopefully) has just been fixed. This fix will be released in 3.2.3, but could you please try the latest development build and see if this resolves the problem?

Development builds are normally available here vassalengine.org/builds/ but they seem to have been cleaned out. Joel, could you please build the latest?

Thx,
Brent.

Ah, looking closer, I may not have fixed yet, I am looking into it.

Rgds,
Brent.

Thus spake wootersl:

Yes. Well, the one time it crashed. I didn’t think you needed every time
it did it since it seemed to be the same error information. You should
have got it from wooterslw at gmail.

Brent, check the last two dupes of Bug 9555. Those are from wootersl.


J.

Thus spake Brent Easton:

Ah, ok. Found it. This is actually a known bug that (hopefully) has just
been fixed. This fix will be released in 3.2.3, but could you please try
the latest development build and see if this resolves the problem?

Development builds are normally available here
vassalengine.org/builds/[1] but they seem to have been
cleaned out. Joel, could you please build the latest?

They’re here now:

vassalengine.sourceforge.net/builds/


J.