Skip to content

Commit

Permalink
Merge pull request KC3Kai#2493 from KC3Kai/master
Browse files Browse the repository at this point in the history
Release 32.3.0
  • Loading branch information
mikenzb authored Mar 9, 2018
2 parents bd60707 + 6201704 commit 832d2fc
Show file tree
Hide file tree
Showing 30 changed files with 558 additions and 384 deletions.
Binary file added files/icons/los33.xcf
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "KC3Kai",
"version": "32.2.6",
"version": "32.3.0",
"description": "Kantai Collection Game Viewer and Tools",
"repository": {
"type": "git",
Expand Down
Binary file modified src/assets/img/stats/los2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/img/stats/los3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/img/stats/los4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/stats/ls_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/stats/ls_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 13 additions & 13 deletions src/data/WhoCallsTheFleet_ships.nedb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/data/edges.json
Original file line number Diff line number Diff line change
Expand Up @@ -1797,8 +1797,8 @@
"30": ["S", "T"],
"31": ["M", "W"],
"32": ["W", "X"],
"33": ["K", "H"],
"33": ["L", "H"],
"34": ["B", "D"],
"35": ["L", "H"]
"35": ["K", "H"]
}
}
29 changes: 3 additions & 26 deletions src/data/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@
"options" : {
"choices" : [
[ 1, "SettingsELosSum" ],
[ 2, "SettingsELosOld" ],
[ 3, "SettingsELosNew" ],
[ 4, "SettingsELosF33" ]
[ 2, "SettingsELosF33" ],
[ 3, "SettingsELosF33x3" ],
[ 4, "SettingsELosF33x4" ]
]
}
},
Expand Down Expand Up @@ -894,29 +894,6 @@
}
]
},
{
"section": "SettingsDBSubmissionWarn",
"help" : "https://github.com/KC3Kai/KC3Kai/issues/2459",
"contents" :[
{
"id" : "DBSubmission_enabled",
"name" : "SettingsEnableDBSubmission",
"type" : "check",
"options" : {},
"hide" : 1
},
{
"id" : "DBSubmission_key",
"name" : "SettingsDBSubmissionKey",
"type" : "long_text",
"options" : {"placeholder" : "API Key" },
"bound" : {
"length_min" : 27,
"length_max" : 27
}
}
]
},
{
"section": "SettingsPoiDBSubmission",
"help" : "",
Expand Down
4 changes: 1 addition & 3 deletions src/library/managers/ConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Retrieves when needed to apply on components
version : 8,
language : "en",
hqInfoPage : 1,
elosFormula : 4,
elosFormula : 2,
aaFormation : 1,
imaginaryEnemyType : 0,
imaginaryEnemyArmor : 0,
Expand All @@ -43,8 +43,6 @@ Retrieves when needed to apply on components
repeatApiError : true,
detailedApiError : true,

DBSubmission_enabled : 0,
DBSubmission_key : '',
PoiDBSubmission_enabled : false,
KC3DBSubmission_enabled : false,
OpenDBSubmission_enabled : false,
Expand Down
101 changes: 73 additions & 28 deletions src/library/managers/SortieManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ Stores and manages states and functions during sortie of fleets (including PvP b
$.extend(mergedEventInfo, eventData, {
// api_state not stored, use this instead
"api_cleared": thisMap.clear,
"api_gauge_type": thisMap.gaugeType
"api_gauge_type": thisMap.gaugeType,
"api_gauge_num": thisMap.gaugeNum || 1
});
// api_dmg seems always 0 on sortie start
delete mergedEventInfo.api_dmg;
Expand Down Expand Up @@ -123,7 +124,7 @@ Stores and manages states and functions during sortie of fleets (including PvP b
snapshotFleetState :function(){
PlayerManager.hq.lastSortie = PlayerManager.cloneFleets();
// remember index(es) of sent fleet(s) to battle
this.focusedFleet = (PlayerManager.combinedFleet && this.fleetSent === 1) ? [0,1] : [this.fleetSent-1];
this.focusedFleet = this.isCombinedSortie() ? [0,1] : [this.fleetSent-1];
// remember index(es) of sent fleet(s) to exped support
this.supportFleet = [];
if(!this.isPvP()){
Expand Down Expand Up @@ -221,6 +222,10 @@ Stores and manages states and functions during sortie of fleets (including PvP b
return this.isSortieAt(-1) || this.onPvP;
},

isCombinedSortie: function() {
return PlayerManager.combinedFleet && this.fleetSent === 1;
},

setBoss :function( cellno, comp ){
// These are set on sortie start API call
this.boss.bosscell = cellno;
Expand Down Expand Up @@ -394,7 +399,7 @@ Stores and manages states and functions during sortie of fleets (including PvP b

updateMvps :function(mvps){
if(Array.isArray(mvps) && mvps.length){
if(PlayerManager.combinedFleet && this.fleetSent === 1){
if(this.isCombinedSortie()){
const mainMvp = mvps[0] || 1,
escortMvp = mvps[1] || 1,
mainFleet = PlayerManager.fleets[0],
Expand Down Expand Up @@ -424,38 +429,75 @@ Stores and manages states and functions during sortie of fleets (including PvP b
});
},

checkFCF :function( escapeData ){
if ((typeof escapeData !== "undefined") && (escapeData !== null)) {
console.debug("FCF triggered");

const taihadShip = this.getRetreatedShip(escapeData.api_escape_idx);
const escortShip = this.getRetreatedShip(escapeData.api_tow_idx);

this.fcfCheck = [taihadShip, escortShip].filter(function (ship) {
return typeof ship !== 'undefined';
});

console.log("Has set fcfCheck to", this.fcfCheck);
checkFCF :function(escapeData){
if (escapeData) {
const getRetreatableShipId = (escapeIdx) => {
if (!escapeIdx || !escapeIdx[0]) { return 0; }
// Although there may be more elements in escape array, but only 1st element used
// since only 1 ship (topmost one) can be retreated per battle
const shipIndex = escapeIdx[0];
// If combined fleets sent, index > 6 belongs to escort fleet
if (this.isCombinedSortie() && shipIndex > 6) {
return PlayerManager.fleets[1].ship(shipIndex - 7).rosterId;
}
return PlayerManager.fleets[this.fleetSent - 1].ship(shipIndex - 1).rosterId;
};
const taihadShip = getRetreatableShipId(escapeData.api_escape_idx);
const escortShip = getRetreatableShipId(escapeData.api_tow_idx);
this.fcfCheck = [taihadShip, escortShip].filter(rosterId => rosterId > 0);
console.log("FCF escape-able ships have set to", this.fcfCheck);
}
},

getRetreatedShip: function (escapeIdx) {
if (!escapeIdx) { return undefined; }

const shipIndex = escapeIdx[0];
if (PlayerManager.combinedFleet && shipIndex > 6) {
return PlayerManager.fleets[this.fleetSent].ship(shipIndex - 7).rosterId;
}
return PlayerManager.fleets[this.fleetSent - 1].ship(shipIndex - 1).rosterId;

getCurrentFCF :function(){
// For now only to event map, can sortie with CF and SF
const isSortieAtEvent = this.map_world >= 10;
const sortiedFleets = this.focusedFleet.map(id => PlayerManager.fleets[id]);
if(!isSortieAtEvent || !sortiedFleets.length || !this.fcfCheck.length)
return { isAvailable: false };
const isCombinedSortie = sortiedFleets.length >= 2;
const flagship = sortiedFleets[0].ship(0);
const taihaShip = KC3ShipManager.get(this.fcfCheck[0]);
const escortShip = isCombinedSortie && KC3ShipManager.get(this.fcfCheck[1]);
const isNextNodeFound = !!this.currentNode().nodeData.api_next;
const canUseFCF = !isCombinedSortie ?
// is Striking Force (fleet #3) sortied (both check)
this.fleetSent === 3 && sortiedFleets[0].ships[6] > 0
// And flagship has SF-FCF (FCF incapable) (client check)
&& flagship.hasEquipment(272)
// And not flagship Taiha (supposed server-side checked already)
//&& taihaShip.fleetPosition()[0] > 0
// And current battle is not the final node (client check)
&& isNextNodeFound
:
// Main fleet flagship has FCF (client check)
flagship.hasEquipment(107)
// And Taiha ship not flagship of main and escort (server check)
//&& taihaShip.fleetPosition()[0] > 0
// And escort-able DD available (flagship DD incapable) (server check)
//&& !!escortShip && !escortShip.isDummy() && !escortShip.isAbsent()
//&& escortShip.fleetPosition()[0] > 0
//&& !escortShip.isTaiha()
// And current battle is not the final node (client check)
&& isNextNodeFound
;
return {
isAvailable: canUseFCF,
isCombined: isCombinedSortie,
shipToRetreat: taihaShip,
shipToEscort: escortShip,
sortiedFleets: sortiedFleets,
shipIdsToBeAbsent: this.fcfCheck.slice(0)
};
},

sendFCFHome :function(){
console.debug("Setting escape flag for fcfCheck", this.fcfCheck);
this.fcfCheck.forEach(function(fcfShip){
console.debug("FCF escape-able ships", this.fcfCheck);
this.fcfCheck.forEach(function(fcfShip) {
KC3ShipManager.get(fcfShip).didFlee = true;
});
[].push.apply(this.escapedList,this.fcfCheck.splice(0));
console.log("New escapedList", this.escapedList);
[].push.apply(this.escapedList, this.fcfCheck.splice(0));
console.log("Have escaped ships", this.escapedList);
},

addSunk :function(shizuList){
Expand Down Expand Up @@ -666,8 +708,11 @@ Stores and manages states and functions during sortie of fleets (including PvP b
if(PlayerManager.combinedFleet && sentFleet === 1){
this.cleanMvpShips(PlayerManager.fleets[0]);
this.cleanMvpShips(PlayerManager.fleets[1]);
PlayerManager.fleets[0].setEscapeShip();
PlayerManager.fleets[1].setEscapeShip();
} else {
this.cleanMvpShips(PlayerManager.fleets[sentFleet - 1]);
PlayerManager.fleets[sentFleet - 1].setEscapeShip();
}
for(var ectr in this.escapedList){
KC3ShipManager.get( this.escapedList[ectr] ).didFlee = false;
Expand Down
26 changes: 26 additions & 0 deletions src/library/modules/BattlePrediction.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@
}
};

BP.analyzeBattlePartially = (battleData, playerDamecons, selectedPhases) => {
const { fleets, battle, formatResult } = KC3BattlePrediction;

try {
const initialFleets = fleets.getInitialState(battleData, playerDamecons);
const resultFleets = battle.simulateBattlePartially(battleData, initialFleets, selectedPhases);

return formatResult(initialFleets, resultFleets);
} catch (error) {
// Pass context explicitly, so it is recorded
KC3Log.error(error, error.data, { selectedPhases, battleData, playerDamecons });
throw error;
}
};

BP.predictRank = (apiName, battleData, battleResult) => {
const { parseStartJson, normalizeFleets, getRankPredictor } = KC3BattlePrediction.rank;

Expand Down Expand Up @@ -228,6 +243,17 @@
)(battleData);
};

battle.simulateBattlePartially = (battleData, initalFleets, battlePhases = []) => {
const { fleets: { simulateAttack } } = KC3BattlePrediction;
const { getPhaseParser } = KC3BattlePrediction.battle;

return pipe(
juxt(battlePhases.map(getPhaseParser)),
flatten,
reduce(simulateAttack, initalFleets)
)(battleData);
};

/*--------------------------------------------------------*/
/* ---------------------[ INTERNAL ]--------------------- */
/*--------------------------------------------------------*/
Expand Down
11 changes: 11 additions & 0 deletions src/library/modules/BattlePrediction/Battle.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
)(battleData);
};

battle.simulateBattlePartially = (battleData, initalFleets, battlePhases = []) => {
const { fleets: { simulateAttack } } = KC3BattlePrediction;
const { getPhaseParser } = KC3BattlePrediction.battle;

return pipe(
juxt(battlePhases.map(getPhaseParser)),
flatten,
reduce(simulateAttack, initalFleets)
)(battleData);
};

/*--------------------------------------------------------*/
/* ---------------------[ INTERNAL ]--------------------- */
/*--------------------------------------------------------*/
Expand Down
15 changes: 15 additions & 0 deletions src/library/modules/BattlePrediction/BattlePrediction.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@
}
};

BP.analyzeBattlePartially = (battleData, playerDamecons, selectedPhases) => {
const { fleets, battle, formatResult } = KC3BattlePrediction;

try {
const initialFleets = fleets.getInitialState(battleData, playerDamecons);
const resultFleets = battle.simulateBattlePartially(battleData, initialFleets, selectedPhases);

return formatResult(initialFleets, resultFleets);
} catch (error) {
// Pass context explicitly, so it is recorded
KC3Log.error(error, error.data, { selectedPhases, battleData, playerDamecons });
throw error;
}
};

BP.predictRank = (apiName, battleData, battleResult) => {
const { parseStartJson, normalizeFleets, getRankPredictor } = KC3BattlePrediction.rank;

Expand Down
2 changes: 1 addition & 1 deletion src/library/modules/Kcsapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ Previously known as "Reactor"
// old slot from unset ship will be empty, and old item from set ship (if any) will be freed
const setExSlot = params.api_set_slot_kind == 1;
const setShipRosterId = parseInt(params.api_set_ship, 10);
const setItemIndex = setExSlot ? 4 : parseInt(params.api_set_idx, 10);
const setItemIndex = setExSlot ? -1 : parseInt(params.api_set_idx, 10);
const newShipData = response.api_data.api_ship_data;

// old status of set ship
Expand Down
2 changes: 1 addition & 1 deletion src/library/modules/TsunDBSubmission.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
this.data.fleetSpeed = Math.min(this.data.fleetSpeed, fleet.minSpeed);
// F33 Cn 1,2,3 & 4
[1,2,3,4].forEach(i => { this.data.los[i - 1] += fleet.eLos4(i); });
return fleet.ship().map(ship => (ship.isDummy() || ship.didFlee || ship.hp[0] <= 0) ? -1 : {
return fleet.ship().map(ship => (ship.isDummy() || ship.isAbsent()) ? -1 : {
id : ship.master().api_id,
name: ship.master().api_name,
shiplock: ship.sally,
Expand Down
Loading

0 comments on commit 832d2fc

Please sign in to comment.