mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Simplified the code found in forge.card.cardFactory.CardFactory_Soceries and forge.card.cardFactory.CardFactory. Updating c.getType().contains(string) to c.isType(string).
This commit is contained in:
@@ -139,27 +139,27 @@ public class CardFactory implements NewConstants {
|
|||||||
|
|
||||||
final public Card dynamicCopyCard(Card in)
|
final public Card dynamicCopyCard(Card in)
|
||||||
{
|
{
|
||||||
if(in.getType().contains("Creature")) {
|
if(in.isType("Creature")) {
|
||||||
Card card2 = new Card();
|
Card card2 = new Card();
|
||||||
card2 = CardFactory_Creatures.getCard(in, in.getName(), in.getOwner(), this);
|
card2 = CardFactory_Creatures.getCard(in, in.getName(), in.getOwner(), this);
|
||||||
|
|
||||||
return card2;
|
return card2;
|
||||||
} else if(in.getType().contains("Aura")) {
|
} else if(in.isType("Aura")) {
|
||||||
Card card2 = new Card();
|
Card card2 = new Card();
|
||||||
card2 = CardFactory_Auras.getCard(in, in.getName(), in.getOwner());
|
card2 = CardFactory_Auras.getCard(in, in.getName(), in.getOwner());
|
||||||
|
|
||||||
return card2;
|
return card2;
|
||||||
} else if(in.getType().contains("Equipment")) {
|
} else if(in.isType("Equipment")) {
|
||||||
Card card2 = new Card();
|
Card card2 = new Card();
|
||||||
card2 = CardFactory_Equipment.getCard(in, in.getName(), in.getOwner());
|
card2 = CardFactory_Equipment.getCard(in, in.getName(), in.getOwner());
|
||||||
|
|
||||||
return card2;
|
return card2;
|
||||||
} else if(in.getType().contains("Planeswalker")) {
|
} else if(in.isType("Planeswalker")) {
|
||||||
Card card2 = new Card();
|
Card card2 = new Card();
|
||||||
card2 = CardFactory_Planeswalkers.getCard(in, in.getName(), in.getOwner());
|
card2 = CardFactory_Planeswalkers.getCard(in, in.getName(), in.getOwner());
|
||||||
|
|
||||||
return card2;
|
return card2;
|
||||||
} else if(in.getType().contains("Land")) {
|
} else if(in.isType("Land")) {
|
||||||
Card card2 = new Card();
|
Card card2 = new Card();
|
||||||
card2 = CardFactory_Lands.getCard(in, in.getName(), in.getOwner());
|
card2 = CardFactory_Lands.getCard(in, in.getName(), in.getOwner());
|
||||||
|
|
||||||
@@ -416,7 +416,7 @@ public class CardFactory implements NewConstants {
|
|||||||
{
|
{
|
||||||
Card c = clICtrl.get(i);
|
Card c = clICtrl.get(i);
|
||||||
for (int j = 0; j < types.length; j++)
|
for (int j = 0; j < types.length; j++)
|
||||||
if (c.getType().contains(types[j].trim()))
|
if (c.isType(types[j].trim()))
|
||||||
fnd = true;
|
fnd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -819,19 +819,19 @@ public class CardFactory implements NewConstants {
|
|||||||
//******************************************************************
|
//******************************************************************
|
||||||
//************** Link to different CardFactories *******************
|
//************** Link to different CardFactories *******************
|
||||||
Card card2 = null;
|
Card card2 = null;
|
||||||
if(card.getType().contains("Creature")) {
|
if(card.isType("Creature")) {
|
||||||
card2 = CardFactory_Creatures.getCard(card, cardName, owner, this);
|
card2 = CardFactory_Creatures.getCard(card, cardName, owner, this);
|
||||||
} else if(card.getType().contains("Aura")) {
|
} else if(card.isType("Aura")) {
|
||||||
card2 = CardFactory_Auras.getCard(card, cardName, owner);
|
card2 = CardFactory_Auras.getCard(card, cardName, owner);
|
||||||
} else if(card.getType().contains("Equipment")) {
|
} else if(card.isType("Equipment")) {
|
||||||
card2 = CardFactory_Equipment.getCard(card, cardName, owner);
|
card2 = CardFactory_Equipment.getCard(card, cardName, owner);
|
||||||
} else if(card.getType().contains("Planeswalker")) {
|
} else if(card.isType("Planeswalker")) {
|
||||||
card2 = CardFactory_Planeswalkers.getCard(card, cardName, owner);
|
card2 = CardFactory_Planeswalkers.getCard(card, cardName, owner);
|
||||||
} else if(card.getType().contains("Land")) {
|
} else if(card.isType("Land")) {
|
||||||
card2 = CardFactory_Lands.getCard(card, cardName, owner);
|
card2 = CardFactory_Lands.getCard(card, cardName, owner);
|
||||||
} else if (card.getType().contains("Instant")) {
|
} else if (card.isType("Instant")) {
|
||||||
card2 = CardFactory_Instants.getCard(card, cardName, owner);
|
card2 = CardFactory_Instants.getCard(card, cardName, owner);
|
||||||
} else if (card.getType().contains("Sorcery")) {
|
} else if (card.isType("Sorcery")) {
|
||||||
card2 = CardFactory_Sorceries.getCard(card, cardName, owner);
|
card2 = CardFactory_Sorceries.getCard(card, cardName, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1443,7 +1443,7 @@ public class CardFactory implements NewConstants {
|
|||||||
CardList creatures = new CardList();
|
CardList creatures = new CardList();
|
||||||
|
|
||||||
for(int i = 0; i < hand.size(); i++) {
|
for(int i = 0; i < hand.size(); i++) {
|
||||||
if(hand.get(i).getType().contains("Creature")
|
if (hand.get(i).isType("Creature")
|
||||||
&& CardUtil.getConvertedManaCost(hand.get(i).getManaCost()) <= 3) creatures.add(hand.get(i));
|
&& CardUtil.getConvertedManaCost(hand.get(i).getManaCost()) <= 3) creatures.add(hand.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1097,8 +1097,10 @@ public class CardFactory_Sorceries {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectCard(Card c, PlayerZone zone) {
|
public void selectCard(Card c, PlayerZone zone) {
|
||||||
if(c.isLand() && zone.is(Constant.Zone.Battlefield) && !c.getType().contains("Basic")) {
|
if (c.isLand()
|
||||||
if(card.isCopiedSpell()) card.getChoiceTargets().remove(0);
|
&& zone.is(Constant.Zone.Battlefield)
|
||||||
|
&& !c.isType("Basic")) {
|
||||||
|
if (card.isCopiedSpell()) card.getChoiceTargets().remove(0);
|
||||||
m_land[0] = c;
|
m_land[0] = c;
|
||||||
spell.setTargetCard(c);
|
spell.setTargetCard(c);
|
||||||
card.setSpellChoiceTarget(String.valueOf(c.getUniqueNumber()));
|
card.setSpellChoiceTarget(String.valueOf(c.getUniqueNumber()));
|
||||||
@@ -1330,11 +1332,11 @@ public class CardFactory_Sorceries {
|
|||||||
land = land.filter(new CardListFilter() {
|
land = land.filter(new CardListFilter() {
|
||||||
public boolean addCard(Card c){
|
public boolean addCard(Card c){
|
||||||
if (c.getName().contains("Dryad Arbor")) return true;
|
if (c.getName().contains("Dryad Arbor")) return true;
|
||||||
else if (!(c.getType().contains("Forest")
|
else if (!(c.isType("Forest")
|
||||||
|| c.getType().contains("Plains")
|
|| c.isType("Plains")
|
||||||
|| c.getType().contains("Mountain")
|
|| c.isType("Mountain")
|
||||||
|| c.getType().contains("Island")
|
|| c.isType("Island")
|
||||||
|| c.getType().contains("Swamp"))) return true;
|
|| c.isType("Swamp"))) return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1380,7 +1382,7 @@ public class CardFactory_Sorceries {
|
|||||||
if(c.isLand() && zone.is(Constant.Zone.Battlefield)
|
if(c.isLand() && zone.is(Constant.Zone.Battlefield)
|
||||||
&& c.getController().isHuman()
|
&& c.getController().isHuman()
|
||||||
/*&& c.getName().equals(humanBasic.get(count))*/
|
/*&& c.getName().equals(humanBasic.get(count))*/
|
||||||
&& c.getType().contains(humanBasic.get(count))
|
&& c.isType(humanBasic.get(count))
|
||||||
/*&& !saveList.contains(c) */) {
|
/*&& !saveList.contains(c) */) {
|
||||||
//get all other basic[count] lands human player controls and add them to target
|
//get all other basic[count] lands human player controls and add them to target
|
||||||
CardList land = AllZoneUtil.getPlayerLandsInPlay(AllZone.HumanPlayer);
|
CardList land = AllZoneUtil.getPlayerLandsInPlay(AllZone.HumanPlayer);
|
||||||
@@ -1408,11 +1410,11 @@ public class CardFactory_Sorceries {
|
|||||||
land = land.filter(new CardListFilter() {
|
land = land.filter(new CardListFilter() {
|
||||||
public boolean addCard(Card c){
|
public boolean addCard(Card c){
|
||||||
if (c.getName().contains("Dryad Arbor")) return true;
|
if (c.getName().contains("Dryad Arbor")) return true;
|
||||||
else if (!(c.getType().contains("Forest")
|
else if (!(c.isType("Forest")
|
||||||
|| c.getType().contains("Plains")
|
|| c.isType("Plains")
|
||||||
|| c.getType().contains("Mountain")
|
|| c.isType("Mountain")
|
||||||
|| c.getType().contains("Island")
|
|| c.isType("Island")
|
||||||
|| c.getType().contains("Swamp"))) return true;
|
|| c.isType("Swamp"))) return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1495,11 +1497,11 @@ public class CardFactory_Sorceries {
|
|||||||
|
|
||||||
c2.getController().discard(c2, null);
|
c2.getController().discard(c2, null);
|
||||||
|
|
||||||
if(c1.getType().contains("Land")) {
|
if(c1.isType("Land")) {
|
||||||
AllZone.HumanPlayer.gainLife(3, card);
|
AllZone.HumanPlayer.gainLife(3, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c2.getType().contains("Land")) {
|
if(c2.isType("Land")) {
|
||||||
AllZone.HumanPlayer.gainLife(3, card);
|
AllZone.HumanPlayer.gainLife(3, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1509,7 +1511,7 @@ public class CardFactory_Sorceries {
|
|||||||
public void computerResolve() {
|
public void computerResolve() {
|
||||||
CardList list = AllZoneUtil.getPlayerHand(AllZone.HumanPlayer);
|
CardList list = AllZoneUtil.getPlayerHand(AllZone.HumanPlayer);
|
||||||
|
|
||||||
if(list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
|
|
||||||
Object o = GuiUtils.getChoiceOptional("First card to discard", list.toArray());
|
Object o = GuiUtils.getChoiceOptional("First card to discard", list.toArray());
|
||||||
|
|
||||||
@@ -1518,11 +1520,11 @@ public class CardFactory_Sorceries {
|
|||||||
|
|
||||||
c.getController().discard(c, null);
|
c.getController().discard(c, null);
|
||||||
|
|
||||||
if(c.getType().contains("Land")) {
|
if (c.isType("Land")) {
|
||||||
AllZone.ComputerPlayer.gainLife(3, card);
|
AllZone.ComputerPlayer.gainLife(3, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
Object o2 = GuiUtils.getChoiceOptional("Second card to discard", list.toArray());
|
Object o2 = GuiUtils.getChoiceOptional("Second card to discard", list.toArray());
|
||||||
|
|
||||||
Card c2 = (Card) o2;
|
Card c2 = (Card) o2;
|
||||||
@@ -1530,7 +1532,7 @@ public class CardFactory_Sorceries {
|
|||||||
|
|
||||||
c2.getController().discard(c2, null);
|
c2.getController().discard(c2, null);
|
||||||
|
|
||||||
if(c2.getType().contains("Land")) {
|
if (c2.isType("Land")) {
|
||||||
AllZone.ComputerPlayer.gainLife(3, card);
|
AllZone.ComputerPlayer.gainLife(3, card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1594,7 +1596,7 @@ public class CardFactory_Sorceries {
|
|||||||
CardList creature = AllZoneUtil.getCreaturesInPlay(card.getController());
|
CardList creature = AllZoneUtil.getCreaturesInPlay(card.getController());
|
||||||
creature = creature.filter(new CardListFilter() {
|
creature = creature.filter(new CardListFilter() {
|
||||||
public boolean addCard(Card card) {
|
public boolean addCard(Card card) {
|
||||||
return (!card.getType().contains("Legendary"));
|
return (!card.isType("Legendary"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(creature.size() == 0) return false;
|
if(creature.size() == 0) return false;
|
||||||
@@ -1611,7 +1613,7 @@ public class CardFactory_Sorceries {
|
|||||||
CardList creature = AllZoneUtil.getCreaturesInPlay();
|
CardList creature = AllZoneUtil.getCreaturesInPlay();
|
||||||
creature = creature.filter(new CardListFilter() {
|
creature = creature.filter(new CardListFilter() {
|
||||||
public boolean addCard(Card card) {
|
public boolean addCard(Card card) {
|
||||||
return (!card.getType().contains("Legendary"));
|
return (!card.isType("Legendary"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(creature.size() > 0) {
|
if(creature.size() > 0) {
|
||||||
@@ -1673,13 +1675,13 @@ public class CardFactory_Sorceries {
|
|||||||
CardList creature = AllZoneUtil.getCreaturesInPlay(card.getController());
|
CardList creature = AllZoneUtil.getCreaturesInPlay(card.getController());
|
||||||
creature = creature.filter(new CardListFilter() {
|
creature = creature.filter(new CardListFilter() {
|
||||||
public boolean addCard(Card card) {
|
public boolean addCard(Card card) {
|
||||||
return (!card.getType().contains("Legendary"));
|
return (!card.isType("Legendary"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(creature.size() == 0) return false;
|
if(creature.size() == 0) return false;
|
||||||
biggest = creature.get(0);
|
biggest = creature.get(0);
|
||||||
for(int i = 0; i < creature.size(); i++)
|
for (int i = 0; i < creature.size(); i++)
|
||||||
if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
|
if (biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
|
||||||
setTargetCard(biggest);
|
setTargetCard(biggest);
|
||||||
|
|
||||||
return biggest.getNetAttack() > 3;
|
return biggest.getNetAttack() > 3;
|
||||||
@@ -1690,13 +1692,13 @@ public class CardFactory_Sorceries {
|
|||||||
CardList creature = AllZoneUtil.getCreaturesInPlay(card.getController());
|
CardList creature = AllZoneUtil.getCreaturesInPlay(card.getController());
|
||||||
creature = creature.filter(new CardListFilter() {
|
creature = creature.filter(new CardListFilter() {
|
||||||
public boolean addCard(Card card) {
|
public boolean addCard(Card card) {
|
||||||
return (!card.getType().contains("Legendary"));
|
return (!card.isType("Legendary"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(creature.size() > 0) {
|
if (creature.size() > 0) {
|
||||||
Card biggest = creature.get(0);
|
Card biggest = creature.get(0);
|
||||||
for(int i = 0; i < creature.size(); i++)
|
for (int i = 0; i < creature.size(); i++)
|
||||||
if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
|
if (biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i);
|
||||||
setTargetCard(biggest);
|
setTargetCard(biggest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user