package logbook.dto; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import javax.json.JsonObject; import logbook.internal.MapNames; import logbook.internal.Ship; import org.apache.commons.lang3.StringUtils; /** * 海戦とドロップした艦娘を表します */ public final class BattleResultDto extends AbstractDto { /** 日付 */ private final Date battleDate; /** 海域名 */ private final String questName; /** ランク */ private final String rank; /** マス */ private final int mapCellNo; /** 出撃 */ private final boolean start; /** ボスマス */ private final boolean boss; /** 敵艦隊名 */ private final String enemyName; /** ドロップフラグ */ private final boolean dropFlag; /** 艦種 */ private final String dropType; /** 艦名 */ private final String dropName; /** 戦闘詳細 */ private final BattleDto battle; /** * コンストラクター * * @param object JSON Object * @param mapCellNo マップ上のマス * @param mapBossCellNo ボスマス * @param eventId EventId * @param isStart 出撃 * @param battle 戦闘 */ public BattleResultDto(JsonObject object, int mapCellNo, int mapBossCellNo, int eventId, boolean isStart, BattleDto battle) { this.battleDate = Calendar.getInstance().getTime(); String jpname = object.getString("api_quest_name"); this.questName = MapNames.get(jpname); this.rank = object.getString("api_win_rank"); this.mapCellNo = mapCellNo; this.start = isStart; this.boss = (mapCellNo == mapBossCellNo) || (eventId == 5); this.enemyName = object.getJsonObject("api_enemy_info").getString("api_deck_name"); this.dropFlag = object.containsKey("api_get_ship") || object.containsKey("api_get_useitem"); if (this.dropFlag) { if (object.containsKey("api_get_useitem") && (object.getJsonObject("api_get_useitem").getJsonNumber("api_useitem_id").intValue() == 62)) { this.dropType = "Item"; this.dropName = "Hishimochi"; } else { String id = object.getJsonObject("api_get_ship").getJsonNumber("api_ship_id").toString(); ShipInfoDto intname = Ship.get(id); this.dropType = intname.getType(); this.dropName = intname.getName(); } } else { this.dropType = ""; this.dropName = ""; } this.battle = battle; } /** * 日付を取得します。 * @return 日付 */ public Date getBattleDate() { return this.battleDate; } /** * 海域名を取得します。 * @return 海域名 */ public String getQuestName() { return this.questName; } /** * ランクを取得します。 * @return ランク */ public String getRank() { return this.rank; } /** * マスを取得します。 * @return マス */ public int getMapCellNo() { return this.mapCellNo; } /** * 出撃を取得します * @return 出撃 */ public boolean isStart() { return this.start; } /** * ボスマスを取得します * @return ボスマス */ public boolean isBoss() { return this.boss; } /** * 出撃・ボステキストを取得します * @return 出撃・ボステキスト */ public String getBossText() { if (this.isStart() || this.isBoss()) { List<String> list = new ArrayList<>(); if (this.isStart()) { list.add("Sortie"); } if (this.isBoss()) { list.add("Boss"); } return StringUtils.join(list, "&"); } return ""; } /** * 敵艦隊名を取得します。 * @return 敵艦隊名 */ public String getEnemyName() { return this.enemyName; } /** * ドロップフラグを取得します。 * @return ドロップフラグ */ public boolean isDropFlag() { return this.dropFlag; } /** * 艦種を取得します。 * @return 艦種 */ public String getDropType() { return this.dropType; } /** * @return 戦闘詳細 */ public BattleDto getBattleDto() { return this.battle; } /** * 艦名を取得します。 * @return 艦名 */ public String getDropName() { return this.dropName; } /** * 戦闘詳細を取得します。 * @return 戦闘詳細 */ public BattleDto getBattle() { return this.battle; } }