mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
code simplifications in CF_Creatures
This commit is contained in:
@@ -129,6 +129,14 @@ public class CardList implements Iterable<Card> {
|
|||||||
addAll(in.toArray());
|
addAll(in.toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* addAll(CardList) - lets you add one CardList to another directly
|
||||||
|
* @param in - CardList to add to the current CardList
|
||||||
|
*/
|
||||||
|
public void addAll(CardList in) {
|
||||||
|
addAll(in.toArray());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean contains(Card c) {
|
public boolean contains(Card c) {
|
||||||
return list.contains(c);
|
return list.contains(c);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public class CardFactory_Creatures {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
CardList list = new CardList(AllZone.Computer_Battlefield.getCards());
|
CardList list = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
|
||||||
|
|
||||||
return list.containsName("Glorious Anthem") || list.containsName("Gaea's Anthem");
|
return list.containsName("Glorious Anthem") || list.containsName("Gaea's Anthem");
|
||||||
}
|
}
|
||||||
@@ -371,11 +371,8 @@ public class CardFactory_Creatures {
|
|||||||
color = (String)o;
|
color = (String)o;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, AllZone.HumanPlayer);
|
CardList list = AllZoneUtil.getPlayerCardsInLibrary(AllZone.HumanPlayer);
|
||||||
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, AllZone.HumanPlayer);
|
list.addAll(AllZoneUtil.getPlayerHand(AllZone.HumanPlayer));
|
||||||
CardList list = new CardList();
|
|
||||||
list.addAll(lib.getCards());
|
|
||||||
list.addAll(hand.getCards());
|
|
||||||
|
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
String mpcolor = CardFactoryUtil.getMostProminentColor(list);
|
String mpcolor = CardFactoryUtil.getMostProminentColor(list);
|
||||||
@@ -395,27 +392,24 @@ public class CardFactory_Creatures {
|
|||||||
public void resolve() {
|
public void resolve() {
|
||||||
final String kboost = getKeywordBoost();
|
final String kboost = getKeywordBoost();
|
||||||
|
|
||||||
CardList list = new CardList();
|
CardList list = AllZoneUtil.getPlayerCardsInPlay(card.getController());
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
|
||||||
list.addAll(play.getCards());
|
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
final Card[] target = new Card[1];
|
final Card target = list.get(i);
|
||||||
target[0] = list.get(i);
|
|
||||||
|
|
||||||
final Command untilEOT = new Command() {
|
final Command untilEOT = new Command() {
|
||||||
private static final long serialVersionUID = 6308754740309909072L;
|
private static final long serialVersionUID = 6308754740309909072L;
|
||||||
|
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (AllZoneUtil.isCardInPlay(target[0])) {
|
if (AllZoneUtil.isCardInPlay(target)) {
|
||||||
target[0].removeExtrinsicKeyword(kboost);
|
target.removeExtrinsicKeyword(kboost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};//Command
|
};//Command
|
||||||
|
|
||||||
if (AllZoneUtil.isCardInPlay(target[0]) &&
|
if (AllZoneUtil.isCardInPlay(target) &&
|
||||||
!target[0].getKeyword().contains(kboost)) {
|
!target.getKeyword().contains(kboost)) {
|
||||||
target[0].addExtrinsicKeyword(kboost);
|
target.addExtrinsicKeyword(kboost);
|
||||||
|
|
||||||
AllZone.EndOfTurn.addUntil(untilEOT);
|
AllZone.EndOfTurn.addUntil(untilEOT);
|
||||||
}//if
|
}//if
|
||||||
@@ -535,7 +529,7 @@ public class CardFactory_Creatures {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlay() {
|
public boolean canPlay() {
|
||||||
CardList library = new CardList(AllZone.getZone(Constant.Zone.Library, card.getController()).getCards());
|
CardList library = AllZoneUtil.getPlayerCardsInLibrary(card.getController());
|
||||||
if(library.size() == 0) return false;
|
if(library.size() == 0) return false;
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
||||||
boolean canPlayLand = card.getController().canPlayLand();
|
boolean canPlayLand = card.getController().canPlayLand();
|
||||||
@@ -581,10 +575,10 @@ public class CardFactory_Creatures {
|
|||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
if(card.getController().isHuman()) {
|
if(card.getController().isHuman()) {
|
||||||
if(AllZone.Human_Hand.getCards().length == 0) AllZone.GameAction.sacrifice(card);
|
if(AllZoneUtil.getPlayerHand(AllZone.HumanPlayer).size() == 0) AllZone.GameAction.sacrifice(card);
|
||||||
else AllZone.InputControl.setInput(discard);
|
else AllZone.InputControl.setInput(discard);
|
||||||
} else {
|
} else {
|
||||||
CardList list = new CardList(AllZone.Computer_Hand.getCards());
|
CardList list = AllZoneUtil.getPlayerHand(AllZone.ComputerPlayer);
|
||||||
list = list.filter(new CardListFilter() {
|
list = list.filter(new CardListFilter() {
|
||||||
public boolean addCard(Card c) {
|
public boolean addCard(Card c) {
|
||||||
return (!c.isCreature());
|
return (!c.isCreature());
|
||||||
@@ -620,8 +614,7 @@ public class CardFactory_Creatures {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlay() {
|
public boolean canPlay() {
|
||||||
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
|
CardList list = AllZoneUtil.getPlayerHand(card.getController());
|
||||||
CardList list = new CardList(hand.getCards());
|
|
||||||
list.remove(card);
|
list.remove(card);
|
||||||
list = list.filter(new CardListFilter() {
|
list = list.filter(new CardListFilter() {
|
||||||
public boolean addCard(Card c) {
|
public boolean addCard(Card c) {
|
||||||
@@ -662,8 +655,8 @@ public class CardFactory_Creatures {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
|
CardList hand = AllZoneUtil.getPlayerHand(card.getController());
|
||||||
if(hand.getCards().length == 0)
|
if(hand.size() == 0)
|
||||||
AllZone.GameAction.sacrifice(card);
|
AllZone.GameAction.sacrifice(card);
|
||||||
else
|
else
|
||||||
card.getController().discardRandom(this);
|
card.getController().discardRandom(this);
|
||||||
@@ -815,14 +808,14 @@ public class CardFactory_Creatures {
|
|||||||
public void resolve() {
|
public void resolve() {
|
||||||
//shuffle hand into library, then shuffle library
|
//shuffle hand into library, then shuffle library
|
||||||
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
|
PlayerZone library = AllZone.getZone(Constant.Zone.Library, card.getController());
|
||||||
PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController());
|
CardList hand = AllZoneUtil.getPlayerHand(card.getController());
|
||||||
Card c[] = hand.getCards();
|
for(int i = 0; i < hand.size(); i++) {
|
||||||
for(int i = 0; i < c.length; i++)
|
AllZone.GameAction.moveTo(library, hand.get(i));
|
||||||
AllZone.GameAction.moveTo(library, c[i]);
|
}
|
||||||
card.getController().shuffle();
|
card.getController().shuffle();
|
||||||
|
|
||||||
//draw same number of cards as before
|
//draw same number of cards as before
|
||||||
for(int i = 0; i < c.length; i++)
|
for(int i = 0; i < hand.size(); i++)
|
||||||
card.getController().drawCard();
|
card.getController().drawCard();
|
||||||
}
|
}
|
||||||
};//SpellAbility
|
};//SpellAbility
|
||||||
@@ -881,9 +874,7 @@ public class CardFactory_Creatures {
|
|||||||
final CommandReturn getCreature = new CommandReturn() {
|
final CommandReturn getCreature = new CommandReturn() {
|
||||||
public Object execute() {
|
public Object execute() {
|
||||||
//get all creatures
|
//get all creatures
|
||||||
CardList list = new CardList();
|
CardList list = AllZoneUtil.getPlayerCardsInPlay(card.getController());
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController());
|
|
||||||
list.addAll(play.getCards());
|
|
||||||
|
|
||||||
list = list.filter(new CardListFilter() {
|
list = list.filter(new CardListFilter() {
|
||||||
public boolean addCard(Card c) {
|
public boolean addCard(Card c) {
|
||||||
@@ -934,7 +925,7 @@ public class CardFactory_Creatures {
|
|||||||
{
|
{
|
||||||
Card target;
|
Card target;
|
||||||
//must target computer creature
|
//must target computer creature
|
||||||
CardList computer = new CardList(AllZone.Computer_Battlefield.getCards());
|
CardList computer = AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer);
|
||||||
computer = computer.getType("Goblin");
|
computer = computer.getType("Goblin");
|
||||||
computer.remove(card);
|
computer.remove(card);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user