mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
consolidate code from Player and GameAction classes related to sacrifice permanents.
This commit is contained in:
@@ -18044,7 +18044,7 @@ public class CardFactory_Creatures {
|
||||
public void resolve() {
|
||||
if (card.getController().equals(AllZone.ComputerPlayer))
|
||||
setTargetPlayer(AllZone.HumanPlayer);
|
||||
AllZone.GameAction.sacrificeCreature(getTargetPlayer(), this);
|
||||
getTargetPlayer().sacrificeCreature();
|
||||
|
||||
card.setKicked(false);
|
||||
}
|
||||
|
||||
@@ -3346,7 +3346,7 @@ public class CardFactory_Instants {
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
AllZone.GameAction.sacrificeCreature(getTargetPlayer(), this);
|
||||
getTargetPlayer().sacrificeCreature();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4091,8 +4091,8 @@ public class CardFactory_Sorceries {
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
AllZone.GameAction.sacrificeCreature(AllZone.HumanPlayer, this);
|
||||
AllZone.GameAction.sacrificeCreature(AllZone.ComputerPlayer, this);
|
||||
AllZone.HumanPlayer.sacrificeCreature();
|
||||
AllZone.ComputerPlayer.sacrificeCreature();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -4129,7 +4129,7 @@ public class CardFactory_Sorceries {
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
AllZone.GameAction.sacrificeCreature(getTargetPlayer(), this);
|
||||
getTargetPlayer().sacrificeCreature();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -4171,7 +4171,7 @@ public class CardFactory_Sorceries {
|
||||
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
|
||||
PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, card.getController());
|
||||
|
||||
AllZone.GameAction.sacrificeCreature(getTargetPlayer(), this);
|
||||
getTargetPlayer().sacrificeCreature();
|
||||
|
||||
grave.remove(card);
|
||||
removed.add(card);
|
||||
@@ -4196,8 +4196,7 @@ public class CardFactory_Sorceries {
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
AllZone.GameAction.sacrificeCreature(card.getController().getOpponent(),
|
||||
this);
|
||||
card.getController().getOpponent().sacrificeCreature();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -639,46 +639,6 @@ public class GameAction {
|
||||
if(c[i].getName().equals(name)) a.add(c[i]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
public void sacrificeCreature(Player player, SpellAbility sa) {
|
||||
PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
|
||||
CardList list = new CardList(play.getCards());
|
||||
list = list.getType("Creature");
|
||||
|
||||
this.sacrificePermanent(player, sa, list);
|
||||
}
|
||||
|
||||
/*
|
||||
public void sacrificePermanent(Player player, String prompt, CardList choices) {
|
||||
if(choices.size() > 0) {
|
||||
if(player.isHuman()) {
|
||||
Input in = CardFactoryUtil.input_sacrificePermanent(choices, prompt);
|
||||
AllZone.InputControl.setInput(in);
|
||||
} else {
|
||||
CardListUtil.sortDefense(choices);
|
||||
choices.reverse();
|
||||
CardListUtil.sortAttackLowFirst(choices);
|
||||
Card c = choices.get(0);
|
||||
this.sacrificeDestroy(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public void sacrificePermanent(Player player, SpellAbility sa, CardList choices) {
|
||||
if(choices.size() > 0) {
|
||||
if(player.equals(AllZone.HumanPlayer)) {
|
||||
Input in = CardFactoryUtil.input_sacrificePermanent(choices, "Select a creature to sacrifice.");
|
||||
AllZone.InputControl.setInput(in);
|
||||
} else {
|
||||
CardListUtil.sortDefense(choices);
|
||||
choices.reverse();
|
||||
CardListUtil.sortAttackLowFirst(choices);
|
||||
Card c = choices.get(0);
|
||||
this.sacrificeDestroy(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sacrifice(Card c) {
|
||||
|
||||
@@ -7054,14 +7054,12 @@ public class GameActionUtil {
|
||||
};
|
||||
|
||||
choices = choices.filter(filter);
|
||||
if(choices.size() > 0) AllZone.GameAction.sacrificePermanent(AllZone.HumanPlayer, this,
|
||||
choices);
|
||||
if(choices.size() > 0) AllZone.HumanPlayer.sacrificeCreature(choices);
|
||||
|
||||
CardList compCreats = new CardList(cPlay.getCards());
|
||||
compCreats = compCreats.filter(filter);
|
||||
|
||||
if(compCreats.size() > 0) AllZone.GameAction.sacrificePermanent(AllZone.ComputerPlayer,
|
||||
this, compCreats);
|
||||
if(compCreats.size() > 0) AllZone.ComputerPlayer.sacrificeCreature(compCreats);
|
||||
}
|
||||
};
|
||||
ability.setStackDescription("At the beginning of your upkeep, each player sacrifices a non-Vampire creature.");
|
||||
|
||||
@@ -501,6 +501,15 @@ public abstract class Player extends MyObservable{
|
||||
////////////////////////////////
|
||||
public abstract void sacrificePermanent(String prompt, CardList choices);
|
||||
|
||||
public void sacrificeCreature() {
|
||||
CardList choices = AllZoneUtil.getCreaturesInPlay(this);
|
||||
sacrificePermanent("Select a creature to sacrifice.", choices);
|
||||
}
|
||||
|
||||
public void sacrificeCreature(CardList choices) {
|
||||
sacrificePermanent("Select a creature to sacrifice.", choices);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//
|
||||
// generic Object overrides
|
||||
|
||||
Reference in New Issue
Block a user