Dr Vesuvius's Adventure Deck Macros
Pre-requisites
(1) Lib:GM token with the following attributes
AdventureDeck:1,2,3,4,5,6,7,...,52,53,54
RequestedAdventureCard:";"
PlayedAdventureCard:";"
AdventureDeck is a list of numbers corresponding to each card number in the deck
RequestedAdventureCard is a StrProp which will temporarily hold a token name and the card they want to play
PlayedAdventureCard is another StrProp which will hold the last card played and who played it.
(2) A table called "Adventure" numbered 1-54 containing the text and image of every adventure card.
Token Macros
(1) Draw Adventure Card
This macro calls the corresponding macro from Lib:GM and adds the result it returns to the token's hand. I think the reason I put the "add to hand" code here was because the Lib:GM macro changes the active token to Lib:GM. Could work around this easily enough if you want to limit all your token macros to stubs.
Code: Select all
<!-- DrawAdventure -->
[MACRO("DrawAdventureCard@Lib:GM"): 0]
[H: CardDrawn = macro.return]
[H: AdventureCardHand =listAppend(AdventureCardHand+"", CardDrawn+"")]
(2) View Adventure Card (see Lib:GM tokens)
This macro is a stub that just calls the corresponding macro from Lib:GM
Code: Select all
<!-- ViewAdventure -->
[MACRO("ViewCardHand@Lib:GM"): 0 ]
[H: abort(0)]
Lib:GM Macros
(1) DrawAdventureCard
Draws a card from the Adventure deck and returns the number to the calling macro. It displays that the character has drawn a card but does not display it.
Code: Select all
<!-- DrawAdventureCard -->
[h:CurrentPlayer = findToken(token.name) ]
[h:PlayerName = token.name]
[h:switchToken("Lib:GM")]
[H: NoOfCardsInDeck = listCount(AdventureDeck)]
[H: DrawPseudoDie = '1d'+NoOfCardsInDeck]
[H: CardRolled = eval(DrawPseudoDie)-1]
[H: CardDrawn = listGet(AdventureDeck,CardRolled)]
[H: AdventureDeck = listDelete(AdventureDeck, CardRolled)]
[H: macro.return = CardDrawn]
draws a card from the Adventure Deck
(2) ViewCardHand
This plugs into my existing character sheet frame and displays a simple list of the cards in the hand, showing picture, text and two macrolinks "Play This Card Now" or "Discard This Card Now"
Code: Select all
<-- ViewCardHand -->
[Frame("CharSheet"): {
<html>
<head>
<title>[R: TokenViewed = getImpersonatedName() ] Adventure Card Hand</title>
</head>
<body>
<table>
[foreach(Card, AdventureCardHand, ""), code: {
[H: Callback = "PlayAdventureCard@" + getMacroLocation()]
<tr>
<td>
<image src='[R: tableImage("Adventure",Card)]' ></image>
</td>
<td width = "400">
<table>
<tr>
<td>
[R: table("Adventure",Card)]
</td>
</tr>
<tr>
<td>
[R: macroLink("Play This Card Now", "PlayAdventureCard@" + getMacroLocation(), "gm", Card,"selected")]
<br>
[R: macroLink("Discard This Card Now", "DiscardAdventureCard@" + getMacroLocation(), "gm", Card,"selected")]
</td>
</tr>
</table>
</td>
</tr>
}]
</table>
</body>
</html>
}
]
(3) PlayAdventureCard
Because of the restriction in b48, macrolinks were only able to display direct to the GM or the player themselves, not to all players. To get around this, instead of simply playing the card and announcing it to everyone, this macro sends the card to the GM who must then approve it separately announcing it to all players. With hindsight, I think this is probably the best approach to take anyway, since players have a tendency to suggest pretty tenuous/munchkiny/outright incorrect uses for Adventure cards at times, and I often find I have to veto them, like "No you can't use the Romance card to find treasure, no matter how much you love gold."
This does not remove the card from the player's hand until the GM approves the card's use.
Code: Select all
<!-- PlayAdventureCard -->
<br>
[H: CardPlayed = macro.args ]
[R: PlayerName=token.name]
would like to play an Adventure Card! <br>
<img src='[R: tableImage("Adventure",CardPlayed)]'></image>
<br>
[R: table("Adventure",CardPlayed)]
[H, token("Lib:GM"): RequestedAdventureCard = "Player = "+PlayerName+"; CardPlayed = "+CardPlayed]
(4) DiscardAdventureCard
Self explanatory
Code: Select all
<!-- DiscardAdventureCard -->
<br>
[H: CardPlayed = macro.args ]
[R: PlayerName=token.name]
discards an Adventure Card! <br>
[H: CardToRemove = listFind(AdventureCardHand+"", CardPlayed+"")]
[H: AdventureCardHand = listDelete(AdventureCardHand+"", CardToRemove)]
(5) ApproveCard
This is the macro used by the GM to approve the use of a proposed Adventure Card. It removes it from the player's hand and announces it to all players.
Code: Select all
<!-- ApproveCard -->
[H, token("Lib:GM"): PlayerName = getStrProp(RequestedAdventureCard, "Player")]
[H, token("Lib:GM"): CardPlayed = getStrProp(RequestedAdventureCard, "CardPlayed")]
[R: PlayerName] has played an Adventure Card! <br>
<img src='[R: tableImage("Adventure",CardPlayed)]'></image>
<br>
[R: table("Adventure",CardPlayed)]
[H, token(PlayerName): CardToRemove = listFind(AdventureCardHand+"", CardPlayed+"")]
[H, token(PlayerName): AdventureCardHand = listDelete(AdventureCardHand+"", CardToRemove)]
[H, token("Lib:GM"): PlayedAdventureCard = RequestedAdventureCard]
[H, token("Lib:GM"): RequestedAdventureCard = ";"]
(6) LastCardPlayed
In case the GM needs to check who played the last Adventure Card
Code: Select all
<!-- LastCardPlayed -->
[H, token("Lib:GM"): PlayerName = getStrProp(PlayedAdventureCard, "Player")]
[H, token("Lib:GM"): CardPlayed = getStrProp(PlayedAdventureCard, "CardPlayed")]
[R: PlayerName] played the last Adventure Card! <br>
<img src='[R: tableImage("Adventure",CardPlayed)]'></image>
<br>
[R: table("Adventure",CardPlayed)]
(7) ShuffleAdventure
This just resets to the default value of the Adventure deck. In theory this might mean it's possible to have duplicate cards in play. In practice this would only be done at the start of a session when player's adventure hands should be emptied anyway.
Code: Select all
<!-- ShuffleAdventure -->
[h:switchToken("Lib:GM")]
[H: AdventureDeck = getPropertyDefault('AdventureDeck')]
The Adventure Deck has been Shuffled.
And here's what it looks like. You can probably see one drawback already - the player must refresh their adventure hand view when the GM approves the card they've played. Not sure if it's possible to get this to update automatically.
Hope this is of some use to someone.