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 justAnyone = null;
|
||||
for (Player p : game.getPlayers()) {
|
||||
if ( p == this ) continue;
|
||||
if (p == this) {
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returns all opponents
|
||||
* returns all opponents.
|
||||
* Should keep player relations somewhere in the match structure
|
||||
* @return
|
||||
*/
|
||||
public final List<Player> getOpponents() {
|
||||
List<Player> result = new ArrayList<Player>();
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (p == this || p.getType() == this.getType())
|
||||
if (p == this || p.getType() == this.getType()) {
|
||||
continue;
|
||||
}
|
||||
result.add(p);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns allied players
|
||||
* returns allied players.
|
||||
* Should keep player relations somewhere in the match structure
|
||||
* @return
|
||||
*/
|
||||
public final List<Player> getAllies() {
|
||||
List<Player> result = new ArrayList<Player>();
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (p == this || p.getType() != this.getType())
|
||||
if (p == this || p.getType() != this.getType()) {
|
||||
continue;
|
||||
}
|
||||
result.add(p);
|
||||
}
|
||||
return result;
|
||||
@@ -588,7 +594,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
// Predict replacement effects
|
||||
for (final Card ca : game.getCardsIn(ZoneType.Battlefield)) {
|
||||
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")) {
|
||||
continue;
|
||||
}
|
||||
@@ -1480,7 +1486,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
int cntLibrary = this.getCardsIn(ZoneType.Library).size();
|
||||
for (final Card c : this.getCardsIn(ZoneType.Graveyard)) {
|
||||
int nDr = getDredgeNumber(c);
|
||||
if ( nDr > 0 && cntLibrary >= nDr) {
|
||||
if (nDr > 0 && cntLibrary >= nDr) {
|
||||
dredge.add(c);
|
||||
}
|
||||
}
|
||||
@@ -1599,12 +1605,12 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
|
||||
game.getAction().discardMadness(c);
|
||||
|
||||
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.");
|
||||
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.");
|
||||
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.");
|
||||
|
||||
if ( ( hasPutIntoPlayInsteadOfDiscard || hasPutIntoPlayWith2xP1P1InsteadOfDiscard )
|
||||
if ((hasPutIntoPlayInsteadOfDiscard || hasPutIntoPlayWith2xP1P1InsteadOfDiscard)
|
||||
&& null != sa && sa.getSourceCard().getController().isHostileTo(c.getController())) {
|
||||
game.getAction().moveToPlay(c);
|
||||
|
||||
@@ -1786,7 +1792,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
|
||||
int s = list.size();
|
||||
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);
|
||||
@@ -2169,7 +2175,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean loseConditionMet(final GameLossReason state, final String spellName) {
|
||||
if ( state != GameLossReason.OpponentWon ) {
|
||||
if (state != GameLossReason.OpponentWon) {
|
||||
if (this.cantLose()) {
|
||||
System.out.println("Tried to lose, but currently can't.");
|
||||
return false;
|
||||
@@ -2231,8 +2237,11 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
*/
|
||||
public final boolean cantWin() {
|
||||
boolean isAnyOppLoseProof = false;
|
||||
for( Player p : game.getPlayers() ) {
|
||||
if ( p == this || p.getOutcome() != null ) continue; // except self and already dead
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (p == this || p.getOutcome() != null) {
|
||||
|
||||
continue; // except self and already dead
|
||||
}
|
||||
isAnyOppLoseProof |= p.hasKeyword("You can't lose the game.");
|
||||
}
|
||||
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() {
|
||||
|
||||
if ( this.getOutcome() != null )
|
||||
if (this.getOutcome() != null) {
|
||||
return this.getOutcome().lossState != null;
|
||||
}
|
||||
|
||||
if (this.poisonCounters >= 10) {
|
||||
return this.loseConditionMet(GameLossReason.Poisoned, null);
|
||||
@@ -2728,7 +2738,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.abs(subtractedHash)/subtractedHash;
|
||||
return Math.abs(subtractedHash) / subtractedHash;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@@ -2749,7 +2759,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
public static Predicate<Player> isType(final PlayerType type) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(Player input){
|
||||
public boolean apply(Player input) {
|
||||
return input.getType() == type;
|
||||
}
|
||||
};
|
||||
@@ -2757,36 +2767,36 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
|
||||
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
|
||||
public LobbyPlayer apply(Player input) {
|
||||
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
|
||||
public Integer apply(Player input) {
|
||||
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
|
||||
public PlayerType apply(Player input) {
|
||||
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
|
||||
public String apply(Player input) {
|
||||
return input.getName();
|
||||
}
|
||||
};
|
||||
|
||||
public static Function<Player, Integer> countCardsInZone(final ZoneType zone){
|
||||
return new Function<Player, Integer>(){
|
||||
public static Function<Player, Integer> countCardsInZone(final ZoneType zone) {
|
||||
return new Function<Player, Integer>() {
|
||||
@Override
|
||||
public Integer apply(Player input) {
|
||||
return input.getZone(zone).size();
|
||||
@@ -2811,9 +2821,11 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
* TODO: Write javadoc for this method.
|
||||
*/
|
||||
public void onGameOver() {
|
||||
if ( null == stats.getOutcome() ) // not lost?
|
||||
if (null == stats.getOutcome()) {
|
||||
|
||||
setOutcome(PlayerOutcome.win()); // then won!
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* use to get a list of creatures in play for a given player.
|
||||
@@ -2852,7 +2864,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
|
||||
public int getCounterDoublersMagnitude(final CounterType type) {
|
||||
int counterDoublers = getCardsIn(ZoneType.Battlefield, "Doubling Season").size();
|
||||
if(type == CounterType.P1P1) {
|
||||
if (type == CounterType.P1P1) {
|
||||
counterDoublers += getCardsIn(ZoneType.Battlefield, "Corpsejack Menace").size();
|
||||
}
|
||||
return 1 << counterDoublers;
|
||||
@@ -2865,9 +2877,9 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
|
||||
public void onCleanupPhase() {
|
||||
for (Card c : getCardsIn(ZoneType.Hand))
|
||||
for (Card c : getCardsIn(ZoneType.Hand)) {
|
||||
c.setDrawnThisTurn(false);
|
||||
|
||||
}
|
||||
resetPreventNextDamage();
|
||||
resetNumDrawnThisTurn();
|
||||
setAttackedWithCreatureThisTurn(false);
|
||||
@@ -2981,8 +2993,9 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
|
||||
* @return
|
||||
*/
|
||||
public boolean isHostileTo(Player other) {
|
||||
if ( other.equals(getOpponent()) )
|
||||
if (other.equals(getOpponent())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,4 @@ public class PlayerController {
|
||||
aiInput = computerAIInput;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class PlayerOutcome {
|
||||
public final String loseConditionSpell;
|
||||
|
||||
private PlayerOutcome(String altWinSourceName, GameLossReason lossState, String loseConditionSpell) {
|
||||
this.altWinSourceName= altWinSourceName;
|
||||
this.altWinSourceName = altWinSourceName;
|
||||
this.loseConditionSpell = loseConditionSpell;
|
||||
this.lossState = lossState;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user