Adding character strength to GameStats.

This commit is contained in:
marcins78@gmail.com
2011-10-25 12:49:21 +00:00
parent 54fc7e9481
commit 0f90f8f9b0
2 changed files with 29 additions and 1 deletions

View File

@@ -75,6 +75,15 @@ public class EventSerializer {
eventElem.appendChild(playerZonesElem);
}
StringBuilder charStr = new StringBuilder();
for (Map.Entry<Integer, Integer> characters : gameStats.getCharStrengths().entrySet()) {
charStr.append("," + characters.getKey() + "=" + characters.getValue());
}
if (charStr.length() > 0)
charStr.delete(0, 1);
eventElem.setAttribute("charStrengths", charStr.toString());
}
return eventElem;

View File

@@ -1,9 +1,13 @@
package com.gempukku.lotro.logic.timing;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.PlayerOrder;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -18,6 +22,7 @@ public class GameStats {
private int _shadowSkirmishStrength;
private Map<String, Map<Zone, Integer>> _zoneSizes = new HashMap<String, Map<Zone, Integer>>();
private Map<Integer, Integer> _charStrengths = new HashMap<Integer, Integer>();
/**
* @return If the stats have changed
@@ -79,6 +84,15 @@ public class GameStats {
_zoneSizes = newZoneSizes;
}
Map<Integer, Integer> newCharStrengths = new HashMap<Integer, Integer>();
for (PhysicalCard character : Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), Filters.or(CardType.COMPANION, CardType.ALLY, CardType.MINION)))
newCharStrengths.put(character.getCardId(), game.getModifiersQuerying().getStrength(game.getGameState(), character));
if (!newCharStrengths.equals(_charStrengths)) {
changed = true;
_charStrengths = newCharStrengths;
}
return changed;
}
@@ -107,7 +121,11 @@ public class GameStats {
}
public Map<String, Map<Zone, Integer>> getZoneSizes() {
return _zoneSizes;
return Collections.unmodifiableMap(_zoneSizes);
}
public Map<Integer, Integer> getCharStrengths() {
return Collections.unmodifiableMap(_charStrengths);
}
public GameStats makeACopy() {
@@ -119,6 +137,7 @@ public class GameStats {
copy._shadowArchery = _shadowArchery;
copy._shadowSkirmishStrength = _shadowSkirmishStrength;
copy._zoneSizes = _zoneSizes;
copy._charStrengths = _charStrengths;
return copy;
}
}