Skip to content

Commit

Permalink
Merge tag 'v2.1.4' of https://github.com/nekopanda/logbook
Browse files Browse the repository at this point in the history
  • Loading branch information
biikame committed Feb 16, 2016
2 parents acbfda3 + f5249f5 commit 34f6387
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 46 deletions.
2 changes: 1 addition & 1 deletion main/logbook/constants/AppConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AppConstants {
public static final String SUFFIX = "拡張版(赤)";

/** バージョン */
public static final String VERSION = "2.0.5.33";
public static final String VERSION = "2.1.4.33";

/** ホームページ */
public static final URI HOME_PAGE_URI = URI.create("http://nekopanda.blog.jp/");
Expand Down
4 changes: 4 additions & 0 deletions main/logbook/data/DataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ public enum DataType {
BATTLE_NIGHT_TO_DAY("/kcsapi/api_req_sortie/night_to_day"),
/** 戦闘(航空戦) */
AIR_BATTLE("/kcsapi/api_req_sortie/airbattle"),
/** 戦闘(長距離空襲戦) */
LD_AIRBATTLE("/kcsapi/api_req_sortie/ld_airbattle"),
/** 戦闘(航空戦) */
COMBINED_AIR_BATTLE("/kcsapi/api_req_combined_battle/airbattle"),
/** 戦闘(長距離空襲戦) */
COMBINED_LD_AIRBATTLE("/kcsapi/api_req_combined_battle/ld_airbattle"),
/** 戦闘 */
COMBINED_BATTLE("/kcsapi/api_req_combined_battle/battle"),
/** 戦闘 */
Expand Down
8 changes: 8 additions & 0 deletions main/logbook/data/context/GlobalContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,18 @@ public static void updateContext(Data data) {
doBattle(data, BattlePhaseKind.AIR_BATTLE);
break;
// 海戦
case LD_AIRBATTLE:
doBattle(data, BattlePhaseKind.LD_AIRBATTLE);
break;
// 海戦
case COMBINED_AIR_BATTLE:
doBattle(data, BattlePhaseKind.COMBINED_AIR);
break;
// 海戦
case COMBINED_LD_AIRBATTLE:
doBattle(data, BattlePhaseKind.COMBINED_LD_AIR);
break;
// 海戦
case COMBINED_BATTLE:
doBattle(data, BattlePhaseKind.COMBINED_BATTLE);
break;
Expand Down
5 changes: 4 additions & 1 deletion main/logbook/dto/AtackKind.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
*/
package logbook.dto;


/**
* @author Nekopanda
*
*/
public enum AtackKind {

// protostuffの仕様からenumの途中への追加削除厳禁
// 後ろへの追加のみ可

AIR,
SUPPORT,
HOUGEKI,
Expand Down
97 changes: 58 additions & 39 deletions main/logbook/dto/BattleExDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -472,59 +472,78 @@ private ResultRank calcResultRank(BattleExDto battle) {
boolean equalOrMore = (enemyGaugeRate > (0.9 * friendGaugeRate));
boolean superior = (enemyGaugeRate > 0) && (enemyGaugeRate > (2.5 * friendGaugeRate));

if (friendSunk == 0) { // 味方轟沈数ゼロ
if (enemyNowShips == 0) { // 敵を殲滅した
if (friendGauge == 0) { // 味方ダメージゼロ
return ResultRank.PERFECT;
}
return ResultRank.S;
if ((this.kind == BattlePhaseKind.LD_AIRBATTLE) ||
(this.kind == BattlePhaseKind.COMBINED_LD_AIR)) {
// 空襲戦
if (friendGaugeRate == 0) {
return ResultRank.PERFECT;
}
else {
// 6隻の場合のみ4隻以上撃沈?
if (numEships == 6) {
if (enemySunk >= 4) {
if (friendGaugeRate <= 10) {
return ResultRank.A;
}
if (friendGaugeRate <= 20) {
return ResultRank.B;
}
if (friendGaugeRate <= 50) {
return ResultRank.C;
}
}
else {
if (friendSunk == 0) { // 味方轟沈数ゼロ
if (enemyNowShips == 0) { // 敵を殲滅した
if (friendGauge == 0) { // 味方ダメージゼロ
return ResultRank.PERFECT;
}
return ResultRank.S;
}
else {
// 6隻の場合のみ4隻以上撃沈?
if (numEships == 6) {
if (enemySunk >= 4) {
return ResultRank.A;
}
}
// 半数以上撃沈?
else if ((enemySunk * 2) >= numEships) {
return ResultRank.A;
}
// 敵旗艦を撃沈
if (this.nowEnemyHp[0] == 0) {
return ResultRank.B;
}
// 戦果ゲージが2.5倍以上
if (superior) {
return ResultRank.B;
}
}
// 半数以上撃沈?
else if ((enemySunk * 2) >= numEships) {
return ResultRank.A;
}
else {
// 敵を殲滅した
if (enemyNowShips == 0) {
return ResultRank.B;
}
// 敵旗艦を撃沈
if (this.nowEnemyHp[0] == 0) {
// 敵旗艦を撃沈 and 味方轟沈数 < 敵撃沈数
if ((this.nowEnemyHp[0] == 0) && (friendSunk < enemySunk)) {
return ResultRank.B;
}
// 戦果ゲージが2.5倍以上
if (superior) {
return ResultRank.B;
}
// 敵旗艦を撃沈
// TODO: 味方の轟沈艦が2隻以上ある場合、敵旗艦を撃沈してもDになる場合がある
if (this.nowEnemyHp[0] == 0) {
return ResultRank.C;
}
}
}
else {
// 敵を殲滅した
if (enemyNowShips == 0) {
return ResultRank.B;
}
// 敵旗艦を撃沈 and 味方轟沈数 < 敵撃沈数
if ((this.nowEnemyHp[0] == 0) && (friendSunk < enemySunk)) {
return ResultRank.B;
}
// 戦果ゲージが2.5倍以上
if (superior) {
return ResultRank.B;
}
// 敵旗艦を撃沈
// TODO: 味方の轟沈艦が2隻以上ある場合、敵旗艦を撃沈してもDになる場合がある
if (this.nowEnemyHp[0] == 0) {
return ResultRank.C;
}
}
// 敵に与えたダメージが一定以上 and 戦果ゲージが1.0倍以上
if (enemyGauge > 0) {
if (equalOrMore) {
return ResultRank.C;
// 敵に与えたダメージが一定以上 and 戦果ゲージが1.0倍以上
if (enemyGauge > 0) {
if (equalOrMore) {
return ResultRank.C;
}
}
}

// 轟沈艦があり かつ 残った艦が1隻のみ
if ((friendSunk > 0) && ((numFships - friendSunk) == 1)) {
return ResultRank.E;
Expand Down
6 changes: 5 additions & 1 deletion main/logbook/dto/BattlePhaseKind.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public enum BattlePhaseKind {
/** 連合艦隊での夜戦マスの戦闘 */
COMBINED_SP_MIDNIGHT(true, false, BattlePatternConstants.BATTLE_PATTERN, DataType.COMBINED_BATTLE_SP_MIDNIGHT),
/** 連合艦隊水上打撃部隊の昼戦 */
COMBINED_BATTLE_WATER(false, false, BattlePatternConstants.WATER_PATTERN, DataType.COMBINED_BATTLE_WATER);
COMBINED_BATTLE_WATER(false, false, BattlePatternConstants.WATER_PATTERN, DataType.COMBINED_BATTLE_WATER),
/** 長距離空襲戦 */
LD_AIRBATTLE(false, false, BattlePatternConstants.NON_COMBINED_PTTERN, DataType.LD_AIRBATTLE),
/** 連合艦隊長距離空襲戦 */
COMBINED_LD_AIR(false, false, BattlePatternConstants.BATTLE_PATTERN, DataType.COMBINED_LD_AIRBATTLE);

private final boolean night;
private final boolean practice;
Expand Down
3 changes: 3 additions & 0 deletions main/logbook/dto/ResultRank.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*/
public enum ResultRank {

// protostuffの仕様からenumの途中への追加削除厳禁
// 後ろへの追加のみ可

/** 完全勝利S */
PERFECT("S", "完全勝利!!S"),
/** 勝利S */
Expand Down
4 changes: 4 additions & 0 deletions main/logbook/gui/background/BackgroundInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,15 @@ public void run() {
try {
// 出撃ログファイル読み込み
BattleResultServer.load();
final int failCount = BattleResultServer.get().getFailCount();
this.display.asyncExec(new Runnable() {
@Override
public void run() {
final int numLogRecord = BattleResultServer.get().size();
ApplicationMain.logPrint("出撃ログ読み込み完了(" + numLogRecord + "件)");
if (failCount > 0) {
ApplicationMain.logPrint("注意:" + failCount + "件の出撃ログ読み込みに失敗しています");
}
}
});
} catch (Exception e) {
Expand Down
26 changes: 22 additions & 4 deletions main/logbook/internal/BattleResultServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import logbook.constants.AppConstants;
import logbook.dto.BattleExDto;
import logbook.dto.BattleResultDto;
import logbook.gui.logic.DateTimeString;
import logbook.gui.logic.IntegerPair;
import logbook.scripting.BattleLogListener;
import logbook.scripting.BattleLogProxy;
Expand Down Expand Up @@ -141,6 +142,8 @@ public static BattleResultServer get() {
// 一時ストア
private List<BattleExDto> tmpDat = null;

private int failCount = 0;

private abstract class DataFile {
final File file;
int numRecords = 0;
Expand All @@ -166,7 +169,8 @@ public int getNumRecords() {
}

List<BattleExDto> load(InputStream input) throws IOException {
List<BattleExDto> result = loadFromInputStream(input, BattleResultServer.this.buffer);
List<BattleExDto> result = BattleResultServer.this.loadFromInputStream(input,
BattleResultServer.this.buffer);
this.numRecords = result.size();
return result;
}
Expand Down Expand Up @@ -228,14 +232,19 @@ public String getPath() {
}
}

private static List<BattleExDto> loadFromInputStream(InputStream input, LinkedBuffer buffer) throws IOException {
private List<BattleExDto> loadFromInputStream(InputStream input, LinkedBuffer buffer) throws IOException {
List<BattleExDto> result = new ArrayList<BattleExDto>();
try {
while (input.available() > 0) {
BattleExDto battle = schema.newMessage();
ProtostuffIOUtil.mergeDelimitedFrom(input, battle, schema, buffer);
battle.readFromJson();
result.add(battle);
try {
battle.readFromJson();
result.add(battle);
} catch (Exception e) {
this.failCount++;
LOG.get().warn("戦闘ログの読み込みに失敗しました(" + new DateTimeString(battle.getBattleDate()) + ")", e);
}
}
} catch (EOFException e) {
}
Expand Down Expand Up @@ -290,6 +299,7 @@ private BattleResultServer(String path) {
public void reloadFiles() {
this.resultDateSet.clear();
this.resultList.clear();
this.failCount = 0;

BattleLogListener battleLogScript = BattleLogProxy.get();

Expand Down Expand Up @@ -535,4 +545,12 @@ private static void mergeAltFile(File report, File alt_report) throws IOExceptio
}
alt_report.delete();
}

/**
* 読み取りに失敗した戦闘数
* @return failCount
*/
public int getFailCount() {
return this.failCount;
}
}

0 comments on commit 34f6387

Please sign in to comment.