Ejemplo n.º 1
0
  /**
   * テキストでフィルタ
   *
   * @param ship
   * @param filter
   */
  private static boolean textFilter(ShipDto ship, ShipFilterDto filter) {
    // 検索ワード
    String[] words = StringUtils.split(filter.nametext, " ");
    // 検索対象
    // 名前
    String name = ship.getName();
    // 艦種
    String type = ship.getType();
    // 装備
    List<String> items = ship.getSlot();

    // テキストが入力されている場合処理する
    if (filter.regexp) {
      // 正規表現で検索
      for (int i = 0; i < words.length; i++) {
        Pattern pattern;
        try {
          pattern = Pattern.compile(words[i]);
        } catch (PatternSyntaxException e) {
          // 無効な正規表現はfalseを返す
          return false;
        }
        boolean find = false;

        // 名前で検索
        find = find ? find : pattern.matcher(name).find();
        // 艦種で検索
        find = find ? find : pattern.matcher(type).find();
        // 装備で検索
        for (String item : items) {
          find = find ? find : pattern.matcher(item).find();
        }

        if (!find) {
          // どれにもマッチしない場合
          return false;
        }
      }
    } else {
      // 部分一致で検索する
      for (int i = 0; i < words.length; i++) {
        boolean find = false;

        // 名前で検索
        find = find ? find : name.indexOf(words[i]) != -1;
        // 艦種で検索
        find = find ? find : type.indexOf(words[i]) != -1;
        // 装備で検索
        for (String item : items) {
          find = find ? find : item.indexOf(words[i]) != -1;
        }

        if (!find) {
          // どれにもマッチしない場合
          return false;
        }
      }
    }
    return true;
  }
    /** 艦隊が出撃中で大破した場合に警告を行います */
    private void postFatal(List<ShipDto> badlyDamaged) {
      if (badlyDamaged.size() > 0) {
        if (AppConfig.get().isBalloonBybadlyDamage()) {
          StringBuilder sb = new StringBuilder();
          sb.append(AppConstants.MESSAGE_STOP_SORTIE);
          sb.append("\n");
          for (ShipDto shipDto : badlyDamaged) {
            sb.append(shipDto.getName());
            sb.append("(" + shipDto.getLv() + ")");
            sb.append(" : ");
            List<ItemInfoDto> items = shipDto.getItem();
            List<String> names = new ArrayList<String>();
            for (ItemInfoDto itemDto : items) {
              if (itemDto != null) {
                names.add(itemDto.getName());
              }
            }
            sb.append(StringUtils.join(names, ","));
            sb.append("\n");
          }
          ToolTip tip = new ToolTip(this.main.getShell(), SWT.BALLOON | SWT.ICON_ERROR);
          tip.setText("大破警告");
          tip.setMessage(sb.toString());

          this.main.getTrayItem().setToolTip(tip);
          tip.setVisible(true);
        }
        // 大破時にサウンドを再生する
        Sound.randomBadlySoundPlay();
      }
    }
Ejemplo n.º 3
0
  /**
   * 所有艦娘一覧の内容
   *
   * @param specdiff 成長余地
   * @param filter 鍵付きのみ
   * @return 内容
   */
  public static List<String[]> getShipListBody(boolean specdiff, ShipFilterDto filter) {
    Set<Entry<Long, ShipDto>> ships = ShipContext.get().entrySet();
    List<Object[]> body = new ArrayList<Object[]>();
    int count = 0;
    for (Entry<Long, ShipDto> entry : ships) {
      ShipDto ship = entry.getValue();

      if ((filter != null) && !ShipFilterLogic.shipFilter(ship, filter)) {
        continue;
      }

      count++;

      if (!specdiff) {
        // 通常
        body.add(
            new Object[] {
              count,
              ship.getId(),
              ship.getFleetid(),
              ship.getName(),
              ship.getType(),
              ship.getCond(),
              ship.getCondClearDateString(),
              ship.getLv(),
              ship.getNext(),
              ship.getExp(),
              ship.getSallyArea().getName(),
              ship.getSeiku(),
              ship.getSlot().get(0),
              ship.getSlot().get(1),
              ship.getSlot().get(2),
              ship.getSlot().get(3),
              ship.getSlot().get(5),
              ship.getMaxhp(),
              ship.getKaryoku(),
              ship.getRaisou(),
              ship.getTaiku(),
              ship.getSoukou(),
              ship.getKaihi(),
              ship.getTaisen(),
              ship.getSakuteki(),
              ship.getLucky(),
              ship.getAccuracy(),
              ship.getHougekiPower(),
              ship.getRaigekiPower(),
              ship.getTaisenPower(),
              ship.getYasenPower()
            });
      } else {
        // 成長の余地
        // 火力
        long karyoku = ship.getKaryokuMax() - ship.getKaryoku();
        // 雷装
        long raisou = ship.getRaisouMax() - ship.getRaisou();
        // 対空
        long taiku = ship.getTaikuMax() - ship.getTaiku();
        // 装甲
        long soukou = ship.getSoukouMax() - ship.getSoukou();
        // 回避
        long kaihi = ship.getKaihiMax() - ship.getKaihi();
        // 対潜
        long taisen = ship.getTaisenMax() - ship.getTaisen();
        // 索敵
        long sakuteki = ship.getSakutekiMax() - ship.getSakuteki();
        // 運
        long lucky = ship.getLuckyMax() - ship.getLucky();

        for (ItemDto item : ship.getItem()) {
          if (item != null) {
            karyoku += item.getHoug();
            raisou += item.getRaig();
            taiku += item.getTyku();
            soukou += item.getSouk();
            kaihi += item.getHouk();
            taisen += item.getTais();
            sakuteki += item.getSaku();
            lucky += item.getLuck();
          }
        }
        body.add(
            new Object[] {
              count,
              ship.getId(),
              ship.getFleetid(),
              ship.getName(),
              ship.getType(),
              ship.getCond(),
              ship.getCondClearDateString(),
              ship.getLv(),
              ship.getNext(),
              ship.getExp(),
              ship.getSallyArea().getName(),
              ship.getSeiku(),
              ship.getSlot().get(0),
              ship.getSlot().get(1),
              ship.getSlot().get(2),
              ship.getSlot().get(3),
              ship.getSlot().get(5),
              ship.getMaxhp(),
              karyoku,
              raisou,
              taiku,
              soukou,
              kaihi,
              taisen,
              sakuteki,
              lucky,
              ship.getAccuracy(),
              ship.getHougekiPower(),
              ship.getRaigekiPower(),
              ship.getTaisenPower(),
              ship.getYasenPower()
            });
      }
    }
    return toListStringArray(body);
  }
Ejemplo n.º 4
0
  /**
   * ドロップ報告書の内容(保存用)
   *
   * @param results ドロップ報告書
   * @return 内容
   */
  public static List<String[]> getBattleResultStoreBody(List<BattleResultDto> results) {
    List<Object[]> body = new ArrayList<Object[]>();

    SimpleDateFormat format = new SimpleDateFormat(AppConstants.DATE_FORMAT);

    for (int i = 0; i < results.size(); i++) {
      BattleResultDto item = results.get(i);
      BattleDto battle = item.getBattleDto();
      if (battle == null) {
        continue;
      }
      String[] friend = new String[6];
      String[] friendHp = new String[6];
      String[] enemy = new String[6];
      String[] enemyHp = new String[6];

      Arrays.fill(friend, "");
      Arrays.fill(friendHp, "");
      Arrays.fill(enemy, "");
      Arrays.fill(enemyHp, "");

      List<DockDto> docks = battle.getFriends();
      if (docks != null) {
        DockDto dock = docks.get(0);
        List<ShipDto> friendships = dock.getShips();
        int[] fnowhps = battle.getNowFriendHp();
        int[] fmaxhps = battle.getMaxFriendHp();
        for (int j = 0; j < friendships.size(); j++) {
          ShipDto ship = friendships.get(j);
          friend[j] = ship.getName() + "(Lv" + ship.getLv() + ")";
          friendHp[j] = fnowhps[j] + "/" + fmaxhps[j];
        }
        List<ShipInfoDto> enemyships = battle.getEnemy();
        int[] enowhps = battle.getNowEnemyHp();
        int[] emaxhps = battle.getMaxEnemyHp();
        for (int j = 0; j < enemyships.size(); j++) {
          ShipInfoDto ship = enemyships.get(j);
          if (!StringUtils.isEmpty(ship.getFlagship())) {
            enemy[j] = ship.getName() + "(" + ship.getFlagship() + ")";
          } else {
            enemy[j] = ship.getName();
          }
          enemyHp[j] = enowhps[j] + "/" + emaxhps[j];
        }
      }

      body.add(
          new Object[] {
            Integer.toString(i + 1),
            format.format(item.getBattleDate()),
            item.getQuestName(),
            item.getMapCellNo(),
            item.getBossText(),
            item.getRank(),
            battle.getIntercept(),
            battle.getFriendFormation(),
            battle.getEnemyFormation(),
            item.getEnemyName(),
            item.getDropType(),
            item.getDropName(),
            friend[0],
            friendHp[0],
            friend[1],
            friendHp[1],
            friend[2],
            friendHp[2],
            friend[3],
            friendHp[3],
            friend[4],
            friendHp[4],
            friend[5],
            friendHp[5],
            enemy[0],
            enemyHp[0],
            enemy[1],
            enemyHp[1],
            enemy[2],
            enemyHp[2],
            enemy[3],
            enemyHp[3],
            enemy[4],
            enemyHp[4],
            enemy[5],
            enemyHp[5]
          });
    }
    return toListStringArray(body);
  }