mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Fix (hopefully) attack icons on cards and a possible NPE.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user