mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
- More cleanup related to moveTo and PlayerZone.remove()
- Re-removing the Cruel Tutor block that got added back in during a recent submission
This commit is contained in:
@@ -133,12 +133,19 @@ public class AIPlayer extends Player{
|
||||
|
||||
public void handToLibrary(final int numToLibrary, final String libPosIn) {
|
||||
String libPos = libPosIn;
|
||||
|
||||
for(int i = 0; i < numToLibrary; i++) {
|
||||
if(libPos.equals("Top") || libPos.equals("Bottom")) libPos = libPos.toLowerCase();
|
||||
else {
|
||||
int position;
|
||||
if (libPos.equalsIgnoreCase("Top"))
|
||||
position = 0;
|
||||
else if (libPos.equalsIgnoreCase("Bottom"))
|
||||
position = -1;
|
||||
else{
|
||||
Random r = new Random();
|
||||
if(r.nextBoolean()) libPos = "top";
|
||||
else libPos = "bottom";
|
||||
if(r.nextBoolean())
|
||||
position = 0;
|
||||
else
|
||||
position = -1;
|
||||
}
|
||||
CardList hand = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
|
||||
|
||||
@@ -149,27 +156,20 @@ public class AIPlayer extends Player{
|
||||
CardList blIH = hand.getType("Basic");
|
||||
if(blIH.size() > 0) {
|
||||
Card card = blIH.get(CardUtil.getRandomIndex(blIH));
|
||||
AllZone.Computer_Hand.remove(card);
|
||||
if(libPos.equals("top")) AllZone.Computer_Library.add(card, 0);
|
||||
else AllZone.Computer_Library.add(card);
|
||||
//return;
|
||||
|
||||
AllZone.GameAction.moveToLibrary(card, position);
|
||||
}
|
||||
else {
|
||||
|
||||
CardListUtil.sortAttackLowFirst(hand);
|
||||
CardListUtil.sortNonFlyingFirst(hand);
|
||||
if(libPos.equals("top")) AllZone.Computer_Library.add(hand.get(0), 0);
|
||||
else AllZone.Computer_Library.add(hand.get(0));
|
||||
AllZone.Computer_Hand.remove(hand.get(0));
|
||||
//return;
|
||||
|
||||
AllZone.GameAction.moveToLibrary(hand.get(0), position);
|
||||
}
|
||||
}
|
||||
else {
|
||||
CardListUtil.sortCMC(hand);
|
||||
if(libPos.equals("top")) AllZone.Computer_Library.add(hand.get(0), 0);
|
||||
else AllZone.Computer_Library.add(hand.get(0));
|
||||
AllZone.Computer_Hand.remove(hand.get(0));
|
||||
//return;
|
||||
|
||||
AllZone.GameAction.moveToLibrary(hand.get(0), position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2186,13 +2186,9 @@ public class CardFactory_Creatures {
|
||||
final SpellAbility ability = new Ability(card, "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
card.setDamage(0);
|
||||
card.clearAssignedDamage();
|
||||
card.untap();
|
||||
|
||||
//moves card to top of library
|
||||
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getOwner());
|
||||
library.add(card, 0);
|
||||
if (AllZone.getZone(card).is(Constant.Zone.Graveyard))
|
||||
AllZone.GameAction.moveToLibrary(card);
|
||||
|
||||
}
|
||||
};
|
||||
Command destroy = new Command() {
|
||||
@@ -2200,11 +2196,7 @@ public class CardFactory_Creatures {
|
||||
|
||||
public void execute() {
|
||||
if(card.isToken()) return;
|
||||
|
||||
//remove from graveyard
|
||||
PlayerZone grave = AllZone.getZone(card);
|
||||
grave.remove(card);
|
||||
|
||||
|
||||
ability.setStackDescription("Put Undying Beast on top of its owner's library.");
|
||||
AllZone.Stack.add(ability);
|
||||
}
|
||||
|
||||
@@ -33,34 +33,22 @@ public class CardFactory_Sorceries {
|
||||
}//resolve()
|
||||
|
||||
void discardDraw7(Player player) {
|
||||
// Discard hand into graveyard
|
||||
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
|
||||
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
|
||||
PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
|
||||
Card[] c = hand.getCards();
|
||||
for(int i = 0; i < c.length; i++) {
|
||||
hand.remove(c[i]);
|
||||
library.add(c[i], 0);
|
||||
}
|
||||
|
||||
// Move graveyard into library
|
||||
|
||||
Card[] g = grave.getCards();
|
||||
for(int i = 0; i < g.length; i++) {
|
||||
grave.remove(g[i]);
|
||||
library.add(g[i], 0);
|
||||
}
|
||||
|
||||
// Move hand into library
|
||||
CardList hand = AllZoneUtil.getPlayerHand(player);
|
||||
CardList grave = AllZoneUtil.getPlayerGraveyard(player);
|
||||
|
||||
for(Card c : hand)
|
||||
AllZone.GameAction.moveToLibrary(c);
|
||||
|
||||
// Move graveyard into library
|
||||
for(Card c : grave)
|
||||
AllZone.GameAction.moveToLibrary(c);
|
||||
|
||||
// Shuffle library
|
||||
player.shuffle();
|
||||
|
||||
// Draw seven cards
|
||||
player.drawCards(7);
|
||||
|
||||
if(card.getController().equals(player)) {
|
||||
library.remove(card);
|
||||
grave.add(card);
|
||||
}
|
||||
}
|
||||
|
||||
// Simple, If computer has two or less playable cards remaining in hand play Timetwister
|
||||
@@ -3218,74 +3206,6 @@ public class CardFactory_Sorceries {
|
||||
card.addSpellAbility(spell);
|
||||
}//*************** END ************ END **************************
|
||||
|
||||
//*************** START *********** START **************************
|
||||
else if(cardName.equals("Cruel Tutor") || cardName.equals("Imperial Seal")) {
|
||||
SpellAbility spell = new Spell(card) {
|
||||
private static final long serialVersionUID = -948983382014193129L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
int life = AllZone.ComputerPlayer.getLife();
|
||||
if(4 < AllZone.Phase.getTurn() && AllZone.Computer_Library.size() > 0 && life >= 4) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
Player player = card.getController();
|
||||
if(player.isHuman()) humanResolve();
|
||||
else computerResolve();
|
||||
}
|
||||
|
||||
public void computerResolve() {
|
||||
//TODO: somehow select a good noncreature card for AI
|
||||
CardList creature = new CardList(AllZone.Computer_Library.getCards());
|
||||
creature = creature.getType("Creature");
|
||||
if(creature.size() != 0) {
|
||||
Card c = CardFactoryUtil.AI_getBestCreature(creature);
|
||||
|
||||
if(c == null) {
|
||||
creature.shuffle();
|
||||
c = creature.get(0);
|
||||
}
|
||||
|
||||
card.getController().shuffle();
|
||||
|
||||
//move to top of library
|
||||
AllZone.Computer_Library.remove(c);
|
||||
AllZone.Computer_Library.add(c, 0);
|
||||
|
||||
//lose 2 life
|
||||
AllZone.ComputerPlayer.loseLife(2, card);
|
||||
}
|
||||
}//computerResolve()
|
||||
|
||||
public void humanResolve() {
|
||||
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
|
||||
|
||||
CardList list = new CardList(library.getCards());
|
||||
|
||||
if(list.size() != 0) {
|
||||
Object o = GuiUtils.getChoiceOptional("Select a card", list.toArray());
|
||||
|
||||
card.getController().shuffle();
|
||||
if(o != null) {
|
||||
//put card on top of library
|
||||
library.remove(o);
|
||||
library.add((Card) o, 0);
|
||||
}
|
||||
//lose 2 life
|
||||
AllZone.HumanPlayer.loseLife(2, card);
|
||||
}//if
|
||||
|
||||
|
||||
}//resolve()
|
||||
};
|
||||
card.clearSpellAbility();
|
||||
card.addSpellAbility(spell);
|
||||
}//*************** END ************ END **************************
|
||||
|
||||
|
||||
//*************** START *********** START **************************
|
||||
else if(cardName.equals("Invincible Hymn")) {
|
||||
final Player player = card.getController();
|
||||
@@ -6555,21 +6475,15 @@ public class CardFactory_Sorceries {
|
||||
}//resolve()
|
||||
|
||||
void discardDrawX(Player player) {
|
||||
int handSize = 0;
|
||||
// Discard hand into library
|
||||
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
|
||||
handSize = hand.size();
|
||||
PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
|
||||
Card[] c = hand.getCards();
|
||||
for(int i = 0; i < c.length; i++) {
|
||||
hand.remove(c[i]);
|
||||
library.add(c[i], 0);
|
||||
}
|
||||
CardList hand = AllZoneUtil.getPlayerHand(player);
|
||||
|
||||
for(Card c : hand)
|
||||
AllZone.GameAction.moveToLibrary(c);
|
||||
|
||||
// Shuffle library
|
||||
player.shuffle();
|
||||
|
||||
player.drawCards(handSize);
|
||||
player.drawCards(hand.size());
|
||||
}
|
||||
|
||||
// Simple, If computer has two or less playable cards remaining in hand play Winds of Change
|
||||
|
||||
@@ -23,17 +23,14 @@ public class Input_Mulligan extends Input {
|
||||
public void selectButtonCancel() {
|
||||
AllZone.GameInfo.setHumanMulliganedToZero(false);
|
||||
|
||||
Card[] hand = AllZone.Human_Hand.getCards();
|
||||
for(int i = 0; i < hand.length; i++) {
|
||||
AllZone.Human_Library.add(hand[i]);
|
||||
AllZone.Human_Hand.remove(hand[i]);
|
||||
}
|
||||
|
||||
CardList hand = AllZoneUtil.getPlayerHand(AllZone.HumanPlayer);
|
||||
for(Card c : hand)
|
||||
AllZone.GameAction.moveToLibrary(c);
|
||||
|
||||
for(int i = 0; i < 100; i++)
|
||||
AllZone.HumanPlayer.shuffle();
|
||||
|
||||
|
||||
int newHand = hand.length - 1;
|
||||
int newHand = hand.size() - 1;
|
||||
|
||||
AllZone.GameInfo.addHumanNumberOfTimesMulliganed(1);
|
||||
|
||||
@@ -42,7 +39,7 @@ public class Input_Mulligan extends Input {
|
||||
if(AllZone.QuestData != null)
|
||||
{
|
||||
if (AllZone.QuestData.getSleightOfHandLevel() >= 1 && AllZone.GameInfo.getHumanNumberOfTimesMulliganed() == 1)
|
||||
newHand = hand.length;
|
||||
newHand++;
|
||||
}
|
||||
for(int i = 0; i < newHand; i++)
|
||||
AllZone.HumanPlayer.drawCard();
|
||||
@@ -81,18 +78,11 @@ public class Input_Mulligan extends Input {
|
||||
//Human Leylines
|
||||
ButtonUtil.reset();
|
||||
CardList HHandList = AllZoneUtil.getPlayerHand(AllZone.HumanPlayer);
|
||||
PlayerZone HPlay = AllZone.getZone(Constant.Zone.Battlefield, AllZone.HumanPlayer);
|
||||
PlayerZone HHand = AllZone.getZone(Constant.Zone.Hand, AllZone.HumanPlayer);
|
||||
for(int i = 0; i < HHandList.size() ; i++) {
|
||||
if(HHandList.get(i).getName().startsWith("Leyline")) {
|
||||
String[] choices = {"Yes", "No"};
|
||||
Object q = null;
|
||||
q = GuiUtils.getChoiceOptional("Put " + HHandList.get(i).getName() + " onto the battlefield?", choices);
|
||||
if(q == null || q.equals("No"));
|
||||
else {
|
||||
HPlay.add(HHandList.get(i));
|
||||
HHand.remove(HHandList.get(i));
|
||||
}
|
||||
|
||||
for(Card c : HHandList){
|
||||
if(c.getName().startsWith("Leyline")) {
|
||||
if (GameActionUtil.showYesNoDialog(c, "Put onto Battlefield?"))
|
||||
AllZone.GameAction.moveToPlay(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,8 @@ public class Input_PayManaCost extends Input {
|
||||
|
||||
// this seems to remove a card if it is in the player's hand
|
||||
// and trys to remove abilities, but no error messsage is generated
|
||||
|
||||
// todo(sol) if spell but not copied spell, move to stack
|
||||
AllZone.Human_Hand.remove(originalCard);
|
||||
|
||||
if (spell.getAfterPayMana() != null)
|
||||
|
||||
Reference in New Issue
Block a user