Fix (hopefully) attack icons on cards and a possible NPE.

This commit is contained in:
elcnesh
2014-09-16 21:05:39 +00:00
parent 8bade53caa
commit d3b6893d33
10 changed files with 35 additions and 15 deletions

View File

@@ -271,7 +271,8 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
@Override
public void run() {
synchronized (cardsToUpdate) {
gui.updateCards(cardsToUpdate);
final Iterable<CardView> newCardsToUpdate = gameView.getRefreshedCardViews(cardsToUpdate);
gui.updateCards(newCardsToUpdate);
cardsToUpdate.clear();
}
}

View File

@@ -4,7 +4,6 @@ import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.tuple.Pair;
@@ -76,7 +75,7 @@ public interface IGuiBase {
void restoreOldZones(Map<PlayerView, Object> playersToRestoreZonesFor);
void updateStack();
void updateZones(List<Pair<PlayerView, ZoneType>> zonesToUpdate);
void updateCards(Set<CardView> cardsToUpdate);
void updateCards(Iterable<CardView> cardsToUpdate);
void refreshCardDetails(Iterable<CardView> cards);
void updateManaPool(List<PlayerView> manaPoolUpdate);
void updateLives(List<PlayerView> livesUpdate);

View File

@@ -31,6 +31,22 @@ public class Cache<K, V> {
return inverseCache.get(value);
}
/**
* Get a value as it is present in this Cache, compared using the equals
* method.
*
* @param value
* @return a value equal to value, if such a value is present in the Cache.
*/
public synchronized V getValue(final V value) {
for (final V currentValue : inverseCache.keySet()) {
if (currentValue.equals(value)) {
return currentValue;
}
}
return null;
}
/**
* @param key
* @param value

View File

@@ -426,6 +426,15 @@ public abstract class LocalGameView implements IGameView {
return ViewUtil.transformIfNotNull(cards, FN_GET_CARD_VIEW);
}
public final List<CardView> getRefreshedCardViews(final Iterable<CardView> cardViews) {
return ViewUtil.transformIfNotNull(cardViews, new Function<CardView, CardView>() {
@Override
public CardView apply(CardView input) {
return cards.getValue(input);
}
});
}
private CardView getCardViewFast(final Card c) {
if (c == null) {
return null;