/** 艦隊が出撃中で大破した場合に警告を行います */
    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();
      }
    }
Esempio n. 2
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 updateOtherTimer() {
      Label condTimerLabel = this.main.getCondTimerLabel();
      Text condTimerText = this.main.getCondTimerTime();

      CondTiming timing = GlobalContext.getCondTiming();
      Date nextUpdateTime = timing.getNextUpdateTime(this.now);

      // 疲労のある艦娘はいる?
      boolean needTimer = false;
      for (ShipDto ship : GlobalContext.getShipMap().values()) {
        if (ship.getCond() < 49) {
          needTimer = true;
          break;
        }
      }

      if (needTimer == false) {
        condTimerLabel.setText("");
        condTimerText.setToolTipText(null);
        condTimerText.setText("");
      } else if (nextUpdateTime == null) {
        condTimerLabel.setText("次の疲労回復まで");
        condTimerText.setToolTipText("十分な情報がありません");
        condTimerText.setText("???");
      } else {
        int accuracy = (int) timing.getCurrentAccuracy() / 2000;
        condTimerLabel.setText("次の疲労回復まで(±" + accuracy + "秒)");

        long rest = TimeLogic.getRest(this.now, nextUpdateTime);

        // ツールチップテキストで時刻を表示する
        condTimerText.setToolTipText(this.format.format(nextUpdateTime));
        condTimerText.setText(TimeLogic.toDateRestString(rest, true));
      }

      // 泊地修理タイマー
      Label akashiTimerLabel = this.main.getAkashiTimerLabel();
      Text akashiTimerText = this.main.getAkashiTimerTime();

      AkashiTimer akashiTimer = GlobalContext.getAkashiTimer();
      if (akashiTimer.getStartTime() == null) {
        // 不明
        akashiTimerText.setText("???");
        akashiTimerText.setToolTipText("十分な情報がありません");
        akashiTimerText.setBackground(ColorManager.getColor(SWT.COLOR_WHITE));
      } else {
        long elapsed = this.now.getTime() - akashiTimer.getStartTime().getTime();
        String time = TimeLogic.toDateRestString(elapsed / 1000, true);
        akashiTimerText.setText(time);
        akashiTimerText.setToolTipText(null);
        akashiTimerText.setBackground(ColorManager.getColor(AppConstants.AKASHI_REPAIR_COLOR));
      }
    }
    /**
     * 入渠を更新する
     *
     * @param now
     * @param notice
     * @return
     */
    private void updateNdock() {
      Map<Integer, ShipDto> shipMap = GlobalContext.getShipMap();

      Label[] ndockNameLabels = {
        this.main.getNdock1name(),
        this.main.getNdock2name(),
        this.main.getNdock3name(),
        this.main.getNdock4name()
      };
      Text[] ndockTimeTexts = {
        this.main.getNdock1time(),
        this.main.getNdock2time(),
        this.main.getNdock3time(),
        this.main.getNdock4time()
      };

      NdockDto[] ndocks = GlobalContext.getNdocks();

      for (int i = 0; i < ndocks.length; i++) {
        String name = "";
        String time = "";

        if (ndocks[i].getNdockid() != 0) {
          ShipDto ship = shipMap.get(ndocks[i].getNdockid());
          if (ship != null) {
            name = ship.getFriendlyName();
            long rest = TimeLogic.getRest(this.now, ndocks[i].getNdocktime());

            // ツールチップテキストで時刻を表示する
            ndockTimeTexts[i].setToolTipText(this.format.format(ndocks[i].getNdocktime()));

            // 20分前、10分前、5分前になったら背景色を変更する
            ndockTimeTexts[i].setBackground(getBackgroundColor(rest));

            // 通知生成
            this.updateNdockNotice(name, i, rest);

            time = TimeLogic.toDateRestString(rest);
            if (time == null) {
              time = "まもなくお風呂からあがります";
            }
          }
        } else {
          ndockTimeTexts[i].setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
          ndockTimeTexts[i].setToolTipText(null);
        }
        ndockNameLabels[i].setText(name);
        ndockTimeTexts[i].setText(time);
      }
    }
Esempio n. 5
0
 /**
  * 艦娘をフィルタします
  *
  * @param ship 艦娘
  * @param filter フィルターオブジェクト
  * @return フィルタ結果
  */
 public static boolean shipFilter(ShipDto ship, ShipFilterDto filter) {
   // テキストでフィルタ
   if (!StringUtils.isEmpty(filter.nametext)) {
     if (!textFilter(ship, filter)) {
       return false;
     }
   }
   // 艦種でフィルタ
   if (!typeFilter(ship, filter)) {
     return false;
   }
   // グループでフィルタ
   if (filter.group != null) {
     if (!filter.group.getShips().contains(ship.getId())) {
       return false;
     }
   }
   // 装備でフィルタ
   if (!StringUtils.isEmpty(filter.itemname)) {
     if (!itemFilter(ship, filter)) {
       return false;
     }
   }
   // 艦隊に所属
   if (!filter.onfleet) {
     if (!StringUtils.isEmpty(ship.getFleetid())) {
       return false;
     }
   }
   // 艦隊に非所属
   if (!filter.notonfleet) {
     if (StringUtils.isEmpty(ship.getFleetid())) {
       return false;
     }
   }
   // 鍵付き
   if (!filter.locked) {
     if (ship.getLocked()) {
       return false;
     }
   }
   // 鍵付きではない
   if (!filter.notlocked) {
     if (!ship.getLocked()) {
       return false;
     }
   }
   return true;
 }
 private void updateNoticeAkashi(DockDto dock, AkashiTimer.RepairState repairState) {
   if (this.main.getAkashiNotice().getSelection()) {
     if (repairState.isFirstNotify() && AppConfig.get().isAkashiNotifyFirstStep()) {
       this.noticeAkashi.add(dock.getName() + " の泊地修理が20分経過しました");
     }
     for (AkashiTimer.ShipState state : repairState.get()) {
       if (state != null) {
         ShipDto ship = state.getShip();
         if (state.isStepNotify()) {
           int estimatedHp = state.getCurrentGain() + ship.getNowhp();
           boolean full = (estimatedHp == ship.getMaxhp());
           if (full) {
             this.noticeAkashi.add(ship.getFriendlyName() + " がまもなく修理完了します");
           }
           // 20分経過通知があるときはそれで代用する
           else if (!repairState.isFirstNotify() && AppConfig.get().isAkashiNotifyEveryStep()) {
             this.noticeAkashi.add(
                 ship.getFriendlyName()
                     + " がHP1ポイント回復("
                     + (estimatedHp - 1)
                     + "→"
                     + estimatedHp
                     + "/"
                     + ship.getMaxhp()
                     + ")");
           }
         }
       }
     }
   }
 }
Esempio n. 7
0
 /**
  * 装備でフィルタ
  *
  * @param ship
  * @param filter
  */
 private static boolean itemFilter(ShipDto ship, ShipFilterDto filter) {
   List<ItemDto> item = ship.getItem();
   boolean hit = false;
   for (ItemDto itemDto : item) {
     if (itemDto != null) {
       if (filter.itemname.equals(itemDto.getName())) {
         hit = true;
         break;
       }
     }
   }
   if (!hit) {
     return false;
   }
   return true;
 }
Esempio n. 8
0
 /**
  * 艦種でフィルタ
  *
  * @param ship
  * @param filter
  */
 private static boolean typeFilter(ShipDto ship, ShipFilterDto filter) {
   if (ship.getType() == null) {
     return false;
   }
   if (!filter.destroyer) {
     if ("駆逐艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.lightCruiser) {
     if ("軽巡洋艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.torpedoCruiser) {
     if ("重雷装巡洋艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.heavyCruiser) {
     if ("重巡洋艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.flyingDeckCruiser) {
     if ("航空巡洋艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.seaplaneTender) {
     if ("水上機母艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.escortCarrier) {
     if ("軽空母".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.carrier) {
     if ("正規空母".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.battleship) {
     if ("戦艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.flyingDeckBattleship) {
     if ("航空戦艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.submarine) {
     if ("潜水艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.carrierSubmarine) {
     if ("潜水空母".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.landingship) {
     if ("揚陸艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.armoredcarrier) {
     if ("装甲空母".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.repairship) {
     if ("工作艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.submarineTender) {
     if ("潜水母艦".equals(ship.getType())) {
       return false;
     }
   }
   if (!filter.trainingShip) {
     if ("練習巡洋艦".equals(ship.getType())) {
       return false;
     }
   }
   return true;
 }
    /**
     * 遠征を更新する
     *
     * @param now
     * @param notice
     * @return
     */
    private void updateDeck() {
      BasicInfoDto basicDto = GlobalContext.getBasicInfo();
      if (AppConfig.get().isNameOnTitlebar() && (basicDto != null)) {
        String titlebarText = basicDto.getNickname() + " - 航海日誌";
        this.main.setTitleText(titlebarText);
      } else {
        this.main.setTitleText(AppConstants.TITLEBAR_TEXT);
      }

      Label[] deckNameLabels = {
        this.main.getDeck1name(), this.main.getDeck2name(),
        this.main.getDeck3name(), this.main.getDeck4name()
      };
      Text[] deckTimeTexts = {
        this.main.getDeck1time(), this.main.getDeck2time(),
        this.main.getDeck3time(), this.main.getDeck4time()
      };

      DeckMissionDto[] deckMissions = GlobalContext.getDeckMissions();
      Map<Integer, Date> ndockMap = GlobalContext.getNDockCompleteTimeMap();

      for (int i = 0; i < 4; i++) {
        String time = "";
        String dispname = "";
        String tooltip = null;
        Color backColor = SWTResourceManager.getColor(SWT.COLOR_WHITE);

        DockDto dock = GlobalContext.getDock(String.valueOf(i + 1));

        if (dock != null) {
          String dockName = dock.getName();
          if ((i >= 1) && (deckMissions[i - 1].getMission() != null)) {
            // 遠征中
            DeckMissionDto mission = deckMissions[i - 1];
            dispname = dockName + " (" + mission.getDisplayText("missioncheck_" + (i + 1)) + ")";

            if (mission.getTime() != null) {
              long rest = TimeLogic.getRest(this.now, mission.getTime());

              // ツールチップテキストで時刻を表示する
              tooltip = this.format.format(mission.getTime());

              // 20分前、10分前、5分前になったら背景色を変更する
              backColor = getBackgroundColor(rest);

              // 通知生成
              this.updateNoticeDeck(dispname, i - 1, rest);

              time = TimeLogic.toDateRestString(rest);
              if (time == null) {
                time = "まもなく帰投します";
              }
            }
          } else {
            // 遠征中でない
            // 疲労回復時刻を計算
            CondTiming condTiming = GlobalContext.getCondTiming();
            Date condClearTime = null;
            long condRest = -1;
            for (ShipDto ship : dock.getShips()) {
              Date clearTime =
                  ship.getCondClearTime(
                      condTiming, ndockMap.get(ship.getId()), AppConfig.get().getOkCond());
              if (clearTime != null) {
                if ((condClearTime == null) || condClearTime.before(clearTime)) {
                  condClearTime = clearTime;
                }
                condRest = Math.max(condRest, TimeLogic.getRest(this.now, clearTime));
              }
            }
            if (condClearTime != null) {
              // 疲労回復通知生成
              this.updateNoticeCond(dockName, i, condRest);
            }

            // 泊地修理タイマー更新
            AkashiTimer.RepairState repairState = TimerContext.get().getAkashiRepairState(i);
            if (repairState.isRepairing()) {
              // 泊地修理中
              dispname = dockName + " (泊地修理中)";
              time = TimeLogic.toDateRestString(repairState.getElapsed() / 1000, true);
              backColor = ColorManager.getColor(AppConstants.AKASHI_REPAIR_COLOR);

              // ツールチップで詳細表示
              for (AkashiTimer.ShipState state : repairState.get()) {
                if (state != null) {
                  ShipDto ship = state.getShip();
                  long rest = TimeLogic.getRest(this.now, state.getFinish());
                  String txt = ship.getFriendlyName();
                  String remainStr = TimeLogic.toDateRestString(rest);
                  if (remainStr == null) {
                    txt += ":まもなく修理完了します";
                  } else {
                    txt += ":残り" + remainStr + "(" + this.format.format(state.getFinish()) + ")";
                  }
                  if (tooltip == null) {
                    tooltip = txt;
                  } else {
                    tooltip += "\n" + txt;
                  }
                }
              }

              this.updateNoticeAkashi(dock, repairState);
            } else if (!GlobalContext.isSortie(dock.getId()) && (condClearTime != null)) {
              dispname = dockName + " (疲労回復中)";

              // ツールチップテキストで時刻を表示する
              tooltip = this.format.format(condClearTime);

              // 20分前、10分前、5分前になったら背景色を変更する
              backColor = getCondBackgroundColor(condRest);

              time = TimeLogic.toDateRestString(condRest);
              if (time == null) {
                time = "疲労回復しました";
              }
            }
          }
        }

        deckNameLabels[i].setText(dispname);
        deckNameLabels[i].setToolTipText(dispname);
        deckTimeTexts[i].setText(time);
        deckTimeTexts[i].setToolTipText(tooltip);
        deckTimeTexts[i].setBackground(backColor);
      }
    }
  /**
   * 所有艦娘一覧の内容
   *
   * @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);
  }
  /**
   * ドロップ報告書の内容(保存用)
   *
   * @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);
  }