* Alternative costs - fixed that it can be activated on free cast (example: cascade with overload, #6925, #7410, #7741, #6342);

This commit is contained in:
Oleg Agafonov 2021-09-21 14:22:46 +04:00
parent 6aaf461362
commit 6bc5a00e8a
7 changed files with 151 additions and 44 deletions

View file

@ -1544,13 +1544,14 @@ public abstract class PlayerImpl implements Player, Serializable {
* for choosing from the card (example: effect allow to cast card and player
* must choose the spell ability)
*
* @param game
* @param playerId
* @param object
* @param zone
* @param game
* @param noMana
* @return
*/
public static LinkedHashMap<UUID, ActivatedAbility> getSpellAbilities(UUID playerId, MageObject object, Zone zone, Game game) {
public static LinkedHashMap<UUID, ActivatedAbility> getCastableSpellAbilities(Game game, UUID playerId, MageObject object, Zone zone, boolean noMana) {
// it uses simple check from spellCanBeActivatedRegularlyNow
// reason: no approved info here (e.g. forced to choose spell ability from cast card)
LinkedHashMap<UUID, ActivatedAbility> useable = new LinkedHashMap<>();
@ -1563,16 +1564,29 @@ public abstract class PlayerImpl implements Player, Serializable {
for (Ability ability : allAbilities) {
if (ability instanceof SpellAbility) {
switch (((SpellAbility) ability).getSpellAbilityType()) {
SpellAbility spellAbility = (SpellAbility) ability;
switch (spellAbility.getSpellAbilityType()) {
case BASE_ALTERNATE:
if (((SpellAbility) ability).spellCanBeActivatedRegularlyNow(playerId, game)) {
useable.put(ability.getId(), (SpellAbility) ability); // example: Chandra, Torch of Defiance +1 loyal ability
// rules:
// If you cast a spell without paying its mana cost, you cant choose to cast it for
// any alternative costs. You can, however, pay additional costs, such as kicker costs.
// If the card has any mandatory additional costs, those must be paid to cast the spell.
// (2021-02-05)
if (!noMana) {
if (spellAbility.spellCanBeActivatedRegularlyNow(playerId, game)) {
useable.put(spellAbility.getId(), spellAbility); // example: Chandra, Torch of Defiance +1 loyal ability
}
return useable;
}
return useable;
break;
case SPLIT_FUSED:
// rules:
// If you cast a split card with fuse from your hand without paying its mana cost,
// you can choose to use its fuse ability and cast both halves without paying their mana costs.
if (zone == Zone.HAND) {
if (ability.canChooseTarget(game, playerId)) {
useable.put(ability.getId(), (SpellAbility) ability);
if (spellAbility.canChooseTarget(game, playerId)) {
useable.put(spellAbility.getId(), spellAbility);
}
}
case SPLIT:
@ -1599,8 +1613,8 @@ public abstract class PlayerImpl implements Player, Serializable {
}
return useable;
default:
if (((SpellAbility) ability).spellCanBeActivatedRegularlyNow(playerId, game)) {
useable.put(ability.getId(), (SpellAbility) ability);
if (spellAbility.spellCanBeActivatedRegularlyNow(playerId, game)) {
useable.put(spellAbility.getId(), spellAbility);
}
}
}