Last active
September 19, 2024 00:07
-
-
Save Nishisonic/d1224e9ecd64b38fa32823a36411480a to your computer and use it in GitHub Desktop.
【拡張版script】轟沈セーフティサポート
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataType = Java.type("logbook.data.DataType"); | |
GlobalContext = Java.type("logbook.data.context.GlobalContext"); | |
ApplicationMain = Java.type("logbook.gui.ApplicationMain"); | |
/** | |
* @param {logbook.data.DataType} type | |
* @param {logbook.data.Data} data | |
*/ | |
function update(type, data) { | |
var json = data.jsonObject.api_data; | |
switch (type) { | |
case DataType.START: | |
case DataType.NEXT: | |
if (shouldDisposeState() && shouldDisposeCell(json) && !needsContinue(json)) { | |
// アプリを落とす | |
ApplicationMain.main.shell.dispose(); | |
} | |
break; | |
default: | |
break; | |
} | |
} | |
/** | |
* アプリを落とすべき状態か | |
* @return {boolean} | |
*/ | |
function shouldDisposeState() { | |
var isSorties = Java.from(GlobalContext.getIsSortie()); | |
return isSorties.some(function (isSortie, i) { | |
if (isSortie) { | |
var dock = GlobalContext.getDock(String(i + 1)); | |
return Java.from(dock.ships) | |
.filter(function (_, j) { | |
// 旗艦または退避している艦は除外 | |
return j > 0 && (!dock.escaped || !dock.escaped[j]); | |
}) | |
.some(function (ship) { | |
var items = Java.from(ship.item2.toArray()); | |
items.push(ship.slotExItem); | |
if ( | |
// 以下のうち何れかに当てはまる艦に限定する | |
// ・30Lv以上 | |
// ・まるゆ | |
// ・海防艦 | |
// ・ロック済み艦娘 | |
// ・ロック済み装備を所持 | |
( | |
ship.lv >= 30 || | |
ship.name.indexOf("まるゆ") >= 0 || | |
ship.stype === 1 || | |
ship.locked || | |
items.some(function (item) { | |
return item && item.isLocked(); | |
}) | |
) && | |
// 大破している艦 | |
ship.isBadlyDamage() | |
) { | |
// ダメコン所持判定 | |
return !items.some(function (item) { | |
// 42:応急修理要員, 43:応急修理女神 | |
return item && [42, 43].indexOf(item.slotitemId) >= 0; | |
}); | |
} | |
return false; | |
}); | |
} | |
return false; | |
}); | |
} | |
/** | |
* アプリを落とすべきセルか | |
* @param {javax.json.JsonObject} json JSON | |
* @return {boolean} | |
*/ | |
function shouldDisposeCell(json) { | |
// イベント種別(0:非戦闘セル) | |
return json.api_event_kind.intValue() !== 0; | |
} | |
/** | |
* アプリを続行した(落とさない)方が良いか | |
* @param {javax.json.JsonObject} json JSON | |
* @return {boolean} | |
*/ | |
function needsContinue(json) { | |
// 潜水艦隊かつ7-4かつ(KマスまたはMマス)の場合はアプリを続行させる | |
return isSubmarineFleet() && | |
json.api_maparea_id.intValue() === 7 && | |
json.api_mapinfo_no.intValue() === 4 && | |
// [11, 19]:Kマス, 13:Mマス | |
[11, 19, 13].indexOf(json.api_no.intValue()) >= 0; | |
} | |
/** | |
* 潜水艦隊か | |
* @return {boolean} | |
*/ | |
function isSubmarineFleet() { | |
var isSorties = Java.from(GlobalContext.getIsSortie()); | |
return isSorties.every(function (isSortie, i) { | |
if (isSortie) { | |
var dock = GlobalContext.getDock(String(i + 1)); | |
return Java.from(dock.ships) | |
.every(function (ship) { | |
// 13:潜水艦, 14:潜水空母 | |
return ship.stype === 13 || ship.stype === 14; | |
}); | |
} | |
return true; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment