# How to find maximum out of 6 properties?

I’ve not used the Math.max before, but it looks handy.

In my case though, I want to calculate which of 6 properties has the highest value, and output that value for use in another trigger. Specifically, which of 6 decks has the highest deck_numPieces for an automated step of bookkeeping.

Is there a simple solution?

What I have come up with, assuming the deck names are A~F

Calculated property MaxAB: Math.max(A_numPieces,B_numPieces)
Calculated property MaxABC: Math.max(MaxAB,C_numPieces)
Calculated property MaxABCD: Math.max(MaxABC,D_numPieces)
Calculated property MaxABCDE: Math.max(MaxABCD,E_numPieces)
Calculated property MaxABCDEF: Math.max(MaxABCDE,F_numPieces)

This last gives me the highest number (only)

Calculated property BiggestDeck: A_numPieces==MaxABCDEF ? “DeckA” : B_numPieces …

This gives me a deck with a number of pieces matching the maximum number, but fails to randomise among decks that are equally large, and that’s also something I want to do. Or, at least, maybe I’ll randomise, maybe I’ll give players the choice with a popup.

Any help most appreciated.

Don’t make 6 different CP’s, that will be horrendously inefficient, 6 separate Beanshell invocations and 6 additional scans of the trait stack. Create one that looks something like:

Math.max(Math.max(Math.max(Math.max(Math.max(A_numPieces,B_numPieces), C_numPieces), D_numPieces), E_numPieces), F_numPieces)

Awesome, thanks.

OK, that gets me the maximum value.

Can you tell me how to select one deck if only one shares that value, or ask a player to select a value for a GP if two or more share that value?