mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Fix so poison counters show up properly
This commit is contained in:
@@ -191,6 +191,16 @@ public class CardView extends GameEntityView {
|
||||
public Map<CounterType, Integer> getCounters() {
|
||||
return get(TrackableProperty.Counters);
|
||||
}
|
||||
public int getCounters(CounterType counterType) {
|
||||
final Map<CounterType, Integer> counters = getCounters();
|
||||
if (counters != null) {
|
||||
Integer count = counters.get(counterType);
|
||||
if (count != null) {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public boolean hasSameCounters(CardView otherCard) {
|
||||
Map<CounterType, Integer> counters = getCounters();
|
||||
if (counters == null) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import forge.game.card.CounterType;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
@@ -153,16 +154,19 @@ public class PlayerView extends GameEntityView {
|
||||
set(TrackableProperty.Life, p.getLife());
|
||||
}
|
||||
|
||||
public int getPoisonCounters() {
|
||||
return get(TrackableProperty.PoisonCounters);
|
||||
}
|
||||
void updatePoisonCounters(Player p) {
|
||||
set(TrackableProperty.PoisonCounters, p.getPoisonCounters());
|
||||
}
|
||||
|
||||
public Map<CounterType, Integer> getCounters() {
|
||||
return get(TrackableProperty.Counters);
|
||||
}
|
||||
public int getCounters(CounterType counterType) {
|
||||
final Map<CounterType, Integer> counters = getCounters();
|
||||
if (counters != null) {
|
||||
Integer count = counters.get(counterType);
|
||||
if (count != null) {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void updateCounters(Player p) {
|
||||
set(TrackableProperty.Counters, p.getCounters());
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.google.common.collect.Maps;
|
||||
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.toolbox.FButton;
|
||||
@@ -429,7 +430,7 @@ public class VAssignDamage {
|
||||
if (card == null) {
|
||||
if (defender instanceof PlayerView) {
|
||||
final PlayerView p = (PlayerView)defender;
|
||||
lethalDamage = attackerHasInfect ? matchUI.getGameView().getPoisonCountersToLose() - p.getPoisonCounters() : p.getLife();
|
||||
lethalDamage = attackerHasInfect ? matchUI.getGameView().getPoisonCountersToLose() - p.getCounters(CounterType.POISON) : p.getLife();
|
||||
}
|
||||
else if (defender instanceof CardView) { // planeswalker
|
||||
final CardView pw = (CardView)defender;
|
||||
|
||||
@@ -29,6 +29,7 @@ import javax.swing.border.LineBorder;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.DragCell;
|
||||
@@ -238,7 +239,7 @@ public class VField implements IVDoc<CField> {
|
||||
}
|
||||
|
||||
// Update poison counters
|
||||
final int poison = player.getPoisonCounters();
|
||||
final int poison = player.getCounters(CounterType.POISON);
|
||||
if (poison > 0) {
|
||||
addLblPoison();
|
||||
lblPoison.setText(String.valueOf(poison));
|
||||
|
||||
@@ -26,6 +26,7 @@ import forge.assets.FSkinColor.Colors;
|
||||
import forge.card.CardZoom;
|
||||
import forge.game.GameEntityView;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.screens.match.MatchController;
|
||||
import forge.toolbox.FCardPanel;
|
||||
@@ -439,7 +440,7 @@ public class VAssignDamage extends FDialog {
|
||||
if (source == null) {
|
||||
if (defender instanceof PlayerView) {
|
||||
PlayerView p = (PlayerView)defender;
|
||||
lethalDamage = attackerHasInfect ? MatchController.instance.getGameView().getPoisonCountersToLose() - p.getPoisonCounters() : p.getLife();
|
||||
lethalDamage = attackerHasInfect ? MatchController.instance.getGameView().getPoisonCountersToLose() - p.getCounters(CounterType.POISON) : p.getLife();
|
||||
}
|
||||
else if (defender instanceof CardView) { // planeswalker
|
||||
CardView pw = (CardView)defender;
|
||||
|
||||
@@ -15,6 +15,7 @@ import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.game.card.CardView;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.model.FModel;
|
||||
@@ -331,7 +332,7 @@ public class VPlayerPanel extends FContainer {
|
||||
|
||||
private class LifeLabel extends FDisplayObject {
|
||||
private int life = player.getLife();
|
||||
private int poisonCounters = player.getPoisonCounters();
|
||||
private int poisonCounters = player.getCounters(CounterType.POISON);
|
||||
private String lifeStr = String.valueOf(life);
|
||||
|
||||
private LifeLabel() {
|
||||
@@ -349,13 +350,13 @@ public class VPlayerPanel extends FContainer {
|
||||
lifeStr = String.valueOf(life);
|
||||
}
|
||||
|
||||
delta = player.getPoisonCounters() - poisonCounters;
|
||||
delta = player.getCounters(CounterType.POISON) - poisonCounters;
|
||||
if (delta != 0) {
|
||||
if (delta > 0) {
|
||||
//TODO: Show animation on avatar for gaining poison counters
|
||||
vibrateDuration += delta * 200;
|
||||
}
|
||||
poisonCounters = player.getPoisonCounters();
|
||||
poisonCounters = player.getCounters(CounterType.POISON);
|
||||
}
|
||||
|
||||
//when gui player loses life, vibrate device for a length of time based on amount of life lost
|
||||
|
||||
Reference in New Issue
Block a user