mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 12:22:10 -08:00
* Simplified flip handling. Flip continiuous effect has now time stamp of time the card flipped so it works with copied cards.
This commit is contained in:
parent
948449ee13
commit
85e90881c1
14 changed files with 33 additions and 112 deletions
|
|
@ -1,10 +1,14 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.common.FlippedCondition;
|
||||
import mage.abilities.decorator.ConditionalContinousEffect;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -12,20 +16,28 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class FlipSourceEffect extends OneShotEffect<FlipSourceEffect> {
|
||||
|
||||
public FlipSourceEffect() {
|
||||
private final Token flipToken;
|
||||
|
||||
public FlipSourceEffect(Token flipToken) {
|
||||
super(Outcome.BecomeCreature);
|
||||
this.flipToken = flipToken;
|
||||
staticText = "flip it";
|
||||
}
|
||||
|
||||
public FlipSourceEffect(final FlipSourceEffect effect) {
|
||||
super(effect);
|
||||
this.flipToken = effect.flipToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
return p.flip(game);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
if (permanent.flip(game)) {
|
||||
ContinuousEffect effect = new ConditionalContinousEffect(new CopyTokenEffect(flipToken), FlippedCondition.getInstance(), "");
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue