mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- CheckStyle.
This commit is contained in:
@@ -286,7 +286,7 @@ public class Deck extends DeckBase {
|
|||||||
out.add(String.format("%s", "[sideboard]"));
|
out.add(String.format("%s", "[sideboard]"));
|
||||||
out.addAll(Deck.writeCardPool(this.getSideboard()));
|
out.addAll(Deck.writeCardPool(this.getSideboard()));
|
||||||
|
|
||||||
if ( getCommander() != null ) {
|
if (getCommander() != null) {
|
||||||
out.add(String.format("%s", "[commander]"));
|
out.add(String.format("%s", "[commander]"));
|
||||||
out.add(Deck.serializeSingleCard(getCommander(), 1));
|
out.add(Deck.serializeSingleCard(getCommander(), 1));
|
||||||
}
|
}
|
||||||
@@ -352,44 +352,52 @@ public class Deck extends DeckBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == GameType.Commander)
|
if (type == GameType.Commander) { //Must contain exactly 1 legendary Commander and no sideboard.
|
||||||
{//Must contain exactly 1 legendary Commander and no sideboard.
|
|
||||||
//TODO:Enforce color identity
|
|
||||||
if ( null == getCommander())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(!getCommander().getCard().getType().isLegendary())
|
//TODO:Enforce color identity
|
||||||
|
if (null == getCommander()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
if (!getCommander().getCard().getType().isLegendary()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//No sideboarding in Commander
|
//No sideboarding in Commander
|
||||||
if(!getSideboard().isEmpty())
|
if (!getSideboard().isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if(type == GameType.Planechase)
|
|
||||||
{//Must contain at least 10 planes/phenomenons, but max 2 phenomenons. Singleton.
|
|
||||||
if(getPlanes().countAll() < 10)
|
|
||||||
return false;
|
|
||||||
int phenoms = 0;
|
|
||||||
for(CardPrinted cp : getPlanes().toFlatList())
|
|
||||||
{
|
|
||||||
if(cp.getType().contains("Phenomenon"))
|
|
||||||
phenoms++;
|
|
||||||
if(getPlanes().count(cp) > 1)
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if(phenoms > 2)
|
else if (type == GameType.Planechase) { //Must contain at least 10 planes/phenomenons, but max 2 phenomenons. Singleton.
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if(type == GameType.Archenemy)
|
|
||||||
{//Must contain at least 20 schemes, max 2 of each.
|
|
||||||
if(getSchemes().countAll() < 20)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for(CardPrinted cp : getSchemes().toFlatList())
|
if (getPlanes().countAll() < 10) {
|
||||||
{
|
|
||||||
if(getSchemes().count(cp) > 2)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
int phenoms = 0;
|
||||||
|
for (CardPrinted cp : getPlanes().toFlatList()) {
|
||||||
|
|
||||||
|
if (cp.getType().contains("Phenomenon")) {
|
||||||
|
phenoms++;
|
||||||
|
}
|
||||||
|
if (getPlanes().count(cp) > 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (phenoms > 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type == GameType.Archenemy) { //Must contain at least 20 schemes, max 2 of each.
|
||||||
|
|
||||||
|
if (getSchemes().countAll() < 20) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (CardPrinted cp : getSchemes().toFlatList()) {
|
||||||
|
|
||||||
|
if (getSchemes().count(cp) > 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class GameNew {
|
|||||||
final Card card = cardPrinted.toForgeCard(player);
|
final Card card = cardPrinted.toForgeCard(player);
|
||||||
|
|
||||||
// apply random pictures for cards
|
// apply random pictures for cards
|
||||||
if ( player.isComputer() ) {
|
if (player.isComputer()) {
|
||||||
final int cntVariants = cardPrinted.getCard().getEditionInfo(cardPrinted.getEdition()).getCopiesCount();
|
final int cntVariants = cardPrinted.getCard().getEditionInfo(cardPrinted.getEdition()).getCopiesCount();
|
||||||
if (cntVariants > 1) {
|
if (cntVariants > 1) {
|
||||||
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
|
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
|
||||||
@@ -70,15 +70,16 @@ public class GameNew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!useAnte && card.hasKeyword("Remove CARDNAME from your deck before playing if you're not playing for ante.")) {
|
if (!useAnte && card.hasKeyword("Remove CARDNAME from your deck before playing if you're not playing for ante.")) {
|
||||||
if(!removedAnteCards.containsKey(player))
|
if (!removedAnteCards.containsKey(player)) {
|
||||||
removedAnteCards.put(player, new ArrayList<String>());
|
removedAnteCards.put(player, new ArrayList<String>());
|
||||||
|
}
|
||||||
removedAnteCards.get(player).add(card.getName());
|
removedAnteCards.get(player).add(card.getName());
|
||||||
} else {
|
} else {
|
||||||
library.add(card);
|
library.add(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark card as difficult for AI to play
|
// mark card as difficult for AI to play
|
||||||
if ( player.isComputer() && card.getSVar("RemAIDeck").equals("True") && !rAICards.contains(card.getName())) {
|
if (player.isComputer() && card.getSVar("RemAIDeck").equals("True") && !rAICards.contains(card.getName())) {
|
||||||
rAICards.add(card.getName());
|
rAICards.add(card.getName());
|
||||||
// get card picture so that it is in the image cache
|
// get card picture so that it is in the image cache
|
||||||
// ImageCache.getImage(card);
|
// ImageCache.getImage(card);
|
||||||
@@ -88,13 +89,14 @@ public class GameNew {
|
|||||||
|
|
||||||
// Shuffling
|
// Shuffling
|
||||||
// Ai may cheat
|
// Ai may cheat
|
||||||
if ( player.isComputer() && Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_SMOOTH_LAND) ) {
|
if (player.isComputer() && Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_SMOOTH_LAND)) {
|
||||||
// do this instead of shuffling Computer's deck
|
// do this instead of shuffling Computer's deck
|
||||||
final Iterable<Card> c1 = GameNew.smoothComputerManaCurve(player.getCardsIn(ZoneType.Library));
|
final Iterable<Card> c1 = GameNew.smoothComputerManaCurve(player.getCardsIn(ZoneType.Library));
|
||||||
player.getZone(ZoneType.Library).setCards(c1);
|
player.getZone(ZoneType.Library).setCards(c1);
|
||||||
} else
|
} else {
|
||||||
player.shuffle();
|
player.shuffle();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +106,7 @@ public class GameNew {
|
|||||||
* TODO: Accept something like match state as parameter. Match should be aware of players,
|
* TODO: Accept something like match state as parameter. Match should be aware of players,
|
||||||
* their decks and other special starting conditions.
|
* their decks and other special starting conditions.
|
||||||
*/
|
*/
|
||||||
public static void newGame(final Map<Player, PlayerStartConditions> playersConditions, final GameState game, final boolean canRandomFoil ) {
|
public static void newGame(final Map<Player, PlayerStartConditions> playersConditions, final GameState game, final boolean canRandomFoil) {
|
||||||
Singletons.getModel().getMatch().getInput().clearInput();
|
Singletons.getModel().getMatch().getInput().clearInput();
|
||||||
|
|
||||||
Card.resetUniqueNumber();
|
Card.resetUniqueNumber();
|
||||||
@@ -118,7 +120,7 @@ public class GameNew {
|
|||||||
final Map<Player, List<String>> removedAnteCards = new HashMap<Player, List<String>>();
|
final Map<Player, List<String>> removedAnteCards = new HashMap<Player, List<String>>();
|
||||||
final List<String> rAICards = new ArrayList<String>();
|
final List<String> rAICards = new ArrayList<String>();
|
||||||
|
|
||||||
for( Entry<Player, PlayerStartConditions> p : playersConditions.entrySet() ) {
|
for (Entry<Player, PlayerStartConditions> p : playersConditions.entrySet()) {
|
||||||
final Player player = p.getKey();
|
final Player player = p.getKey();
|
||||||
player.setStartingLife(p.getValue().getStartingLife());
|
player.setStartingLife(p.getValue().getStartingLife());
|
||||||
int hand = p.getValue().getStartingHand();
|
int hand = p.getValue().getStartingHand();
|
||||||
@@ -164,8 +166,8 @@ public class GameNew {
|
|||||||
|
|
||||||
if (!removedAnteCards.isEmpty()) {
|
if (!removedAnteCards.isEmpty()) {
|
||||||
StringBuilder ante = new StringBuilder("The following ante cards were removed:\n\n");
|
StringBuilder ante = new StringBuilder("The following ante cards were removed:\n\n");
|
||||||
for(Entry<Player, List<String>> ants : removedAnteCards.entrySet() ) {
|
for (Entry<Player, List<String>> ants : removedAnteCards.entrySet()) {
|
||||||
ante.append(buildFourColumnList( "From the " + ants.getKey().getName() + "'s deck:", ants.getValue()));
|
ante.append(buildFourColumnList("From the " + ants.getKey().getName() + "'s deck:", ants.getValue()));
|
||||||
}
|
}
|
||||||
JOptionPane.showMessageDialog(null, ante.toString(), "", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, ante.toString(), "", JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
@@ -198,7 +200,7 @@ public class GameNew {
|
|||||||
GameAction action = game.getAction();
|
GameAction action = game.getAction();
|
||||||
|
|
||||||
|
|
||||||
for( Entry<Player, PlayerStartConditions> p : playersConditions.entrySet() ) {
|
for (Entry<Player, PlayerStartConditions> p : playersConditions.entrySet()) {
|
||||||
final Player player = p.getKey();
|
final Player player = p.getKey();
|
||||||
player.setStartingLife(p.getValue().getStartingLife());
|
player.setStartingLife(p.getValue().getStartingLife());
|
||||||
player.setNumLandsPlayed(0);
|
player.setNumLandsPlayed(0);
|
||||||
@@ -218,7 +220,7 @@ public class GameNew {
|
|||||||
|
|
||||||
PlayerZone library = player.getZone(ZoneType.Library);
|
PlayerZone library = player.getZone(ZoneType.Library);
|
||||||
List<Card> newLibrary = playerLibraries.get(player);
|
List<Card> newLibrary = playerLibraries.get(player);
|
||||||
for(Card c : newLibrary) {
|
for (Card c : newLibrary) {
|
||||||
action.moveTo(library, c);
|
action.moveTo(library, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +289,7 @@ public class GameNew {
|
|||||||
control.setInput(new InputMulligan());
|
control.setInput(new InputMulligan());
|
||||||
} // newGame()
|
} // newGame()
|
||||||
|
|
||||||
private static String buildFourColumnList(String firstLine, List<String> cAnteRemoved ) {
|
private static String buildFourColumnList(String firstLine, List<String> cAnteRemoved) {
|
||||||
StringBuilder sb = new StringBuilder(firstLine);
|
StringBuilder sb = new StringBuilder(firstLine);
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
for (int i = 0; i < cAnteRemoved.size(); i++) {
|
for (int i = 0; i < cAnteRemoved.size(); i++) {
|
||||||
@@ -387,9 +389,10 @@ public class GameNew {
|
|||||||
else {
|
else {
|
||||||
sb.append(" lost the last game.");
|
sb.append(" lost the last game.");
|
||||||
}
|
}
|
||||||
if ( goesFirst.isHuman() ) {
|
if (goesFirst.isHuman()) {
|
||||||
if( !humanPlayOrDraw(sb.toString()) )
|
if (!humanPlayOrDraw(sb.toString())) {
|
||||||
goesFirst = goesFirst.getOpponent();
|
goesFirst = goesFirst.getOpponent();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sb.append("\nComputer Going First");
|
sb.append("\nComputer Going First");
|
||||||
JOptionPane.showMessageDialog(null, sb.toString(),
|
JOptionPane.showMessageDialog(null, sb.toString(),
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class MatchStartHelper {
|
|||||||
private final Map<LobbyPlayer, PlayerStartConditions> players = new HashMap<LobbyPlayer, PlayerStartConditions>();
|
private final Map<LobbyPlayer, PlayerStartConditions> players = new HashMap<LobbyPlayer, PlayerStartConditions>();
|
||||||
|
|
||||||
public void addPlayer(final LobbyPlayer player, final PlayerStartConditions c) {
|
public void addPlayer(final LobbyPlayer player, final PlayerStartConditions c) {
|
||||||
players.put(player,c);
|
players.put(player, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(final LobbyPlayer player, final Deck deck) {
|
public void addPlayer(final LobbyPlayer player, final Deck deck) {
|
||||||
@@ -29,8 +29,8 @@ public class MatchStartHelper {
|
|||||||
players.put(player, start);
|
players.put(player, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addVanguardPlayer(final LobbyPlayer player, final Deck deck, final CardPrinted avatar)
|
public void addVanguardPlayer(final LobbyPlayer player, final Deck deck, final CardPrinted avatar) {
|
||||||
{
|
|
||||||
PlayerStartConditions start = new PlayerStartConditions(deck);
|
PlayerStartConditions start = new PlayerStartConditions(deck);
|
||||||
|
|
||||||
start.setStartingLife(start.getStartingLife() + avatar.getCard().getLife());
|
start.setStartingLife(start.getStartingLife() + avatar.getCard().getLife());
|
||||||
@@ -50,8 +50,8 @@ public class MatchStartHelper {
|
|||||||
players.put(player, start);
|
players.put(player, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<LobbyPlayer, PlayerStartConditions> getPlayerMap()
|
public Map<LobbyPlayer, PlayerStartConditions> getPlayerMap() {
|
||||||
{
|
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -488,9 +488,10 @@ public class MagicStack extends MyObservable {
|
|||||||
//GuiDisplayUtil.updateGUI();
|
//GuiDisplayUtil.updateGUI();
|
||||||
} else {
|
} else {
|
||||||
if (sp.getOptionalAdditionalCosts() != null) {
|
if (sp.getOptionalAdditionalCosts() != null) {
|
||||||
for (String s : sp.getOptionalAdditionalCosts())
|
for (String s : sp.getOptionalAdditionalCosts()) {
|
||||||
sp.getSourceCard().addOptionalAdditionalCostsPaid(s);
|
sp.getSourceCard().addOptionalAdditionalCostsPaid(s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (sp.getSourceCard().isCopiedSpell()) {
|
if (sp.getSourceCard().isCopiedSpell()) {
|
||||||
this.push(sp);
|
this.push(sp);
|
||||||
} else if (!sp.isMultiKicker() && !sp.isReplicate() && !sp.isXCost()) {
|
} else if (!sp.isMultiKicker() && !sp.isReplicate() && !sp.isXCost()) {
|
||||||
@@ -1008,13 +1009,13 @@ public class MagicStack extends MyObservable {
|
|||||||
//Move rebounding card to exile
|
//Move rebounding card to exile
|
||||||
source = game.getAction().exile(source);
|
source = game.getAction().exile(source);
|
||||||
|
|
||||||
source.setSVar("ReboundAbilityTrigger", "DB$ Play | Defined$ Self " +
|
source.setSVar("ReboundAbilityTrigger", "DB$ Play | Defined$ Self "
|
||||||
"| WithoutManaCost$ True | Optional$ True");
|
+ "| WithoutManaCost$ True | Optional$ True");
|
||||||
|
|
||||||
//Setup a Rebound-trigger
|
//Setup a Rebound-trigger
|
||||||
final Trigger reboundTrigger = forge.card.trigger.TriggerHandler.parseTrigger("Mode$ Phase " +
|
final Trigger reboundTrigger = forge.card.trigger.TriggerHandler.parseTrigger("Mode$ Phase "
|
||||||
"| Phase$ Upkeep | ValidPlayer$ You | OptionalDecider$ You | Execute$ ReboundAbilityTrigger " +
|
+ "| Phase$ Upkeep | ValidPlayer$ You | OptionalDecider$ You | Execute$ ReboundAbilityTrigger "
|
||||||
"| TriggerDescription$ At the beginning of your next upkeep, you may cast " + source.toString()
|
+ "| TriggerDescription$ At the beginning of your next upkeep, you may cast " + source.toString()
|
||||||
+ " without paying it's manacost.", source, true);
|
+ " without paying it's manacost.", source, true);
|
||||||
|
|
||||||
game.getTriggerHandler().registerDelayedTrigger(reboundTrigger);
|
game.getTriggerHandler().registerDelayedTrigger(reboundTrigger);
|
||||||
@@ -1370,12 +1371,11 @@ public class MagicStack extends MyObservable {
|
|||||||
} else {
|
} else {
|
||||||
this.add(next);
|
this.add(next);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
// Otherwise, gave a dual list form to create instead of needing to do it one at a time
|
// Otherwise, gave a dual list form to create instead of needing to do it one at a time
|
||||||
List<SpellAbility> orderedSAs = GuiChoose.getOrderChoices("Select order for Simultaneous Spell Abilities", "Resolve first", 0, activePlayerSAs, null, null);
|
List<SpellAbility> orderedSAs = GuiChoose.getOrderChoices("Select order for Simultaneous Spell Abilities", "Resolve first", 0, activePlayerSAs, null, null);
|
||||||
int size = orderedSAs.size();
|
int size = orderedSAs.size();
|
||||||
for(int i = size-1; i >= 0; i--){
|
for (int i = size - 1; i >= 0; i--) {
|
||||||
SpellAbility next = orderedSAs.get(i);
|
SpellAbility next = orderedSAs.get(i);
|
||||||
if (next.isTrigger()) {
|
if (next.isTrigger()) {
|
||||||
game.getAction().playSpellAbility(next);
|
game.getAction().playSpellAbility(next);
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ public class PlayerZoneBattlefield extends PlayerZone {
|
|||||||
this.leavesTrigger = b;
|
this.leavesTrigger = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Predicate<Card> isNotPhased = new Predicate<Card>(){
|
private static Predicate<Card> isNotPhased = new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Card crd) {
|
public boolean apply(Card crd) {
|
||||||
return !crd.isPhasedOut();
|
return !crd.isPhasedOut();
|
||||||
|
|||||||
@@ -207,8 +207,9 @@ public class Zone extends MyObservable implements IZone, Observer, java.io.Seria
|
|||||||
@Override
|
@Override
|
||||||
public final void setCards(final Iterable<Card> cards) {
|
public final void setCards(final Iterable<Card> cards) {
|
||||||
cardList.clear();
|
cardList.clear();
|
||||||
for(Card c : cards)
|
for (Card c : cards) {
|
||||||
cardList.add(c);
|
cardList.add(c);
|
||||||
|
}
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user