mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
* Scry effect - Added message to the game log, how many cards were put on bottom of the library.
This commit is contained in:
parent
b4a1e79f85
commit
478bd3979b
1 changed files with 41 additions and 33 deletions
|
@ -66,45 +66,53 @@ public class ScryEffect extends OneShotEffect<ScryEffect> {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
Cards cards = new CardsImpl(Zone.PICK);
|
if (player != null) {
|
||||||
int count = Math.min(scryNumber, player.getLibrary().size());
|
Cards cards = new CardsImpl(Zone.PICK);
|
||||||
if (count == 0) {
|
int count = Math.min(scryNumber, player.getLibrary().size());
|
||||||
return false;
|
if (count == 0) {
|
||||||
}
|
return false;
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
Card card = player.getLibrary().removeFromTop(game);
|
|
||||||
cards.add(card);
|
|
||||||
game.setZone(card.getId(), Zone.PICK);
|
|
||||||
}
|
|
||||||
TargetCard target1 = new TargetCard(Zone.PICK, filter1);
|
|
||||||
// move cards to the bottom of the library
|
|
||||||
while (cards.size() > 0 && player.choose(Outcome.Detriment, cards, target1, game)) {
|
|
||||||
Card card = cards.get(target1.getFirstTarget(), game);
|
|
||||||
if (card != null) {
|
|
||||||
cards.remove(card);
|
|
||||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, false);
|
|
||||||
}
|
}
|
||||||
target1.clearChosen();
|
for (int i = 0; i < count; i++) {
|
||||||
}
|
Card card = player.getLibrary().removeFromTop(game);
|
||||||
// move cards to the top of the library
|
cards.add(card);
|
||||||
if (cards.size() > 1) {
|
game.setZone(card.getId(), Zone.PICK);
|
||||||
TargetCard target2 = new TargetCard(Zone.PICK, filter2);
|
}
|
||||||
target2.setRequired(true);
|
TargetCard target1 = new TargetCard(Zone.PICK, filter1);
|
||||||
while (cards.size() > 1) {
|
// move cards to the bottom of the library
|
||||||
player.choose(Outcome.Benefit, cards, target2, game);
|
while (cards.size() > 0 && player.choose(Outcome.Detriment, cards, target1, game)) {
|
||||||
Card card = cards.get(target2.getFirstTarget(), game);
|
Card card = cards.get(target1.getFirstTarget(), game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
cards.remove(card);
|
cards.remove(card);
|
||||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
card.moveToZone(Zone.LIBRARY, source.getId(), game, false);
|
||||||
}
|
}
|
||||||
target2.clearChosen();
|
target1.clearChosen();
|
||||||
}
|
}
|
||||||
|
// move cards to the top of the library
|
||||||
|
int onTop = cards.size();
|
||||||
|
if (cards.size() > 1) {
|
||||||
|
TargetCard target2 = new TargetCard(Zone.PICK, filter2);
|
||||||
|
target2.setRequired(true);
|
||||||
|
while (cards.size() > 1) {
|
||||||
|
player.choose(Outcome.Benefit, cards, target2, game);
|
||||||
|
Card card = cards.get(target2.getFirstTarget(), game);
|
||||||
|
if (card != null) {
|
||||||
|
cards.remove(card);
|
||||||
|
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
||||||
|
}
|
||||||
|
target2.clearChosen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cards.size() == 1) {
|
||||||
|
Card card = cards.get(cards.iterator().next(), game);
|
||||||
|
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
||||||
|
}
|
||||||
|
game.informPlayers(new StringBuilder(player.getName()).append(" puts ")
|
||||||
|
.append(onTop).append(onTop == 1 ?" card":"cards")
|
||||||
|
.append(" on the bottom of his or her library (scry ")
|
||||||
|
.append(scryNumber).append(")").toString());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (cards.size() == 1) {
|
return false;
|
||||||
Card card = cards.get(cards.iterator().next(), game);
|
|
||||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue