Commit stage 1 of large game view refactoring

This commit is contained in:
drdev
2014-10-06 04:06:42 +00:00
parent e599aef134
commit afcad4e672
92 changed files with 3490 additions and 6023 deletions

View File

@@ -5,6 +5,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
@@ -167,7 +168,7 @@ public class CardDetailUtil {
}
public static String formatCardType(final CardStateView card) {
final List<String> list = card.getType();
final Set<String> list = card.getType();
final StringBuilder sb = new StringBuilder();
final List<String> superTypes = new ArrayList<String>();

View File

@@ -82,7 +82,7 @@ public class InputBlock extends InputSyncronizedBase {
showMessage("Select another attacker to declare blockers for.");
}
else {
String attackerName = currentAttacker.isFaceDown() ? "Morph" : currentAttacker.getName() + " (" + currentAttacker.getUniqueNumber() + ")";
String attackerName = currentAttacker.isFaceDown() ? "Morph" : currentAttacker.getName() + " (" + currentAttacker.getId() + ")";
String message = "Select creatures to block " + attackerName + " or select another attacker to declare blockers for.";
showMessage(message);
}

View File

@@ -327,7 +327,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
for (SpellAbilityStackInstance si : game.getStack()) {
final Card stC = si.getSourceCard();
final SpellAbility stSA = si.getSpellAbility().getRootAbility();
final SpellAbility stSA = si.getSpellAbility(true).getRootAbility();
if (stC.isValid(cost.getType().split(";"), ability.getActivatingPlayer(), source) && stSA.isSpell()) {
saList.add(stSA);
if (stC.isCopiedSpell()) {

View File

@@ -1275,10 +1275,14 @@ public class PlayerControllerHuman extends PlayerController {
@Override
public CardShields chooseRegenerationShield(Card c) {
if (c.getShield().size() < 2) {
return Iterables.getFirst(c.getShield(), null);
if (c.getShieldCount() < 2) {
return Iterables.getFirst(c.getShields(), null);
}
return SGuiChoose.one(getGui(), "Choose a regeneration shield:", c.getShield());
ArrayList<CardShields> shields = new ArrayList<CardShields>();
for (CardShields shield : c.getShields()) {
shields.add(shield);
}
return SGuiChoose.one(getGui(), "Choose a regeneration shield:", shields);
}
@Override

View File

@@ -318,7 +318,7 @@ public class TargetSelection {
final Game game = ability.getActivatingPlayer().getGame();
for (final SpellAbilityStackInstance si : game.getStack()) {
SpellAbility abilityOnStack = si.getSpellAbility();
SpellAbility abilityOnStack = si.getSpellAbility(true);
if (ability.equals(abilityOnStack)) {
// By peeking at stack item, target is set to its SI state. So set it back before adding targets
ability.resetTargets();
@@ -346,7 +346,7 @@ public class TargetSelection {
return false;
}
if (madeChoice instanceof StackItemView) {
ability.getTargets().add(controller.getStackItem((StackItemView)madeChoice).getSpellAbility());
ability.getTargets().add(controller.getStackItem((StackItemView)madeChoice).getSpellAbility(true));
} else // 'FINISH TARGETING' chosen
bTargetingDone = true;
}

View File

@@ -3,6 +3,7 @@ package forge.view;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
@@ -751,7 +752,7 @@ public class CardView extends GameEntityView {
private String name;
private ColorSet colors;
private String imageKey;
private List<String> type;
private Set<String> type;
private ManaCost manaCost;
private int power, toughness, loyalty;
private String text;
@@ -768,7 +769,7 @@ public class CardView extends GameEntityView {
this.name = "";
this.colors = ColorSet.getNullColor();
this.imageKey = ImageKeys.HIDDEN_CARD;
this.type = Collections.emptyList();
this.type = Collections.emptySet();
this.manaCost = ManaCost.NO_COST;
this.power = 0;
this.toughness = 0;
@@ -837,15 +838,15 @@ public class CardView extends GameEntityView {
/**
* @return the type
*/
public List<String> getType() {
public Set<String> getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(final List<String> type) {
this.type = Collections.unmodifiableList(type);
public void setType(final Set<String> type) {
this.type = type;
}
/**

View File

@@ -484,7 +484,7 @@ public abstract class LocalGameView implements IGameView {
view.setAttacking(combat != null && combat.isAttacking(c));
view.setBlocking(combat != null && combat.isBlocking(c));
view.setChosenPlayer(getPlayerView(c.getChosenPlayer(), false));
view.setEquipping(getCardView(Iterables.getFirst(c.getEquipping(), null), false));
view.setEquipping(getCardView(c.getEquipping(), false));
view.setEquippedBy(getCardViews(c.getEquippedBy(), false));
view.setEnchantingCard(getCardView(c.getEnchantingCard(), false));
view.setEnchantingPlayer(getPlayerView(c.getEnchantingPlayer(), false));

View File

@@ -27,8 +27,8 @@ public class StackItemView implements IIdentifiable {
public StackItemView(SpellAbilityStackInstance si, LocalGameView gameView) {
id = si.getId();
key = si.getSpellAbility().toUnsuppressedString();
sourceTrigger = si.getSpellAbility().getSourceTrigger();
key = si.getSpellAbility(false).toUnsuppressedString();
sourceTrigger = si.getSpellAbility(false).getSourceTrigger();
text = si.getStackDescription();
source = gameView.getCardView(si.getSourceCard(), true);
activatingPlayer = gameView.getPlayerView(si.getActivator(), false);

View File

@@ -1,6 +1,5 @@
package forge.view;
import java.util.Collections;
import java.util.List;
import com.google.common.base.Function;
@@ -53,10 +52,10 @@ public final class ViewUtil {
view.setCounters(c.getCounters());
view.setDamage(c.getDamage());
view.setAssignedDamage(c.getTotalAssignedDamage());
view.setRegenerationShields(c.getShield().size());
view.setRegenerationShields(c.getShieldCount());
view.setPreventNextDamage(c.getPreventNextDamageTotalShields());
view.setChosenType(c.getChosenType());
view.setChosenColors(c.getChosenColor());
view.setChosenColors(c.getChosenColors());
view.setNamedCard(c.getNamedCard());
if (c.isSplitCard()) {
@@ -78,7 +77,7 @@ public final class ViewUtil {
origView.setName(c.getName());
origView.setColors(c.determineColor());
origView.setImageKey(c.getImageKey() );
origView.setType(Collections.unmodifiableList(c.getType()));
origView.setType(c.getType());
origView.setManaCost(c.getManaCost());
origView.setPower(c.getNetAttack());
origView.setToughness(c.getNetDefense());
@@ -119,7 +118,7 @@ public final class ViewUtil {
view.setName(chars.getName());
view.setColors(chars.determineColor());
view.setImageKey(chars.getImageKey());
view.setType(Collections.unmodifiableList(chars.getType()));
view.setType(chars.getType());
view.setManaCost(chars.getManaCost());
view.setPower(chars.getBaseAttack());
view.setToughness(chars.getBaseDefense());