Fa triggers malament

This commit is contained in:
2026-10-29 20:30:29 +01:00
parent bc05b63083
commit 9ec486274f
16 changed files with 2287 additions and 128 deletions

View File

@@ -162,7 +162,7 @@ permanents.withType('creature').withSubtype('dragon').withColor('red')
```
Available filters include `withType`, `withSubtype`, `withSupertype`,
`withColor`, `withKeyword`, `withoutKeyword`, `withoutType`, `other`, `tapped`,
`withColor`, `withoutColor`, `withKeyword`, `withoutKeyword`, `withoutType`, `other`, `tapped`,
`untapped`, `attacking`, `token`, `nontoken`, `equipped`, `enchanted`,
`youControl`, `opponentControls`, `controlledBy`, `ownedBy`, `named`,
`inZone`, `withCounter`, `powerAtLeast`/`powerAtMost`,
@@ -198,6 +198,7 @@ damage(target(permanents.withType('creature')), 3)
draw(you, 2)
gainLife(you, 1)
createToken(you, 1, token({ types: ['creature'], subtypes: ['goblin'], colors: ['red'], power: 1, toughness: 1 }))
createToken(you, 1, token({ name: 'Monster', types: ['enchantment'], subtypes: ['aura', 'role'] }), { attachTo: target(permanents.withType('creature')) })
putCounters(target(permanents.withType('creature')), '+1/+1', 2)
destroy(target(permanents.withType('creature')))
addMana(you, mana('{G}{G}'))
@@ -213,8 +214,9 @@ the cost builders in `source.ts`.
Static effects are also distinct, so their AST shape is unambiguous:
`staticPump`, `staticGrant`, `staticRestrict`, `staticSetPt`, `grantAbility`,
`entersTapped`, `entersWithCounters`, `control`, `choose`, `replace`,
`costReduction`, `costIncrease`, `searchRestriction` and
`exileInsteadOfGraveyard`. `entersTapped` takes an optional `unlessCost` builder
`costReduction`, `costIncrease`, `searchRestriction`,
`exileInsteadOfGraveyard` and `tokenMultiplier` (with optional
`who: 'each_player'` or `creatureOnly: true`). `entersTapped` takes an optional `unlessCost` builder
for "you may pay N life; if you don't, it enters tapped":
`entersTapped(self, { unlessCost: payLife(2) })`.
@@ -339,7 +341,7 @@ The types live in `src/effects/types.ts`. A card contains one or more abilities:
| `pump` | `target`, `power`, `toughness`, `duration` |
| `grant` | `target`, `keyword`, optional `value`, `duration` |
| `put_counters`, `remove_counters` | `target`, `counter`, `amount` |
| `create_token` | `player`, `amount`, `token` |
| `create_token` | `player`, `amount`, `token`, optional `attachTo` target |
| `destroy`, `exile`, `tap`, `untap`, `regenerate` | `target` |
| `sacrifice` | `player`, `target`, optional `unless` cost |
| `counter` | `what`, `target`, optional `unless` cost |
@@ -351,11 +353,18 @@ The types live in `src/effects/types.ts`. A card contains one or more abilities:
| `energy` | `player`, `amount` |
| `attach` | target to attach this/trigger object to |
| `restriction` | target, rule, duration |
| `keyword_action` | `action`, optional `amount`, `detail`, `target` |
| `keyword_action` | `action`, optional `amount`, `detail`, `target`; the engine implements `explore`, `incubate`, and `impulse` |
| `proliferate` | no payload |
| `hideaway` | `amount`; exiles the top card and links it to the source |
| `hideaway` | `amount`; looks at that many cards and pauses for the controller to exile one face down, linking it to the source |
| `play_exiled` | `player`, optional `free`; plays a card linked with `hideaway` |
| `exile_graveyards` | no payload; exiles all cards from every graveyard |
| `transform` | `target`; swaps the object's front and back faces |
A created token whose name or subtype matches one of the predefined tokens in
comprehensive rules 111.10 gets that token's full characteristics and abilities
from `src/game/tokens.ts`. The compiled `token` spec only needs enough information
to identify it, for example `token({ subtypes: ['treasure'] })` or
`token({ name: 'Monster', subtypes: ['aura', 'role'] })` for a Role.
### Targets, values, costs

View File

@@ -65,17 +65,19 @@ const bolt: CardDefinition = {
| `putOnBottom(playerId, cardId)` | Puts one chosen card from a mulliganed opening hand on the bottom of its owner's library. |
| `playLand(playerId, cardId)` | Plays a land from hand; once per turn, main phase, empty stack. |
| `castSpell(playerId, cardId, { targets, x, mode, overload })` | Puts a spell on the stack and pays its mana cost. Accepts a commander in the command zone, adds commander tax, and can pay the overload cost instead. |
| `activateAbility(playerId, sourceId, abilityIndex, { targets, x, mode })` | Activates an ability on a permanent. Mana abilities resolve immediately. |
| `activateAbility(playerId, sourceId, abilityIndex, { targets, x, mode, manaColor })` | Activates an ability on a permanent. Mana abilities resolve immediately; `manaColor` picks the color when the ability can make several. |
| `movePermanent(playerId, cardId, x, y)` | Cosmetic board layout for a permanent you control; coordinates are 0..1 within the battlefield. |
| `declareAttackers(playerId, [{ attackerId, defenderId }])` | Starts combat from the precombat main if needed. |
| `declareBlockers(playerId, [{ blockerId, attackerId }])` | Declares blocks for one defending player. In multiplayer, combat damage waits until every defending player has declared or passed. |
| `resolveCombatDamage()` | Deals combat damage manually; passing priority also does this. |
| `pass(playerId?)` | Passes priority; when everyone passes, resolves the top of the stack or advances the phase. |
| `chooseSearchCard(playerId, cardId)` | Finishes one pick of a paused library search. |
| `chooseHideawayCard(playerId, cardId)` | Exiles one of the cards looked at with hideaway; the rest go to the bottom in a random order. |
| `chooseCreatureType(playerId, type)` | Answers an "as this enters, choose a creature type" prompt. |
| `resolveStack()` | Convenience for tests/scripts: passes priority until the stack is empty. Does not advance phases. |
| `endTurn(playerId)` | Ends the active player's turn, skipping remaining phases. Requires an empty stack. |
| `canPlayCard(playerId, cardId)` | Whether a hand or command-zone card can legally be played now, including timing, mana, and targets. |
| `legalTargetsForCard(playerId, cardId)`, `legalTargetsForAbility(playerId, sourceId, abilityIndex)` | Legal `TargetChoice`s for a spell or activated ability, so the UI can offer only real targets. |
| `autoAdvance()` | Passes priority for players with nothing meaningful to do; stops when someone can act or the turn ends. |
| `getPower`, `getToughness`, `hasKeyword` | Current characteristics after static and continuous effects. |
| `addCard`, `moveToZone` | Setup helpers for placing cards directly into zones. |
@@ -105,12 +107,12 @@ untap -> upkeep -> draw -> precombat main -> begin combat -> declare attackers
-> end step -> cleanup -> next player's turn
```
The starting player skips their first draw. Cleanup discards down to seven cards,
clears damage, expires `until_end_of_turn` and `until_end_of_your_next_turn`
effects, and empties mana pools. The engine advances phases when every living
player passes in turn; it does not stop at every rules-defined priority window.
The match manager calls `autoAdvance()` after each action, so priority is only
shown to players who can actually do something.
The starting player draws on their first turn, as in multiplayer Commander. Cleanup
discards down to seven cards, clears damage, expires `until_end_of_turn` and
`until_end_of_your_next_turn` effects, and empties mana pools. The engine advances
phases when every living player passes in turn; it does not stop at every
rules-defined priority window. The match manager calls `autoAdvance()` after each
action, so priority is only shown to players who can actually do something.
## Supported
@@ -134,6 +136,14 @@ shown to players who can actually do something.
counter spell/ability, zone returns, tap/untap, search/shuffle, add mana, fight,
regenerate, energy, attach, restrictions, conditional and modal effects, dig,
divided damage, hideaway, and playing a card exiled with hideaway.
- Tokens: the predefined tokens from comprehensive rules 111.10 (Treasure, Food,
Gold, Walker, Shard, Clue, Blood, Powerstone, Incubator, Map, Junk, Lander,
Mutagen, Vibranium, Heartwood, and the seven Role tokens). `tokens.ts` supplies
their characteristics and abilities when a created token names that subtype or
name. Role tokens can be created already attached to their target. Incubator
tokens carry their counters and can transform into a Phyrexian.
- Keyword actions: explore, incubate, and impulse. Impulse exiles the top card and
marks it playable from exile until the end of the current turn.
- Restrictions and conditions: activated abilities can be disabled, opponents can
be limited to the top N cards when searching, cards can begin the game on the
battlefield from the opening hand, and conditions can count commander control or
@@ -148,9 +158,27 @@ shown to players who can actually do something.
## Known limitations
- Some effect nodes are accepted but intentionally do nothing yet:
`prevent_damage`, `gain_control`, `emblem`, `transform`, `schedule`, `level_up`,
`put_from_among`, `look_top`, `scry`, `surveil`, and `keyword_action`.
Unsupported oracle lines are already marked by the compiler and never reach here.
`prevent_damage`, `gain_control`, `emblem`, `schedule`, `level_up`,
`put_from_among`, `look_top`, `scry`, and `surveil`. Scry and surveil are
no-ops, so an effect that scries and then draws still draws. `keyword_action`
implements explore, incubate, and impulse; any other action is ignored.
`transform` only works on an object that has a back face, currently the
Incubator token. Unsupported oracle lines are already marked by the compiler
and never reach here.
- Explore puts a revealed land card into its controller's hand. For a nonland
card, the exploring creature gets a +1/+1 counter and the card goes to the
graveyard; it does not ask whether to put that card on top instead.
- Impulse grants the engine's play-from-exile permission. The web client marks a
playable exiled card and offers a Play button in the exile browser; other clients
must expose the same cast/play path.
- Powerstone and Vibranium mana carries an "artifact spells" restriction that the
mana pool does not enforce, so it can currently pay for any spell.
- Role and other Aura static abilities use the `attached: enchanted` selector,
which matches any creature that has an Aura attached rather than only that
Aura's own enchanted creature. With several Auras, a pump can apply more widely
than printed.
- Ward is recorded as a keyword and shown on the permanent, but targeting does not
yet ask for its cost, so Royal Role's ward {1} is not enforced.
- Commander support covers single commanders. Partner, backgrounds, companions,
and "choose a commander" variants are not modelled. The engine always takes the
command-zone replacement instead of asking.
@@ -167,8 +195,10 @@ shown to players who can actually do something.
(color, card name, player, opponent, number) are accepted and ignored. Cavern of
Souls' mana is not restricted to the chosen type and does not make the spell
uncounterable.
- Hideaway automatically exiles the top card and does not track cards as face down.
`play_exiled` only supports the free "without paying its mana cost" case.
- Hideaway pauses for its controller to exile one of the looked-at cards; the
rest go to the bottom in a random order. The exiled card stays face down and is
shown under its source, hidden from every player's card list. `play_exiled` only
supports the free "without paying its mana cost" case.
- Overload widens only top-level effect targets; a nested modal or conditional target
keeps its printed target. Free alternative costs are modelled only for controlling
a commander, and search restrictions cap the searching player's own library.