- Improvements to Quest game trying to update Battlefield Observers before it's finished being setup (not fixed, but seems better)

This commit is contained in:
Sol
2012-08-09 06:36:33 +00:00
parent 51bf1472f9
commit fd7bbff564
3 changed files with 38 additions and 18 deletions

View File

@@ -20,6 +20,7 @@ import forge.control.FControl;
import forge.control.input.InputMulligan;
import forge.deck.Deck;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.match.CMatchUI;
import forge.gui.match.VMatchUI;
@@ -57,35 +58,44 @@ public class GameNew {
* @param iconEnemy
*   {@link java.lang.String}
*/
public static void newGame(final Deck humanDeck, final Deck computerDeck, final CardList human,
final CardList computer, final int humanLife, final int computerLife, String iconEnemy) {
public static void newGame(final Deck humanDeck, final Deck computerDeck, final CardList humanStart,
final CardList computerStart, final int humanLife, final int computerLife, String iconEnemy) {
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
CMatchUI.SINGLETON_INSTANCE.initMatch(iconEnemy);
GameNew.newGameCleanup();
GameNew.newMatchCleanup();
AllZone.getComputerPlayer().setStartingLife(computerLife);
AllZone.getHumanPlayer().setStartingLife(humanLife);
AllZone.getHumanPlayer().updateObservers();
Player human = AllZone.getHumanPlayer();
Player computer = AllZone.getComputerPlayer();
computer.setStartingLife(computerLife);
human.setStartingLife(humanLife);
human.updateObservers();
Card.resetUniqueNumber();
PlayerZone humanBf = human.getZone(ZoneType.Battlefield);
for (final Card c : human) {
AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).add(c);
for (final Card c : humanStart) {
humanBf.add(c, false);
c.setSickness(true);
c.setStartsGameInPlay(true);
c.refreshUniqueNumber();
}
for (final Card c : computer) {
AllZone.getComputerPlayer().getZone(ZoneType.Battlefield).add(c);
PlayerZone aiBf = AllZone.getComputerPlayer().getZone(ZoneType.Battlefield);
for (final Card c : computerStart) {
aiBf.add(c, false);
c.setSickness(true);
c.setStartsGameInPlay(true);
c.refreshUniqueNumber();
}
GameNew.actuateGame(humanDeck, computerDeck);
humanBf.updateObservers();
aiBf.updateObservers();
}
/**

View File

@@ -66,14 +66,7 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl
// ************ BEGIN - these methods fire updateObservers() *************
/**
* Adds the.
*
* @param o
* a {@link java.lang.Object} object.
*/
@Override
public void add(final Object o) {
public void add(final Object o, boolean update) {
final Card c = (Card) o;
// Immutable cards are usually emblems,effects and the mana pool and we
@@ -115,7 +108,22 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl
}
this.getCardList().add(c);
this.update();
if (update) {
this.update();
}
}
/**
* Adds the.
*
* @param o
* a {@link java.lang.Object} object.
*/
@Override
public void add(final Object o) {
this.add(o, true);
}
/**

View File

@@ -68,6 +68,8 @@ interface IPlayerZone {
* a {@link java.lang.Object} object.
*/
void add(Object o);
void add(Object o, boolean b);
/**
* <p>