예제 #1
0
  public String getValue(boolean useHidden) {
    StringBuilder sb = new StringBuilder(1024);

    sb.append(turnNum)
        .append(turn.getPhaseType())
        .append(turn.getStepType())
        .append(activePlayerId)
        .append(priorityPlayerId);

    for (Player player : players.values()) {
      sb.append("player").append(player.getLife()).append("hand");
      if (useHidden) {
        sb.append(player.getHand());
      } else {
        sb.append(player.getHand().size());
      }
      sb.append("library")
          .append(player.getLibrary().size())
          .append("graveyard")
          .append(player.getGraveyard());
    }

    sb.append("permanents");
    for (Permanent permanent : battlefield.getAllPermanents()) {
      sb.append(permanent.getValue());
    }

    sb.append("spells");
    for (StackObject spell : stack) {
      sb.append(spell.getControllerId()).append(spell.getName());
    }

    for (ExileZone zone : exile.getExileZones()) {
      sb.append("exile").append(zone.getName()).append(zone);
    }

    sb.append("combat");
    for (CombatGroup group : combat.getGroups()) {
      sb.append(group.getDefenderId()).append(group.getAttackers()).append(group.getBlockers());
    }

    return sb.toString();
  }
예제 #2
0
 public static CombatSimulator load(Game game) {
   CombatSimulator simCombat = new CombatSimulator();
   for (CombatGroup group : game.getCombat().getGroups()) {
     simCombat.groups.add(
         new CombatGroupSimulator(
             group.getDefenderId(), group.getAttackers(), group.getBlockers(), game));
   }
   for (UUID defenderId : game.getCombat().getDefenders()) {
     simCombat.defenders.add(defenderId);
     Player player = game.getPlayer(defenderId);
     if (player != null) {
       simCombat.playersLife.put(defenderId, player.getLife());
     } else {
       Permanent permanent = game.getPermanent(defenderId);
       simCombat.planeswalkerLoyalty.put(
           defenderId, permanent.getCounters(game).getCount(CounterType.LOYALTY));
     }
   }
   return simCombat;
 }
예제 #3
0
  public String getValue(boolean useHidden, Game game) {
    StringBuilder sb = new StringBuilder(1024);

    sb.append(turnNum)
        .append(turn.getPhaseType())
        .append(turn.getStepType())
        .append(activePlayerId)
        .append(priorityPlayerId);

    for (Player player : players.values()) {
      sb.append("player").append(player.isPassed()).append(player.getLife()).append("hand");
      if (useHidden) {
        sb.append(player.getHand());
      } else {
        sb.append(player.getHand().size());
      }
      sb.append("library").append(player.getLibrary().size());
      sb.append("graveyard");
      for (Card card : player.getGraveyard().getCards(game)) {
        sb.append(card.getName());
      }
    }

    sb.append("permanents");
    List<String> perms = new ArrayList<String>();
    for (Permanent permanent : battlefield.getAllPermanents()) {
      perms.add(permanent.getValue());
    }
    Collections.sort(perms);
    sb.append(perms);

    sb.append("spells");
    for (StackObject spell : stack) {
      sb.append(spell.getControllerId()).append(spell.getName());
      sb.append(spell.getStackAbility().toString());
      for (Mode mode : spell.getStackAbility().getModes().values()) {
        if (!mode.getTargets().isEmpty()) {
          sb.append("targets");
          for (Target target : mode.getTargets()) {
            sb.append(target.getTargets());
          }
        }
        if (!mode.getChoices().isEmpty()) {
          sb.append("choices");
          for (Choice choice : mode.getChoices()) {
            sb.append(choice.getChoice());
          }
        }
      }
    }

    for (ExileZone zone : exile.getExileZones()) {
      sb.append("exile").append(zone.getName()).append(zone);
    }

    sb.append("combat");
    for (CombatGroup group : combat.getGroups()) {
      sb.append(group.getDefenderId()).append(group.getAttackers()).append(group.getBlockers());
    }

    return sb.toString();
  }