Fix crash when tapping mana

This commit is contained in:
drdev
2014-10-09 01:12:59 +00:00
parent 14c5e5242f
commit 122e1ca75a

View File

@@ -187,25 +187,18 @@ public class PlayerView extends GameEntityView {
set(prop, CardView.getCollection(zone.getCards()));
}
private Map<Byte, Integer> getMana() {
return get(TrackableProperty.Mana);
}
void updateMana(Player p) {
boolean changed = false;
Map<Byte, Integer> mana = getMana();
for (byte b : MagicColor.WUBRGC) {
int value = p.getManaPool().getAmountOfColor(b);
if (mana.put(b, value) != value) {
changed = true;
}
}
if (changed) {
flagAsChanged(TrackableProperty.Mana);
}
}
public int getMana(final byte color) {
Integer count = getMana().get(color);
return count != null ? count.intValue() : 0;
}
private Map<Byte, Integer> getMana() {
return get(TrackableProperty.Mana);
}
void updateMana(Player p) {
Map<Byte, Integer> mana = new HashMap<Byte, Integer>();
for (byte b : MagicColor.WUBRGC) {
mana.put(b, p.getManaPool().getAmountOfColor(b));
}
set(TrackableProperty.Mana, mana);
}
}