(Game game)
| 156 | } |
| 157 | |
| 158 | public void initFromGame(Game game) { |
| 159 | playerStates.clear(); |
| 160 | for (Player player : game.getPlayers()) { |
| 161 | PlayerState p = new PlayerState(); |
| 162 | p.life = player.getLife(); |
| 163 | p.landsPlayed = player.getLandsPlayedThisTurn(); |
| 164 | p.landsPlayedLastTurn = player.getLandsPlayedLastTurn(); |
| 165 | p.counters = countersToString(player.getCounters()); |
| 166 | p.manaPool = processManaPool(player.getManaPool()); |
| 167 | p.numRingTemptedYou = player.getNumRingTemptedYou(); |
| 168 | p.speed = player.getSpeed(); |
| 169 | playerStates.add(p); |
| 170 | } |
| 171 | |
| 172 | tChangePlayer = "p" + game.getPlayers().indexOf(game.getPhaseHandler().getPlayerTurn()); |
| 173 | tChangePhase = game.getPhaseHandler().getPhase().toString(); |
| 174 | turn = game.getPhaseHandler().getTurn(); |
| 175 | |
| 176 | // Mark the cards that need their ID remembered for various reasons |
| 177 | cardsReferencedByID.clear(); |
| 178 | for (ZoneType zone : ZONES.keySet()) { |
| 179 | for (Card card : game.getCardsIncludePhasingIn(zone)) { |
| 180 | if (card.getExiledWith() != null) { |
| 181 | // Remember the ID of the card that exiled this card |
| 182 | cardsReferencedByID.add(card.getExiledWith()); |
| 183 | } |
| 184 | if (zone == ZoneType.Battlefield) { |
| 185 | if (!card.getAllAttachedCards().isEmpty()) { |
| 186 | // Remember the ID of cards that have attachments |
| 187 | cardsReferencedByID.add(card); |
| 188 | } |
| 189 | } |
| 190 | for (Object o : card.getRemembered()) { |
| 191 | // Remember the IDs of remembered cards |
| 192 | if (o instanceof Card) { |
| 193 | cardsReferencedByID.add((Card)o); |
| 194 | } |
| 195 | } |
| 196 | for (Card i : card.getImprintedCards()) { |
| 197 | // Remember the IDs of imprinted cards |
| 198 | cardsReferencedByID.add(i); |
| 199 | } |
| 200 | for (Card i : card.getChosenCards()) { |
| 201 | // Remember the IDs of chosen cards |
| 202 | cardsReferencedByID.add(i); |
| 203 | } |
| 204 | if (game.getCombat() != null && game.getCombat().isAttacking(card)) { |
| 205 | // Remember the IDs of attacked planeswalkers |
| 206 | GameEntity def = game.getCombat().getDefenderByAttacker(card); |
| 207 | if (def instanceof Card) { |
| 208 | cardsReferencedByID.add((Card)def); |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | for (ZoneType zone : ZONES.keySet()) { |
| 215 | // Init texts to empty, so that restoring will clear the state |
no test coverage detected