Counting card value

hi guys, i’m wondering how i would go about this.

I have cards with a marker - CardValue = X, where X equals 1, 2 or 3.

But then i want to count the combined value of the cards listed in a deck.

I’m currently successfully counting the cards themselves, but i’m looking for the combine value.

Your insight is greatly appreciated.

It might be possible to do something of the sort in a straightforward manner with 3.2.0 by using Calculated properties and the beanshell stuff.

However, sticking with 3.1.x if your cards are in a deck you can first of all turn on performing “counting of regular expressions” on the deck, and export properties like:

1s: CardValue=1
2s: CardValue=2
3s: CardValue=3

Then your total will be given by the simple expression: $_1s$ + 2*$_2s$ + 3*$_3s$ + …

For testing purposes you might want to print it out that total. However, you cannot stick the above string in a text label because it won’t work. With 3.2.0 you could define a Calculated Property at this stage - containing that exact expression - and then print that out with a text label. With 3.1.x, instead, define some button with a right/left click command to set up a global property with a bunch of “increment numeric value by” commands, all firing on the same command: the first with $_1s$, the second and third with $_2s$ etc. Then have the text label print out the value of this global property instead.

that’s quite disappointing. It’s my last hurdle in a module.

What’s disappointing? You don’t like the solution I gave you…?

i’m not sure i understand it really. especially the button whatnots. so i would have to click a button to total it?

3.1.x: yes (but there are many ways a button can be clicked, including automatically from other pieces, the turn counter etc)

3.2.x: no.

???

Anything that can be done in 3.1 can be done in 3.2

You didn’t follow the thread, did you?

I was answering to this question

and my answer was that, no, you don’t need a button in 3.2.x

Ah thanks,

I was following, but lost track.

Cheers.

On 24/07/2012 8:14 AM, barbanera wrote:

You didn’t follow the thread, did you?

I was answering to this question

i’m not sure i understand it really. especially the button whatnots.
so i would have to click a button to total it?

and my answer was that, no, you don’t need a button in 3.2.x


Brent Easton
Analyst/Programmer
University of Western Sydney
Email: b.easton@exemail.com.au

Barbanera, is it possible you could show me how would would set up that button via a screenshot?

My reccomendation is to go with Vassal 3.2.0 so that you do not need the “button”, because you
can use a Calculated Property and a text label to show it (and it will dynamically change as expected).

However, if you really want to use 3.1.x (but why?), the “button” we are talking about is simply a piece/unit (even a card) with some left/right click command to fire those “increment numeric values by” commands I discussed before.

For example, it can be a piece with a simple gif/text labels showing “UPDATE DECK TOTAL”, an action button covering the whole of it and firing CTRL-A, and the described set global property trait, with all those “increment numeric values by” commands, all firing on CTRL-A.

Mostly because I wasn’t aware 3.2 was available. :slight_smile: But i’ve got it now. still stuck however. My apologies for being dense.

I have a deck and three expressions.

1s: CardValue = 1
2s: CardValue = 2
3s: CardValue = 3

You can drop cards into this deck and cards have a Trait named CardValue which is either 1, 2 or 3.

I’ve got an “at start stack” with a single piece that currently just counts the cards. I can see the calculated property option added it to the piece but no matter what i put in the expression field, I just get a red X.

Does this calculated property print itself. if not how do i call it?

Give the Calculated Property a name, like TotalValue, and in the expression field enter:

$_1s$ + 2*$_2s$ + 3*$_3s$

where is of course the name you gave to your deck of cards. Don’t click on “Insert”, just add that string to the expression field and you should get a green checkmark in the end.

Maybe “1s”, “2s” etc are not legit name… then use other strings (e.g. cv1, cv2, cv3…).

Then, add to the single piece a text label to print out $TotalValue$.