Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
andanteyk committed Nov 20, 2017
2 parents 00d55e1 + 7956185 commit 7653751
Show file tree
Hide file tree
Showing 17 changed files with 168 additions and 155 deletions.
Binary file modified ElectronicObserver/Assets.zip
Binary file not shown.
Binary file added ElectronicObserver/Assets/Equipment/LandASPatrol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 18 additions & 20 deletions ElectronicObserver/Data/Battle/BattleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ public override void LoadFromResponse(string apiname, dynamic data)
case "api_req_sortie/night_to_day":
BattleMode = BattleModes.NightDay;
BattleDay = new BattleDayFromNight();
BattleDay.TakeOverParameters(BattleNight);
BattleDay.LoadFromResponse(apiname, data);
break;

Expand Down Expand Up @@ -261,8 +260,8 @@ public override void LoadFromResponse(string apiname, dynamic data)
break;

case "api_req_combined_battle/ec_night_to_day":
BattleMode = BattleModes.NightDay | BattleModes.EnemyCombinedFleet;
BattleDay = new BattleEnemyCombinedDayFromNight();
BattleDay.TakeOverParameters(BattleNight);
BattleDay.LoadFromResponse(apiname, data);
break;

Expand Down Expand Up @@ -500,7 +499,7 @@ public int PredictWinRank(out double friendrate, out double enemyrate)
int enemysunk = 0;

BattleData activeBattle = SecondBattle ?? FirstBattle;

var firstInitial = FirstBattle.Initial;

var friend = activeBattle.Initial.FriendFleet.MembersWithoutEscaped;
var friendescort = activeBattle.Initial.FriendFleetEscort?.MembersWithoutEscaped;
Expand All @@ -509,9 +508,9 @@ public int PredictWinRank(out double friendrate, out double enemyrate)



for (int i = 0; i < activeBattle.Initial.FriendInitialHPs.Length; i++)
for (int i = 0; i < firstInitial.FriendInitialHPs.Length; i++)
{
int initial = activeBattle.Initial.FriendInitialHPs[i];
int initial = firstInitial.FriendInitialHPs[i];
if (initial < 0)
continue;

Expand All @@ -521,15 +520,15 @@ public int PredictWinRank(out double friendrate, out double enemyrate)
friendafter += Math.Max(result, 0);
friendcount++;

if (result < 0)
if (result <= 0)
friendsunk++;
}

if (IsCombinedBattle)
if (firstInitial.FriendInitialHPsEscort != null)
{
for (int i = 0; i < activeBattle.Initial.FriendInitialHPsEscort.Length; i++)
for (int i = 0; i < firstInitial.FriendInitialHPsEscort.Length; i++)
{
int initial = activeBattle.Initial.FriendInitialHPsEscort[i];
int initial = firstInitial.FriendInitialHPsEscort[i];
if (initial < 0)
continue;

Expand All @@ -539,14 +538,14 @@ public int PredictWinRank(out double friendrate, out double enemyrate)
friendafter += Math.Max(result, 0);
friendcount++;

if (result < 0)
if (result <= 0)
friendsunk++;
}
}

for (int i = 0; i < activeBattle.Initial.EnemyInitialHPs.Length; i++)
for (int i = 0; i < firstInitial.EnemyInitialHPs.Length; i++)
{
int initial = activeBattle.Initial.EnemyInitialHPs[i];
int initial = firstInitial.EnemyInitialHPs[i];
if (initial < 0)
continue;

Expand All @@ -556,15 +555,15 @@ public int PredictWinRank(out double friendrate, out double enemyrate)
enemyafter += Math.Max(result, 0);
enemycount++;

if (result < 0)
if (result <= 0)
enemysunk++;
}

if (IsEnemyCombined)
if (firstInitial.EnemyInitialHPsEscort != null)
{
for (int i = 0; i < activeBattle.Initial.EnemyInitialHPsEscort.Length; i++)
for (int i = 0; i < firstInitial.EnemyInitialHPsEscort.Length; i++)
{
int initial = activeBattle.Initial.EnemyInitialHPsEscort[i];
int initial = firstInitial.EnemyInitialHPsEscort[i];
if (initial < 0)
continue;

Expand All @@ -574,7 +573,7 @@ public int PredictWinRank(out double friendrate, out double enemyrate)
enemyafter += Math.Max(result, 0);
enemycount++;

if (result < 0)
if (result <= 0)
enemysunk++;
}

Expand All @@ -588,9 +587,8 @@ public int PredictWinRank(out double friendrate, out double enemyrate)
if ((BattleMode & BattleModes.BattlePhaseMask) == BattleModes.AirRaid)
return GetWinRankAirRaid(friendcount, friendsunk, friendrate);
else
return GetWinRank(friendcount, enemycount, friendsunk, enemysunk, friendrate, enemyrate,
friend[0].HPRate <= 0.25, resultHPs[BattleIndex.Get(BattleSides.EnemyMain, 0)] <= 0);

return GetWinRank(friendcount, enemycount, friendsunk, enemysunk, friendrate, enemyrate,
friend[0].HPRate <= 0.25, resultHPs[BattleIndex.EnemyMain1] <= 0);

}

Expand Down
24 changes: 12 additions & 12 deletions ElectronicObserver/Data/Battle/BattleResultData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public int[] ExpList
{
get
{
int[] ret = new int[6];
if (RawData.api_get_ship_exp())
{
var src = (int[])RawData.api_get_ship_exp;
Array.Copy(src, 1, ret, 0, src.Length - 1);
}
if (!RawData.api_get_ship_exp())
return new int[6];

var src = (int[])RawData.api_get_ship_exp;
var ret = new int[Math.Max(src.Length - 1, 6)];
Array.Copy(src, 1, ret, 0, src.Length - 1);
return ret;
}
}
Expand All @@ -82,12 +82,12 @@ public int[] ExpListCombined
{
get
{
int[] ret = new int[6];
if (RawData.api_get_ship_exp_combined())
{
var src = (int[])RawData.api_get_ship_exp_combined;
Array.Copy(src, 1, ret, 0, src.Length - 1);
}
if (!RawData.api_get_ship_exp_combined())
return new int[6];

var src = (int[])RawData.api_get_ship_exp_combined;
var ret = new int[Math.Max(src.Length - 1, 6)];
Array.Copy(src, 1, ret, 0, src.Length - 1);
return ret;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,9 @@ private static void OutputEnemyData(StringBuilder sb, ShipDataMaster[] members,
if (members[i] == null)
continue;

sb.AppendFormat("#{0}: {1} {2} Lv. {3} HP: {4} / {5}",
sb.AppendFormat("#{0}: ID:{1} {2} {3} Lv. {4} HP: {5} / {6}",
i + 1,
members[i].ShipID,
members[i].ShipTypeName, members[i].NameWithClass,
levels[i],
initialHPs[i], maxHPs[i]);
Expand Down
42 changes: 26 additions & 16 deletions ElectronicObserver/Data/Battle/Phase/PhaseAirBattleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,29 +220,39 @@ protected T[] ConcatStage3Array<T>(string friendName, string enemyName) where T

T[] ret = new T[24];

if (IsStage3Available)
void SetArray(string stage3Name, string sideName, int retIndex)
{
T[] friend = AirBattleData.api_stage3.IsDefined(friendName) ? (T[])AirBattleData.api_stage3[friendName] ?? new T[0] : new T[0];
T[] enemy = AirBattleData.api_stage3.IsDefined(enemyName) ? (T[])AirBattleData.api_stage3[enemyName] ?? new T[0] : new T[0];
if (!AirBattleData[stage3Name].IsDefined(sideName))
return;

Array.Copy(friend, 0, ret, 0, friend.Length);
Array.Copy(enemy, 0, ret, 12, enemy.Length);
}
if (IsStage3CombinedAvailable)
{
T[] friend = AirBattleData.api_stage3_combined.IsDefined(friendName) ? (T[])AirBattleData.api_stage3_combined[friendName] ?? new T[0] : new T[0];
T[] enemy = AirBattleData.api_stage3_combined.IsDefined(enemyName) ? (T[])AirBattleData.api_stage3_combined[enemyName] ?? new T[0] : new T[0];
var ar = (dynamic[])AirBattleData[stage3Name][sideName];
if (ar == null)
return;

Array.Copy(friend, 0, ret, 6, friend.Length);
Array.Copy(enemy, 0, ret, 18, enemy.Length);
for (int i = 0; i < ar.Length; i++)
{
var value = (T?)ar[i] ?? default(T);

// Max(value, 0)
if (value.CompareTo(default(T)) < 0)
value = default(T);

ret[retIndex + i] = value;
}
}

for (int i = 0; i < ret.Length; i++)

if (IsStage3Available)
{
SetArray("api_stage3", friendName, 0);
SetArray("api_stage3", enemyName, 12);
}
if (IsStage3CombinedAvailable)
{
// Max( ret[i], 0 )
if (ret[i].CompareTo(default(T)) < 0)
ret[i] = default(T);
SetArray("api_stage3_combined", friendName, 6);
SetArray("api_stage3_combined", enemyName, 18);
}

return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions ElectronicObserver/Data/Quest/QuestProgressManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void BattleFinished(string apiname, dynamic data)
for (int i = 0; i < 6; i++)
{

if (hps[i + 6] <= 0)
if (hps[Battle.BattleIndex.Get(Battle.BattleSides.EnemyMain, i)] <= 0)
{
var ship = battle.Initial.EnemyMembersInstance[i];
if (ship == null)
Expand All @@ -414,7 +414,7 @@ void BattleFinished(string apiname, dynamic data)
p.Increment(ship.ShipType);
}

if (bm.IsEnemyCombined && hps[i + 18] <= 0)
if (bm.IsEnemyCombined && hps[Battle.BattleIndex.Get(Battle.BattleSides.EnemyEscort, i)] <= 0)
{
var ship = battle.Initial.EnemyMembersEscortInstance[i];
if (ship == null)
Expand Down
64 changes: 7 additions & 57 deletions ElectronicObserver/Notifier/NotifierDamage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private void Initialize()
o["api_req_battle_midnight/sp_midnight"].ResponseReceived += BattleStarted;
o["api_req_sortie/airbattle"].ResponseReceived += BattleStarted;
o["api_req_sortie/ld_airbattle"].ResponseReceived += BattleStarted;
o["api_req_sortie/night_to_day"].ResponseReceived += BattleStarted;
o["api_req_combined_battle/battle"].ResponseReceived += BattleStarted;
o["api_req_combined_battle/battle_water"].ResponseReceived += BattleStarted;
o["api_req_combined_battle/airbattle"].ResponseReceived += BattleStarted;
Expand All @@ -109,6 +110,7 @@ private void Initialize()
o["api_req_combined_battle/ld_airbattle"].ResponseReceived += BattleStarted;
o["api_req_combined_battle/ec_battle"].ResponseReceived += BattleStarted;
o["api_req_combined_battle/ec_midnight_battle"].ResponseReceived += BattleStarted;
o["api_req_combined_battle/ec_night_to_day"].ResponseReceived += BattleStarted;
o["api_req_combined_battle/each_battle"].ResponseReceived += BattleStarted;
o["api_req_combined_battle/each_battle_water"].ResponseReceived += BattleStarted;

Expand Down Expand Up @@ -185,66 +187,17 @@ private void CheckBattle()
return;


List<string> list = new List<string>();
var list = new List<string>();

if (bm.StartsFromDayBattle)
{
if (bm.BattleNight != null)
{
list.AddRange(GetDamagedShips(bm.BattleNight.Initial.FriendFleet, bm.BattleNight.ResultHPs.ToArray()));
}
else
{
list.AddRange(GetDamagedShips(bm.BattleDay.Initial.FriendFleet, bm.BattleDay.ResultHPs.ToArray()));
}

}
else
{
if (bm.BattleDay != null)
{
list.AddRange(GetDamagedShips(bm.BattleDay.Initial.FriendFleet, bm.BattleDay.ResultHPs.ToArray()));
}
else
{
list.AddRange(GetDamagedShips(bm.BattleNight.Initial.FriendFleet, bm.BattleNight.ResultHPs.ToArray()));
}

}
var battle = bm.SecondBattle ?? bm.FirstBattle;
list.AddRange(GetDamagedShips(battle.Initial.FriendFleet, battle.ResultHPs.ToArray()));

if (bm.IsCombinedBattle)
{
if (bm.StartsFromDayBattle)
{
if (bm.BattleNight != null)
{
list.AddRange(GetDamagedShips(KCDatabase.Instance.Fleet[2], bm.BattleNight.ResultHPs.Skip(12).ToArray()));
}
else
{
list.AddRange(GetDamagedShips(KCDatabase.Instance.Fleet[2], bm.BattleDay.ResultHPs.Skip(12).ToArray()));
}

}
else
{
if (bm.BattleDay != null)
{
list.AddRange(GetDamagedShips(KCDatabase.Instance.Fleet[2], bm.BattleDay.ResultHPs.Skip(12).ToArray()));
}
else
{
list.AddRange(GetDamagedShips(KCDatabase.Instance.Fleet[2], bm.BattleNight.ResultHPs.Skip(12).ToArray()));
}

}
}
list.AddRange(GetDamagedShips(battle.Initial.FriendFleetEscort, battle.ResultHPs.Skip(6).ToArray()));


if (list.Count > 0)
{
Notify(list.ToArray());
}

}

Expand Down Expand Up @@ -273,15 +226,12 @@ private string[] GetDamagedShips(FleetData fleet, int[] hps)

for (int i = 0; i < fleet.Members.Count; i++)
{

if (i == 0 && !ContainsFlagship) continue;

ShipData s = fleet.MembersInstance[i];

if (s != null && !fleet.EscapedShipList.Contains(s.MasterID) &&
IsShipDamaged(s, hps[i]))
if (s != null && !fleet.EscapedShipList.Contains(s.MasterID) && IsShipDamaged(s, hps[i]))
{

list.AddLast($"{s.NameWithLevel} ({hps[i]}/{s.HPMax})");
}
}
Expand Down
2 changes: 1 addition & 1 deletion ElectronicObserver/Other/Information/apilist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ api_get_member/deck :艦隊情報 個数はそのまま保有艦隊数と同
api_name_id :
api_mission :遠征状況 [0]={0=未出撃, 1=遠征中, 2=遠征帰投, 3=強制帰投中}, [1]=遠征先ID, [2]=帰投時間, [3]=0
api_flagship :
api_ship :所属艦船ID 空きは-1
api_ship :所属艦船ID 基本的には[6] ('17 秋イベントでは第三艦隊のみ[7]) 空きは-1


Request.api_req_hensei/change :艦隊編成変更
Expand Down
2 changes: 2 additions & 0 deletions ElectronicObserver/Resource/Record/ShipParameterRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,14 @@ public override void RegisterEvents()
ao["api_req_battle_midnight/sp_midnight"].ResponseReceived += BattleStart;
ao["api_req_sortie/airbattle"].ResponseReceived += BattleStart;
ao["api_req_sortie/ld_airbattle"].ResponseReceived += BattleStart;
ao["api_req_sortie/night_to_day"].ResponseReceived += BattleStart;
ao["api_req_combined_battle/battle"].ResponseReceived += BattleStart;
ao["api_req_combined_battle/sp_midnight"].ResponseReceived += BattleStart;
ao["api_req_combined_battle/airbattle"].ResponseReceived += BattleStart;
ao["api_req_combined_battle/battle_water"].ResponseReceived += BattleStart;
ao["api_req_combined_battle/ld_airbattle"].ResponseReceived += BattleStart;
ao["api_req_combined_battle/ec_battle"].ResponseReceived += BattleStart;
ao["api_req_combined_battle/ec_night_to_day"].ResponseReceived += BattleStart;
ao["api_req_combined_battle/each_battle"].ResponseReceived += BattleStart;
ao["api_req_combined_battle/each_battle_water"].ResponseReceived += BattleStart;

Expand Down
2 changes: 2 additions & 0 deletions ElectronicObserver/Resource/ResourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public enum EquipmentContent
ArmyInterceptor,
NightFighter,
NightAttacker,
LandASPatrol,
Locked,
Unknown,
}
Expand Down Expand Up @@ -444,6 +445,7 @@ private void LoadFromArchive(string path)
LoadImageFromArchive(Equipments, archive, mstpath + @"Equipment/ArmyInterceptor.png", "Equipment_ArmyInterceptor");
LoadImageFromArchive(Equipments, archive, mstpath + @"Equipment/NightFighter.png", "Equipment_NightFighter");
LoadImageFromArchive(Equipments, archive, mstpath + @"Equipment/NightAttacker.png", "Equipment_NightAttacker");
LoadImageFromArchive(Equipments, archive, mstpath + @"Equipment/LandASPatrol.png", "Equipment_LandASPatrol");
LoadImageFromArchive(Equipments, archive, mstpath + @"Equipment/Locked.png", "Equipment_Locked");
LoadImageFromArchive(Equipments, archive, mstpath + @"Equipment/Unknown.png", "Equipment_Unknown");

Expand Down
Loading

0 comments on commit 7653751

Please sign in to comment.