Augmented values

Simulated dice for role playing games
Post Reply
gandreas
Immortal
Posts: 1464
Joined: Wed Feb 04, 2004 6:02 pm
Contact:

Augmented values

Post by gandreas » Wed Nov 16, 2011 2:58 pm

To satisfy a number of request for more detailed dice control (over things like rerolls), and a way to clean up dice references, and, as I realized this morning, a way to help to implemented "cards", I've come up with an interesting solution that I'm calling "augmented values".

If you roll a single die (or a list of dice such as "3d6@"), besides being a simple numeric value, there will also be "augmented properties" on that value, which can be accessed via the subscript [] operator. So, if you roll:

Code: Select all

@x <- d+6
you'll get some sort of open ended value. If, for some reason, you wanted to see what each of the values that went into that total value (i.e., examine all the rerolls), you can do:

Code: Select all

@x <- d+6.
@x["allRolls"]
and you'll either get a single value (if there was nothing re-rolled) or a list of values (just so happens that it'll be one or more 6s and then the final value).

For the potential "playing card" support, you can do:

Code: Select all

1pPoker
and get something like "Six of Spades"

Code: Select all

1pPoker["rank"]
and get 6

Code: Select all

1pPoker["suit"]
and get 4 (where Clubs = 1, Diamonds = 2, Hearts = 3, Spades = 4)

This will also make the :badge: action easier to use (which uses the "index" of the die, which is now one of the augmented properties). For example, to add a green tint to the higher of two dice easily:

Code: Select all

@higher <- d+6 \/ d+4.
:badge:( ":red:", @higher["index"])
(augmented properties are maintained on certain operators, notably "/\", "\/", "<-", ",", "." and ideally even when using an if statement - anything that doesn't result in throwing away an old value and creating a new one (such as addition, subtraction, etc...)

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests