Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[don't merge] implement [UNF] Xenosquirrels #12742

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions Mage.Sets/src/mage/cards/x/Xenosquirrels.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package mage.cards.x;

import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.RollDieEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;

import java.util.UUID;

/**
* @author tiera3 - based on SnickeringSquirrel.java, Magmasaur.java, JinnieFayJetmirsSecond.java
*/
public final class Xenosquirrels extends CardImpl {

public Xenosquirrels(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}");
this.subtype.add(SubType.ALIEN, SubType.SQUIRREL);
this.power = new MageInt(0);
this.toughness = new MageInt(0);

// Xenosquirrels enters with two +1/+1 counters on it.
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(
CounterType.P1P1.createInstance(2), true
), "with two +1/+1 counters on it"));

// After you roll a die, you may remove a +1/+1 counter from Xenosquirrels. If you do, increase or decrease the result by 1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new XenosquirrelsEffect()));
}

private Xenosquirrels(final Xenosquirrels card) {
super(card);
}

@Override
public Xenosquirrels copy() {
return new Xenosquirrels(this);
}
}

class XenosquirrelsEffect extends ReplacementEffectImpl {

XenosquirrelsEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "After you roll a die, you may remove a +1/+1 counter from Xenosquirrels. If you do, increase or decrease the result by 1.";
}

private XenosquirrelsEffect(final XenosquirrelsEffect effect) {
super(effect);
}

public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
Player dieRoller = game.getPlayer(event.getPlayerId());
if (controller == null || dieRoller == null || controller != dieRoller) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't compare Player objects directly, compare UUID using equals

return false;
}
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null || 0 == permanent.getCounters(game).getCount(CounterType.P1P1) ) {
return false;
}
if (controller.chooseUse(outcome, "Remove a +1/+1 counter from " + permanent.getLogName() + " to increase or decrease the result of a die ("
+ event.getAmount() + ") by 1?", source, game)) {
permanent.removeCounters(CounterType.P1P1.getName(), 1, source, game);
((RollDieEvent) event).incResultModifier( player.chooseUse(
outcome, "Increase or Decrease " + event.getAmount() + " by 1", null,
"Increase", "Decrease", source, game ) ? 1 : -1 );
}
return false;
}

@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ROLL_DIE
&& ((RollDieEvent) event).getRollDieType() == RollDieType.NUMERICAL;
}

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return source.isControlledBy(event.getPlayerId());
}

@Override
public XenosquirrelsEffect copy() {
return new XenosquirrelsEffect(this);
}
}
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/sets/Unfinity.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ private Unfinity() {
cards.add(new SetCardInfo("The Space Family Goblinson", 179, Rarity.UNCOMMON, mage.cards.t.TheSpaceFamilyGoblinson.class));
cards.add(new SetCardInfo("Vegetation Abomination", 160, Rarity.COMMON, mage.cards.v.VegetationAbomination.class));
cards.add(new SetCardInfo("Watery Grave", 278, Rarity.RARE, mage.cards.w.WateryGrave.class));
cards.add(new SetCardInfo("Xenosquirrels", 96, Rarity.COMMON, mage.cards.x.Xenosquirrels.class));
}
}
Loading