Create account / Log in

Counting card value

Talk about module design ideas and techniques.

Moderators: Tim M, uckelman

Counting card value

Postby abodi » July 23rd, 2012, 10:47 am

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.
abodi
 
Posts: 5
Joined: November 19th, 2011, 8:56 pm

Re: Counting card value

Postby barbanera » July 23rd, 2012, 11:40 am

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: $<deckname>_1s$ + 2*$<deckname>_2s$ + 3*$<deckname>_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 $<deckname>_1s$, the second and third with $<deckname>_2s$ etc. Then have the text label print out the value of this global property instead.
barbanera
 
Posts: 377
Joined: January 12th, 2012, 2:27 pm

Re: Counting card value

Postby abodi » July 23rd, 2012, 12:02 pm

that's quite disappointing. It's my last hurdle in a module.
abodi
 
Posts: 5
Joined: November 19th, 2011, 8:56 pm

Re: Counting card value

Postby barbanera » July 23rd, 2012, 12:24 pm

What's disappointing? You don't like the solution I gave you..?
barbanera
 
Posts: 377
Joined: January 12th, 2012, 2:27 pm

Re: Counting card value

Postby abodi » July 23rd, 2012, 12:56 pm

i'm not sure i understand it really. especially the button whatnots. so i would have to click a button to total it?
abodi
 
Posts: 5
Joined: November 19th, 2011, 8:56 pm

Re: Counting card value

Postby barbanera » July 23rd, 2012, 1:05 pm

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.
barbanera
 
Posts: 377
Joined: January 12th, 2012, 2:27 pm

Re: Counting card value

Postby Brent Easton » July 23rd, 2012, 9:47 pm

3.2.x: no.


???

Anything that can be done in 3.1 can be done in 3.2
User avatar
Brent Easton
 
Posts: 2757
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Counting card value

Postby barbanera » July 23rd, 2012, 10:14 pm

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
barbanera
 
Posts: 377
Joined: January 12th, 2012, 2:27 pm

Re: Counting card value

Postby Brent Easton » July 23rd, 2012, 10:25 pm

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
User avatar
Brent Easton
 
Posts: 2757
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Counting card value

Postby abodi » July 24th, 2012, 1:25 am

Barbanera, is it possible you could show me how would would set up that button via a screenshot?
abodi
 
Posts: 5
Joined: November 19th, 2011, 8:56 pm

Re: Counting card value

Postby barbanera » July 24th, 2012, 3:36 pm

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).
barbanera
 
Posts: 377
Joined: January 12th, 2012, 2:27 pm

Re: Counting card value

Postby barbanera » July 24th, 2012, 3:54 pm

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.
barbanera
 
Posts: 377
Joined: January 12th, 2012, 2:27 pm

Re: Counting card value

Postby abodi » July 26th, 2012, 6:16 am

Mostly because I wasn't aware 3.2 was available. :) 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?
abodi
 
Posts: 5
Joined: November 19th, 2011, 8:56 pm

Re: Counting card value

Postby barbanera » July 26th, 2012, 8:41 am

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

$<deckname>_1s$ + 2*$<deckname>_2s$ + 3*$<deckname>_3s$

where <deckname> 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$.
barbanera
 
Posts: 377
Joined: January 12th, 2012, 2:27 pm


Return to Module Design

Who is online

Users browsing this forum: No registered users and 1 guest