mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
refactor ManaShards
- remove Mana Shards as countertype
This commit is contained in:
@@ -297,7 +297,7 @@ public class Game {
|
|||||||
pl.setStartingHandSize(psc.getStartingHand());
|
pl.setStartingHandSize(psc.getStartingHand());
|
||||||
|
|
||||||
if (psc.getManaShards() > 0) {
|
if (psc.getManaShards() > 0) {
|
||||||
pl.setCounters(CounterEnumType.MANASHARDS, psc.getManaShards(), true);
|
pl.setNumManaShards(psc.getManaShards());
|
||||||
}
|
}
|
||||||
int teamNum = psc.getTeamNumber();
|
int teamNum = psc.getTeamNumber();
|
||||||
if (teamNum == -1) {
|
if (teamNum == -1) {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package forge.game;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
@@ -281,10 +280,7 @@ public abstract class GameEntity extends GameObject implements IIdentifiable {
|
|||||||
|
|
||||||
// Counters!
|
// Counters!
|
||||||
public boolean hasCounters() {
|
public boolean hasCounters() {
|
||||||
if (counters.isEmpty())
|
return !counters.isEmpty();
|
||||||
return false;
|
|
||||||
int size = counters.entrySet().stream().filter(ct -> !ct.getKey().is(CounterEnumType.MANASHARDS)).collect(Collectors.toList()).size();
|
|
||||||
return size > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all counters from a card
|
// get all counters from a card
|
||||||
|
|||||||
@@ -65,8 +65,6 @@ public class CountersProliferateEffect extends SpellAbilityEffect {
|
|||||||
GameEntityCounterTable table = new GameEntityCounterTable();
|
GameEntityCounterTable table = new GameEntityCounterTable();
|
||||||
for (final GameEntity ge : result) {
|
for (final GameEntity ge : result) {
|
||||||
for (final CounterType ct : ge.getCounters().keySet()) {
|
for (final CounterType ct : ge.getCounters().keySet()) {
|
||||||
if (ct.is(CounterEnumType.MANASHARDS))
|
|
||||||
continue;
|
|
||||||
ge.addCounter(ct, 1, p, table);
|
ge.addCounter(ct, 1, p, table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -394,7 +394,6 @@ public enum CounterEnumType {
|
|||||||
POISON("POISN"),
|
POISON("POISN"),
|
||||||
|
|
||||||
TICKET("TICKET"),
|
TICKET("TICKET"),
|
||||||
MANASHARDS("MANASHARDS"), //Adventure-specific mechanic
|
|
||||||
|
|
||||||
// Keyword Counters
|
// Keyword Counters
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package forge.game.cost;
|
|||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CounterEnumType;
|
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
|
||||||
@@ -47,7 +46,7 @@ public class CostPayShards extends CostPart {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getMaxAmountX(final SpellAbility ability, final Player payer, final boolean effect) {
|
public Integer getMaxAmountX(final SpellAbility ability, final Player payer, final boolean effect) {
|
||||||
return payer.getCounters(CounterEnumType.MANASHARDS);
|
return payer.getNumManaShards();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -83,7 +82,7 @@ public class CostPayShards extends CostPart {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canPay(final SpellAbility ability, final Player payer, final boolean effect) {
|
public final boolean canPay(final SpellAbility ability, final Player payer, final boolean effect) {
|
||||||
return payer.getCounters(CounterEnumType.MANASHARDS) >= this.getAbilityAmount(ability);
|
return payer.getNumManaShards() >= this.getAbilityAmount(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package forge.game.event;
|
||||||
|
|
||||||
|
import forge.game.player.Player;
|
||||||
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
|
public class GameEventPlayerShardsChanged extends GameEvent {
|
||||||
|
public final Player player;
|
||||||
|
public final int oldShards;
|
||||||
|
public final int newShards;
|
||||||
|
|
||||||
|
public GameEventPlayerShardsChanged(Player who, int oldValue, int newValue) {
|
||||||
|
player = who;
|
||||||
|
oldShards = oldValue;
|
||||||
|
newShards = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T visit(IGameEventVisitor<T> visitor) {
|
||||||
|
return visitor.visit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return TextUtil.concatWithSpace(Lang.getInstance().getPossesive(player.getName()),"shards changed:", String.valueOf(oldShards),"->", String.valueOf(newShards));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,7 @@ public interface IGameEventVisitor<T> {
|
|||||||
T visit(GameEventPlayerCounters event);
|
T visit(GameEventPlayerCounters event);
|
||||||
T visit(GameEventPlayerPoisoned event);
|
T visit(GameEventPlayerPoisoned event);
|
||||||
T visit(GameEventPlayerPriority event);
|
T visit(GameEventPlayerPriority event);
|
||||||
|
T visit(GameEventPlayerShardsChanged event);
|
||||||
T visit(GameEventPlayerStatsChanged event);
|
T visit(GameEventPlayerStatsChanged event);
|
||||||
T visit(GameEventRandomLog event);
|
T visit(GameEventRandomLog event);
|
||||||
T visit(GameEventRollDie event);
|
T visit(GameEventRollDie event);
|
||||||
@@ -90,6 +91,7 @@ public interface IGameEventVisitor<T> {
|
|||||||
public T visit(GameEventPlayerCounters event) { return null; }
|
public T visit(GameEventPlayerCounters event) { return null; }
|
||||||
public T visit(GameEventPlayerPoisoned event) { return null; }
|
public T visit(GameEventPlayerPoisoned event) { return null; }
|
||||||
public T visit(GameEventPlayerPriority event) { return null; }
|
public T visit(GameEventPlayerPriority event) { return null; }
|
||||||
|
public T visit(GameEventPlayerShardsChanged event) { return null; }
|
||||||
public T visit(GameEventPlayerStatsChanged event) { return null; }
|
public T visit(GameEventPlayerStatsChanged event) { return null; }
|
||||||
public T visit(GameEventRandomLog event) { return null; }
|
public T visit(GameEventRandomLog event) { return null; }
|
||||||
public T visit(GameEventRollDie event) { return null; }
|
public T visit(GameEventRollDie event) { return null; }
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import java.util.NavigableMap;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import forge.game.event.*;
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
@@ -78,18 +79,6 @@ import forge.game.card.CardUtil;
|
|||||||
import forge.game.card.CardZoneTable;
|
import forge.game.card.CardZoneTable;
|
||||||
import forge.game.card.CounterEnumType;
|
import forge.game.card.CounterEnumType;
|
||||||
import forge.game.card.CounterType;
|
import forge.game.card.CounterType;
|
||||||
import forge.game.event.GameEventCardSacrificed;
|
|
||||||
import forge.game.event.GameEventLandPlayed;
|
|
||||||
import forge.game.event.GameEventManaBurn;
|
|
||||||
import forge.game.event.GameEventMulligan;
|
|
||||||
import forge.game.event.GameEventPlayerControl;
|
|
||||||
import forge.game.event.GameEventPlayerCounters;
|
|
||||||
import forge.game.event.GameEventPlayerDamaged;
|
|
||||||
import forge.game.event.GameEventPlayerLivesChanged;
|
|
||||||
import forge.game.event.GameEventPlayerPoisoned;
|
|
||||||
import forge.game.event.GameEventPlayerStatsChanged;
|
|
||||||
import forge.game.event.GameEventShuffle;
|
|
||||||
import forge.game.event.GameEventSurveil;
|
|
||||||
import forge.game.keyword.Companion;
|
import forge.game.keyword.Companion;
|
||||||
import forge.game.keyword.Keyword;
|
import forge.game.keyword.Keyword;
|
||||||
import forge.game.keyword.KeywordCollection;
|
import forge.game.keyword.KeywordCollection;
|
||||||
@@ -162,6 +151,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
private int lifeGainedThisTurn;
|
private int lifeGainedThisTurn;
|
||||||
private int lifeGainedTimesThisTurn;
|
private int lifeGainedTimesThisTurn;
|
||||||
private int lifeGainedByTeamThisTurn;
|
private int lifeGainedByTeamThisTurn;
|
||||||
|
private int numManaShards;
|
||||||
private int numPowerSurgeLands;
|
private int numPowerSurgeLands;
|
||||||
private int numLibrarySearchedOwn; //The number of times this player has searched his library
|
private int numLibrarySearchedOwn; //The number of times this player has searched his library
|
||||||
private int numDrawnThisTurn;
|
private int numDrawnThisTurn;
|
||||||
@@ -662,17 +652,17 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean canPayShards(final int shardPayment) {
|
public final boolean canPayShards(final int shardPayment) {
|
||||||
int cnt = getCounters(CounterEnumType.MANASHARDS);
|
int cnt = getNumManaShards();
|
||||||
return cnt >= shardPayment;
|
return cnt >= shardPayment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int loseShards(int lostShards) {
|
public final int loseShards(int lostShards) {
|
||||||
int cnt = getCounters(CounterEnumType.MANASHARDS);
|
int cnt = getNumManaShards();
|
||||||
if (lostShards > cnt) {
|
if (lostShards > cnt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
cnt -= lostShards;
|
cnt -= lostShards;
|
||||||
this.setCounters(CounterEnumType.MANASHARDS, cnt, true);
|
this.setNumManaShards(cnt);
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2299,6 +2289,16 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
lifeLostLastTurn = n;
|
lifeLostLastTurn = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final int getNumManaShards() {
|
||||||
|
return numManaShards;
|
||||||
|
}
|
||||||
|
public final void setNumManaShards(final int n) {
|
||||||
|
int old = numManaShards;
|
||||||
|
numManaShards = n;
|
||||||
|
view.updateNumManaShards(this);
|
||||||
|
game.fireEvent(new GameEventPlayerShardsChanged(this, old, numManaShards));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Player o) {
|
public int compareTo(Player o) {
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
|
|||||||
@@ -294,6 +294,13 @@ public class PlayerView extends GameEntityView {
|
|||||||
set(TrackableProperty.NumLandThisTurn, p.getLandsPlayedThisTurn());
|
set(TrackableProperty.NumLandThisTurn, p.getLandsPlayedThisTurn());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNumManaShards() {
|
||||||
|
return get(TrackableProperty.NumManaShards);
|
||||||
|
}
|
||||||
|
void updateNumManaShards(Player p) {
|
||||||
|
set(TrackableProperty.NumManaShards, p.getNumManaShards());
|
||||||
|
}
|
||||||
|
|
||||||
public int getNumDrawnThisTurn() {
|
public int getNumDrawnThisTurn() {
|
||||||
return get(TrackableProperty.NumDrawnThisTurn);
|
return get(TrackableProperty.NumDrawnThisTurn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ public enum TrackableProperty {
|
|||||||
MaxLandPlay(TrackableTypes.IntegerType),
|
MaxLandPlay(TrackableTypes.IntegerType),
|
||||||
HasUnlimitedLandPlay(TrackableTypes.BooleanType),
|
HasUnlimitedLandPlay(TrackableTypes.BooleanType),
|
||||||
NumLandThisTurn(TrackableTypes.IntegerType),
|
NumLandThisTurn(TrackableTypes.IntegerType),
|
||||||
|
NumManaShards(TrackableTypes.IntegerType),
|
||||||
NumDrawnThisTurn(TrackableTypes.IntegerType),
|
NumDrawnThisTurn(TrackableTypes.IntegerType),
|
||||||
AdditionalVote(TrackableTypes.IntegerType),
|
AdditionalVote(TrackableTypes.IntegerType),
|
||||||
OptionalAdditionalVote(TrackableTypes.IntegerType),
|
OptionalAdditionalVote(TrackableTypes.IntegerType),
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import forge.deck.Deck;
|
|||||||
import forge.deck.DeckProxy;
|
import forge.deck.DeckProxy;
|
||||||
import forge.game.GameRules;
|
import forge.game.GameRules;
|
||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
import forge.game.card.CounterEnumType;
|
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.RegisteredPlayer;
|
import forge.game.player.RegisteredPlayer;
|
||||||
import forge.gamemodes.match.HostedMatch;
|
import forge.gamemodes.match.HostedMatch;
|
||||||
@@ -96,7 +95,7 @@ public class DuelScene extends ForgeScene {
|
|||||||
//TODO: Progress towards applicable Adventure quests also needs to be reported here.
|
//TODO: Progress towards applicable Adventure quests also needs to be reported here.
|
||||||
List<PlayerControllerHuman> humans = hostedMatch.getHumanControllers();
|
List<PlayerControllerHuman> humans = hostedMatch.getHumanControllers();
|
||||||
if (humans.size() == 1) {
|
if (humans.size() == 1) {
|
||||||
Current.player().setShards(humans.get(0).getPlayer().getCounters(CounterEnumType.MANASHARDS));
|
Current.player().setShards(humans.get(0).getPlayer().getNumManaShards());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ public class VPlayerPanel extends FContainer {
|
|||||||
private int energyCounters = player.getCounters(CounterEnumType.ENERGY);
|
private int energyCounters = player.getCounters(CounterEnumType.ENERGY);
|
||||||
private int experienceCounters = player.getCounters(CounterEnumType.EXPERIENCE);
|
private int experienceCounters = player.getCounters(CounterEnumType.EXPERIENCE);
|
||||||
private int ticketCounters = player.getCounters(CounterEnumType.TICKET);
|
private int ticketCounters = player.getCounters(CounterEnumType.TICKET);
|
||||||
private int manaShards = player.getCounters(CounterEnumType.MANASHARDS);
|
private int manaShards = player.getNumManaShards();
|
||||||
private String lifeStr = String.valueOf(life);
|
private String lifeStr = String.valueOf(life);
|
||||||
|
|
||||||
private LifeLabel() {
|
private LifeLabel() {
|
||||||
@@ -497,7 +497,7 @@ public class VPlayerPanel extends FContainer {
|
|||||||
|
|
||||||
energyCounters = player.getCounters(CounterEnumType.ENERGY);
|
energyCounters = player.getCounters(CounterEnumType.ENERGY);
|
||||||
experienceCounters = player.getCounters(CounterEnumType.EXPERIENCE);
|
experienceCounters = player.getCounters(CounterEnumType.EXPERIENCE);
|
||||||
manaShards = player.getCounters(CounterEnumType.MANASHARDS);
|
manaShards = player.getNumManaShards();
|
||||||
|
|
||||||
//when gui player loses life, vibrate device for a length of time based on amount of life lost
|
//when gui player loses life, vibrate device for a length of time based on amount of life lost
|
||||||
if (vibrateDuration > 0 && MatchController.instance.isLocalPlayer(player) &&
|
if (vibrateDuration > 0 && MatchController.instance.isLocalPlayer(player) &&
|
||||||
|
|||||||
@@ -483,6 +483,11 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
|||||||
return processPlayer(event.player, livesUpdate);
|
return processPlayer(event.player, livesUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visit(final GameEventPlayerShardsChanged event) {
|
||||||
|
return processPlayer(event.player, livesUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visit(GameEventManaBurn event) {
|
public Void visit(GameEventManaBurn event) {
|
||||||
return processPlayer(event.player, livesUpdate);
|
return processPlayer(event.player, livesUpdate);
|
||||||
|
|||||||
@@ -594,7 +594,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
Integer c = cost.getAbilityAmount(ability);
|
Integer c = cost.getAbilityAmount(ability);
|
||||||
|
|
||||||
if (player.canPayShards(c) &&
|
if (player.canPayShards(c) &&
|
||||||
confirmAction(cost, Localizer.getInstance().getMessage("lblPayShardsConfirm", cost.toString(), String.valueOf(player.getCounters(CounterEnumType.MANASHARDS)), "{M} (Mana Shards)"))) {
|
confirmAction(cost, Localizer.getInstance().getMessage("lblPayShardsConfirm", cost.toString(), String.valueOf(player.getNumManaShards()), "{M} (Mana Shards)"))) {
|
||||||
return PaymentDecision.number(c);
|
return PaymentDecision.number(c);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -457,10 +457,9 @@ public class HumanPlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (part instanceof CostPayShards) {
|
else if (part instanceof CostPayShards) {
|
||||||
CounterType counterType = CounterType.get(CounterEnumType.MANASHARDS);
|
|
||||||
int amount = part.getAbilityAmount(sourceAbility);
|
int amount = part.getAbilityAmount(sourceAbility);
|
||||||
|
|
||||||
if (!mandatory && !p.getController().confirmPayment(part, Localizer.getInstance().getMessage("lblDoYouWantSpendNTargetTypeCounter", String.valueOf(amount), counterType.getName()), sourceAbility)) {
|
if (!mandatory && !p.getController().confirmPayment(part, Localizer.getInstance().getMessage("lblDoYouWantPay") + " " + amount + " {M}?", sourceAbility)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user