mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 13:32:06 -08:00
[MH2] Implemented Lucid Dreams
This commit is contained in:
parent
b3ac432377
commit
4127030c9d
48 changed files with 241 additions and 212 deletions
|
|
@ -0,0 +1,82 @@
|
|||
package mage.abilities.hint.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.CardType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public enum CardTypesInGraveyardHint implements Hint {
|
||||
YOU("your graveyard"),
|
||||
ALL("all graveyards"),
|
||||
OPPONENTS("your opponents' graveyards");
|
||||
private final String message;
|
||||
|
||||
CardTypesInGraveyardHint(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Game game, Ability ability) {
|
||||
Stream<Card> stream = getStream(game, ability);
|
||||
if (stream == null) {
|
||||
return null;
|
||||
}
|
||||
List<String> types = stream
|
||||
.map(MageObject::getCardType)
|
||||
.flatMap(Collection::stream)
|
||||
.distinct()
|
||||
.map(CardType::toString)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
String message = "" + types.size();
|
||||
if (types.size() > 0) {
|
||||
message += " (" + String.join(" , ", types) + ')';
|
||||
}
|
||||
return "Card types in " + message + ": " + message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hint copy() {
|
||||
return YOU;
|
||||
}
|
||||
|
||||
private final Stream<Card> getStream(Game game, Ability ability) {
|
||||
Collection<UUID> playerIds;
|
||||
switch (this) {
|
||||
case YOU:
|
||||
Player player = game.getPlayer(ability.getControllerId());
|
||||
return player == null
|
||||
? null : player
|
||||
.getGraveyard()
|
||||
.getCards(game)
|
||||
.stream();
|
||||
case OPPONENTS:
|
||||
playerIds = game.getOpponents(ability.getControllerId());
|
||||
break;
|
||||
case ALL:
|
||||
playerIds = game.getState().getPlayersInRange(ability.getControllerId(), game);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return playerIds.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.map(Player::getGraveyard)
|
||||
.map(graveyard -> graveyard.getCards(game))
|
||||
.flatMap(Collection::stream);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
package mage.abilities.hint.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.constants.CardType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public enum DeliriumHint implements Hint {
|
||||
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public String getText(Game game, Ability ability) {
|
||||
Player player = game.getPlayer(ability.getControllerId());
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
List<String> types = player
|
||||
.getGraveyard()
|
||||
.getCards(game)
|
||||
.stream()
|
||||
.map(MageObject::getCardType)
|
||||
.flatMap(Collection::stream)
|
||||
.distinct()
|
||||
.map(CardType::toString)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
String message = "" + types.size();
|
||||
if (types.size() > 0) {
|
||||
message += " (";
|
||||
message += types.stream().reduce((a, b) -> a + ", " + b).orElse("");
|
||||
message += ')';
|
||||
}
|
||||
return "Card types in your graveyard: " + message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hint copy() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue