mirror of
https://github.com/correl/mage.git
synced 2025-01-13 11:01:58 +00:00
Plenty of Panglacial Wurm fixes
This commit is contained in:
parent
549fb0fb22
commit
d671c2a06c
1 changed files with 52 additions and 8 deletions
|
@ -2322,17 +2322,14 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
boolean finishedSearch = false;
|
||||
while (true) {
|
||||
if (newTarget.choose(Outcome.Neutral, playerId, targetPlayerId, game)) {
|
||||
target.getTargets().clear();
|
||||
for (UUID targetId : newTarget.getTargets()) {
|
||||
target.add(targetId, game);
|
||||
}
|
||||
finishedSearch = true;
|
||||
}
|
||||
Card pickedCard = game.getCard(newTarget.getTargets().get(0));
|
||||
if (pickedCard != null) {
|
||||
}
|
||||
if (!targetPlayerId.equals(playerId) || handleLibraryCastableCreatures(library, game, targetPlayerId, newTarget)) { // for handling Panglacial Wurm
|
||||
if (!targetPlayerId.equals(playerId) || handleLibraryCastableCreatures(library, game, targetPlayerId)) { // for handling Panglacial Wurm
|
||||
if (finishedSearch) {
|
||||
target.getTargets().clear();
|
||||
for (UUID targetId : newTarget.getTargets()) {
|
||||
target.add(targetId, game);
|
||||
}
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LIBRARY_SEARCHED, targetPlayerId, playerId));
|
||||
}
|
||||
break;
|
||||
|
@ -2345,6 +2342,53 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean handleLibraryCastableCreatures(Library library, Game game, UUID targetPlayerId) {
|
||||
// for handling Panglacial Wurm
|
||||
Map<UUID, String> libraryCastableCardTracker = new HashMap<>();
|
||||
for (Card card : library.getCards(game)) {
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability.getClass() == WhileSearchingPlayFromLibraryAbility.class) {
|
||||
libraryCastableCardTracker.put(card.getId(), card.getName() + " [" + card.getId().toString().substring(0, 3) + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!libraryCastableCardTracker.isEmpty()) {
|
||||
Player player = game.getPlayer(targetPlayerId);
|
||||
if (player != null) {
|
||||
if (player.isHuman() && player.chooseUse(Outcome.AIDontUseIt, "Cast a creature card from your library? (choose \"No\" to finish search)", null, game)) {
|
||||
ChoiceImpl chooseCard = new ChoiceImpl();
|
||||
chooseCard.setMessage("Which creature do you wish to cast from your library?");
|
||||
Set<String> choice = new LinkedHashSet<>();
|
||||
for (Entry<UUID, String> entry : libraryCastableCardTracker.entrySet()) {
|
||||
choice.add(new AbstractMap.SimpleEntry<UUID, String>(entry).getValue());
|
||||
}
|
||||
chooseCard.setChoices(choice);
|
||||
while (!choice.isEmpty()) {
|
||||
if (player.choose(Outcome.AIDontUseIt, chooseCard, game)) {
|
||||
String chosenCard = chooseCard.getChoice();
|
||||
for (Entry<UUID, String> entry : libraryCastableCardTracker.entrySet()) {
|
||||
if (chosenCard.equals(entry.getValue())) {
|
||||
Card card = game.getCard(entry.getKey());
|
||||
if (card != null) {
|
||||
// TODO: fix costs (why is Panglacial Wurm automatically accepting payment?)
|
||||
if (player.cast(card.getSpellAbility(), game, false)) {
|
||||
choice.remove(chosenCard);
|
||||
chooseCard.setChoices(choice);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean handleLibraryCastableCreatures(Library library, Game game, UUID targetPlayerId, TargetCardInLibrary newTarget) {
|
||||
// for handling Panglacial Wurm
|
||||
Map<UUID, String> libraryCastableCardTracker = new HashMap<>();
|
||||
|
|
Loading…
Reference in a new issue