mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- CheckStyle.
This commit is contained in:
@@ -210,39 +210,45 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
Player otherType = null;
|
Player otherType = null;
|
||||||
Player justAnyone = null;
|
Player justAnyone = null;
|
||||||
for (Player p : game.getPlayers()) {
|
for (Player p : game.getPlayers()) {
|
||||||
if ( p == this ) continue;
|
if (p == this) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
justAnyone = p;
|
justAnyone = p;
|
||||||
if( otherType == null && p.getType() != this.getType() ) otherType = p;
|
if (otherType == null && p.getType() != this.getType()) {
|
||||||
|
otherType = p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return otherType != null ? otherType : justAnyone;
|
return otherType != null ? otherType : justAnyone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* returns all opponents
|
* returns all opponents.
|
||||||
* Should keep player relations somewhere in the match structure
|
* Should keep player relations somewhere in the match structure
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public final List<Player> getOpponents() {
|
public final List<Player> getOpponents() {
|
||||||
List<Player> result = new ArrayList<Player>();
|
List<Player> result = new ArrayList<Player>();
|
||||||
for (Player p : game.getPlayers()) {
|
for (Player p : game.getPlayers()) {
|
||||||
if (p == this || p.getType() == this.getType())
|
if (p == this || p.getType() == this.getType()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
result.add(p);
|
result.add(p);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns allied players
|
* returns allied players.
|
||||||
* Should keep player relations somewhere in the match structure
|
* Should keep player relations somewhere in the match structure
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public final List<Player> getAllies() {
|
public final List<Player> getAllies() {
|
||||||
List<Player> result = new ArrayList<Player>();
|
List<Player> result = new ArrayList<Player>();
|
||||||
for (Player p : game.getPlayers()) {
|
for (Player p : game.getPlayers()) {
|
||||||
if (p == this || p.getType() != this.getType())
|
if (p == this || p.getType() != this.getType()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
result.add(p);
|
result.add(p);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -588,7 +594,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
// Predict replacement effects
|
// Predict replacement effects
|
||||||
for (final Card ca : game.getCardsIn(ZoneType.Battlefield)) {
|
for (final Card ca : game.getCardsIn(ZoneType.Battlefield)) {
|
||||||
for (final ReplacementEffect re : ca.getReplacementEffects()) {
|
for (final ReplacementEffect re : ca.getReplacementEffects()) {
|
||||||
HashMap<String,String> params = re.getMapParams();
|
HashMap<String, String> params = re.getMapParams();
|
||||||
if (!"DamageDone".equals(params.get("Event")) || !params.containsKey("PreventionEffect")) {
|
if (!"DamageDone".equals(params.get("Event")) || !params.containsKey("PreventionEffect")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1480,7 +1486,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
int cntLibrary = this.getCardsIn(ZoneType.Library).size();
|
int cntLibrary = this.getCardsIn(ZoneType.Library).size();
|
||||||
for (final Card c : this.getCardsIn(ZoneType.Graveyard)) {
|
for (final Card c : this.getCardsIn(ZoneType.Graveyard)) {
|
||||||
int nDr = getDredgeNumber(c);
|
int nDr = getDredgeNumber(c);
|
||||||
if ( nDr > 0 && cntLibrary >= nDr) {
|
if (nDr > 0 && cntLibrary >= nDr) {
|
||||||
dredge.add(c);
|
dredge.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1599,12 +1605,12 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
|
|
||||||
game.getAction().discardMadness(c);
|
game.getAction().discardMadness(c);
|
||||||
|
|
||||||
boolean hasPutIntoPlayInsteadOfDiscard = c.hasKeyword("If a spell or ability an opponent controls causes you " +
|
boolean hasPutIntoPlayInsteadOfDiscard = c.hasKeyword("If a spell or ability an opponent controls causes you "
|
||||||
"to discard CARDNAME, put it onto the battlefield instead of putting it into your graveyard.");
|
+ "to discard CARDNAME, put it onto the battlefield instead of putting it into your graveyard.");
|
||||||
boolean hasPutIntoPlayWith2xP1P1InsteadOfDiscard = c.hasKeyword("If a spell or ability an opponent controls causes you to discard CARDNAME, "
|
boolean hasPutIntoPlayWith2xP1P1InsteadOfDiscard = c.hasKeyword("If a spell or ability an opponent controls causes you to discard CARDNAME, "
|
||||||
+ "put it onto the battlefield with two +1/+1 counters on it instead of putting it into your graveyard.");
|
+ "put it onto the battlefield with two +1/+1 counters on it instead of putting it into your graveyard.");
|
||||||
|
|
||||||
if ( ( hasPutIntoPlayInsteadOfDiscard || hasPutIntoPlayWith2xP1P1InsteadOfDiscard )
|
if ((hasPutIntoPlayInsteadOfDiscard || hasPutIntoPlayWith2xP1P1InsteadOfDiscard)
|
||||||
&& null != sa && sa.getSourceCard().getController().isHostileTo(c.getController())) {
|
&& null != sa && sa.getSourceCard().getController().isHostileTo(c.getController())) {
|
||||||
game.getAction().moveToPlay(c);
|
game.getAction().moveToPlay(c);
|
||||||
|
|
||||||
@@ -1786,7 +1792,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
|
|
||||||
int s = list.size();
|
int s = list.size();
|
||||||
for (int i = 0; i < s; i++) {
|
for (int i = 0; i < s; i++) {
|
||||||
list.add(random.nextInt(s-1), list.remove(random.nextInt(s)));
|
list.add(random.nextInt(s - 1), list.remove(random.nextInt(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.shuffle(list, random);
|
Collections.shuffle(list, random);
|
||||||
@@ -2169,7 +2175,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean loseConditionMet(final GameLossReason state, final String spellName) {
|
public final boolean loseConditionMet(final GameLossReason state, final String spellName) {
|
||||||
if ( state != GameLossReason.OpponentWon ) {
|
if (state != GameLossReason.OpponentWon) {
|
||||||
if (this.cantLose()) {
|
if (this.cantLose()) {
|
||||||
System.out.println("Tried to lose, but currently can't.");
|
System.out.println("Tried to lose, but currently can't.");
|
||||||
return false;
|
return false;
|
||||||
@@ -2231,8 +2237,11 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
*/
|
*/
|
||||||
public final boolean cantWin() {
|
public final boolean cantWin() {
|
||||||
boolean isAnyOppLoseProof = false;
|
boolean isAnyOppLoseProof = false;
|
||||||
for( Player p : game.getPlayers() ) {
|
for (Player p : game.getPlayers()) {
|
||||||
if ( p == this || p.getOutcome() != null ) continue; // except self and already dead
|
if (p == this || p.getOutcome() != null) {
|
||||||
|
|
||||||
|
continue; // except self and already dead
|
||||||
|
}
|
||||||
isAnyOppLoseProof |= p.hasKeyword("You can't lose the game.");
|
isAnyOppLoseProof |= p.hasKeyword("You can't lose the game.");
|
||||||
}
|
}
|
||||||
return this.hasKeyword("You can't win the game.") || isAnyOppLoseProof;
|
return this.hasKeyword("You can't win the game.") || isAnyOppLoseProof;
|
||||||
@@ -2247,8 +2256,9 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
*/
|
*/
|
||||||
public final boolean checkLoseCondition() {
|
public final boolean checkLoseCondition() {
|
||||||
|
|
||||||
if ( this.getOutcome() != null )
|
if (this.getOutcome() != null) {
|
||||||
return this.getOutcome().lossState != null;
|
return this.getOutcome().lossState != null;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.poisonCounters >= 10) {
|
if (this.poisonCounters >= 10) {
|
||||||
return this.loseConditionMet(GameLossReason.Poisoned, null);
|
return this.loseConditionMet(GameLossReason.Poisoned, null);
|
||||||
@@ -2728,7 +2738,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.abs(subtractedHash)/subtractedHash;
|
return Math.abs(subtractedHash) / subtractedHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@@ -2749,7 +2759,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
public static Predicate<Player> isType(final PlayerType type) {
|
public static Predicate<Player> isType(final PlayerType type) {
|
||||||
return new Predicate<Player>() {
|
return new Predicate<Player>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Player input){
|
public boolean apply(Player input) {
|
||||||
return input.getType() == type;
|
return input.getType() == type;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2757,36 +2767,36 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Accessors {
|
public static class Accessors {
|
||||||
public static Function<Player, LobbyPlayer> FN_GET_LOBBY_PLAYER = new Function<Player, LobbyPlayer>(){
|
public static Function<Player, LobbyPlayer> FN_GET_LOBBY_PLAYER = new Function<Player, LobbyPlayer>() {
|
||||||
@Override
|
@Override
|
||||||
public LobbyPlayer apply(Player input) {
|
public LobbyPlayer apply(Player input) {
|
||||||
return input.getLobbyPlayer();
|
return input.getLobbyPlayer();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Function<Player, Integer> FN_GET_LIFE = new Function<Player, Integer>(){
|
public static Function<Player, Integer> FN_GET_LIFE = new Function<Player, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public Integer apply(Player input) {
|
public Integer apply(Player input) {
|
||||||
return input.getLife();
|
return input.getLife();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Function<Player, PlayerType> FN_GET_TYPE = new Function<Player, PlayerType>(){
|
public static Function<Player, PlayerType> FN_GET_TYPE = new Function<Player, PlayerType>() {
|
||||||
@Override
|
@Override
|
||||||
public PlayerType apply(Player input) {
|
public PlayerType apply(Player input) {
|
||||||
return input.getType();
|
return input.getType();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Function<Player, String> FN_GET_NAME = new Function<Player, String>(){
|
public static Function<Player, String> FN_GET_NAME = new Function<Player, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String apply(Player input) {
|
public String apply(Player input) {
|
||||||
return input.getName();
|
return input.getName();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Function<Player, Integer> countCardsInZone(final ZoneType zone){
|
public static Function<Player, Integer> countCardsInZone(final ZoneType zone) {
|
||||||
return new Function<Player, Integer>(){
|
return new Function<Player, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public Integer apply(Player input) {
|
public Integer apply(Player input) {
|
||||||
return input.getZone(zone).size();
|
return input.getZone(zone).size();
|
||||||
@@ -2811,8 +2821,10 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
*/
|
*/
|
||||||
public void onGameOver() {
|
public void onGameOver() {
|
||||||
if ( null == stats.getOutcome() ) // not lost?
|
if (null == stats.getOutcome()) {
|
||||||
|
|
||||||
setOutcome(PlayerOutcome.win()); // then won!
|
setOutcome(PlayerOutcome.win()); // then won!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2852,7 +2864,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
|
|
||||||
public int getCounterDoublersMagnitude(final CounterType type) {
|
public int getCounterDoublersMagnitude(final CounterType type) {
|
||||||
int counterDoublers = getCardsIn(ZoneType.Battlefield, "Doubling Season").size();
|
int counterDoublers = getCardsIn(ZoneType.Battlefield, "Doubling Season").size();
|
||||||
if(type == CounterType.P1P1) {
|
if (type == CounterType.P1P1) {
|
||||||
counterDoublers += getCardsIn(ZoneType.Battlefield, "Corpsejack Menace").size();
|
counterDoublers += getCardsIn(ZoneType.Battlefield, "Corpsejack Menace").size();
|
||||||
}
|
}
|
||||||
return 1 << counterDoublers;
|
return 1 << counterDoublers;
|
||||||
@@ -2865,9 +2877,9 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onCleanupPhase() {
|
public void onCleanupPhase() {
|
||||||
for (Card c : getCardsIn(ZoneType.Hand))
|
for (Card c : getCardsIn(ZoneType.Hand)) {
|
||||||
c.setDrawnThisTurn(false);
|
c.setDrawnThisTurn(false);
|
||||||
|
}
|
||||||
resetPreventNextDamage();
|
resetPreventNextDamage();
|
||||||
resetNumDrawnThisTurn();
|
resetNumDrawnThisTurn();
|
||||||
setAttackedWithCreatureThisTurn(false);
|
setAttackedWithCreatureThisTurn(false);
|
||||||
@@ -2981,8 +2993,9 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isHostileTo(Player other) {
|
public boolean isHostileTo(Player other) {
|
||||||
if ( other.equals(getOpponent()) )
|
if (other.equals(getOpponent())) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return other.getType() != this.getType();
|
return other.getType() != this.getType();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ public class PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean mayAutoPass(PhaseType phase)
|
public boolean mayAutoPass(PhaseType phase) {
|
||||||
{
|
|
||||||
return phase.isBefore(autoPassUntil);
|
return phase.isBefore(autoPassUntil);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +58,4 @@ public class PlayerController {
|
|||||||
aiInput = computerAIInput;
|
aiInput = computerAIInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class PlayerOutcome {
|
|||||||
public final String loseConditionSpell;
|
public final String loseConditionSpell;
|
||||||
|
|
||||||
private PlayerOutcome(String altWinSourceName, GameLossReason lossState, String loseConditionSpell) {
|
private PlayerOutcome(String altWinSourceName, GameLossReason lossState, String loseConditionSpell) {
|
||||||
this.altWinSourceName= altWinSourceName;
|
this.altWinSourceName = altWinSourceName;
|
||||||
this.loseConditionSpell = loseConditionSpell;
|
this.loseConditionSpell = loseConditionSpell;
|
||||||
this.lossState = lossState;
|
this.lossState = lossState;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user