Merge pull request #7259 from weirddan455/armed

[KHM] Implemented Armed and Armored
This commit is contained in:
Oleg Agafonov 2020-12-19 22:33:01 +01:00 committed by GitHub
commit 96a4defac9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 126 additions and 0 deletions

View file

@ -0,0 +1,125 @@
package mage.cards.a;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
/**
*
* @author weirddan455
*/
public final class ArmedAndArmored extends CardImpl {
public ArmedAndArmored(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}");
// Vehicles you control become artifact creatures until end of turn.
this.getSpellAbility().addEffect(new ArmedAndArmoredEffect());
// Choose a Dwarf you control. Attach any number of Equipment you control to it.
this.getSpellAbility().addEffect(new ArmedAndArmoredEquipEffect());
}
private ArmedAndArmored(final ArmedAndArmored card) {
super(card);
}
@Override
public ArmedAndArmored copy() {
return new ArmedAndArmored(this);
}
}
class ArmedAndArmoredEffect extends ContinuousEffectImpl {
public ArmedAndArmoredEffect() {
super(Duration.EndOfTurn, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.BecomeCreature);
staticText = "Vehicles you control become artifact creatures until end of turn";
}
private ArmedAndArmoredEffect(final ArmedAndArmoredEffect effect) {
super(effect);
}
@Override
public ArmedAndArmoredEffect copy() {
return new ArmedAndArmoredEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
if (permanent != null && permanent.hasSubtype(SubType.VEHICLE, game)) {
if (sublayer == SubLayer.NA) {
permanent.addCardType(CardType.ARTIFACT);
permanent.addCardType(CardType.CREATURE);// TODO: Check if giving CREATURE Type is correct
}
}
}
return true;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
}
class ArmedAndArmoredEquipEffect extends OneShotEffect {
public ArmedAndArmoredEquipEffect() {
super(Outcome.Benefit);
staticText = "Choose a Dwarf you control. Attach any number of Equipment you control to it.";
}
private ArmedAndArmoredEquipEffect(final ArmedAndArmoredEquipEffect effect) {
super(effect);
}
@Override
public ArmedAndArmoredEquipEffect copy() {
return new ArmedAndArmoredEquipEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
FilterControlledPermanent dwarfFilter = new FilterControlledPermanent(SubType.DWARF);
List<Permanent> dwarves = game.getBattlefield().getAllActivePermanents(dwarfFilter, controller.getId(), game);
FilterControlledPermanent equipmentFilter = new FilterControlledPermanent(SubType.EQUIPMENT);
List<Permanent> equipment = game.getBattlefield().getAllActivePermanents(equipmentFilter, controller.getId(), game);
if (!dwarves.isEmpty() && !equipment.isEmpty()) {
TargetPermanent target = new TargetPermanent(0, 1, dwarfFilter, true);
target.withChooseHint("dwarf to be equipped");
controller.choose(outcome, target, source.getId(), game);
Permanent dwarf = game.getPermanent(target.getFirstTarget());
if (dwarf != null) {
target = new TargetPermanent(0, Integer.MAX_VALUE, equipmentFilter, true);
target.withChooseHint("equip to " + dwarf.getLogName());
controller.choose(outcome, target, source.getId(), game);
for (UUID targetId : target.getTargets()) {
dwarf.addAttachment(targetId, source, game);
game.informPlayers(game.getPermanent(targetId).getLogName() + " was attached to " + dwarf.getLogName());
}
}
}
return true;
}
}

View file

@ -29,6 +29,7 @@ public final class Kaldheim extends ExpansionSet {
this.maxCardNumberInBooster = 285; this.maxCardNumberInBooster = 285;
cards.add(new SetCardInfo("Absorb Identity", 383, Rarity.UNCOMMON, mage.cards.a.AbsorbIdentity.class)); cards.add(new SetCardInfo("Absorb Identity", 383, Rarity.UNCOMMON, mage.cards.a.AbsorbIdentity.class));
cards.add(new SetCardInfo("Armed and Armored", 379, Rarity.UNCOMMON, mage.cards.a.ArmedAndArmored.class));
cards.add(new SetCardInfo("Barkchannel Pathway", 251, Rarity.RARE, mage.cards.b.BarkchannelPathway.class)); cards.add(new SetCardInfo("Barkchannel Pathway", 251, Rarity.RARE, mage.cards.b.BarkchannelPathway.class));
cards.add(new SetCardInfo("Bearded Axe", 388, Rarity.UNCOMMON, mage.cards.b.BeardedAxe.class)); cards.add(new SetCardInfo("Bearded Axe", 388, Rarity.UNCOMMON, mage.cards.b.BeardedAxe.class));
cards.add(new SetCardInfo("Blightstep Pathway", 252, Rarity.RARE, mage.cards.b.BlightstepPathway.class)); cards.add(new SetCardInfo("Blightstep Pathway", 252, Rarity.RARE, mage.cards.b.BlightstepPathway.class));