mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
[PCY] reworked Celestial Convergence
This commit is contained in:
parent
0bd402876d
commit
5547d04938
1 changed files with 36 additions and 46 deletions
|
@ -1,9 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
import mage.abilities.common.EntersBattlefieldAbility;
|
import mage.abilities.common.EntersBattlefieldAbility;
|
||||||
|
@ -11,7 +7,6 @@ import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||||
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
|
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
@ -20,10 +15,12 @@ import mage.constants.TargetController;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class CelestialConvergence extends CardImpl {
|
public final class CelestialConvergence extends CardImpl {
|
||||||
|
@ -70,49 +67,42 @@ class CelestialConvergenceEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Card sourceObject = game.getCard(source.getSourceId());
|
Permanent sourcePermanent = source.getSourcePermanentOrLKI(game);
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (sourceObject != null
|
if (sourcePermanent == null || controller == null
|
||||||
&& controller != null
|
|| sourcePermanent.getCounters(game).getCount(CounterType.OMEN) > 0) {
|
||||||
&& sourceObject.getCounters(game).getCount(CounterType.OMEN) == 0) {
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 801.14. If an effect states that a player wins the game, all of
|
* 801.14. If an effect states that a player wins the game, all of
|
||||||
* that player's opponents within their range of influence lose the
|
* that player's opponents within their range of influence lose the
|
||||||
* game instead. #
|
* game instead. #
|
||||||
*
|
*
|
||||||
* 801.15. If the effect of a spell or ability states that the game
|
* 801.15. If the effect of a spell or ability states that the game
|
||||||
* is a draw, the game is a draw for that spell or ability's
|
* is a draw, the game is a draw for that spell or ability's
|
||||||
* controller and all players within their range of influence. They
|
* controller and all players within their range of influence. They
|
||||||
* leave the game. All remaining players continue to play the game.
|
* leave the game. All remaining players continue to play the game.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
List<UUID> highestLifePlayers = new ArrayList<>();
|
Map<Integer, Set<UUID>> playerMap = new HashMap<>();
|
||||||
int highLife = Integer.MIN_VALUE;
|
game.getState()
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
.getPlayersInRange(controller.getId(), game)
|
||||||
Player player = game.getPlayer(playerId);
|
.stream()
|
||||||
if (player != null) {
|
.map(game::getPlayer)
|
||||||
if (player.getLife() > highLife) {
|
.filter(Objects::nonNull)
|
||||||
highestLifePlayers.clear();
|
.forEach(player -> playerMap.computeIfAbsent(
|
||||||
highestLifePlayers.add(player.getId());
|
player.getLife(), x -> new HashSet<>()
|
||||||
} else if (player.getLife() == highLife) {
|
).add(player.getId()));
|
||||||
highestLifePlayers.add(player.getId());
|
int highLife = playerMap.keySet().stream().mapToInt(x -> x).max().orElse(Integer.MIN_VALUE);
|
||||||
}
|
if (playerMap.get(highLife).size() > 1) {
|
||||||
}
|
game.setDraw(controller.getId());
|
||||||
}
|
|
||||||
if (highestLifePlayers.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (highestLifePlayers.size() > 1) {
|
|
||||||
game.setDraw(controller.getId());
|
|
||||||
} else {
|
|
||||||
Player winner = game.getPlayer(highestLifePlayers.iterator().next());
|
|
||||||
if (winner != null) {
|
|
||||||
winner.won(game);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
Player winner = game.getPlayer(playerMap.get(highLife).iterator().next());
|
||||||
|
if (winner != null) {
|
||||||
|
winner.won(game);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue