mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- C17: Added Portal Mage
This commit is contained in:
@@ -27,6 +27,7 @@ public enum ApiType {
|
||||
BidLife (BidLifeEffect.class),
|
||||
Bond (BondEffect.class),
|
||||
Branch (BranchEffect.class),
|
||||
ChangeCombatants (ChangeCombatantsEffect.class),
|
||||
ChangeTargets (ChangeTargetsEffect.class),
|
||||
ChangeText (ChangeTextEffect.class),
|
||||
ChangeZone (ChangeZoneEffect.class),
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.combat.AttackingBand;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.event.GameEventCombatChanged;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.util.collect.FCollectionView;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ChangeCombatantsEffect extends SpellAbilityEffect {
|
||||
|
||||
@Override
|
||||
protected String getStackDescription(SpellAbility sa) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
final List<Card> tgtCards = getTargetCards(sa);
|
||||
// should update when adding effects for defined blocker
|
||||
sb.append("Reselect the defender of ");
|
||||
sb.append(StringUtils.join(tgtCards, ", "));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
boolean isCombatChanged = false;
|
||||
final Game game = sa.getActivatingPlayer().getGame();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
// TODO: may expand this effect for defined blocker (False Orders, General Jarkeld, Sorrow's Path, Ydwen Efreet)
|
||||
for (final Card c : getTargetCards(sa)) {
|
||||
if ((tgt == null) || c.canBeTargetedBy(sa)) {
|
||||
final Combat combat = game.getCombat();
|
||||
final GameEntity orginalDefender = combat.getDefenderByAttacker(c);
|
||||
final FCollectionView<GameEntity> defs = combat.getDefenders();
|
||||
final GameEntity defender = sa.getActivatingPlayer().getController().chooseSingleEntityForEffect(defs, sa,
|
||||
"Choose which defender to attack with " + c, false);
|
||||
if (orginalDefender != null && !orginalDefender.equals(defender)) {
|
||||
AttackingBand ab = combat.getBandOfAttacker(c);
|
||||
if (ab != null) {
|
||||
combat.unregisterAttacker(c, ab);
|
||||
ab.removeAttacker(c);
|
||||
}
|
||||
combat.addAttacker(c, defender);
|
||||
isCombatChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isCombatChanged) {
|
||||
game.updateCombatForView();
|
||||
game.fireEvent(new GameEventCombatChanged());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -529,7 +529,7 @@ public class Combat {
|
||||
}
|
||||
|
||||
// removes references to this attacker from all indices and orders
|
||||
private void unregisterAttacker(final Card c, AttackingBand ab) {
|
||||
public void unregisterAttacker(final Card c, AttackingBand ab) {
|
||||
blockersOrderedForDamageAssignment.remove(c);
|
||||
|
||||
Collection<Card> blockers = blockedBands.get(ab);
|
||||
@@ -544,7 +544,7 @@ public class Combat {
|
||||
}
|
||||
|
||||
// removes references to this defender from all indices and orders
|
||||
private void unregisterDefender(final Card c, AttackingBand bandBeingBlocked) {
|
||||
public void unregisterDefender(final Card c, AttackingBand bandBeingBlocked) {
|
||||
attackersOrderedForDamageAssignment.remove(c);
|
||||
for (Card atk : bandBeingBlocked.getAttackers()) {
|
||||
if (blockersOrderedForDamageAssignment.containsKey(atk)) {
|
||||
|
||||
Reference in New Issue
Block a user