mirror of
https://github.com/correl/mage.git
synced 2024-12-27 20:06:31 +00:00
[SNC] Fixes for Scheming Fence
This commit is contained in:
commit
c8331bf846
1 changed files with 36 additions and 16 deletions
|
@ -77,10 +77,11 @@ class SchemingFenceChooseEffect extends OneShotEffect {
|
||||||
@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());
|
||||||
Permanent mageObject = game.getPermanentEntering(source.getSourceId());
|
Permanent schemingFencePermanent = game.getPermanentEntering(source.getSourceId());
|
||||||
if (controller == null || mageObject == null) {
|
if (controller == null || schemingFencePermanent == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetPermanent target = new TargetNonlandPermanent(0, 1, true);
|
TargetPermanent target = new TargetNonlandPermanent(0, 1, true);
|
||||||
controller.choose(this.outcome, target, source, game);
|
controller.choose(this.outcome, target, source, game);
|
||||||
Permanent chosenPermanent = game.getPermanent(target.getFirstTarget());
|
Permanent chosenPermanent = game.getPermanent(target.getFirstTarget());
|
||||||
|
@ -88,10 +89,10 @@ class SchemingFenceChooseEffect extends OneShotEffect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
game.getState().setValue(
|
game.getState().setValue(
|
||||||
mageObject.getId() + "_chosenPermanent",
|
schemingFencePermanent.getId() + "_chosenPermanent",
|
||||||
new MageObjectReference(chosenPermanent, game)
|
new MageObjectReference(chosenPermanent, game)
|
||||||
);
|
);
|
||||||
mageObject.addInfo(
|
schemingFencePermanent.addInfo(
|
||||||
"chosen permanent",
|
"chosen permanent",
|
||||||
CardUtil.addToolTipMarkTags(
|
CardUtil.addToolTipMarkTags(
|
||||||
"Chosen permanent: " + chosenPermanent.getIdName()
|
"Chosen permanent: " + chosenPermanent.getIdName()
|
||||||
|
@ -129,12 +130,22 @@ class SchemingFenceDisableEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
return Optional.of(game.getState().getValue(source.getId() + "_chosenPermanent"))
|
Permanent sourcePermanent = game.getState().getPermanent(source.getSourceId());
|
||||||
.filter(Objects::nonNull)
|
if (sourcePermanent == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MageObjectReference chosenPermanentMOR = (MageObjectReference) game.getState().getValue(sourcePermanent.getId() + "_chosenPermanent");
|
||||||
|
if (chosenPermanentMOR == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.of(chosenPermanentMOR)
|
||||||
.map(MageObjectReference.class::cast)
|
.map(MageObjectReference.class::cast)
|
||||||
.filter(mor -> mor.zoneCounterIsCurrent(game))
|
.filter(mor -> mor.zoneCounterIsCurrent(game))
|
||||||
.map(MageObjectReference::getSourceId)
|
.map(MageObjectReference::getSourceId) // TODO: Are both of this line and the next one necessary?
|
||||||
.equals(event.getSourceId());
|
.map(uuid -> uuid.equals(event.getSourceId()))
|
||||||
|
.orElse(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,20 +168,29 @@ class SchemingFenceGainEffect extends ContinuousEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||||
Permanent chosen = Optional.of(game.getState().getValue(source.getId() + "_chosenPermanent"))
|
if (permanent == null) {
|
||||||
.filter(Objects::nonNull)
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MageObjectReference chosenPermanentMOR = (MageObjectReference) game.getState().getValue(source.getSourceId() + "_chosenPermanent");
|
||||||
|
if (chosenPermanentMOR == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Permanent chosenPermanent = Optional.of(chosenPermanentMOR)
|
||||||
.map(MageObjectReference.class::cast)
|
.map(MageObjectReference.class::cast)
|
||||||
.map(mor -> mor.getPermanent(game))
|
.map(mor -> mor.getPermanent(game))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (permanent == null || chosen == null) {
|
if (chosenPermanent == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (Ability ability : chosen.getAbilities(game).getActivatedAbilities(Zone.ALL)) {
|
|
||||||
if (ability instanceof LoyaltyAbility) {
|
for (Ability ability : chosenPermanent.getAbilities(game).getActivatedAbilities(Zone.ALL)) {
|
||||||
|
if (!(ability instanceof LoyaltyAbility)) {
|
||||||
|
Ability copied = ability.copy();
|
||||||
|
ability.getEffects().setValue("schemingFence", source.getSourceId());
|
||||||
|
permanent.addAbility(copied, source.getSourceId(), game);
|
||||||
}
|
}
|
||||||
Ability copied = ability.copy();
|
|
||||||
ability.getEffects().setValue("schemingFence", source.getSourceId());
|
|
||||||
permanent.addAbility(ability, source.getSourceId(), game);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue