Shandalar - Program Bugs
Replaced discards don't count as paying a discard cost (reviewed)
117.11. The actions performed when paying a cost may be modified by effects. Even if they are, meaning the actions that are performed don't match the actions that are called for, the cost has still been paid.
Example: A player controls Psychic Vortex, an enchantment with a cumulative upkeep cost of "Draw a card," and Obstinate Familiar, a creature that says "If you would draw a card, you may skip that draw instead." The player may decide to pay Psychic Vortex's cumulative upkeep cost and then draw no cards instead of drawing the appropriate amount. The cumulative upkeep cost has still been paid.
discard_maybe_random() (and thus discard()) doesn't have a way to communicate whether any cards were discarded, only that at least one was discarded and the discard not replaced.
Two classes of mishandling here:
Plan of attack:
It may or may not be convenient to make multiple-card discards be marked and swept while I'm at it, so e.g. if you're discarding two cards and misclick the first one, you can click it again to unselect instead of discarding it immediately.
Example: A player controls Psychic Vortex, an enchantment with a cumulative upkeep cost of "Draw a card," and Obstinate Familiar, a creature that says "If you would draw a card, you may skip that draw instead." The player may decide to pay Psychic Vortex's cumulative upkeep cost and then draw no cards instead of drawing the appropriate amount. The cumulative upkeep cost has still been paid.
discard_maybe_random() (and thus discard()) doesn't have a way to communicate whether any cards were discarded, only that at least one was discarded and the discard not replaced.
Two classes of mishandling here:
- All variants of ActivateDiscard make the first discarded card optional; if all discards are replaced, it's interpreted as declining to pay activation cost.
- Painful Quandary is typical:
- Code: Select all
CARD(card_when_opponent_casts_spell_take5life_unless_he_discards, CARD_ID_PAINFUL_QUANDARY)
{
{ /* Painful Quandary |3|B|B
* Enchantment
* Whenever an opponent casts a spell, that player loses 5 life unless he or she discards a card. */
}
if (TRIGGER(TRIGGER_SPELL_CAST, {1-player, -1})
&& (hand_count[trigger_cause_controller] <= 0 || discard(trigger_cause_controller, 1, DISCARD_COST|DISCARD_SPELL_ABIL|player, TYPE_NONE, false) < 0))
lose_life(trigger_cause_controller, 5);
RETURN();
}
Plan of attack:
- Make discard_maybe_random() return void to find all cases where the return value is inspected.
- Track down all the places - there probably aren't many - that are actually interested in which card is discarded and call a different overload that explicitly sets that.
- Mark all the rest, which use the return value to tell whether any cards were discarded - probably nearly all of them - as needing update.
- Make discard_maybe_random() return number of cards discarded, pre-replacement.
- Fix the marked calls.
It may or may not be convenient to make multiple-card discards be marked and swept while I'm at it, so e.g. if you're discarding two cards and misclick the first one, you can click it again to unselect instead of discarding it immediately.
Comments
Posted by Korath » 17 Nov 2015, 00:01
Same for draw costs, since draw() also only returns the index of the last non-replaced drawn card. The only implemented cards with draw costs are Riddlesmith and Jeskai Elder; but there's draw replacement in the original card set, so this affects versions all the way back to those cards' original deployment in TH1.
1 Post
• Page 1 of 1
Ticket details
- Ticket ID: 916
- Project: Shandalar
- Status: Reviewed
- Component: Duel Engine
- Project version: Nomad's Bazaar 1
- Priority: Normal
- Severity: Normal
- Assigned to: Korath
- Reported by: Korath
- Reporter's tickets: List all tickets
- Reported on: 16 Nov 2015, 21:48
- Last visited by Korath » 26 Feb 2016, 08:25.
