mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
* Karona, False God - Reworked gain control handling.
This commit is contained in:
parent
eb767b13a6
commit
3eb2531cee
2 changed files with 42 additions and 30 deletions
|
@ -62,7 +62,7 @@ import mage.target.targetpointer.FixedTarget;
|
||||||
public class KaronaFalseGod extends CardImpl {
|
public class KaronaFalseGod extends CardImpl {
|
||||||
|
|
||||||
public KaronaFalseGod(UUID ownerId, CardSetInfo setInfo) {
|
public KaronaFalseGod(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}{U}{B}{R}{G}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{U}{B}{R}{G}");
|
||||||
this.supertype.add("Legendary");
|
this.supertype.add("Legendary");
|
||||||
this.subtype.add("Avatar");
|
this.subtype.add("Avatar");
|
||||||
|
|
||||||
|
@ -71,10 +71,10 @@ public class KaronaFalseGod extends CardImpl {
|
||||||
|
|
||||||
// Haste
|
// Haste
|
||||||
this.addAbility(HasteAbility.getInstance());
|
this.addAbility(HasteAbility.getInstance());
|
||||||
|
|
||||||
// At the beginning of each player's upkeep, that player untaps Karona, False God and gains control of it.
|
// At the beginning of each player's upkeep, that player untaps Karona, False God and gains control of it.
|
||||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new KaronaFalseGodUntapGetControlEffect(), TargetController.ANY, false, true));
|
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new KaronaFalseGodUntapGetControlEffect(), TargetController.ANY, false, true));
|
||||||
|
|
||||||
// Whenever Karona attacks, creatures of the creature type of your choice get +3/+3 until end of turn.
|
// Whenever Karona attacks, creatures of the creature type of your choice get +3/+3 until end of turn.
|
||||||
this.addAbility(new AttacksTriggeredAbility(new KaronaFalseGodEffect(), false));
|
this.addAbility(new AttacksTriggeredAbility(new KaronaFalseGodEffect(), false));
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ class KaronaFalseGodUntapGetControlEffect extends OneShotEffect {
|
||||||
|
|
||||||
public KaronaFalseGodUntapGetControlEffect() {
|
public KaronaFalseGodUntapGetControlEffect() {
|
||||||
super(Outcome.GainControl);
|
super(Outcome.GainControl);
|
||||||
this.staticText = "that player untaps Karona, False God and gains control of it";
|
this.staticText = "that player untaps {this} and gains control of it";
|
||||||
}
|
}
|
||||||
|
|
||||||
public KaronaFalseGodUntapGetControlEffect(final KaronaFalseGodUntapGetControlEffect effect) {
|
public KaronaFalseGodUntapGetControlEffect(final KaronaFalseGodUntapGetControlEffect effect) {
|
||||||
|
@ -110,9 +110,23 @@ class KaronaFalseGodUntapGetControlEffect extends OneShotEffect {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = source.getSourceObject(game);
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||||
if (controller != null && sourceObject != null && sourceObject.equals(sourcePermanent)) {
|
Player newController = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||||
|
if (newController != null && controller != null && sourceObject != null && sourceObject.equals(sourcePermanent)) {
|
||||||
sourcePermanent.untap(game);
|
sourcePermanent.untap(game);
|
||||||
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, getTargetPointer().getFirst(game, source));
|
game.informPlayers(newController.getLogName() + " untaps " + sourceObject.getIdName());
|
||||||
|
// remove old control effects of the same player
|
||||||
|
for (ContinuousEffect effect : game.getState().getContinuousEffects().getLayeredEffects(game)) {
|
||||||
|
if (effect instanceof GainControlTargetEffect) {
|
||||||
|
UUID checkId = (UUID) ((GainControlTargetEffect) effect).getValue("KaronaFalseGodSourceId");
|
||||||
|
UUID controllerId = (UUID) ((GainControlTargetEffect) effect).getValue("KaronaFalseGodControllerId");
|
||||||
|
if (source.getSourceId().equals(checkId) && newController.getId().equals(controllerId)) {
|
||||||
|
effect.discard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, newController.getId());
|
||||||
|
effect.setValue("KaronaFalseGodSourceId", source.getSourceId());
|
||||||
|
effect.setValue("KaronaFalseGodControllerId", newController.getId());
|
||||||
effect.setTargetPointer(new FixedTarget(sourcePermanent.getId()));
|
effect.setTargetPointer(new FixedTarget(sourcePermanent.getId()));
|
||||||
effect.setText("and gains control of it");
|
effect.setText("and gains control of it");
|
||||||
game.addEffect(effect, source);
|
game.addEffect(effect, source);
|
||||||
|
@ -123,21 +137,21 @@ class KaronaFalseGodUntapGetControlEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
class KaronaFalseGodEffect extends OneShotEffect {
|
class KaronaFalseGodEffect extends OneShotEffect {
|
||||||
|
|
||||||
public KaronaFalseGodEffect() {
|
public KaronaFalseGodEffect() {
|
||||||
super(Outcome.BoostCreature);
|
super(Outcome.BoostCreature);
|
||||||
this.staticText = "creatures of the creature type of your choice get +3/+3 until end of turn";
|
this.staticText = "creatures of the creature type of your choice get +3/+3 until end of turn";
|
||||||
}
|
}
|
||||||
|
|
||||||
public KaronaFalseGodEffect(final KaronaFalseGodEffect effect) {
|
public KaronaFalseGodEffect(final KaronaFalseGodEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KaronaFalseGodEffect copy() {
|
public KaronaFalseGodEffect copy() {
|
||||||
return new KaronaFalseGodEffect(this);
|
return new KaronaFalseGodEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
@ -156,7 +170,7 @@ class KaronaFalseGodEffect extends OneShotEffect {
|
||||||
game.informPlayers(controller.getLogName() + " has chosen " + typeChosen);
|
game.informPlayers(controller.getLogName() + " has chosen " + typeChosen);
|
||||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||||
filter.add(new SubtypePredicate(typeChosen));
|
filter.add(new SubtypePredicate(typeChosen));
|
||||||
game.addEffect(new BoostAllEffect(3,3,Duration.EndOfTurn, filter, false), source);
|
game.addEffect(new BoostAllEffect(3, 3, Duration.EndOfTurn, filter, false), source);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,8 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param duration
|
* @param duration
|
||||||
* @param fixedControl Controlling player is fixed even if the controller of the ability changes later
|
* @param fixedControl Controlling player is fixed even if the controller of
|
||||||
|
* the ability changes later
|
||||||
*/
|
*/
|
||||||
public GainControlTargetEffect(Duration duration, boolean fixedControl) {
|
public GainControlTargetEffect(Duration duration, boolean fixedControl) {
|
||||||
this(duration, fixedControl, null);
|
this(duration, fixedControl, null);
|
||||||
|
@ -104,23 +105,22 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
boolean targetStillExists = false;
|
boolean targetStillExists = false;
|
||||||
for (UUID permanentId: getTargetPointer().getTargets(game, source)) {
|
for (UUID permanentId : getTargetPointer().getTargets(game, source)) {
|
||||||
Permanent permanent = game.getPermanent(permanentId);
|
Permanent permanent = game.getPermanent(permanentId);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
targetStillExists = true;
|
targetStillExists = true;
|
||||||
|
if (!permanent.getControllerId().equals(controllingPlayerId)) {
|
||||||
GameEvent loseControlEvent = GameEvent.getEvent(GameEvent.EventType.LOSE_CONTROL, permanentId, source.getId(), permanent.getControllerId());
|
GameEvent loseControlEvent = GameEvent.getEvent(GameEvent.EventType.LOSE_CONTROL, permanentId, source.getId(), permanent.getControllerId());
|
||||||
|
if (game.replaceEvent(loseControlEvent)) {
|
||||||
if (game.replaceEvent(loseControlEvent)) {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
if (controllingPlayerId != null) {
|
||||||
|
permanent.changeControllerId(controllingPlayerId, game);
|
||||||
if (controllingPlayerId != null) {
|
permanent.getAbilities().setControllerId(controllingPlayerId);
|
||||||
permanent.changeControllerId(controllingPlayerId, game);
|
} else {
|
||||||
permanent.getAbilities().setControllerId(controllingPlayerId);
|
permanent.changeControllerId(source.getControllerId(), game);
|
||||||
} else {
|
permanent.getAbilities().setControllerId(source.getControllerId());
|
||||||
permanent.changeControllerId(source.getControllerId(), game);
|
}
|
||||||
permanent.getAbilities().setControllerId(source.getControllerId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,16 +140,14 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
|
||||||
}
|
}
|
||||||
Target target = mode.getTargets().get(0);
|
Target target = mode.getTargets().get(0);
|
||||||
StringBuilder sb = new StringBuilder("gain control of ");
|
StringBuilder sb = new StringBuilder("gain control of ");
|
||||||
if (target.getMaxNumberOfTargets() > 1){
|
if (target.getMaxNumberOfTargets() > 1) {
|
||||||
if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) {
|
if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) {
|
||||||
sb.append("up to ");
|
sb.append("up to ");
|
||||||
}
|
}
|
||||||
sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" target ");
|
sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" target ");
|
||||||
} else {
|
} else if (!target.getTargetName().startsWith("another")) {
|
||||||
if (!target.getTargetName().startsWith("another")) {
|
|
||||||
sb.append("target ");
|
sb.append("target ");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
sb.append(mode.getTargets().get(0).getTargetName());
|
sb.append(mode.getTargets().get(0).getTargetName());
|
||||||
if (!duration.toString().isEmpty()) {
|
if (!duration.toString().isEmpty()) {
|
||||||
sb.append(" ").append(duration.toString());
|
sb.append(" ").append(duration.toString());
|
||||||
|
|
Loading…
Reference in a new issue