mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 06:22:01 -08:00
[MKM] Implement No Witnesses
This commit is contained in:
parent
1a8dce83d0
commit
fe97d3d77b
4 changed files with 107 additions and 14 deletions
88
Mage.Sets/src/mage/cards/n/NoWitnesses.java
Normal file
88
Mage.Sets/src/mage/cards/n/NoWitnesses.java
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
package mage.cards.n;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DestroyAllEffect;
|
||||
import mage.abilities.effects.keyword.InvestigateEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Controllable;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class NoWitnesses extends CardImpl {
|
||||
|
||||
public NoWitnesses(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{W}{W}");
|
||||
|
||||
// Each player who controls the most creatures investigates. Then destroy all creatures.
|
||||
this.getSpellAbility().addEffect(new NoWitnessesEffect());
|
||||
this.getSpellAbility().addEffect(new DestroyAllEffect(StaticFilters.FILTER_PERMANENT_CREATURES).concatBy("Then"));
|
||||
}
|
||||
|
||||
private NoWitnesses(final NoWitnesses card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoWitnesses copy() {
|
||||
return new NoWitnesses(this);
|
||||
}
|
||||
}
|
||||
|
||||
class NoWitnessesEffect extends OneShotEffect {
|
||||
|
||||
NoWitnessesEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "each player who controls the most creatures investigates";
|
||||
}
|
||||
|
||||
private NoWitnessesEffect(final NoWitnessesEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoWitnessesEffect copy() {
|
||||
return new NoWitnessesEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Map<UUID, Integer> map = game
|
||||
.getBattlefield()
|
||||
.getActivePermanents(
|
||||
StaticFilters.FILTER_PERMANENT_CREATURE,
|
||||
source.getControllerId(), source, game
|
||||
)
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(Controllable::getControllerId)
|
||||
.collect(Collectors.toMap(Function.identity(), x -> 1, Integer::sum));
|
||||
if (map.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
int maxValue = map
|
||||
.values()
|
||||
.stream()
|
||||
.mapToInt(x -> x)
|
||||
.max()
|
||||
.orElse(0);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
if (map.getOrDefault(playerId, -1) >= maxValue) {
|
||||
InvestigateEffect.doInvestigate(playerId, 1, game, source);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -65,6 +65,7 @@ public final class MurdersAtKarlovManor extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Mountain", 275, Rarity.LAND, mage.cards.basiclands.Mountain.class, FULL_ART_BFZ_VARIOUS));
|
||||
cards.add(new SetCardInfo("Nightdrinker Moroii", 96, Rarity.UNCOMMON, mage.cards.n.NightdrinkerMoroii.class));
|
||||
cards.add(new SetCardInfo("No More Lies", 221, Rarity.UNCOMMON, mage.cards.n.NoMoreLies.class));
|
||||
cards.add(new SetCardInfo("No Witnesses", 27, Rarity.RARE, mage.cards.n.NoWitnesses.class));
|
||||
cards.add(new SetCardInfo("Not on My Watch", 28, Rarity.UNCOMMON, mage.cards.n.NotOnMyWatch.class));
|
||||
cards.add(new SetCardInfo("Novice Inspector", 29, Rarity.COMMON, mage.cards.n.NoviceInspector.class));
|
||||
cards.add(new SetCardInfo("Out Cold", 66, Rarity.COMMON, mage.cards.o.OutCold.class));
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.permanent.token.ClueArtifactToken;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
|
@ -39,14 +41,21 @@ public class InvestigateEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int value = this.amount.calculate(game, source, this);
|
||||
if (value < 1) {
|
||||
return false;
|
||||
if (value > 0) {
|
||||
doInvestigate(source.getControllerId(), value, game, source);
|
||||
return true;
|
||||
}
|
||||
new ClueArtifactToken().putOntoBattlefield(value, game, source, source.getControllerId());
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void doInvestigate(UUID playerId, int value, Game game, Ability source) {
|
||||
new ClueArtifactToken().putOntoBattlefield(value, game, source, playerId);
|
||||
for (int i = 0; i < value; i++) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.INVESTIGATED, source.getSourceId(), source, source.getControllerId()));
|
||||
game.fireEvent(GameEvent.getEvent(
|
||||
GameEvent.EventType.INVESTIGATED,
|
||||
source.getSourceId(), source, playerId
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ import mage.abilities.dynamicvalue.common.StaticValue;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.token.ClueArtifactToken;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
|
@ -43,14 +41,11 @@ public class InvestigateTargetEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
int value = this.amount.calculate(game, source, this);
|
||||
if (value < 1) {
|
||||
return false;
|
||||
if (value > 0) {
|
||||
InvestigateEffect.doInvestigate(targetPlayer.getId(), value, game, source);
|
||||
return true;
|
||||
}
|
||||
new ClueArtifactToken().putOntoBattlefield(value, game, source, targetPlayer.getId());
|
||||
for (int i = 0; i < value; i++) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.INVESTIGATED, source.getSourceId(), source, targetPlayer.getId()));
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue