How to get this calculated property report working

My goal - to make a ‘draw 5’ button report “Player X draws X cards”, where X is 5 when the deck is >5 and deck_numPieces when the deck is <5.

Here’s the expression I tried:

Report Action
\$PlayerSide\$ draws \$Cards\$ cards

Calculated Property - Cards
If(GetProperty(“deck_numPieces”))<5,GetProperty(“deck_numPieces”),5)

Obviously this doesn’t work.

Can anyone help?

is the name of of your deck ‘deck’? if not, this will not work. If the name of the deck is xyzzy, then you would use

If(GetProperty(“xyzzy_numPieces”))<5,GetProperty(“xyzzy_numPieces”),5)

Well, the name is not ‘deck’, I just used that as an example. The exact calc property used is:

If(GetProperty("Arythea deed_numPieces))<5,GetProperty(“Arythea deed_numPieces”),5)

…and it doesn’t work. It either returns a \$PlayerSide\$ draws 5 cards or \$PlayerSide\$ draws \$Arythea deed_numPieces\$ cards result depending on which way I put the > sign. Something is wrong with the If condition.

Well, I got it working by using the following:

Report Action
\$PlayerSide\$ draws \$Number\$ cards

Calculated Property = Number
If(Cards<5,GetProperty(“Arythea deed_numPieces”),5)

Calculated Property - Cards
GetProperty(“Arythea deed_numPieces”)

…but I have no idea what the difference is between the the version that works and the one that doesn’t. I would greatly appreciate any insight you might have.

There are 2 syntax errors in that expression that would cause you to get the Red cross instead of the Green arrow in the Expression field, indicating that it is broken. The correct expression is

If(GetProperty(“Arythea deed_numPieces”)<5,GetProperty(“Arythea deed_numPieces”),5)

Also,the If function was broken in early versions of 3.2, so make sure you have the latest.

The syntax errors were just me not copying and pasting properly and typing while drunk. Irresponsible of me when you are so kindly trying to help troubleshoot my problem! In any case I tested the expression you provided and with a deck size of 16, the combination of:

Report Action
\$PlayerSide\$ draws \$Cards\$ cards

Calculated Property - Cards
If(GetProperty(“Arythea deed_numPieces”)<5,GetProperty(“Arythea deed_numPieces”),5)

always returns reports like this:

Arythea draws 16 cards
Arythea draws 11 cards
Arythea draws 6 cards
Arythea draws 1 cards

In other words it is returning \$PlayerSide\$ draws \$Arythea deed_numPieces\$ cards.

However, the combination of:

Report Action
\$PlayerSide\$ draws \$Number\$ cards

Calculated Property = Number
If(Cards<5,GetProperty(“Arythea deed_numPieces”),5)

Calculated Property - Cards
GetProperty(“Arythea deed_numPieces”)

correctly returns reports like this:

Arythea draws 5 cards
Arythea draws 5 cards
Arythea draws 5 cards
Arythea draws 1 cards

I am still completely confused as to what is making that difference in reporting. This is with 3.2.4.

Thanks, I will look into it.

Ok, found the problem. The GetProperty() calls are returning numerical values as strings instead of numbers and this is causing the comparison to be a String comparison instead of a number comparison (so “10” is less than 5).

Have fixed this in SVN 8662, so look for a dev build of at least this level tomorrow and see if this fixes the problem.

Brent.

Awesome. Presumably doesn’t matter for my module now as the 2 calc property system is up and working, but sounds like an important fix for future module development.

Thus spake Brent Easton:

Ok, found the problem. The GetProperty() calls are returning numerical
values as strings instead of numbers and this is causing the comparison
to be a String comparison instead of a number comparison (so “10” is
less than 5).

Have fixed this in SVN 8662, so look for a dev build of at least this
level tomorrow and see if this fixes the problem.

Merged to trunk@8670.

Try 3.2.5-svn8670:

vassalengine.sourceforge.net/builds/

J.