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) {
|
public void handToLibrary(final int numToLibrary, final String libPosIn) {
|
||||||
String libPos = libPosIn;
|
String libPos = libPosIn;
|
||||||
|
|
||||||
for(int i = 0; i < numToLibrary; i++) {
|
for(int i = 0; i < numToLibrary; i++) {
|
||||||
if(libPos.equals("Top") || libPos.equals("Bottom")) libPos = libPos.toLowerCase();
|
int position;
|
||||||
else {
|
if (libPos.equalsIgnoreCase("Top"))
|
||||||
|
position = 0;
|
||||||
|
else if (libPos.equalsIgnoreCase("Bottom"))
|
||||||
|
position = -1;
|
||||||
|
else{
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
if(r.nextBoolean()) libPos = "top";
|
if(r.nextBoolean())
|
||||||
else libPos = "bottom";
|
position = 0;
|
||||||
|
else
|
||||||
|
position = -1;
|
||||||
}
|
}
|
||||||
CardList hand = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
|
CardList hand = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
|
||||||
|
|
||||||
@@ -149,27 +156,20 @@ public class AIPlayer extends Player{
|
|||||||
CardList blIH = hand.getType("Basic");
|
CardList blIH = hand.getType("Basic");
|
||||||
if(blIH.size() > 0) {
|
if(blIH.size() > 0) {
|
||||||
Card card = blIH.get(CardUtil.getRandomIndex(blIH));
|
Card card = blIH.get(CardUtil.getRandomIndex(blIH));
|
||||||
AllZone.Computer_Hand.remove(card);
|
|
||||||
if(libPos.equals("top")) AllZone.Computer_Library.add(card, 0);
|
AllZone.GameAction.moveToLibrary(card, position);
|
||||||
else AllZone.Computer_Library.add(card);
|
|
||||||
//return;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
CardListUtil.sortAttackLowFirst(hand);
|
CardListUtil.sortAttackLowFirst(hand);
|
||||||
CardListUtil.sortNonFlyingFirst(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.GameAction.moveToLibrary(hand.get(0), position);
|
||||||
AllZone.Computer_Hand.remove(hand.get(0));
|
|
||||||
//return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CardListUtil.sortCMC(hand);
|
CardListUtil.sortCMC(hand);
|
||||||
if(libPos.equals("top")) AllZone.Computer_Library.add(hand.get(0), 0);
|
|
||||||
else AllZone.Computer_Library.add(hand.get(0));
|
AllZone.GameAction.moveToLibrary(hand.get(0), position);
|
||||||
AllZone.Computer_Hand.remove(hand.get(0));
|
|
||||||
//return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2186,13 +2186,9 @@ public class CardFactory_Creatures {
|
|||||||
final SpellAbility ability = new Ability(card, "0") {
|
final SpellAbility ability = new Ability(card, "0") {
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
card.setDamage(0);
|
if (AllZone.getZone(card).is(Constant.Zone.Graveyard))
|
||||||
card.clearAssignedDamage();
|
AllZone.GameAction.moveToLibrary(card);
|
||||||
card.untap();
|
|
||||||
|
|
||||||
//moves card to top of library
|
|
||||||
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getOwner());
|
|
||||||
library.add(card, 0);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Command destroy = new Command() {
|
Command destroy = new Command() {
|
||||||
@@ -2200,11 +2196,7 @@ public class CardFactory_Creatures {
|
|||||||
|
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if(card.isToken()) return;
|
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.");
|
ability.setStackDescription("Put Undying Beast on top of its owner's library.");
|
||||||
AllZone.Stack.add(ability);
|
AllZone.Stack.add(ability);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,34 +33,22 @@ public class CardFactory_Sorceries {
|
|||||||
}//resolve()
|
}//resolve()
|
||||||
|
|
||||||
void discardDraw7(Player player) {
|
void discardDraw7(Player player) {
|
||||||
// Discard hand into graveyard
|
// Move hand into library
|
||||||
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
|
CardList hand = AllZoneUtil.getPlayerHand(player);
|
||||||
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, player);
|
CardList grave = AllZoneUtil.getPlayerGraveyard(player);
|
||||||
PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
|
|
||||||
Card[] c = hand.getCards();
|
for(Card c : hand)
|
||||||
for(int i = 0; i < c.length; i++) {
|
AllZone.GameAction.moveToLibrary(c);
|
||||||
hand.remove(c[i]);
|
|
||||||
library.add(c[i], 0);
|
// Move graveyard into library
|
||||||
}
|
for(Card c : grave)
|
||||||
|
AllZone.GameAction.moveToLibrary(c);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shuffle library
|
// Shuffle library
|
||||||
player.shuffle();
|
player.shuffle();
|
||||||
|
|
||||||
// Draw seven cards
|
// Draw seven cards
|
||||||
player.drawCards(7);
|
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
|
// 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);
|
card.addSpellAbility(spell);
|
||||||
}//*************** END ************ END **************************
|
}//*************** 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 **************************
|
//*************** START *********** START **************************
|
||||||
else if(cardName.equals("Invincible Hymn")) {
|
else if(cardName.equals("Invincible Hymn")) {
|
||||||
final Player player = card.getController();
|
final Player player = card.getController();
|
||||||
@@ -6555,21 +6475,15 @@ public class CardFactory_Sorceries {
|
|||||||
}//resolve()
|
}//resolve()
|
||||||
|
|
||||||
void discardDrawX(Player player) {
|
void discardDrawX(Player player) {
|
||||||
int handSize = 0;
|
CardList hand = AllZoneUtil.getPlayerHand(player);
|
||||||
// Discard hand into library
|
|
||||||
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, player);
|
for(Card c : hand)
|
||||||
handSize = hand.size();
|
AllZone.GameAction.moveToLibrary(c);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shuffle library
|
// Shuffle library
|
||||||
player.shuffle();
|
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
|
// 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() {
|
public void selectButtonCancel() {
|
||||||
AllZone.GameInfo.setHumanMulliganedToZero(false);
|
AllZone.GameInfo.setHumanMulliganedToZero(false);
|
||||||
|
|
||||||
Card[] hand = AllZone.Human_Hand.getCards();
|
CardList hand = AllZoneUtil.getPlayerHand(AllZone.HumanPlayer);
|
||||||
for(int i = 0; i < hand.length; i++) {
|
for(Card c : hand)
|
||||||
AllZone.Human_Library.add(hand[i]);
|
AllZone.GameAction.moveToLibrary(c);
|
||||||
AllZone.Human_Hand.remove(hand[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < 100; i++)
|
for(int i = 0; i < 100; i++)
|
||||||
AllZone.HumanPlayer.shuffle();
|
AllZone.HumanPlayer.shuffle();
|
||||||
|
|
||||||
|
int newHand = hand.size() - 1;
|
||||||
int newHand = hand.length - 1;
|
|
||||||
|
|
||||||
AllZone.GameInfo.addHumanNumberOfTimesMulliganed(1);
|
AllZone.GameInfo.addHumanNumberOfTimesMulliganed(1);
|
||||||
|
|
||||||
@@ -42,7 +39,7 @@ public class Input_Mulligan extends Input {
|
|||||||
if(AllZone.QuestData != null)
|
if(AllZone.QuestData != null)
|
||||||
{
|
{
|
||||||
if (AllZone.QuestData.getSleightOfHandLevel() >= 1 && AllZone.GameInfo.getHumanNumberOfTimesMulliganed() == 1)
|
if (AllZone.QuestData.getSleightOfHandLevel() >= 1 && AllZone.GameInfo.getHumanNumberOfTimesMulliganed() == 1)
|
||||||
newHand = hand.length;
|
newHand++;
|
||||||
}
|
}
|
||||||
for(int i = 0; i < newHand; i++)
|
for(int i = 0; i < newHand; i++)
|
||||||
AllZone.HumanPlayer.drawCard();
|
AllZone.HumanPlayer.drawCard();
|
||||||
@@ -81,18 +78,11 @@ public class Input_Mulligan extends Input {
|
|||||||
//Human Leylines
|
//Human Leylines
|
||||||
ButtonUtil.reset();
|
ButtonUtil.reset();
|
||||||
CardList HHandList = AllZoneUtil.getPlayerHand(AllZone.HumanPlayer);
|
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(Card c : HHandList){
|
||||||
for(int i = 0; i < HHandList.size() ; i++) {
|
if(c.getName().startsWith("Leyline")) {
|
||||||
if(HHandList.get(i).getName().startsWith("Leyline")) {
|
if (GameActionUtil.showYesNoDialog(c, "Put onto Battlefield?"))
|
||||||
String[] choices = {"Yes", "No"};
|
AllZone.GameAction.moveToPlay(c);
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ public class Input_PayManaCost extends Input {
|
|||||||
|
|
||||||
// this seems to remove a card if it is in the player's hand
|
// 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
|
// 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);
|
AllZone.Human_Hand.remove(originalCard);
|
||||||
|
|
||||||
if (spell.getAfterPayMana() != null)
|
if (spell.getAfterPayMana() != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user