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

[BLB] Implement Season of Gathering and Pawprints mechanic #12617

Merged
merged 12 commits into from
Aug 15, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -2585,20 +2585,38 @@ public Mode chooseMode(Modes modes, Ability source, Game game) {
if (!modeText.isEmpty()) {
modeText = Character.toUpperCase(modeText.charAt(0)) + modeText.substring(1);
}
modeMap.put(mode.getId(), modeIndex + ". " + modeText);
StringBuilder sb = new StringBuilder();
if (mode.getPawPrintValue() > 0){
for (int i = 0; i < mode.getPawPrintValue(); ++i){
xenohedron marked this conversation as resolved.
Show resolved Hide resolved
sb.append("{P}");
}
sb.append(": ");
} else {
sb.append(modeIndex).append(". ");
}
modeMap.put(mode.getId(), sb.append(modeText).toString());
}
}

// done button for "for up" choices only
boolean canEndChoice = modes.getSelectedModes().size() >= modes.getMinModes() || modes.isMayChooseNone();
boolean canEndChoice = (modes.getSelectedModes().size() >= modes.getMinModes() && modes.getMaxPawPrints() == 0) ||
(modes.getSelectedPawPrints() >= modes.getMaxPawPrints() && modes.getMaxPawPrints() > 0) ||
modes.isMayChooseNone();
if (canEndChoice) {
modeMap.put(Modes.CHOOSE_OPTION_DONE_ID, "Done");
}
modeMap.put(Modes.CHOOSE_OPTION_CANCEL_ID, "Cancel");

// prepare dialog
String message = "Choose mode (selected " + modes.getSelectedModes().size() + " of " + modes.getMaxModes(game, source)
+ ", min " + modes.getMinModes() + ")";
String message;
if (modes.getMaxPawPrints() == 0){
message = "Choose mode (selected " + modes.getSelectedModes().size() + " of " + modes.getMaxModes(game, source)
+ ", min " + modes.getMinModes() + ")";
} else {
message = "Choose mode (selected " + modes.getSelectedPawPrints() + " of " + modes.getMaxPawPrints()
+ " {P})";
}

if (obj != null) {
message = message + "<br>" + obj.getLogName();
}
Expand Down
162 changes: 162 additions & 0 deletions Mage.Sets/src/mage/cards/s/SeasonOfGathering.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
package mage.cards.s;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.common.GreatestPowerAmongControlledCreaturesValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.*;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.targetpointer.FixedTarget;

/**
*
* @author jimga150
*/
public final class SeasonOfGathering extends CardImpl {

public SeasonOfGathering(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{G}{G}");

// Choose up to five {P} worth of modes. You may choose the same mode more than once.
this.getSpellAbility().getModes().setMaxPawPrints(5);
this.getSpellAbility().getModes().setMinModes(0);
this.getSpellAbility().getModes().setMaxModes(5);
this.getSpellAbility().getModes().setMayChooseSameModeMoreThanOnce(true);

// {P} -- Put a +1/+1 counter on a creature you control. It gains vigilance and trample until end of turn.
this.getSpellAbility().addEffect(new SeasonOfGatheringCounterEffect());
this.spellAbility.getModes().getMode().withPawPrintValue(1);

// {P}{P} -- Choose artifact or enchantment. Destroy all permanents of the chosen type.
Mode mode2 = new Mode(new SeasonOfGatheringRemovalEffect());
this.getSpellAbility().addMode(mode2.withPawPrintValue(2));

// {P}{P}{P} -- Draw cards equal to the greatest power among creatures you control.
JayDi85 marked this conversation as resolved.
Show resolved Hide resolved
Mode mode3 = new Mode(
new DrawCardSourceControllerEffect(GreatestPowerAmongControlledCreaturesValue.instance)
.setText("Draw cards equal to the greatest power among creatures you control.")
);
this.getSpellAbility().addMode(mode3.withPawPrintValue(3));
}

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

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

// Based on KaylasCommandCounterEffect
class SeasonOfGatheringCounterEffect extends OneShotEffect {

SeasonOfGatheringCounterEffect() {
super(Outcome.BoostCreature);
this.staticText = "Put a +1/+1 counter on a creature you control. It gains vigilance and trample until end of turn.";
}

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

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

@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent();
target.withNotTarget(true);
controller.chooseTarget(outcome, target, source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
return false;
}
permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
GainAbilityTargetEffect effect = new GainAbilityTargetEffect(VigilanceAbility.getInstance());
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
GainAbilityTargetEffect effect2 = new GainAbilityTargetEffect(TrampleAbility.getInstance());
effect2.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect2, source);
return true;
}
}

// Based on KindredDominanceEffect and TurnaboutEffect
class SeasonOfGatheringRemovalEffect extends OneShotEffect {

private static final Set<String> choice = new HashSet<>();

static {
choice.add(CardType.ARTIFACT.toString());
choice.add(CardType.ENCHANTMENT.toString());
}

SeasonOfGatheringRemovalEffect() {
super(Outcome.DestroyPermanent);
this.staticText = "Choose artifact or enchantment. Destroy all permanents of the chosen type.";
}

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

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

@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Choice choiceImpl = new ChoiceImpl(true);
choiceImpl.setMessage("Choose card type to destroy");
choiceImpl.setChoices(choice);
if (!controller.choose(Outcome.Neutral, choiceImpl, game)) {
return false;
}
FilterPermanent filter;
switch (choiceImpl.getChoice()) {
case "Artifact":
filter = StaticFilters.FILTER_PERMANENT_ARTIFACT;
break;
case "Enchantment":
filter = StaticFilters.FILTER_PERMANENT_ENCHANTMENT;
break;
default:
throw new IllegalArgumentException("Choice is required");
}
game.informPlayers(controller.getLogName() + " has chosen " + choiceImpl.getChoiceKey());
return new DestroyAllEffect(filter).apply(game, source);
}
}
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/sets/Bloomburrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ private Bloomburrow() {
cards.add(new SetCardInfo("Scales of Shale", 110, Rarity.COMMON, mage.cards.s.ScalesOfShale.class));
cards.add(new SetCardInfo("Scavenger's Talent", 111, Rarity.RARE, mage.cards.s.ScavengersTalent.class));
cards.add(new SetCardInfo("Scrapshooter", 191, Rarity.RARE, mage.cards.s.Scrapshooter.class));
cards.add(new SetCardInfo("Season of Gathering", 192, Rarity.MYTHIC, mage.cards.s.SeasonOfGathering.class));
cards.add(new SetCardInfo("Seasoned Warrenguard", 30, Rarity.UNCOMMON, mage.cards.s.SeasonedWarrenguard.class));
cards.add(new SetCardInfo("Seedglaive Mentor", 231, Rarity.UNCOMMON, mage.cards.s.SeedglaiveMentor.class));
cards.add(new SetCardInfo("Seedpod Squire", 232, Rarity.COMMON, mage.cards.s.SeedpodSquire.class));
Expand Down
Loading
Loading