-
Notifications
You must be signed in to change notification settings - Fork 0
Card Effect Compilation
How to turn a played card into an ordered series of executable commands. This needs to remember to respect control blocks, external modifiers, other effects that could be triggered along the way (maybe more of an execution problem than compilation), and various other issues.
"Compilation" needs to happen as cards are played (not as they are created), because effects may need to read the current board state to work properly (and then those differences can cascade down to affect other effects).
This informs data structures for card effects and the shape of effect handling code.
Each card has an ordered list of instructions, represented in bytecode. During execution, instructions are pushed onto a stack, and taken off incrementally. When an instruction is read from the stack, some corresponding code is run. Effects are chunks of instructions, put together in a deliberate way.
| Effect Name | Byte structure (after HEAD) |
|---|---|
| Loop | INT(num times), BYTES to compile, ENDLOOP |
| Forloop | INT (id), LIST, BYTES (chunks + placeholders), ENDLOOP |
| Add to Hand | |
| Set Points | PLAYER, INT |
| Set Max Hand Size | PLAYER, INT |
| Set Draw Size | PLAYER, INT |
| Set Win Condition | Set a player's win condition |
| Send To Hand | Put a card in a player's hand |
| Discard | Put card in discard |
| Destroy | Destroy a card |
| Change Owner | Give a played card to a player |
| Duplicate | Duplicate a card |
| Deck | Put a card in deck |
| Add Tag | Add tag to a card |
| Set Flag | Set global flag |
| Set Counter | Set global counter |
| Set Var | Set global variable |
| Toggle Turn Order | Reverse turn order |
| Set Player Turn | Make it a player's turn |
| Add Listener | Add a global listener |
| Roll Dice | Roll a 1DX and return result |
| Shuffle Deck | Shuffle deck |
| OOE | Out of engine |