mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Player: added LifeGainedByTeamThisTurn logic
This commit is contained in:
@@ -581,7 +581,9 @@ public class CardFactoryUtil {
|
||||
if (value.contains("LifeGainedThisTurn")) {
|
||||
return doXMath(player.getLifeGainedThisTurn(), m, source);
|
||||
}
|
||||
|
||||
if (value.contains("LifeGainedByTeamThisTurn")) {
|
||||
return doXMath(player.getLifeGainedByTeamThisTurn(), m, source);
|
||||
}
|
||||
if (value.contains("PoisonCounters")) {
|
||||
return doXMath(player.getPoisonCounters(), m, source);
|
||||
}
|
||||
@@ -951,6 +953,9 @@ public class CardFactoryUtil {
|
||||
if (sq[0].contains("LifeYouGainedThisTurn")) {
|
||||
return doXMath(cc.getLifeGainedThisTurn(), m, c);
|
||||
}
|
||||
if (sq[0].contains("LifeYourTeamGainedThisTurn")) {
|
||||
return doXMath(cc.getLifeGainedByTeamThisTurn(), m, c);
|
||||
}
|
||||
if (sq[0].contains("LifeOppsLostThisTurn")) {
|
||||
int lost = 0;
|
||||
for (Player opp : cc.getOpponents()) {
|
||||
|
||||
@@ -771,17 +771,7 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
for (Player p : game.getPlayers()) {
|
||||
p.resetProwl();
|
||||
p.setSpellsCastLastTurn(p.getSpellsCastThisTurn());
|
||||
p.resetSpellsCastThisTurn();
|
||||
p.setLifeLostLastTurn(p.getLifeLostThisTurn());
|
||||
p.setLifeLostThisTurn(0);
|
||||
p.setLifeGainedThisTurn(0);
|
||||
p.setLibrarySearched(0);
|
||||
p.setNumManaConversion(0);
|
||||
|
||||
p.removeKeyword("Skip the untap step of this turn.");
|
||||
p.removeKeyword("Schemes can't be set in motion this turn.");
|
||||
p.clearNextTurn();
|
||||
}
|
||||
|
||||
game.getTriggerHandler().clearThisTurnDelayedTrigger();
|
||||
|
||||
@@ -91,6 +91,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
private int lifeLostThisTurn = 0;
|
||||
private int lifeLostLastTurn = 0;
|
||||
private int lifeGainedThisTurn = 0;
|
||||
private int lifeGainedByTeamThisTurn = 0;
|
||||
private int numPowerSurgeLands;
|
||||
private int numLibrarySearchedOwn = 0; //The number of times this player has searched his library
|
||||
private int maxHandSize = 7;
|
||||
@@ -309,6 +310,15 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
return getAllOtherPlayers().filter(Predicates.not(PlayerPredicates.isOpponentOf(this)));
|
||||
}
|
||||
|
||||
public final PlayerCollection getTeamMates(final boolean inclThis) {
|
||||
PlayerCollection col = new PlayerCollection();
|
||||
if (inclThis) {
|
||||
col.add(this);
|
||||
}
|
||||
col.addAll(getAllOtherPlayers().filter(PlayerPredicates.sameTeam(this)));
|
||||
return col;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns allied players.
|
||||
* Should keep player relations somewhere in the match structure
|
||||
@@ -414,6 +424,11 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
newLifeSet = true;
|
||||
lifeGainedThisTurn += lifeGain;
|
||||
|
||||
// team mates need to be notified about life gained
|
||||
for (final Player p : getTeamMates(true)) {
|
||||
p.addLifeGainedByTeamThisTurn(lifeGain);
|
||||
}
|
||||
|
||||
// Run triggers
|
||||
final Map<String, Object> runParams = Maps.newHashMap();
|
||||
runParams.put("Player", this);
|
||||
@@ -2149,6 +2164,13 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
spellsCastLastTurn = num;
|
||||
}
|
||||
|
||||
public final int getLifeGainedByTeamThisTurn() {
|
||||
return lifeGainedByTeamThisTurn;
|
||||
}
|
||||
public final void addLifeGainedByTeamThisTurn(int val) {
|
||||
lifeGainedByTeamThisTurn += val;
|
||||
}
|
||||
|
||||
public final int getLifeGainedThisTurn() {
|
||||
return lifeGainedThisTurn;
|
||||
}
|
||||
@@ -2789,7 +2811,32 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
this.updateZoneForView(com);
|
||||
}
|
||||
|
||||
public final boolean sameTeam(final Player other) {
|
||||
if (this.equals(other)) {
|
||||
return true;
|
||||
}
|
||||
if (this.teamNumber < 0 || other.getTeam() < 0) {
|
||||
return false;
|
||||
}
|
||||
return this.teamNumber == other.getTeam();
|
||||
}
|
||||
|
||||
public final int countExaltedBonus() {
|
||||
return CardLists.getAmountOfKeyword(this.getCardsIn(ZoneType.Battlefield), Keyword.EXALTED);
|
||||
}
|
||||
|
||||
public final void clearNextTurn() {
|
||||
resetProwl();
|
||||
setSpellsCastLastTurn(getSpellsCastThisTurn());
|
||||
resetSpellsCastThisTurn();
|
||||
setLifeLostLastTurn(getLifeLostThisTurn());
|
||||
setLifeLostThisTurn(0);
|
||||
lifeGainedThisTurn = 0;
|
||||
lifeGainedByTeamThisTurn = 0;
|
||||
setLibrarySearched(0);
|
||||
setNumManaConversion(0);
|
||||
|
||||
removeKeyword("Skip the untap step of this turn.");
|
||||
removeKeyword("Schemes can't be set in motion this turn.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,15 @@ public final class PlayerPredicates {
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Player> sameTeam(final Player player) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
public boolean apply(final Player p) {
|
||||
return player.sameTeam(p);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final Predicate<Player> isCardInPlay(final String cardName) {
|
||||
return new Predicate<Player>() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user