Added Fact or Fiction

This commit is contained in:
jendave
2011-08-06 04:59:22 +00:00
parent ce7b34daad
commit 652dd0a24a
3 changed files with 123 additions and 0 deletions

View File

@@ -8188,6 +8188,123 @@ public class CardFactory implements NewConstants {
card.addSpellAbility(spell);
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if(cardName.equals("Fact or Fiction")) {
final SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = 1481112451519L;
@Override
public void resolve() {
Card choice = null;
//check for no cards in hand on resolve
PlayerZone Library = AllZone.getZone(Constant.Zone.Library, card.getController());
PlayerZone Hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
PlayerZone Grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController());
CardList cards = new CardList();
if(Library.size() == 0) {
JOptionPane.showMessageDialog(null, "No more cards in library.", "", JOptionPane.INFORMATION_MESSAGE);
return;
}
int Count = 5;
if(Library.size() < 5) Count = Library.size();
for(int i = 0; i < Count; i++) cards.add(Library.get(i));
CardList Pile1 = new CardList();
CardList Pile2 = new CardList();
boolean stop = false;
int Pile1CMC = 0;
int Pile2CMC = 0;
AllZone.Display.getChoice("Revealing top " + Count + " cards of library: ", cards.toArray());
//Human chooses
if(card.getController().equals(Constant.Player.Computer)) {
for(int i = 0; i < Count; i++) {
if(stop == false) {
choice = AllZone.Display.getChoiceOptional("Choose cards to put into the first pile: ", cards.toArray());
if(choice != null) {
Pile1.add(choice);
cards.remove(choice);
Pile1CMC = Pile1CMC + CardUtil.getConvertedManaCost(choice);
}
else stop = true;
}
}
for(int i = 0; i < Count; i++) {
if(!Pile1.contains(Library.get(i))) {
Pile2.add(Library.get(i));
Pile2CMC = Pile2CMC + CardUtil.getConvertedManaCost(Library.get(i));
}
}
StringBuilder sb = new StringBuilder();
sb.append("You have spilt the cards into the following piles" + "\r\n" + "\r\n");
sb.append("Pile 1: " + "\r\n");
for(int i = 0; i < Pile1.size(); i++) sb.append(Pile1.get(i).getName() + "\r\n");
sb.append("\r\n" + "Pile 2: " + "\r\n");
for(int i = 0; i < Pile2.size(); i++) sb.append(Pile2.get(i).getName() + "\r\n");
JOptionPane.showMessageDialog(null, sb, "", JOptionPane.INFORMATION_MESSAGE);
if(Pile1CMC >= Pile2CMC) {
JOptionPane.showMessageDialog(null, "Computer adds the first pile to its hand and puts the second pile into the graveyard", "", JOptionPane.INFORMATION_MESSAGE);
for(int i = 0; i < Pile1.size(); i++) AllZone.GameAction.moveTo(Hand, Pile1.get(i));
for(int i = 0; i < Pile2.size(); i++) AllZone.GameAction.moveTo(Grave, Pile2.get(i));
} else {
JOptionPane.showMessageDialog(null, "Computer adds the second pile to its hand and puts the first pile into the graveyard", "", JOptionPane.INFORMATION_MESSAGE);
for(int i = 0; i < Pile2.size(); i++) AllZone.GameAction.moveTo(Hand, Pile2.get(i));
for(int i = 0; i < Pile1.size(); i++) AllZone.GameAction.moveTo(Grave, Pile1.get(i));
}
} else//Computer chooses (It picks the highest converted mana cost card and 1 random card.)
{
Card biggest = null;
biggest = Library.get(0);
for(int i = 0; i < Count; i++) {
if(CardUtil.getConvertedManaCost(biggest.getManaCost()) >= CardUtil.getConvertedManaCost(biggest.getManaCost())) {
biggest = cards.get(i);
}
}
Pile1.add(biggest);
cards.remove(biggest);
if(cards.size() > 0) {
Card Random = CardUtil.getRandom(cards.toArray());
Pile1.add(Random);
}
for(int i = 0; i < Count; i++) if(!Pile1.contains(Library.get(i))) Pile2.add(Library.get(i));
StringBuilder sb = new StringBuilder();
sb.append("Choose a pile to add to your hand: " + "\r\n" + "\r\n");
sb.append("Pile 1: " + "\r\n");
for(int i = 0; i < Pile1.size(); i++) sb.append(Pile1.get(i).getName() + "\r\n");
sb.append("\r\n" + "Pile 2: " + "\r\n");
for(int i = 0; i < Pile2.size(); i++) sb.append(Pile2.get(i).getName() + "\r\n");
Object[] possibleValues = {"Pile 1", "Pile 2"};
Object q = JOptionPane.showOptionDialog(null, sb, "Fact or Fiction",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, possibleValues, possibleValues[0]);
if(q.equals(0)) {
for(int i = 0; i < Pile1.size(); i++) AllZone.GameAction.moveTo(Hand, Pile1.get(i));
for(int i = 0; i < Pile2.size(); i++) AllZone.GameAction.moveTo(Grave, Pile2.get(i));
} else {
for(int i = 0; i < Pile2.size(); i++) AllZone.GameAction.moveTo(Hand, Pile2.get(i));
for(int i = 0; i < Pile1.size(); i++) AllZone.GameAction.moveTo(Grave, Pile1.get(i));
}
}
Pile1.clear();
Pile2.clear();
}//resolve()
@Override
public boolean canPlayAI() {
PlayerZone Library = AllZone.getZone(Constant.Zone.Library, card.getController());
CardList cards = new CardList(Library.getCards());
return cards.size() >= 10;
}
};//SpellAbility
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
//*************** START *********** START **************************
else if(cardName.equals("Temporal Fissure")) {
final SpellAbility spell = new Spell(card) {