diff --git a/ElectronicObserver/Data/APIWrapper.cs b/ElectronicObserver/Data/APIWrapper.cs index a0640c3b2..2b1945851 100644 --- a/ElectronicObserver/Data/APIWrapper.cs +++ b/ElectronicObserver/Data/APIWrapper.cs @@ -12,7 +12,7 @@ namespace ElectronicObserver.Data { /// public abstract class APIWrapper : ResponseWrapper { - protected Dictionary RequestData { get; private set; } + public Dictionary RequestData { get; private set; } public APIWrapper() diff --git a/ElectronicObserver/Data/Battle/BattleAirBattle.cs b/ElectronicObserver/Data/Battle/BattleAirBattle.cs index b35a70b25..cd50b91e7 100644 --- a/ElectronicObserver/Data/Battle/BattleAirBattle.cs +++ b/ElectronicObserver/Data/Battle/BattleAirBattle.cs @@ -1,90 +1,29 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElectronicObserver.Data.Battle { - public class BattleAirBattle : BattleData { - - public override int FleetIDFriend { - get { return (int)RawData.api_dock_id; } - } - - public override int[] EmulateBattle() { - - int[] hp = new int[12]; - - KCDatabase db = KCDatabase.Instance; - - Action DealDamageFriend = ( int index, int damage ) => { - //if ( hp[index] == -1 ) return; - hp[index] -= Math.Max( damage, 0 ); - if ( hp[index] <= 0 ) { - ShipData ship = db.Ships[db.Fleet[FleetIDFriend].Members[index]]; - if ( ship == null ) return; - - foreach ( int id in ship.SlotMaster ) { - - if ( id == 42 ) { //応急修理要員 - hp[index] = (int)( ship.HPMax * 0.2 ); - break; - } else if ( id == 43 ) { //応急修理女神 - hp[index] = ship.HPMax; - break; - } - } - } - }; - - Action DealDamageEnemy = ( int index, int damage ) => { - //if ( hp[index + 6] == -1 ) return; - hp[index + 6] -= Math.Max( damage, 0 ); - }; - - - for ( int i = 0; i < 12; i++ ) { - hp[i] = (int)RawData.api_nowhps[i + 1]; - } - - - //第一次航空戦 - if ( (int)RawData.api_stage_flag[2] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_kouku.api_stage3.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_kouku.api_stage3.api_edam[i + 1] ); - } - } + /// + /// 通常艦隊航空戦 + /// + public class BattleAirBattle : BattleDay { - //*/ //今のところ未実装だけど念のため - if ( RawData.api_support_flag() ) { - //支援艦隊(空撃) - if ( (int)RawData.api_support_flag == 1 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageEnemy( i, (int)RawData.api_support_info.api_support_airatack.api_stage3.api_edam[i + 1] ); - } - } + public PhaseAirBattle AirBattle2 { get; protected set; } - //支援艦隊(砲雷撃) - if ( (int)RawData.api_support_flag == 2 || - (int)RawData.api_support_flag == 3 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageEnemy( i, (int)RawData.api_support_info.api_support_hourai.api_damage[i + 1] ); - } - } - } - //*/ + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); - //第二次航空戦 - if ( (int)RawData.api_stage_flag2[2] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_kouku2.api_stage3.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_kouku2.api_stage3.api_edam[i + 1] ); - } - } + AirBattle = new PhaseAirBattle( this ); + Support = new PhaseSupport( this ); + AirBattle2 = new PhaseAirBattle( this, "2" ); - return hp; + AirBattle.EmulateBattle( _resultHPs, _attackDamages ); + Support.EmulateBattle( _resultHPs, _attackDamages ); + AirBattle2.EmulateBattle( _resultHPs, _attackDamages ); } diff --git a/ElectronicObserver/Data/Battle/BattleCombinedAirBattle.cs b/ElectronicObserver/Data/Battle/BattleCombinedAirBattle.cs index 936933aae..8cab2da84 100644 --- a/ElectronicObserver/Data/Battle/BattleCombinedAirBattle.cs +++ b/ElectronicObserver/Data/Battle/BattleCombinedAirBattle.cs @@ -1,4 +1,5 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -6,95 +7,28 @@ using System.Threading.Tasks; namespace ElectronicObserver.Data.Battle { - - public class BattleCombinedAirBattle : BattleDataCombined { - public override int[] EmulateBattle() { + /// + /// 連合艦隊航空戦 + /// + public class BattleCombinedAirBattle : BattleDay { - int[] hp = new int[18]; + public PhaseAirBattle AirBattle2 { get; protected set; } - KCDatabase db = KCDatabase.Instance; + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); - Action DealDamageFriend = ( int index, int damage ) => { - //if ( hp[index] == -1 ) return; - hp[index] -= Math.Max( damage, 0 ); - if ( hp[index] <= 0 ) { - ShipData ship = db.Ships[db.Fleet[ index < 6 ? 1 : 2 ].Members[ index % 6 ]]; - if ( ship == null ) return; + AirBattle = new PhaseAirBattle( this ); + Support = new PhaseSupport( this ); + AirBattle2 = new PhaseAirBattle( this, "2" ); - foreach ( int id in ship.SlotMaster ) { + AirBattle.EmulateBattle( _resultHPs, _attackDamages ); + Support.EmulateBattle( _resultHPs, _attackDamages ); + AirBattle2.EmulateBattle( _resultHPs, _attackDamages ); - if ( id == 42 ) { //応急修理要員 - hp[index] = (int)( ship.HPMax * 0.2 ); - break; - } else if ( id == 43 ) { //応急修理女神 - hp[index] = ship.HPMax; - break; - } - } - } - }; - - Action DealDamageEnemy = ( int index, int damage ) => { - //if ( hp[index + 6] == -1 ) return; - hp[index + 6] -= Math.Max( damage, 0 ); - }; - - Action DealDamageFriendEscort = ( int index, int damage ) => DealDamageFriend( index + 12, damage ); - - - for ( int i = 0; i < 12; i++ ) { - hp[i] = (int)RawData.api_nowhps[i + 1]; - } - for ( int i = 0; i < 6; i++ ) { - hp[i + 12] = (int)RawData.api_nowhps_combined[i + 1]; - } - - - //第一次航空戦 - if ( (int)RawData.api_stage_flag[2] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_kouku.api_stage3.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_kouku.api_stage3.api_edam[i + 1] ); - DealDamageFriendEscort( i, (int)RawData.api_kouku.api_stage3_combined.api_fdam[i + 1] ); - } - } - - - //支援艦隊(空撃) - if ( (int)RawData.api_support_flag == 1 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageEnemy( i, (int)RawData.api_support_info.api_support_airatack.api_stage3.api_edam[i + 1] ); - } - } - - //支援艦隊(砲雷撃) - if ( (int)RawData.api_support_flag == 2 || - (int)RawData.api_support_flag == 3 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageEnemy( i, (int)RawData.api_support_info.api_support_hourai.api_damage[i + 1] ); - } - } - - - //第二次航空戦 - if ( (int)RawData.api_stage_flag2[2] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_kouku2.api_stage3.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_kouku2.api_stage3.api_edam[i + 1] ); - DealDamageFriendEscort( i, (int)RawData.api_kouku2.api_stage3_combined.api_fdam[i + 1] ); - } - } - - - - - return hp; } - - public override string APIName { get { return "api_req_combined_battle/airbattle"; } } @@ -104,13 +38,6 @@ public override BattleData.BattleTypeFlag BattleType { get { return BattleTypeFlag.Day | BattleTypeFlag.Combined; } } - public override int FleetIDFriend { - get { return int.Parse( RawData.api_deck_id ); } - } - - public override int FleetIDFriendCombined { - get { return 2; } - } } } diff --git a/ElectronicObserver/Data/Battle/BattleCombinedNightOnly.cs b/ElectronicObserver/Data/Battle/BattleCombinedNightOnly.cs index 15664e514..e0b8f1a74 100644 --- a/ElectronicObserver/Data/Battle/BattleCombinedNightOnly.cs +++ b/ElectronicObserver/Data/Battle/BattleCombinedNightOnly.cs @@ -1,4 +1,5 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -7,83 +8,21 @@ namespace ElectronicObserver.Data.Battle { - public class BattleCombinedNightOnly : BattleDataCombined { + /// + /// 連合艦隊開幕夜戦 + /// + public class BattleCombinedNightOnly : BattleNight { + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); - public override int[] EmulateBattle() { + NightBattle = new PhaseNightBattle( this, true ); - int[] hp = new int[18]; + NightBattle.EmulateBattle( _resultHPs, _attackDamages ); - KCDatabase db = KCDatabase.Instance; - - Action DealDamageFriend = ( int index, int damage ) => { - //if ( hp[index] == -1 ) return; - hp[index] -= Math.Max( damage, 0 ); - if ( hp[index] <= 0 ) { - ShipData ship = db.Ships[db.Fleet[index < 6 ? 1 : 2].Members[ index % 6 ]]; - if ( ship == null ) return; - - foreach ( int id in ship.SlotMaster ) { - - if ( id == 42 ) { //応急修理要員 - hp[index] = (int)( ship.HPMax * 0.2 ); - break; - } else if ( id == 43 ) { //応急修理女神 - hp[index] = ship.HPMax; - break; - } - } - } - }; - - Action DealDamageEnemy = ( int index, int damage ) => { - //if ( hp[index + 6] == -1 ) return; - hp[index + 6] -= Math.Max( damage, 0 ); - }; - - Action DealDamageFriendEscort = ( int index, int damage ) => DealDamageFriend( index + 12, damage ); - - - for ( int i = 0; i < 12; i++ ) { - hp[i] = (int)RawData.api_nowhps[i + 1]; - } - for ( int i = 0; i < 6; i++ ) { - hp[i + 12] = (int)RawData.api_nowhps_combined[i + 1]; - } - - - //夜間砲撃戦 - { - dynamic hougeki = RawData.api_hougeki; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriendEscort( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - return hp; } - public override string APIName { get { return "api_req_combined_battle/sp_midnight"; } @@ -94,13 +33,6 @@ public override BattleData.BattleTypeFlag BattleType { get { return BattleTypeFlag.Night | BattleTypeFlag.Combined; } } - public override int FleetIDFriend { - get { return int.Parse( RawData.api_deck_id ); } - } - - public override int FleetIDFriendCombined { - get { return 2; } - } } } diff --git a/ElectronicObserver/Data/Battle/BattleCombinedNormalDay.cs b/ElectronicObserver/Data/Battle/BattleCombinedNormalDay.cs index 0f775222d..3356f2848 100644 --- a/ElectronicObserver/Data/Battle/BattleCombinedNormalDay.cs +++ b/ElectronicObserver/Data/Battle/BattleCombinedNormalDay.cs @@ -1,4 +1,5 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -6,190 +7,35 @@ using System.Threading.Tasks; namespace ElectronicObserver.Data.Battle { - - public class BattleCombinedNormalDay : BattleDataCombined { + /// + /// 連合艦隊(機動部隊)昼戦 + /// + public class BattleCombinedNormalDay : BattleDay { + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); - public override int[] EmulateBattle() { + AirBattle = new PhaseAirBattle( this ); + Support = new PhaseSupport( this ); + OpeningTorpedo = new PhaseTorpedo( this, 0 ); + Shelling1 = new PhaseShelling( this, 1, "1", true ); + Torpedo = new PhaseTorpedo( this, 2 ); + Shelling2 = new PhaseShelling( this, 3, "2", false ); + Shelling3 = new PhaseShelling( this, 4, "3", false ); - int[] hp = new int[18]; - - KCDatabase db = KCDatabase.Instance; - - Action DealDamageFriend = ( int index, int damage ) => { - //if ( hp[index] == -1 ) return; - hp[index] -= Math.Max( damage, 0 ); - if ( hp[index] <= 0 ) { - ShipData ship = db.Ships[db.Fleet[index < 6 ? 1 : 2].Members[ index % 6 ]]; - if ( ship == null ) return; - - foreach ( int id in ship.SlotMaster ) { - - if ( id == 42 ) { //応急修理要員 - hp[index] = (int)( ship.HPMax * 0.2 ); - break; - } else if ( id == 43 ) { //応急修理女神 - hp[index] = ship.HPMax; - break; - } - } - } - }; - - Action DealDamageEnemy = ( int index, int damage ) => { - //if ( hp[index + 6] == -1 ) return; - hp[index + 6] -= Math.Max( damage, 0 ); - }; - - Action DealDamageFriendEscort = ( int index, int damage ) => DealDamageFriend( index + 12, damage ); - - - for ( int i = 0; i < 12; i++ ) { - hp[i] = (int)RawData.api_nowhps[i + 1]; - } - for ( int i = 0; i < 6; i++ ) { - hp[i + 12] = (int)RawData.api_nowhps_combined[i + 1]; - } - - - //航空戦 - if ( (int)RawData.api_stage_flag[2] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_kouku.api_stage3.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_kouku.api_stage3.api_edam[i + 1] ); - DealDamageFriendEscort( i, (int)RawData.api_kouku.api_stage3_combined.api_fdam[i + 1] ); - } - } - - - //支援艦隊(空撃) - if ( (int)RawData.api_support_flag == 1 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageEnemy( i, (int)RawData.api_support_info.api_support_airatack.api_stage3.api_edam[i + 1] ); - } - } - - //支援艦隊(砲雷撃) - if ( (int)RawData.api_support_flag == 2 || - (int)RawData.api_support_flag == 3 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageEnemy( i, (int)RawData.api_support_info.api_support_hourai.api_damage[i + 1] ); - } - } - - - //開幕雷撃 - if ( (int)RawData.api_opening_flag != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriendEscort( i, (int)RawData.api_opening_atack.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_opening_atack.api_edam[i + 1] ); - } - } - - - //砲撃戦(1巡目) - if ( (int)RawData.api_hourai_flag[0] != 0 ) { - dynamic hougeki = RawData.api_hougeki1; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriendEscort( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - //雷撃戦 - if ( (int)RawData.api_hourai_flag[1] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriendEscort( i, (int)RawData.api_raigeki.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_raigeki.api_edam[i + 1] ); - } - } - - - //砲撃戦(2巡目) - if ( (int)RawData.api_hourai_flag[2] != 0 ) { - dynamic hougeki = RawData.api_hougeki2; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriend( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - - //砲撃戦(3巡目) - if ( (int)RawData.api_hourai_flag[3] != 0 ) { - dynamic hougeki = RawData.api_hougeki3; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriend( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - - - - return hp; - + AirBattle.EmulateBattle( _resultHPs, _attackDamages ); + Support.EmulateBattle( _resultHPs, _attackDamages ); + OpeningTorpedo.EmulateBattle( _resultHPs, _attackDamages ); + Shelling1.EmulateBattle( _resultHPs, _attackDamages ); + Torpedo.EmulateBattle( _resultHPs, _attackDamages ); + Shelling2.EmulateBattle( _resultHPs, _attackDamages ); + Shelling3.EmulateBattle( _resultHPs, _attackDamages ); } - public override string APIName { get { return "api_req_combined_battle/battle"; } } @@ -199,13 +45,6 @@ public override BattleData.BattleTypeFlag BattleType { get { return BattleTypeFlag.Day | BattleTypeFlag.Combined; } } - public override int FleetIDFriend { - get { return int.Parse( RawData.api_deck_id ); } - } - - public override int FleetIDFriendCombined { - get { return 2; } - } } } diff --git a/ElectronicObserver/Data/Battle/BattleCombinedNormalNight.cs b/ElectronicObserver/Data/Battle/BattleCombinedNormalNight.cs index 045a39666..3ff09991a 100644 --- a/ElectronicObserver/Data/Battle/BattleCombinedNormalNight.cs +++ b/ElectronicObserver/Data/Battle/BattleCombinedNormalNight.cs @@ -1,4 +1,5 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -7,86 +8,21 @@ namespace ElectronicObserver.Data.Battle { - public class BattleCombinedNormalNight : BattleDataCombined { + /// + /// 連合艦隊夜戦 + /// + public class BattleCombinedNormalNight : BattleNight { + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); - public override int[] EmulateBattle() { + NightBattle = new PhaseNightBattle( this, true ); - int[] hp = new int[18]; + NightBattle.EmulateBattle( _resultHPs, _attackDamages ); - KCDatabase db = KCDatabase.Instance; - - Action DealDamageFriend = ( int index, int damage ) => { - //if ( hp[index] == -1 ) return; - hp[index] -= Math.Max( damage, 0 ); - if ( hp[index] <= 0 ) { - ShipData ship = db.Ships[db.Fleet[index < 6 ? 1 : 2].Members[ index % 6 ]]; - if ( ship == null ) return; - - foreach ( int id in ship.SlotMaster ) { - - if ( id == 42 ) { //応急修理要員 - hp[index] = (int)( ship.HPMax * 0.2 ); - break; - } else if ( id == 43 ) { //応急修理女神 - hp[index] = ship.HPMax; - break; - } - } - } - }; - - Action DealDamageEnemy = ( int index, int damage ) => { - //if ( hp[index + 6] == -1 ) return; - hp[index + 6] -= Math.Max( damage, 0 ); - }; - - Action DealDamageFriendEscort = ( int index, int damage ) => DealDamageFriend( index + 12, damage ); - - - - for ( int i = 0; i < 12; i++ ) { - hp[i] = (int)RawData.api_nowhps[i + 1]; - } - for ( int i = 0; i < 6; i++ ) { - hp[i + 12] = (int)RawData.api_nowhps_combined[i + 1]; - } - - - //夜間砲撃戦 - { - dynamic hougeki = RawData.api_hougeki; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriendEscort( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - return hp; } - - - public override string APIName { get { return "api_req_combined_battle/midnight_battle"; } } @@ -95,13 +31,6 @@ public override BattleData.BattleTypeFlag BattleType { get { return BattleTypeFlag.Night | BattleTypeFlag.Combined; } } - public override int FleetIDFriendCombined { - get { return 2; } - } - - public override int FleetIDFriend { - get { return int.Parse( RawData.api_deck_id ); } - } } } diff --git a/ElectronicObserver/Data/Battle/BattleCombinedWater.cs b/ElectronicObserver/Data/Battle/BattleCombinedWater.cs index 7f6f2049f..6c9ca57af 100644 --- a/ElectronicObserver/Data/Battle/BattleCombinedWater.cs +++ b/ElectronicObserver/Data/Battle/BattleCombinedWater.cs @@ -1,4 +1,5 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,205 +7,42 @@ namespace ElectronicObserver.Data.Battle { - public class BattleCombinedWater : BattleDataCombined { - - - public override int[] EmulateBattle() { - - - int[] hp = new int[18]; - - KCDatabase db = KCDatabase.Instance; - - Action DealDamageFriend = ( int index, int damage ) => { - //if ( hp[index] == -1 ) return; - hp[index] -= Math.Max( damage, 0 ); - if ( hp[index] <= 0 ) { - ShipData ship = db.Ships[db.Fleet[index < 6 ? 1 : 2].Members[ index % 6 ]]; - if ( ship == null ) return; - - foreach ( int id in ship.SlotMaster ) { - - if ( id == 42 ) { //応急修理要員 - hp[index] = (int)( ship.HPMax * 0.2 ); - break; - } else if ( id == 43 ) { //応急修理女神 - hp[index] = ship.HPMax; - break; - } - } - } - }; - - Action DealDamageEnemy = ( int index, int damage ) => { - //if ( hp[index + 6] == -1 ) return; - hp[index + 6] -= Math.Max( damage, 0 ); - }; - - Action DealDamageFriendEscort = ( int index, int damage ) => DealDamageFriend( index + 12, damage ); - - - for ( int i = 0; i < 12; i++ ) { - hp[i] = (int)RawData.api_nowhps[i + 1]; - } - for ( int i = 0; i < 6; i++ ) { - hp[i + 12] = (int)RawData.api_nowhps_combined[i + 1]; - } - - - //航空戦 - if ( (int)RawData.api_stage_flag[2] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_kouku.api_stage3.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_kouku.api_stage3.api_edam[i + 1] ); - DealDamageFriendEscort( i, (int)RawData.api_kouku.api_stage3_combined.api_fdam[i + 1] ); - } - } - - - //支援艦隊(空撃) - if ( (int)RawData.api_support_flag == 1 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageEnemy( i, (int)RawData.api_support_info.api_support_airatack.api_stage3.api_edam[i + 1] ); - } - } - - //支援艦隊(砲雷撃) - if ( (int)RawData.api_support_flag == 2 || - (int)RawData.api_support_flag == 3 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageEnemy( i, (int)RawData.api_support_info.api_support_hourai.api_damage[i + 1] ); - } - } - - - //開幕雷撃 - if ( (int)RawData.api_opening_flag != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriendEscort( i, (int)RawData.api_opening_atack.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_opening_atack.api_edam[i + 1] ); - } - } - - + /// + /// 連合艦隊(水上部隊)抽選 + /// + public class BattleCombinedWater : BattleDay { + + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); + + AirBattle = new PhaseAirBattle( this ); + Support = new PhaseSupport( this ); + OpeningTorpedo = new PhaseTorpedo( this, 0 ); + Shelling1 = new PhaseShelling( this, 1, "1", false ); + Shelling2 = new PhaseShelling( this, 2, "2", false ); + Shelling3 = new PhaseShelling( this, 3, "3", true ); + Torpedo = new PhaseTorpedo( this, 4 ); - //砲撃戦(1巡目) - if ( (int)RawData.api_hourai_flag[0] != 0 ) { - dynamic hougeki = RawData.api_hougeki1; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriend( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - - //砲撃戦(2巡目) - if ( (int)RawData.api_hourai_flag[1] != 0 ) { - dynamic hougeki = RawData.api_hougeki2; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriend( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - - //砲撃戦(3巡目) - if ( (int)RawData.api_hourai_flag[2] != 0 ) { - dynamic hougeki = RawData.api_hougeki3; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriendEscort( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - //雷撃戦 - if ( (int)RawData.api_hourai_flag[3] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriendEscort( i, (int)RawData.api_raigeki.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_raigeki.api_edam[i + 1] ); - } - } - - - - return hp; - + AirBattle.EmulateBattle( _resultHPs, _attackDamages ); + Support.EmulateBattle( _resultHPs, _attackDamages ); + OpeningTorpedo.EmulateBattle( _resultHPs, _attackDamages ); + Shelling1.EmulateBattle( _resultHPs, _attackDamages ); + Shelling2.EmulateBattle( _resultHPs, _attackDamages ); + Shelling3.EmulateBattle( _resultHPs, _attackDamages ); + Torpedo.EmulateBattle( _resultHPs, _attackDamages ); + } - - - public override int FleetIDFriend { - get { return int.Parse( RawData.api_deck_id ); } - } - - public override int FleetIDFriendCombined { - get { return 2; } + public override string APIName { + get { return "api_req_combined_battle/battle_water"; } } - public override BattleData.BattleTypeFlag BattleType { get { return BattleTypeFlag.Day | BattleTypeFlag.Combined; } } - public override string APIName { - get { return "api_req_combined_battle/battle_water"; } - } } } diff --git a/ElectronicObserver/Data/Battle/BattleData.cs b/ElectronicObserver/Data/Battle/BattleData.cs index 17f638d92..71c40bc2e 100644 --- a/ElectronicObserver/Data/Battle/BattleData.cs +++ b/ElectronicObserver/Data/Battle/BattleData.cs @@ -1,4 +1,5 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -12,55 +13,97 @@ namespace ElectronicObserver.Data.Battle { /// public abstract class BattleData : ResponseWrapper { - //戦闘系はデータが安定しないため、特例的に生データを公開する - //可能なら封印できるように作る事 - public dynamic Data { - get { return RawData; } - } - - + protected int[] _resultHPs; /// - /// 戦闘中の自軍艦隊ID + /// 戦闘終了時の各艦のHP /// - public abstract int FleetIDFriend { get; } + public ReadOnlyCollection ResultHPs { get { return Array.AsReadOnly( _resultHPs ); } } + protected int[] _attackDamages; /// - /// 敵艦隊の艦船IDリスト [1-6] + /// 各艦の与ダメージ /// - public ReadOnlyCollection EnemyFleetMembers { - get { return Array.AsReadOnly( (int[])RawData.api_ship_ke ); } + public ReadOnlyCollection AttackDamages { get { return Array.AsReadOnly( _attackDamages ); } } + + + public PhaseInitial Initial { get; protected set; } + public PhaseSearching Searching { get; protected set; } + + + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); + + Initial = new PhaseInitial( this ); + Searching = new PhaseSearching( this ); + + _resultHPs = Initial.InitialHPs.ToArray(); + if ( _attackDamages == null ) + _attackDamages = new int[_resultHPs.Length]; + } + /// - /// 全軍の初期HP [1-6]=味方, [7-12]=敵 + /// MVPを取得した艦のインデックス /// - public ReadOnlyCollection InitialHP { - get { return Array.AsReadOnly( (int[])RawData.api_nowhps ); } + public int MVPShipIndex { + get { + int index = -1; + int max = 1; + for ( int i = 0; i < 6; i++ ) { + if ( _attackDamages[i] >= max ) { + max = _attackDamages[i]; + index = i; + } + } + return index == -1 ? 0 : index; + } } /// - /// 全軍の最大HP [1-6]=味方, [7-12]=敵 + /// MVPを取得した艦 /// - public ReadOnlyCollection MaxHP { - get { return Array.AsReadOnly( (int[])RawData.api_maxhps ); } + public ShipData MVPShip { + get { + return Initial.FriendFleet.MembersInstance[MVPShipIndex]; + } } /// - /// 敵艦のレベル [1-6] + /// MVPを取得した艦のインデックス(随伴護衛部隊) /// - public ReadOnlyCollection EnemyLevels { - get { return Array.AsReadOnly( (int[])RawData.api_ship_lv ); } + public int MVPShipCombinedIndex { + get { + int index = -1; + int max = 1; + for ( int i = 0; i < 6; i++ ) { + if ( _attackDamages[i + 12] >= max ) { + max = _attackDamages[i + 12]; + index = i; + } + } + return index == -1 ? 0 : index; + } } - + /// + /// MVPを取得した艦(随伴護衛部隊) + /// + public ShipData MVPShipCombined { + get { + return KCDatabase.Instance.Fleet[2].MembersInstance[MVPShipCombinedIndex]; + } + } /// - /// 戦闘をエミュレートし、戦闘終了時の各艦船のHPを求めます。 + /// 前回の戦闘データからパラメータを引き継ぎます。 /// - /// 戦闘終了時のHP。 - public abstract int[] EmulateBattle(); + internal void TakeOverParameters( BattleData prev ) { + _attackDamages = (int[])prev._attackDamages.Clone(); + } + /// diff --git a/ElectronicObserver/Data/Battle/BattleDataCombined.cs b/ElectronicObserver/Data/Battle/BattleDataCombined.cs deleted file mode 100644 index 523df7c5c..000000000 --- a/ElectronicObserver/Data/Battle/BattleDataCombined.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ElectronicObserver.Data.Battle { - - public abstract class BattleDataCombined : BattleData { - - public abstract int FleetIDFriendCombined { get; } - - /// - /// 随伴護衛艦隊の初期HP [1-6] - /// - public ReadOnlyCollection InitialHPCombined { - get { return Array.AsReadOnly( (int[])RawData.api_nowhps_combined ); } - } - - /// - /// 随伴護衛艦隊の最大HP [1-6] - /// - public ReadOnlyCollection MaxHPCombined { - get { return Array.AsReadOnly( (int[])RawData.api_maxhps_combined ); } - } - - } -} diff --git a/ElectronicObserver/Data/Battle/BattleDay.cs b/ElectronicObserver/Data/Battle/BattleDay.cs new file mode 100644 index 000000000..697b17dc4 --- /dev/null +++ b/ElectronicObserver/Data/Battle/BattleDay.cs @@ -0,0 +1,24 @@ +using ElectronicObserver.Data.Battle.Phase; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserver.Data.Battle { + + /// + /// 昼戦の基底クラス + /// + public abstract class BattleDay : BattleData { + + public PhaseAirBattle AirBattle { get; protected set; } + public PhaseSupport Support { get; protected set; } + public PhaseTorpedo OpeningTorpedo { get; protected set; } + public PhaseShelling Shelling1 { get; protected set; } + public PhaseShelling Shelling2 { get; protected set; } + public PhaseShelling Shelling3 { get; protected set; } + public PhaseTorpedo Torpedo { get; protected set; } + + } +} diff --git a/ElectronicObserver/Data/Battle/BattleManager.cs b/ElectronicObserver/Data/Battle/BattleManager.cs index 0df357469..aee15e66b 100644 --- a/ElectronicObserver/Data/Battle/BattleManager.cs +++ b/ElectronicObserver/Data/Battle/BattleManager.cs @@ -20,12 +20,12 @@ public class BattleManager : ResponseWrapper { /// /// 昼戦データ /// - public BattleData BattleDay { get; private set; } + public BattleDay BattleDay { get; private set; } /// /// 夜戦データ /// - public BattleData BattleNight { get; private set; } + public BattleNight BattleNight { get; private set; } /// /// 戦闘結果データ @@ -52,6 +52,16 @@ public enum BattleModes { public BattleModes BattleMode { get; private set; } + /// + /// 出撃中に入手した艦船数 + /// + public int DroppedShipCount { get; internal set; } + + /// + /// 出撃中に入手した装備数 + /// + public int DroppedEquipmentCount { get; internal set; } + public override void LoadFromResponse( string apiname, dynamic data ) { //base.LoadFromResponse( apiname, data ); //不要 @@ -75,6 +85,7 @@ public override void LoadFromResponse( string apiname, dynamic data ) { case "api_req_battle_midnight/battle": BattleNight = new BattleNormalNight(); + BattleNight.TakeOverParameters( BattleDay ); BattleNight.LoadFromResponse( apiname, data ); break; @@ -98,6 +109,7 @@ public override void LoadFromResponse( string apiname, dynamic data ) { case "api_req_combined_battle/midnight_battle": BattleNight = new BattleCombinedNormalNight(); + //BattleNight.TakeOverParameters( BattleDay ); //checkme: 連合艦隊夜戦では昼戦での与ダメージがMVPに反映されない仕様? BattleNight.LoadFromResponse( apiname, data ); break; @@ -127,6 +139,7 @@ public override void LoadFromResponse( string apiname, dynamic data ) { case "api_req_practice/midnight_battle": BattleNight = new BattlePracticeNight(); + BattleNight.TakeOverParameters( BattleDay ); BattleNight.LoadFromResponse( apiname, data ); break; @@ -144,6 +157,11 @@ public override void LoadFromResponse( string apiname, dynamic data ) { BattleNight = null; Result = null; BattleMode = BattleModes.Undefined; + DroppedShipCount = DroppedEquipmentCount = 0; + break; + + case "api_get_member/slot_item": + DroppedEquipmentCount = 0; break; } @@ -160,12 +178,12 @@ private void BattleFinished() { switch ( BattleMode & BattleModes.BattlePhaseMask ) { case BattleModes.Normal: case BattleModes.AirBattle: - RecordManager.Instance.EnemyFleet.Update( new EnemyFleetRecord.EnemyFleetElement( Compass.EnemyFleetID, Result.EnemyFleetName, (int)BattleDay.Data.api_formation[1], ( (int[])BattleDay.Data.api_ship_ke ).Skip( 1 ).ToArray() ) ); + RecordManager.Instance.EnemyFleet.Update( new EnemyFleetRecord.EnemyFleetElement( Compass.EnemyFleetID, Result.EnemyFleetName, BattleDay.Searching.FormationEnemy, BattleDay.Initial.EnemyMembers ) ); break; case BattleModes.NightOnly: case BattleModes.NightDay: - RecordManager.Instance.EnemyFleet.Update( new EnemyFleetRecord.EnemyFleetElement( Compass.EnemyFleetID, Result.EnemyFleetName, (int)BattleNight.Data.api_formation[1], ( (int[])BattleNight.Data.api_ship_ke ).Skip( 1 ).ToArray() ) ); + RecordManager.Instance.EnemyFleet.Update( new EnemyFleetRecord.EnemyFleetElement( Compass.EnemyFleetID, Result.EnemyFleetName, BattleNight.Searching.FormationEnemy, BattleNight.Initial.EnemyMembers ) ); break; } @@ -178,9 +196,18 @@ private void BattleFinished() { int dropID = Result.DroppedShipID; bool showLog = Utility.Configuration.Config.Log.ShowSpoiler; - if ( dropID != -1 && showLog ) { + if ( dropID != -1 ) { + ShipDataMaster ship = KCDatabase.Instance.MasterShips[dropID]; - Utility.Logger.Add( 2, string.Format( "{0}「{1}」が戦列に加わりました。", ship.ShipTypeName, ship.NameWithClass ) ); + + DroppedShipCount++; + + var defaultSlot = ship.DefaultSlot; + if ( defaultSlot != null ) + DroppedEquipmentCount += defaultSlot.Count( id => id != -1 ); + + if ( showLog ) + Utility.Logger.Add( 2, string.Format( "{0}「{1}」が戦列に加わりました。", ship.ShipTypeName, ship.NameWithClass ) ); } if ( dropID == -1 ) { @@ -204,12 +231,16 @@ private void BattleFinished() { EquipmentDataMaster eq = KCDatabase.Instance.MasterEquipments[eqID]; Utility.Logger.Add( 2, string.Format( "{0}「{1}」を入手しました。", eq.CategoryTypeInstance.Name, eq.Name ) ); } + + DroppedEquipmentCount++; } + } + if ( dropID == -1 && ( - KCDatabase.Instance.Admiral.MaxShipCount - KCDatabase.Instance.Ships.Count <= 0 || - KCDatabase.Instance.Admiral.MaxEquipmentCount - KCDatabase.Instance.Equipments.Count <= 0 ) ) { + KCDatabase.Instance.Admiral.MaxShipCount - ( KCDatabase.Instance.Ships.Count + DroppedShipCount ) <= 0 || + KCDatabase.Instance.Admiral.MaxEquipmentCount - ( KCDatabase.Instance.Equipments.Count + DroppedEquipmentCount ) <= 0 ) ) { dropID = -2; } diff --git a/ElectronicObserver/Data/Battle/BattleNight.cs b/ElectronicObserver/Data/Battle/BattleNight.cs new file mode 100644 index 000000000..ce5dfa53e --- /dev/null +++ b/ElectronicObserver/Data/Battle/BattleNight.cs @@ -0,0 +1,18 @@ +using ElectronicObserver.Data.Battle.Phase; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserver.Data.Battle { + + /// + /// 夜戦の基底クラス + /// + public abstract class BattleNight : BattleData { + + public PhaseNightBattle NightBattle { get; protected set; } + + } +} diff --git a/ElectronicObserver/Data/Battle/BattleNightOnly.cs b/ElectronicObserver/Data/Battle/BattleNightOnly.cs index d5175c08a..9dd4c85ac 100644 --- a/ElectronicObserver/Data/Battle/BattleNightOnly.cs +++ b/ElectronicObserver/Data/Battle/BattleNightOnly.cs @@ -1,4 +1,5 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,88 +7,29 @@ namespace ElectronicObserver.Data.Battle { - public class BattleNightOnly : BattleData { + /// + /// 通常艦隊開幕夜戦 + /// + public class BattleNightOnly : BattleNight { - public override int[] EmulateBattle() { + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); - int[] hp = new int[12]; + NightBattle = new PhaseNightBattle( this, false ); - KCDatabase db = KCDatabase.Instance; - - Action DealDamageFriend = ( int index, int damage ) => { - //if ( hp[index] == -1 ) return; - hp[index] -= Math.Max( damage, 0 ); - if ( hp[index] <= 0 ) { - ShipData ship = db.Ships[db.Fleet[FleetIDFriend].Members[index]]; - if ( ship == null ) return; - - foreach ( int id in ship.SlotMaster ) { - - if ( id == 42 ) { //応急修理要員 - hp[index] = (int)( ship.HPMax * 0.2 ); - break; - } else if ( id == 43 ) { //応急修理女神 - hp[index] = ship.HPMax; - break; - } - } - } - }; - - Action DealDamageEnemy = ( int index, int damage ) => { - //if ( hp[index + 6] == -1 ) return; - hp[index + 6] -= Math.Max( damage, 0 ); - }; - - - for ( int i = 0; i < 12; i++ ) { - hp[i] = (int)RawData.api_nowhps[i + 1]; - } - - - //夜間砲撃戦 - { - dynamic hougeki = RawData.api_hougeki; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriend( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - return hp; + NightBattle.EmulateBattle( _resultHPs, _attackDamages ); } + public override string APIName { get { return "api_req_battle_midnight/sp_midnight"; } } - - public override int FleetIDFriend { - get { return (int)RawData.api_deck_id; } - } - public override BattleTypeFlag BattleType { get { return BattleTypeFlag.Night; } } + } } diff --git a/ElectronicObserver/Data/Battle/BattleNormalDay.cs b/ElectronicObserver/Data/Battle/BattleNormalDay.cs index f33c372a2..c5d2c03a5 100644 --- a/ElectronicObserver/Data/Battle/BattleNormalDay.cs +++ b/ElectronicObserver/Data/Battle/BattleNormalDay.cs @@ -1,4 +1,5 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,145 +7,32 @@ namespace ElectronicObserver.Data.Battle { - public class BattleNormalDay : BattleData { + /// + /// 通常艦隊昼戦 + /// + public class BattleNormalDay : BattleDay { - public override int[] EmulateBattle() { + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); - int[] hp = new int[12]; + AirBattle = new PhaseAirBattle( this ); + Support = new PhaseSupport( this ); + OpeningTorpedo = new PhaseTorpedo( this, 0 ); + Shelling1 = new PhaseShelling( this, 1, "1", false ); + Shelling2 = new PhaseShelling( this, 2, "2", false ); + Shelling3 = new PhaseShelling( this, 3, "3", false ); + Torpedo = new PhaseTorpedo( this, 4 ); - KCDatabase db = KCDatabase.Instance; - Action DealDamageFriend = ( int index, int damage ) => { - //if ( hp[index] == -1 ) return; - hp[index] -= Math.Max( damage, 0 ); - if ( hp[index] <= 0 ) { - ShipData ship = db.Ships[db.Fleet[FleetIDFriend].Members[index]]; - if ( ship == null ) return; + AirBattle.EmulateBattle( _resultHPs, _attackDamages ); + Support.EmulateBattle( _resultHPs, _attackDamages ); + OpeningTorpedo.EmulateBattle( _resultHPs, _attackDamages ); + Shelling1.EmulateBattle( _resultHPs, _attackDamages ); + Shelling2.EmulateBattle( _resultHPs, _attackDamages ); + Shelling3.EmulateBattle( _resultHPs, _attackDamages ); + Torpedo.EmulateBattle( _resultHPs, _attackDamages ); - foreach ( int id in ship.SlotMaster ) { - - if ( id == 42 ) { //応急修理要員 - hp[index] = (int)( ship.HPMax * 0.2 ); - break; - } else if ( id == 43 ) { //応急修理女神 - hp[index] = ship.HPMax; - break; - } - } - } - }; - - Action DealDamageEnemy = ( int index, int damage ) => { - //if ( hp[index + 6] == -1 ) return; - hp[index + 6] -= Math.Max( damage, 0 ); - }; - - - for ( int i = 0; i < 12; i++ ) { - hp[i] = (int)RawData.api_nowhps[i + 1]; - } - - - //航空戦 - if ( (int)RawData.api_stage_flag[2] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_kouku.api_stage3.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_kouku.api_stage3.api_edam[i + 1] ); - } - } - - - //支援艦隊(空撃) - if ( (int)RawData.api_support_flag == 1 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageEnemy( i, (int)RawData.api_support_info.api_support_airatack.api_stage3.api_edam[i + 1] ); - } - } - - //支援艦隊(砲雷撃) - if ( (int)RawData.api_support_flag == 2 || - (int)RawData.api_support_flag == 3 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageEnemy( i, (int)RawData.api_support_info.api_support_hourai.api_damage[i + 1] ); - } - } - - - //開幕雷撃 - if ( (int)RawData.api_opening_flag != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_opening_atack.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_opening_atack.api_edam[i + 1] ); - } - } - - - //砲撃戦(1巡目) - if ( (int)RawData.api_hourai_flag[0] != 0 ) { - dynamic hougeki = RawData.api_hougeki1; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriend( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - //砲撃戦(2巡目) - if ( (int)RawData.api_hourai_flag[1] != 0 ) { - dynamic hougeki = RawData.api_hougeki2; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriend( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - - //雷撃戦 - if ( (int)RawData.api_hourai_flag[3] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_raigeki.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_raigeki.api_edam[i + 1] ); - } - } - - - return hp; } @@ -157,9 +45,6 @@ public override BattleData.BattleTypeFlag BattleType { get { return BattleTypeFlag.Day; } } - public override int FleetIDFriend { - get { return (int)RawData.api_dock_id; } - } } } diff --git a/ElectronicObserver/Data/Battle/BattleNormalNight.cs b/ElectronicObserver/Data/Battle/BattleNormalNight.cs index 4e7a1042c..276ab2eeb 100644 --- a/ElectronicObserver/Data/Battle/BattleNormalNight.cs +++ b/ElectronicObserver/Data/Battle/BattleNormalNight.cs @@ -1,91 +1,31 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElectronicObserver.Data.Battle { - - public class BattleNormalNight : BattleData { - + /// + /// 通常艦隊夜戦 + /// + public class BattleNormalNight : BattleNight { - public override int[] EmulateBattle() { + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); - int[] hp = new int[12]; + NightBattle = new PhaseNightBattle( this, false ); - KCDatabase db = KCDatabase.Instance; + NightBattle.EmulateBattle( _resultHPs, _attackDamages ); - Action DealDamageFriend = ( int index, int damage ) => { - //if ( hp[index] == -1 ) return; - hp[index] -= Math.Max( damage, 0 ); - if ( hp[index] <= 0 ) { - ShipData ship = db.Ships[db.Fleet[FleetIDFriend].Members[index]]; - if ( ship == null ) return; - - foreach ( int id in ship.SlotMaster ) { - - if ( id == 42 ) { //応急修理要員 - hp[index] = (int)( ship.HPMax * 0.2 ); - break; - } else if ( id == 43 ) { //応急修理女神 - hp[index] = ship.HPMax; - break; - } - } - } - }; - - Action DealDamageEnemy = ( int index, int damage ) => { - //if ( hp[index + 6] == -1 ) return; - hp[index + 6] -= Math.Max( damage, 0 ); - }; - - - for ( int i = 0; i < 12; i++ ) { - hp[i] = (int)RawData.api_nowhps[i + 1]; - } - - - //夜間砲撃戦 - { - dynamic hougeki = RawData.api_hougeki; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriend( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - return hp; } + public override string APIName { get { return "api_req_battle_midnight/battle"; } } - public override int FleetIDFriend { - get { return int.Parse( RawData.api_deck_id ); } - } - - public override BattleTypeFlag BattleType { get { return BattleTypeFlag.Night; } } diff --git a/ElectronicObserver/Data/Battle/BattlePracticeDay.cs b/ElectronicObserver/Data/Battle/BattlePracticeDay.cs index 3c1d10079..9a3abd05a 100644 --- a/ElectronicObserver/Data/Battle/BattlePracticeDay.cs +++ b/ElectronicObserver/Data/Battle/BattlePracticeDay.cs @@ -1,4 +1,5 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,118 +7,28 @@ namespace ElectronicObserver.Data.Battle { - public class BattlePracticeDay : BattleData { + /// + /// 演習昼戦 + /// + public class BattlePracticeDay : BattleDay { - public override int[] EmulateBattle() { + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); + AirBattle = new PhaseAirBattle( this ); + OpeningTorpedo = new PhaseTorpedo( this, 0 ); + Shelling1 = new PhaseShelling( this, 1, "1", false ); + Shelling2 = new PhaseShelling( this, 2, "2", false ); + Shelling3 = new PhaseShelling( this, 3, "3", false ); + Torpedo = new PhaseTorpedo( this, 4 ); - int[] hp = new int[12]; - KCDatabase db = KCDatabase.Instance; - Action DealDamageFriend = ( int index, int damage ) => { - //if ( hp[index] == -1 ) return; - hp[index] -= Math.Max( damage, 0 ); - - //ダメコンは発動しない。 - }; - - Action DealDamageEnemy = ( int index, int damage ) => { - //if ( hp[index + 6] == -1 ) return; - hp[index + 6] -= Math.Max( damage, 0 ); - }; - - - for ( int i = 0; i < 12; i++ ) { - hp[i] = (int)RawData.api_nowhps[i + 1]; - } - - - //航空戦 - if ( (int)RawData.api_stage_flag[2] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_kouku.api_stage3.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_kouku.api_stage3.api_edam[i + 1] ); - } - } - - - //支援艦隊は発動しない。 - - - //開幕雷撃 - if ( (int)RawData.api_opening_flag != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_opening_atack.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_opening_atack.api_edam[i + 1] ); - } - } - - - //砲撃戦(1巡目) - if ( (int)RawData.api_hourai_flag[0] != 0 ) { - dynamic hougeki = RawData.api_hougeki1; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriend( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - //砲撃戦(2巡目) - if ( (int)RawData.api_hourai_flag[1] != 0 ) { - dynamic hougeki = RawData.api_hougeki2; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriend( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - - //雷撃戦 - if ( (int)RawData.api_hourai_flag[3] != 0 ) { - for ( int i = 0; i < 6; i++ ) { - DealDamageFriend( i, (int)RawData.api_raigeki.api_fdam[i + 1] ); - DealDamageEnemy( i, (int)RawData.api_raigeki.api_edam[i + 1] ); - } - } - - - return hp; + AirBattle.EmulateBattle( _resultHPs, _attackDamages ); + OpeningTorpedo.EmulateBattle( _resultHPs, _attackDamages ); + Shelling1.EmulateBattle( _resultHPs, _attackDamages ); + Shelling2.EmulateBattle( _resultHPs, _attackDamages ); + Shelling3.EmulateBattle( _resultHPs, _attackDamages ); + Torpedo.EmulateBattle( _resultHPs, _attackDamages ); } @@ -126,11 +37,6 @@ public override string APIName { get { return "api_req_practice/battle"; } } - public override int FleetIDFriend { - get { return (int)RawData.api_dock_id; } - } - - public override BattleTypeFlag BattleType { get { return BattleTypeFlag.Day | BattleTypeFlag.Practice; } } diff --git a/ElectronicObserver/Data/Battle/BattlePracticeNight.cs b/ElectronicObserver/Data/Battle/BattlePracticeNight.cs index 9efed661a..06338e089 100644 --- a/ElectronicObserver/Data/Battle/BattlePracticeNight.cs +++ b/ElectronicObserver/Data/Battle/BattlePracticeNight.cs @@ -1,80 +1,33 @@ -using System; +using ElectronicObserver.Data.Battle.Phase; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ElectronicObserver.Data.Battle { - - public class BattlePracticeNight : BattleData { - public override int[] EmulateBattle() { + /// + /// 演習夜戦 + /// + public class BattlePracticeNight : BattleNight { + public override void LoadFromResponse( string apiname, dynamic data ) { + base.LoadFromResponse( apiname, (object)data ); - int[] hp = new int[12]; + NightBattle = new PhaseNightBattle( this, false ); - KCDatabase db = KCDatabase.Instance; - Action DealDamageFriend = ( int index, int damage ) => { - //if ( hp[index] == -1 ) return; - hp[index] -= Math.Max( damage, 0 ); - - //ダメコンは発動しない。 - }; - - Action DealDamageEnemy = ( int index, int damage ) => { - //if ( hp[index + 6] == -1 ) return; - hp[index + 6] -= Math.Max( damage, 0 ); - }; - - - for ( int i = 0; i < 12; i++ ) { - hp[i] = (int)RawData.api_nowhps[i + 1]; - } - - - //夜間砲撃戦 - { - dynamic hougeki = RawData.api_hougeki; - - int[] damageList = new int[12]; - int leni = ( (int[])hougeki.api_at_list ).Length; - - for ( int i = 1; i < leni; i++ ) { - - for ( int j = 0; j < damageList.Length; j++ ) { - damageList[j] = 0; - } - - int lenj = ( (int[])hougeki.api_df_list[i] ).Length; - for ( int j = 0; j < lenj; j++ ) { - int target = (int)hougeki.api_df_list[i][j]; - if ( target != -1 ) - damageList[target - 1] += (int)hougeki.api_damage[i][j]; - } - - for ( int j = 0; j < 6; j++ ) { - DealDamageFriend( j, damageList[j] ); - DealDamageEnemy( j, damageList[j + 6] ); - } - } - } - - return hp; + NightBattle.EmulateBattle( _resultHPs, _attackDamages ); } + public override string APIName { get { return "api_req_practice/midnight_battle"; } } - - public override int FleetIDFriend { - get { return (int)RawData.api_deck_id; } - } - - public override BattleTypeFlag BattleType { get { return BattleTypeFlag.Night | BattleTypeFlag.Practice; } - } + } } } diff --git a/ElectronicObserver/Data/Battle/BattleResultData.cs b/ElectronicObserver/Data/Battle/BattleResultData.cs index c206a0625..bfa3c780e 100644 --- a/ElectronicObserver/Data/Battle/BattleResultData.cs +++ b/ElectronicObserver/Data/Battle/BattleResultData.cs @@ -6,6 +6,9 @@ namespace ElectronicObserver.Data.Battle { + /// + /// 戦闘結果のデータを扱います。 + /// public class BattleResultData : ResponseWrapper { /// diff --git a/ElectronicObserver/Data/Battle/Phase/PhaseAirBattle.cs b/ElectronicObserver/Data/Battle/Phase/PhaseAirBattle.cs new file mode 100644 index 000000000..7be854765 --- /dev/null +++ b/ElectronicObserver/Data/Battle/Phase/PhaseAirBattle.cs @@ -0,0 +1,236 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserver.Data.Battle.Phase { + + /// + /// 航空戦フェーズの処理を行います。 + /// + public class PhaseAirBattle : PhaseBase { + + /// + /// API データの接尾辞(第二次航空戦用) + /// + protected readonly string suffix; + + + public PhaseAirBattle( BattleData data, string suffix = "" ) + : base( data ) { + + this.suffix = suffix; + } + + + public override bool IsAvailable { + get { + int[] stageFlag = StageFlag; + return StageFlag != null && !stageFlag.All( i => i == 0 ); + } + } + + public override void EmulateBattle( int[] hps, int[] damages ) { + + if ( !IsAvailable || !IsStage3Available ) return; + + { + int[] dmg = Damages; + + for ( int i = 0; i < hps.Length; i++ ) { + AddDamage( hps, i, dmg[i] ); + } + } + + CalculateAttackDamage( damages ); + + } + + /// + /// 航空戦での与ダメージを推測します。 + /// + /// 与ダメージリスト。 + private void CalculateAttackDamage( int[] damages ) { + // 敵はめんどくさすぎるので省略 + // 仮想火力を求め、それに従って合計ダメージを分配 + + var firepower = new int[6]; + var members = _battleData.Initial.FriendFleet.MembersWithoutEscaped; + + for ( int i = 0; i < members.Count; i++ ) { + var ship = members[i]; + if ( ship == null ) continue; + + var slots = ship.SlotInstanceMaster; + var aircrafts = ship.Aircraft; + for ( int s = 0; s < slots.Count; s++ ) { + + if ( slots[s] == null ) continue; + + switch ( slots[s].CategoryType ) { + case 7: //艦上爆撃機 + case 11: //水上爆撃機 + firepower[i] += (int)( 1.0 * ( slots[s].Bomber * Math.Sqrt( aircrafts[s] ) + 25 ) ); + break; + + case 8: //艦上攻撃機 (80%と150%はランダムのため係数は平均値) + firepower[i] += (int)( 1.15 * ( slots[s].Torpedo * Math.Sqrt( aircrafts[s] ) + 25 ) ); + break; + } + + } + + } + + int totalFirepower = firepower.Sum(); + int totalDamage = Damages.Sum(); + + for ( int i = 0; i < 6; i++ ) { + damages[i] += (int)( (double)totalDamage * firepower[i] / Math.Max( totalFirepower, 1 ) ); + } + } + + + /// + /// 各Stageが存在するか + /// + public int[] StageFlag { + get { + return RawData.IsDefined( "api_stage_flag" + suffix ) ? (int[])RawData["api_stage_flag" + suffix] : null; + } + } + + /// + /// 航空戦の生データ + /// + public dynamic AirBattleData { get { return RawData["api_kouku" + suffix]; } } + + + //stage 1 + + /// + /// Stage1(空対空戦闘)が存在するか + /// + public bool IsStage1Available { get { return StageFlag != null && StageFlag[0] != 0; } } + + + /// + /// 自軍Stage1参加機数 + /// + public int AircraftTotalStage1Friend { get { return (int)AirBattleData.api_stage1.api_f_count; } } + + /// + /// 敵軍Stage1参加機数 + /// + public int AircraftTotalStage1Enemy { get { return (int)AirBattleData.api_stage1.api_e_count; } } + + /// + /// 自軍Stage1撃墜機数 + /// + public int AircraftLostStage1Friend { get { return (int)AirBattleData.api_stage1.api_f_lostcount; } } + + /// + /// 敵軍Stage1撃墜機数 + /// + public int AircraftLostStage1Enemy { get { return (int)AirBattleData.api_stage1.api_e_lostcount; } } + + /// + /// 制空権 + /// + public int AirSuperiority { get { return (int)AirBattleData.api_stage1.api_disp_seiku; } } + + /// + /// 自軍触接機ID + /// + public int TouchAircraftFriend { get { return (int)AirBattleData.api_stage1.api_touch_plane[0]; } } + + /// + /// 敵軍触接機ID + /// + public int TouchAircraftEnemy { get { return (int)AirBattleData.api_stage1.api_touch_plane[1]; } } + + + //stage 2 + + /// + /// Stage2(艦対空戦闘)が存在するか + /// + public bool IsStage2Available { get { return StageFlag != null && StageFlag[1] != 0; } } + + /// + /// 自軍Stage2参加機数 + /// + public int AircraftTotalStage2Friend { get { return (int)AirBattleData.api_stage2.api_f_count; } } + + /// + /// 敵軍Stage2参加機数 + /// + public int AircraftTotalStage2Enemy { get { return (int)AirBattleData.api_stage2.api_e_count; } } + + /// + /// 自軍Stage2撃墜機数 + /// + public int AircraftLostStage2Friend { get { return (int)AirBattleData.api_stage2.api_f_lostcount; } } + + /// + /// 敵軍Stage2撃墜機数 + /// + public int AircraftLostStage2Enemy { get { return (int)AirBattleData.api_stage2.api_e_lostcount; } } + + + /// + /// 対空カットインが発動したか + /// + public bool IsAACutinAvailable { get { return AirBattleData.api_stage2.api_air_fire(); } } + + /// + /// 対空カットイン発動艦番号 + /// + public int AACutInIndex { get { return (int)AirBattleData.api_stage2.api_air_fire.api_idx; } } + + /// + /// 対空カットイン発動艦 + /// + public ShipData AACutInShip { + get { + int index = AACutInIndex; + return index < 6 ? + _battleData.Initial.FriendFleet.MembersInstance[index] : + KCDatabase.Instance.Fleet[2].MembersInstance[index - 6]; + } + } + + /// + /// 対空カットイン種別 + /// + public int AACutInKind { get { return (int)AirBattleData.api_stage2.api_air_fire.api_kind; } } + + + //stage 3 + + /// + /// Stage3(航空攻撃)が存在するか + /// + public bool IsStage3Available { get { return StageFlag != null && StageFlag[2] != 0; } } + + /// + /// 各艦の被ダメージ + /// + public int[] Damages { + get { + if ( AirBattleData.api_stage3_combined() ) { + return ( (int[])AirBattleData.api_stage3.api_fdam ).Skip( 1 ) + .Concat( ( (int[])AirBattleData.api_stage3.api_edam ).Skip( 1 ) ) + .Concat( ( (int[])AirBattleData.api_stage3_combined.api_fdam ).Skip( 1 ) ) + .ToArray(); + } else { + return ( (int[])AirBattleData.api_stage3.api_fdam ).Skip( 1 ) + .Concat( ( (int[])AirBattleData.api_stage3.api_edam ).Skip( 1 ) ) + .ToArray(); + } + } + } + + } +} diff --git a/ElectronicObserver/Data/Battle/Phase/PhaseBase.cs b/ElectronicObserver/Data/Battle/Phase/PhaseBase.cs new file mode 100644 index 000000000..c8f7cbb76 --- /dev/null +++ b/ElectronicObserver/Data/Battle/Phase/PhaseBase.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserver.Data.Battle.Phase { + + /// + /// 戦闘フェーズの基底クラスです。 + /// + public abstract class PhaseBase { + + protected BattleData _battleData; + + public PhaseBase( BattleData data ) { + + _battleData = data; + + } + + + protected dynamic RawData { get { return _battleData.RawData; } } + + protected int[] ArraySkip( int[] array, int skipCount = 1 ) { + return array.Skip( skipCount ).ToArray(); + } + + protected bool IsPractice { get { return ( _battleData.BattleType & BattleData.BattleTypeFlag.Practice ) != 0; } } + protected bool IsCombined { get { return ( _battleData.BattleType & BattleData.BattleTypeFlag.Combined ) != 0; } } + + + /// + /// 被ダメージ処理を行います。 + /// + /// 各艦のHPリスト。 + /// ダメージを受ける艦のインデックス。 + /// ダメージ。 + protected void AddDamage( int[] hps, int index, int damage ) { + + hps[index] -= Math.Max( damage, 0 ); + + //自軍艦の撃沈が発生した場合(ダメコン処理) + if ( hps[index] <= 0 && !( 6 <= index && index < 12 ) && !IsPractice ) { + ShipData ship = KCDatabase.Instance.Fleet[index < 6 ? _battleData.Initial.FriendFleetID : 2].MembersInstance[index % 6]; + if ( ship == null ) return; + + foreach ( var eid in ship.SlotMaster ) { + if ( eid == 42 ) { //応急修理要員 + hps[index] = (int)( ship.HPMax * 0.2 ); + break; + } else if ( eid == 43 ) { //応急修理女神 + hps[index] = ship.HPMax; + break; + } + } + } + } + + + /// + /// データが有効かどうかを示します。 + /// + public abstract bool IsAvailable { get; } + + /// + /// 戦闘をエミュレートします。 + /// + /// 各艦のHPリスト。 + /// 各艦の与ダメージリスト。 + public abstract void EmulateBattle( int[] hps, int[] damages ); + + + } +} diff --git a/ElectronicObserver/Data/Battle/Phase/PhaseInitial.cs b/ElectronicObserver/Data/Battle/Phase/PhaseInitial.cs new file mode 100644 index 000000000..b6faa2d28 --- /dev/null +++ b/ElectronicObserver/Data/Battle/Phase/PhaseInitial.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserver.Data.Battle.Phase { + + /// + /// 戦闘開始フェーズの処理を行います。 + /// + public class PhaseInitial : PhaseBase { + + + public PhaseInitial( BattleData data ) + : base( data ) { } + + + public override bool IsAvailable { + get { return RawData != null; } + } + + public override void EmulateBattle( int[] hps, int[] damages ) { + throw new NotSupportedException(); + } + + /// + /// 自軍艦隊ID + /// + public int FriendFleetID { + get { + dynamic id = RawData.api_dock_id() ? RawData.api_dock_id : RawData.api_deck_id; + return id is string ? int.Parse( (string)id ) : (int)id; + } + } + + /// + /// 自軍艦隊 + /// + public FleetData FriendFleet { get { return KCDatabase.Instance.Fleet[FriendFleetID]; } } + + + /// + /// 敵艦隊メンバ + /// + public int[] EnemyMembers { + get { return ArraySkip( (int[])RawData.api_ship_ke ); } + } + + /// + /// 敵艦隊メンバ + /// + public ShipDataMaster[] EnemyMembersInstance { + get { + return ( (int[])RawData.api_ship_ke ).Skip( 1 ).Select( id => KCDatabase.Instance.MasterShips[id] ).ToArray(); + } + } + + /// + /// 敵艦のレベル + /// + public int[] EnemyLevels { + get { return ArraySkip( (int[])RawData.api_ship_lv ); } + } + + /// + /// 戦闘開始時のHPリスト + /// [0-5]=自軍, [6-11]=敵軍, [12-17]=(連合艦隊時)随伴 + /// + public int[] InitialHPs { + get { + if ( RawData.api_nowhps_combined() ) + return ( (int[])RawData.api_nowhps ).Skip( 1 ).Concat( ( (int[])RawData.api_nowhps_combined ).Skip( 1 ) ).ToArray(); + else + return ArraySkip( (int[])RawData.api_nowhps ); + } + } + + /// + /// 最大HPリスト + /// [0-5]=自軍, [6-11]=敵軍, [12-17]=(連合艦隊時)随伴 + /// + public int[] MaxHPs { + get { + if ( RawData.api_maxhps_combined() ) + return ( (int[])RawData.api_maxhps ).Skip( 1 ).Concat( ( (int[])RawData.api_maxhps_combined ).Skip( 1 ) ).ToArray(); + else + return ArraySkip( (int[])RawData.api_maxhps ); + } + } + + /// + /// 敵艦のスロット + /// + public int[][] EnemySlots { + get { + return ( (dynamic[])RawData.api_eSlot ).Select( d => (int[])d ).ToArray(); + } + } + + /// + /// 敵艦のスロット + /// + public EquipmentDataMaster[][] EnemySlotsInstance { + get { + return ( (dynamic[])RawData.api_eSlot ).Select( d => ( (int[])d ).Select( id => KCDatabase.Instance.MasterEquipments[id] ).ToArray() ).ToArray(); + } + } + + /// + /// 敵艦のパラメータ + /// + public int[][] EnemyParameters { + get { + return ( (dynamic[])RawData.api_eParam ).Select( d => (int[])d ).ToArray(); + } + } + + } +} diff --git a/ElectronicObserver/Data/Battle/Phase/PhaseNightBattle.cs b/ElectronicObserver/Data/Battle/Phase/PhaseNightBattle.cs new file mode 100644 index 000000000..c365c633b --- /dev/null +++ b/ElectronicObserver/Data/Battle/Phase/PhaseNightBattle.cs @@ -0,0 +1,157 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserver.Data.Battle.Phase { + + /// + /// 夜戦フェーズの処理を行います。 + /// + public class PhaseNightBattle : PhaseBase { + + private readonly bool isEscort; + + public PhaseNightBattle( BattleData data, bool isEscort ) + : base( data ) { + + this.isEscort = isEscort; + } + + public override bool IsAvailable { + get { return true; } + } + + public dynamic ShellingData { get { return RawData.api_hougeki; } } + + public override void EmulateBattle( int[] hps, int[] damages ) { + + if ( !IsAvailable ) return; + + int[] attackers = (int[])ShellingData.api_at_list; + + for ( int i = 1; i < attackers.Length; i++ ) { //skip header(-1) + + int[] tempDamages = Enumerable.Repeat( 0, hps.Length ).ToArray(); + + int[] defenders = (int[])( ShellingData.api_df_list[i] ); + int[] unitDamages = (int[])( ShellingData.api_damage[i] ); + + for ( int j = 0; j < defenders.Length; j++ ) { + if ( defenders[j] != -1 ) + tempDamages[GetIndex( defenders[j] )] += Math.Max( unitDamages[j], 0 ); + } + + for ( int j = 0; j < tempDamages.Length; j++ ) + AddDamage( hps, j, tempDamages[j] ); + + damages[GetIndex( attackers[i] )] += tempDamages.Sum(); + } + + } + + + /// + /// 自軍艦隊 + /// + public FleetData FriendFleet { get { return KCDatabase.Instance.Fleet[isEscort ? 2 : _battleData.Initial.FriendFleetID]; } } + + + /// + /// 自軍触接機ID + /// + public int TouchAircraftFriend { get { return (int)RawData.api_touch_plane[0]; } } + + /// + /// 敵軍触接機ID + /// + public int TouchAircraftEnemy { get { return (int)RawData.api_touch_plane[1]; } } + + /// + /// 自軍照明弾投射艦番号 + /// + public int FlareIndexFriend { + get { + int index = (int)RawData.api_flare_pos[0]; + return index != -1 ? index - 1 : -1; + } + } + + /// + /// 敵軍照明弾投射艦番号(0-5, -1=発動せず) + /// + public int FlareIndexEnemy { + get { + int index = (int)RawData.api_flare_pos[1]; + return index != -1 ? index - 1 : -1; + } + } + + /// + /// 敵軍照明弾投射艦 + /// + public ShipDataMaster FlareEnemyInstance { + get { + int index = FlareIndexEnemy; + return index == -1 ? null : _battleData.Initial.EnemyMembersInstance[index]; + } + } + + /// + /// 自軍探照灯照射艦番号 + /// + public int SearchlightIndexFriend { + get { + var ships = KCDatabase.Instance.Fleet[isEscort ? 2 : _battleData.Initial.FriendFleetID].MembersWithoutEscaped; + for ( int i = 0; i < ships.Count; i++ ) { + + var ship = ships[i]; + if ( ship != null && + ship.SlotInstanceMaster.Count( e => e != null && e.CategoryType == 29 ) > 0 && + _battleData.Initial.InitialHPs[( isEscort ? 12 : 0 ) + i] > 1 ) { + + return i; + } + } + + return -1; + } + } + + /// + /// 敵軍探照灯照射艦番号(0-5) + /// + public int SearchlightIndexEnemy { + get { + var ships = _battleData.Initial.EnemyMembersInstance; + var eqs = _battleData.Initial.EnemySlotsInstance; + for ( int i = 0; i < ships.Length; i++ ) { + + if ( ships[i] != null && + eqs[i].Count( e => e != null && e.CategoryType == 29 ) > 0 && + _battleData.Initial.InitialHPs[6 + i] > 1 ) { + + return i; + } + } + + return -1; + } + } + + public ShipDataMaster SearchlightEnemyInstance { + get { + int index = SearchlightIndexEnemy; + return index == -1 ? null : _battleData.Initial.EnemyMembersInstance[index]; + } + } + + + private int GetIndex( int index ) { + if ( isEscort && index <= 6 ) + return 12 + index - 1; + return index - 1; + } + } +} diff --git a/ElectronicObserver/Data/Battle/Phase/PhaseSearching.cs b/ElectronicObserver/Data/Battle/Phase/PhaseSearching.cs new file mode 100644 index 000000000..41293d3c8 --- /dev/null +++ b/ElectronicObserver/Data/Battle/Phase/PhaseSearching.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserver.Data.Battle.Phase { + + /// + /// 索敵フェーズの処理を行います。 + /// + public class PhaseSearching : PhaseBase { + + + public PhaseSearching( BattleData data ) + : base( data ) { } + + + public override bool IsAvailable { + get { return RawData.api_search() && RawData.api_formation(); } + } + + public override void EmulateBattle( int[] hps, int[] damages ) { + throw new NotSupportedException(); + } + + + /// + /// 自軍索敵結果 + /// + public int SearchingFriend { + get { + if ( RawData.api_search() ) + return (int)RawData.api_search[0]; + else return -1; + } + } + + /// + /// 敵軍索敵結果 + /// + public int SearchingEnemy { + get { + if ( RawData.api_search() ) + return (int)RawData.api_search[1]; + else return -1; + } + } + + /// + /// 自軍陣形 + /// + public int FormationFriend { + get { + dynamic form = RawData.api_formation[0]; + return form is string ? int.Parse( (string)form ) : (int)form; + } + } + + /// + /// 敵軍陣形 + /// + public int FormationEnemy { get { return (int)RawData.api_formation[1]; } } + + /// + /// 交戦形態 + /// + public int EngagementForm { get { return (int)RawData.api_formation[2]; } } + + } +} diff --git a/ElectronicObserver/Data/Battle/Phase/PhaseShelling.cs b/ElectronicObserver/Data/Battle/Phase/PhaseShelling.cs new file mode 100644 index 000000000..1bf176f97 --- /dev/null +++ b/ElectronicObserver/Data/Battle/Phase/PhaseShelling.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserver.Data.Battle.Phase { + + /// + /// 砲撃戦フェーズの処理を行います。 + /// + public class PhaseShelling : PhaseBase { + + private readonly int phaseID; + private readonly string suffix; + private readonly bool isEscort; + + public PhaseShelling( BattleData data, int phaseID, string suffix, bool isEscort ) + : base( data ) { + + this.phaseID = phaseID; + this.suffix = suffix; + this.isEscort = isEscort; + } + + + public override bool IsAvailable { + get { return (int)RawData.api_hourai_flag[phaseID - 1] != 0; } + } + + + public dynamic ShellingData { + get { return RawData["api_hougeki" + suffix]; } + } + + + public override void EmulateBattle( int[] hps, int[] damages ) { + + if ( !IsAvailable ) return; + + int[] attackers = (int[])ShellingData.api_at_list; + + for ( int i = 1; i < attackers.Length; i++ ) { //skip header(-1) + + int[] tempDamages = Enumerable.Repeat( 0, hps.Length ).ToArray(); + + int[] defenders = (int[])( ShellingData.api_df_list[i] ); + int[] unitDamages = (int[])( ShellingData.api_damage[i] ); + + for ( int j = 0; j < defenders.Length; j++ ) { + if ( defenders[j] != -1 ) + tempDamages[GetIndex( defenders[j] )] += Math.Max( unitDamages[j], 0 ); + } + + for ( int j = 0; j < tempDamages.Length; j++ ) + AddDamage( hps, j, tempDamages[j] ); + + damages[GetIndex( attackers[i] )] += tempDamages.Sum(); + } + + } + + private int GetIndex( int index ) { + if ( isEscort && index <= 6 ) + return 12 + index - 1; + return index - 1; + } + } +} diff --git a/ElectronicObserver/Data/Battle/Phase/PhaseSupport.cs b/ElectronicObserver/Data/Battle/Phase/PhaseSupport.cs new file mode 100644 index 000000000..e6054d1ca --- /dev/null +++ b/ElectronicObserver/Data/Battle/Phase/PhaseSupport.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserver.Data.Battle.Phase { + + /// + /// 支援攻撃フェーズの処理を行います。 + /// + public class PhaseSupport : PhaseBase { + + + public PhaseSupport( BattleData data ) + : base( data ) { } + + + public override bool IsAvailable { + get { return SupportFlag != 0; } + } + + public override void EmulateBattle( int[] hps, int[] damages ) { + + if ( !IsAvailable ) return; + + if ( SupportFlag == 1 ) { + //空撃 + int[] dmg = AirRaidDamages; + + for ( int i =0; i < 6; i++ ) { + AddDamage( hps, i + 6, dmg[i] ); + } + + } else if ( SupportFlag == 2 || SupportFlag == 3 ) { + //砲雷撃 + int[] dmg = ShellingTorpedoDamages; + + for ( int i =0; i < 6; i++ ) { + AddDamage( hps, i + 6, dmg[i] ); + } + } + + } + + + /// + /// 支援艦隊フラグ + /// + public int SupportFlag { get { return RawData.api_support_flag() ? (int)RawData.api_support_flag : 0; } } + + /// + /// 支援艦隊ID + /// + public int SupportFleetID { + get { + if ( SupportFlag == 1 ) + return (int)RawData.api_support_info.api_support_airatack.api_deck_id; + else if ( SupportFlag == 2 || SupportFlag == 3 ) + return (int)RawData.api_support_info.api_support_hourai.api_deck_id; + else + return -1; + } + } + + /// + /// 支援艦隊 + /// + public FleetData SupportFleet { + get { + int id = SupportFleetID; + if ( id != -1 ) + return KCDatabase.Instance.Fleet[id]; + else + return null; + } + } + + + /// + /// 航空支援ダメージ + /// + public int[] AirRaidDamages { + get { + if ( SupportFlag == 1 && (int)RawData.api_support_info.api_stage_flag[2] != 0 ) { + + return ( (int[])RawData.api_support_info.api_support_airatack.api_stage3.api_edam ).Skip( 1 ).ToArray(); + + } else { + return Enumerable.Repeat( 0, 6 ).ToArray(); + } + } + } + + /// + /// 砲雷撃支援ダメージ + /// + public int[] ShellingTorpedoDamages { + get { + if ( ( SupportFlag == 2 || SupportFlag == 3 ) ) { + + return ( (int[])RawData.api_support_info.api_support_hourai.api_damage ).Skip( 1 ).ToArray(); + + } else { + return Enumerable.Repeat( 0, 6 ).ToArray(); + } + } + } + + } +} diff --git a/ElectronicObserver/Data/Battle/Phase/PhaseTorpedo.cs b/ElectronicObserver/Data/Battle/Phase/PhaseTorpedo.cs new file mode 100644 index 000000000..23e5bf872 --- /dev/null +++ b/ElectronicObserver/Data/Battle/Phase/PhaseTorpedo.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserver.Data.Battle.Phase { + + /// + /// 雷撃戦フェーズの処理を行います。 + /// + public class PhaseTorpedo : PhaseBase { + + /// + /// フェーズID 0=開幕雷撃, 1-4=雷撃戦 + /// + private readonly int phaseID; + + public PhaseTorpedo( BattleData data, int phaseID ) + : base( data ) { + + this.phaseID = phaseID; + } + + public override bool IsAvailable { + get { + + if ( phaseID == 0 ) { + return RawData.api_opening_flag() ? (int)RawData.api_opening_flag != 0 : false; + + } else { + return (int)RawData.api_hourai_flag[phaseID - 1] != 0; + } + } + } + + public override void EmulateBattle( int[] hps, int[] damages ) { + + if ( !IsAvailable ) return; + { + int[] dmg = Damages; + for ( int i = 0; i < hps.Length; i++ ) { + AddDamage( hps, i, dmg[i] ); + } + } + { + int[] dmg = AttackDamages; + for ( int i = 0; i < damages.Length; i++ ) { + damages[i] += dmg[i]; + } + } + } + + + public dynamic TorpedoData { + get { return phaseID == 0 ? RawData.api_opening_atack : RawData.api_raigeki; } + } + + /// + /// 各艦の被ダメージ + /// + public int[] Damages { + get { + if ( IsCombined ) { + return Enumerable.Repeat( 0, 6 ) + .Concat( ( (int[])TorpedoData.api_edam ).Skip( 1 ) ) + .Concat( ( (int[])TorpedoData.api_fdam ).Skip( 1 ) ).ToArray(); + } else { + return ( (int[])TorpedoData.api_fdam ).Skip( 1 ) + .Concat( ( (int[])TorpedoData.api_edam ).Skip( 1 ) ).ToArray(); + } + } + } + + /// + /// 各艦の与ダメージ + /// + public int[] AttackDamages { + get { + if ( IsCombined ) { + return Enumerable.Repeat( 0, 6 ) + .Concat( ( (int[])TorpedoData.api_eydam ).Skip( 1 ) ) + .Concat( ( (int[])TorpedoData.api_fydam ).Skip( 1 ) ).ToArray(); + } else { + return ( (int[])TorpedoData.api_fydam ).Skip( 1 ) + .Concat( ( (int[])TorpedoData.api_eydam ).Skip( 1 ) ).ToArray(); + } + } + } + } +} diff --git a/ElectronicObserver/Data/FleetManager.cs b/ElectronicObserver/Data/FleetManager.cs index e0ef7a53a..c61a5c305 100644 --- a/ElectronicObserver/Data/FleetManager.cs +++ b/ElectronicObserver/Data/FleetManager.cs @@ -44,6 +44,12 @@ public override void LoadFromResponse( string apiname, dynamic data ) { } break; + case "api_get_member/ndock": + foreach ( var fleet in Fleets.Values ) { + fleet.LoadFromResponse( apiname, data ); + } + break; + default: base.LoadFromResponse( apiname, (object)data ); diff --git a/ElectronicObserver/Data/Quest/QuestProgressManager.cs b/ElectronicObserver/Data/Quest/QuestProgressManager.cs index 02979735a..6fcb319d8 100644 --- a/ElectronicObserver/Data/Quest/QuestProgressManager.cs +++ b/ElectronicObserver/Data/Quest/QuestProgressManager.cs @@ -3,6 +3,7 @@ using ElectronicObserver.Utility.Storage; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Runtime.Serialization; using System.Text; @@ -62,7 +63,7 @@ public override void Initialize() { RemoveEvents(); //二重登録防止 - + var ao = APIObserver.Instance; ao.APIList["api_get_member/questlist"].ResponseReceived += QuestUpdated; @@ -302,7 +303,7 @@ void QuestUpdated( string apiname, dynamic data ) { void BattleFinished( string apiname, dynamic data ) { var bm = KCDatabase.Instance.Battle; - int[] hps = null; + ReadOnlyCollection hps = null; #region Slaughter @@ -311,13 +312,13 @@ void BattleFinished( string apiname, dynamic data ) { switch ( bm.BattleMode & Battle.BattleManager.BattleModes.BattlePhaseMask ) { case Battle.BattleManager.BattleModes.Normal: case Battle.BattleManager.BattleModes.AirBattle: - if ( bm.BattleNight != null ) hps = bm.BattleNight.EmulateBattle(); - else hps = bm.BattleDay.EmulateBattle(); + if ( bm.BattleNight != null ) hps = bm.BattleNight.ResultHPs; + else hps = bm.BattleDay.ResultHPs; break; case Battle.BattleManager.BattleModes.NightOnly: case Battle.BattleManager.BattleModes.NightDay: - if ( bm.BattleDay != null ) hps = bm.BattleDay.EmulateBattle(); - else hps = bm.BattleNight.EmulateBattle(); + if ( bm.BattleDay != null ) hps = bm.BattleDay.ResultHPs; + else hps = bm.BattleNight.ResultHPs; break; } @@ -329,7 +330,7 @@ void BattleFinished( string apiname, dynamic data ) { if ( hps[i + 6] <= 0 ) { - var ship = KCDatabase.Instance.MasterShips[bm.BattleDay != null ? bm.BattleDay.EnemyFleetMembers[i + 1] : bm.BattleNight.EnemyFleetMembers[i + 1]]; + var ship = bm.BattleDay != null ? bm.BattleDay.Initial.EnemyMembersInstance[i] : bm.BattleNight.Initial.EnemyMembersInstance[i]; if ( ship == null ) continue; foreach ( var p in slaughterList ) diff --git a/ElectronicObserver/Data/ResponseWrapper.cs b/ElectronicObserver/Data/ResponseWrapper.cs index 8378c7999..2031f7081 100644 --- a/ElectronicObserver/Data/ResponseWrapper.cs +++ b/ElectronicObserver/Data/ResponseWrapper.cs @@ -15,7 +15,7 @@ public abstract class ResponseWrapper { /// /// 生の受信データ(api_data) /// - protected dynamic RawData { get; private set; } + public dynamic RawData { get; private set; } /// /// Responseを読み込みます。 diff --git a/ElectronicObserver/ElectronicObserver.csproj b/ElectronicObserver/ElectronicObserver.csproj index 6b9272695..87f29c4d9 100644 --- a/ElectronicObserver/ElectronicObserver.csproj +++ b/ElectronicObserver/ElectronicObserver.csproj @@ -92,14 +92,23 @@ - + + + + + + + + + + @@ -148,6 +157,7 @@ + @@ -306,6 +316,12 @@ + + Form + + + DialogLocalAPILoader2.cs + Form @@ -497,6 +513,9 @@ DialogLocalAPILoader.cs + + DialogLocalAPILoader2.cs + DialogNotifier.cs diff --git a/ElectronicObserver/Notifier/NotifierDamage.cs b/ElectronicObserver/Notifier/NotifierDamage.cs index 14e0051aa..6e3621642 100644 --- a/ElectronicObserver/Notifier/NotifierDamage.cs +++ b/ElectronicObserver/Notifier/NotifierDamage.cs @@ -162,18 +162,18 @@ private void CheckBattle() { case BattleManager.BattleModes.Normal: case BattleManager.BattleModes.AirBattle: if ( bm.BattleNight != null ) { - list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[bm.BattleNight.FleetIDFriend], bm.BattleNight.EmulateBattle() ) ); + list.AddRange( GetDamagedShips( bm.BattleNight.Initial.FriendFleet, bm.BattleNight.ResultHPs.ToArray() ) ); } else { - list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[bm.BattleDay.FleetIDFriend], bm.BattleDay.EmulateBattle() ) ); + list.AddRange( GetDamagedShips( bm.BattleDay.Initial.FriendFleet, bm.BattleDay.ResultHPs.ToArray() ) ); } break; case BattleManager.BattleModes.NightDay: case BattleManager.BattleModes.NightOnly: if ( bm.BattleDay != null ) { - list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[bm.BattleDay.FleetIDFriend], bm.BattleDay.EmulateBattle() ) ); + list.AddRange( GetDamagedShips( bm.BattleDay.Initial.FriendFleet, bm.BattleDay.ResultHPs.ToArray() ) ); } else { - list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[bm.BattleNight.FleetIDFriend], bm.BattleNight.EmulateBattle() ) ); + list.AddRange( GetDamagedShips( bm.BattleNight.Initial.FriendFleet, bm.BattleNight.ResultHPs.ToArray() ) ); } break; } @@ -183,18 +183,18 @@ private void CheckBattle() { case BattleManager.BattleModes.Normal: case BattleManager.BattleModes.AirBattle: if ( bm.BattleNight != null ) { - list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[2], bm.BattleNight.EmulateBattle().Skip( 12 ).ToArray() ) ); + list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[2], bm.BattleNight.ResultHPs.Skip( 12 ).ToArray() ) ); } else { - list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[2], bm.BattleDay.EmulateBattle().Skip( 12 ).ToArray() ) ); + list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[2], bm.BattleDay.ResultHPs.Skip( 12 ).ToArray() ) ); } break; case BattleManager.BattleModes.NightDay: case BattleManager.BattleModes.NightOnly: if ( bm.BattleDay != null ) { - list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[2], bm.BattleDay.EmulateBattle().Skip( 12 ).ToArray() ) ); + list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[2], bm.BattleDay.ResultHPs.Skip( 12 ).ToArray() ) ); } else { - list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[2], bm.BattleNight.EmulateBattle().Skip( 12 ).ToArray() ) ); + list.AddRange( GetDamagedShips( KCDatabase.Instance.Fleet[2], bm.BattleNight.ResultHPs.Skip( 12 ).ToArray() ) ); } break; } diff --git a/ElectronicObserver/Observer/APIObserver.cs b/ElectronicObserver/Observer/APIObserver.cs index 4912f70da..6bc3edffa 100644 --- a/ElectronicObserver/Observer/APIObserver.cs +++ b/ElectronicObserver/Observer/APIObserver.cs @@ -87,6 +87,7 @@ private APIObserver() { APIList.Add( new kcsapi.api_req_ranking.getlist() ); APIList.Add( new kcsapi.api_req_sortie.airbattle() ); APIList.Add( new kcsapi.api_get_member.ship_deck() ); + APIList.Add( new kcsapi.api_req_kaisou.marriage() ); APIList.Add( new kcsapi.api_req_quest.clearitemget() ); APIList.Add( new kcsapi.api_req_nyukyo.start() ); diff --git a/ElectronicObserver/Observer/kcsapi/api_get_member/ship2.cs b/ElectronicObserver/Observer/kcsapi/api_get_member/ship2.cs index 771a99e62..b6b1dd569 100644 --- a/ElectronicObserver/Observer/kcsapi/api_get_member/ship2.cs +++ b/ElectronicObserver/Observer/kcsapi/api_get_member/ship2.cs @@ -7,7 +7,7 @@ namespace ElectronicObserver.Observer.kcsapi.api_get_member { - [Obsolete( "このAPIは廃止された可能性があります。", false)] + //一応現役、ケッコンした時などに呼ばれる public class ship2 : APIBase { public override void OnResponseReceived( dynamic data ) { diff --git a/ElectronicObserver/Observer/kcsapi/api_get_member/slot_item.cs b/ElectronicObserver/Observer/kcsapi/api_get_member/slot_item.cs index 12dbe956e..07c897f29 100644 --- a/ElectronicObserver/Observer/kcsapi/api_get_member/slot_item.cs +++ b/ElectronicObserver/Observer/kcsapi/api_get_member/slot_item.cs @@ -24,7 +24,9 @@ public override void OnResponseReceived( dynamic data ) { db.Equipments.Add( eq ); } - + + db.Battle.LoadFromResponse( APIName, data ); + base.OnResponseReceived( (object)data ); } diff --git a/ElectronicObserver/Observer/kcsapi/api_port/port.cs b/ElectronicObserver/Observer/kcsapi/api_port/port.cs index a6dfaef51..3adaf98d4 100644 --- a/ElectronicObserver/Observer/kcsapi/api_port/port.cs +++ b/ElectronicObserver/Observer/kcsapi/api_port/port.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace ElectronicObserver.Observer.kcsapi.api_port { - + public class port : APIBase { @@ -29,9 +29,9 @@ public override void OnResponseReceived( dynamic data ) { var a = new ShipData(); a.LoadFromResponse( APIName, elem ); db.Ships.Add( a ); - + } - + //api_ndock foreach ( var elem in data.api_ndock ) { @@ -51,8 +51,10 @@ public override void OnResponseReceived( dynamic data ) { //api_deck_port db.Fleet.LoadFromResponse( APIName, data.api_deck_port ); db.Fleet.CombinedFlag = data.api_combined_flag() ? (int)data.api_combined_flag : 0; - - + + + db.Battle.LoadFromResponse( APIName, data ); + base.OnResponseReceived( (object)data ); } diff --git a/ElectronicObserver/Observer/kcsapi/api_req_kaisou/marriage.cs b/ElectronicObserver/Observer/kcsapi/api_req_kaisou/marriage.cs new file mode 100644 index 000000000..e1143e12f --- /dev/null +++ b/ElectronicObserver/Observer/kcsapi/api_req_kaisou/marriage.cs @@ -0,0 +1,23 @@ +using ElectronicObserver.Data; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserver.Observer.kcsapi.api_req_kaisou { + + public class marriage : APIBase { + + public override void OnResponseReceived( dynamic data ) { + + Utility.Logger.Add( 2, string.Format( "{0} とケッコンカッコカリしました。おめでとうございます!", KCDatabase.Instance.Ships[(int)data.api_id].Name ) ); + + base.OnResponseReceived( (object)data ); + } + + public override string APIName { + get { return "api_req_kaisou/marriage"; } + } + } +} diff --git a/ElectronicObserver/Other/Information/apilist.txt b/ElectronicObserver/Other/Information/apilist.txt index 2b83e39c0..9adf37992 100644 --- a/ElectronicObserver/Other/Information/apilist.txt +++ b/ElectronicObserver/Other/Information/apilist.txt @@ -796,7 +796,8 @@ api_get_member/picture_book :装備図鑑 図鑑登録済みのもののみ api_houk :回避 api_saku :索敵 api_leng :射程 - api_flag : + api_flag :カテゴリ? + [0]=砲, [1]=魚雷, [2]=攻撃機(雷撃機), [3]=爆撃機, [4]=機銃, [5]=戦闘機, [6]=偵察機, [7]=戦闘機/機銃 api_info :説明 @@ -1218,9 +1219,17 @@ api_req_sortie/airbattle :航空戦 (全メンバが api_req_sortie/battle を継承) api_support_flag :(存在せず) api_support_info :(存在せず) + api_opening_flag :(存在せず) + api_opening_atack :(存在せず) + api_hourai_flag :(存在せず) + api_hougeki1 :(存在せず) + api_hougeki2 :(存在せず) + api_hougeki3 :(存在せず) + api_raigeki :(存在せず) api_stage_flag2 :第二次航空戦フラグ api_kouku2 :第二次航空戦 api_koukuに準じる + api_req_sortie/battleresult :戦闘結果 api_ship_id :敵艦船ID api_win_rank :勝利ランク diff --git a/ElectronicObserver/Utility/SoftwareInformation.cs b/ElectronicObserver/Utility/SoftwareInformation.cs index a2baac2f0..8499952ec 100644 --- a/ElectronicObserver/Utility/SoftwareInformation.cs +++ b/ElectronicObserver/Utility/SoftwareInformation.cs @@ -35,7 +35,7 @@ public static string SoftwareNameEnglish { /// public static string VersionJapanese { get { - return SoftwareNameJapanese + "一二型改六"; + return SoftwareNameJapanese + "一三型"; } } @@ -44,7 +44,7 @@ public static string VersionJapanese { /// public static string VersionEnglish { get { - return "1.2.6"; + return "1.3.0"; } } @@ -54,7 +54,7 @@ public static string VersionEnglish { /// public static DateTime UpdateTime { get { - return DateTimeHelper.CSVStringToTime( "2015/05/18 20:00:00" ); + return DateTimeHelper.CSVStringToTime( "2015/05/26 00:00:00" ); } } diff --git a/ElectronicObserver/Window/Dialog/DialogLocalAPILoader2.Designer.cs b/ElectronicObserver/Window/Dialog/DialogLocalAPILoader2.Designer.cs new file mode 100644 index 000000000..017c0ce8a --- /dev/null +++ b/ElectronicObserver/Window/Dialog/DialogLocalAPILoader2.Designer.cs @@ -0,0 +1,247 @@ +namespace ElectronicObserver.Window.Dialog { + partial class DialogLocalAPILoader2 { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose( bool disposing ) { + if ( disposing && ( components != null ) ) { + components.Dispose(); + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + this.APIView = new System.Windows.Forms.DataGridView(); + this.APIView_FileName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); + this.ContextMenu_Execute = new System.Windows.Forms.ToolStripMenuItem(); + this.ContextMenu_Delete = new System.Windows.Forms.ToolStripMenuItem(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.Menu_File = new System.Windows.Forms.ToolStripMenuItem(); + this.Menu_File_OpenFolder = new System.Windows.Forms.ToolStripMenuItem(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.ButtonExecuteNext = new System.Windows.Forms.Button(); + this.ButtonExecute = new System.Windows.Forms.Button(); + this.FolderBrowser = new System.Windows.Forms.FolderBrowserDialog(); + this.APICaller = new System.ComponentModel.BackgroundWorker(); + this.Menu_File_Reload = new System.Windows.Forms.ToolStripMenuItem(); + this.TextFilter = new System.Windows.Forms.TextBox(); + this.ButtonSearch = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.APIView)).BeginInit(); + this.ContextMenu.SuspendLayout(); + this.menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // APIView + // + this.APIView.AllowUserToAddRows = false; + this.APIView.AllowUserToDeleteRows = false; + this.APIView.AllowUserToResizeRows = false; + this.APIView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.APIView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.APIView_FileName}); + this.APIView.ContextMenuStrip = this.ContextMenu; + this.APIView.Dock = System.Windows.Forms.DockStyle.Fill; + this.APIView.Location = new System.Drawing.Point(0, 0); + this.APIView.Name = "APIView"; + this.APIView.ReadOnly = true; + this.APIView.RowHeadersVisible = false; + this.APIView.RowTemplate.Height = 21; + this.APIView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.APIView.Size = new System.Drawing.Size(624, 320); + this.APIView.TabIndex = 0; + // + // APIView_FileName + // + this.APIView_FileName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.APIView_FileName.HeaderText = "ファイル名"; + this.APIView_FileName.Name = "APIView_FileName"; + this.APIView_FileName.ReadOnly = true; + this.APIView_FileName.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // ContextMenu + // + this.ContextMenu.ImageScalingSize = new System.Drawing.Size(32, 32); + this.ContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ContextMenu_Execute, + this.ContextMenu_Delete}); + this.ContextMenu.Name = "ContextMenu"; + this.ContextMenu.Size = new System.Drawing.Size(226, 72); + // + // ContextMenu_Execute + // + this.ContextMenu_Execute.Name = "ContextMenu_Execute"; + this.ContextMenu_Execute.Size = new System.Drawing.Size(225, 34); + this.ContextMenu_Execute.Text = "実行(&E)"; + this.ContextMenu_Execute.Click += new System.EventHandler(this.ContextMenu_Execute_Click); + // + // ContextMenu_Delete + // + this.ContextMenu_Delete.Name = "ContextMenu_Delete"; + this.ContextMenu_Delete.ShortcutKeys = System.Windows.Forms.Keys.Delete; + this.ContextMenu_Delete.Size = new System.Drawing.Size(225, 34); + this.ContextMenu_Delete.Text = "削除(&D)"; + this.ContextMenu_Delete.Click += new System.EventHandler(this.ContextMenu_Delete_Click); + // + // menuStrip1 + // + this.menuStrip1.ImageScalingSize = new System.Drawing.Size(32, 32); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.Menu_File}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(624, 38); + this.menuStrip1.TabIndex = 1; + this.menuStrip1.Text = "menuStrip1"; + // + // Menu_File + // + this.Menu_File.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.Menu_File_OpenFolder, + this.Menu_File_Reload}); + this.Menu_File.Name = "Menu_File"; + this.Menu_File.Size = new System.Drawing.Size(128, 34); + this.Menu_File.Text = "ファイル(&F)"; + // + // Menu_File_OpenFolder + // + this.Menu_File_OpenFolder.Name = "Menu_File_OpenFolder"; + this.Menu_File_OpenFolder.Size = new System.Drawing.Size(273, 34); + this.Menu_File_OpenFolder.Text = "フォルダを開く(&O)..."; + this.Menu_File_OpenFolder.Click += new System.EventHandler(this.Menu_File_OpenFolder_Click); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 38); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.APIView); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.ButtonSearch); + this.splitContainer1.Panel2.Controls.Add(this.TextFilter); + this.splitContainer1.Panel2.Controls.Add(this.ButtonExecuteNext); + this.splitContainer1.Panel2.Controls.Add(this.ButtonExecute); + this.splitContainer1.Size = new System.Drawing.Size(624, 403); + this.splitContainer1.SplitterDistance = 320; + this.splitContainer1.TabIndex = 2; + // + // ButtonExecuteNext + // + this.ButtonExecuteNext.Location = new System.Drawing.Point(93, 3); + this.ButtonExecuteNext.Name = "ButtonExecuteNext"; + this.ButtonExecuteNext.Size = new System.Drawing.Size(75, 23); + this.ButtonExecuteNext.TabIndex = 1; + this.ButtonExecuteNext.Text = "次へ実行"; + this.ButtonExecuteNext.UseVisualStyleBackColor = true; + this.ButtonExecuteNext.Click += new System.EventHandler(this.ButtonExecuteNext_Click); + // + // ButtonExecute + // + this.ButtonExecute.Location = new System.Drawing.Point(12, 3); + this.ButtonExecute.Name = "ButtonExecute"; + this.ButtonExecute.Size = new System.Drawing.Size(75, 23); + this.ButtonExecute.TabIndex = 0; + this.ButtonExecute.Text = "実行"; + this.ButtonExecute.UseVisualStyleBackColor = true; + this.ButtonExecute.Click += new System.EventHandler(this.ContextMenu_Execute_Click); + // + // APICaller + // + this.APICaller.WorkerSupportsCancellation = true; + this.APICaller.DoWork += new System.ComponentModel.DoWorkEventHandler(this.APICaller_DoWork); + // + // Menu_File_Reload + // + this.Menu_File_Reload.Name = "Menu_File_Reload"; + this.Menu_File_Reload.Size = new System.Drawing.Size(273, 34); + this.Menu_File_Reload.Text = "再読み込み(&R)"; + this.Menu_File_Reload.Click += new System.EventHandler(this.Menu_File_Reload_Click); + // + // TextFilter + // + this.TextFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.TextFilter.Location = new System.Drawing.Point(12, 32); + this.TextFilter.Name = "TextFilter"; + this.TextFilter.Size = new System.Drawing.Size(519, 23); + this.TextFilter.TabIndex = 2; + // + // ButtonSearch + // + this.ButtonSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonSearch.Location = new System.Drawing.Point(537, 31); + this.ButtonSearch.Name = "ButtonSearch"; + this.ButtonSearch.Size = new System.Drawing.Size(75, 23); + this.ButtonSearch.TabIndex = 3; + this.ButtonSearch.Text = "検索"; + this.ButtonSearch.UseVisualStyleBackColor = true; + this.ButtonSearch.Click += new System.EventHandler(this.ButtonSearch_Click); + // + // DialogLocalAPILoader2 + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.ClientSize = new System.Drawing.Size(624, 441); + this.Controls.Add(this.splitContainer1); + this.Controls.Add(this.menuStrip1); + this.Font = new System.Drawing.Font("Meiryo UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.MainMenuStrip = this.menuStrip1; + this.Name = "DialogLocalAPILoader2"; + this.Text = "ファイルからAPIをロード"; + this.Load += new System.EventHandler(this.DialogLocalAPILoader2_Load); + ((System.ComponentModel.ISupportInitialize)(this.APIView)).EndInit(); + this.ContextMenu.ResumeLayout(false); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + this.splitContainer1.Panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.DataGridView APIView; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.ToolStripMenuItem Menu_File; + private System.Windows.Forms.ToolStripMenuItem Menu_File_OpenFolder; + private System.Windows.Forms.Button ButtonExecuteNext; + private System.Windows.Forms.Button ButtonExecute; + private System.Windows.Forms.ContextMenuStrip ContextMenu; + private System.Windows.Forms.ToolStripMenuItem ContextMenu_Execute; + private System.Windows.Forms.ToolStripMenuItem ContextMenu_Delete; + private System.Windows.Forms.FolderBrowserDialog FolderBrowser; + private System.Windows.Forms.DataGridViewTextBoxColumn APIView_FileName; + private System.ComponentModel.BackgroundWorker APICaller; + private System.Windows.Forms.ToolStripMenuItem Menu_File_Reload; + private System.Windows.Forms.Button ButtonSearch; + private System.Windows.Forms.TextBox TextFilter; + } +} \ No newline at end of file diff --git a/ElectronicObserver/Window/Dialog/DialogLocalAPILoader2.cs b/ElectronicObserver/Window/Dialog/DialogLocalAPILoader2.cs new file mode 100644 index 000000000..41d6640ad --- /dev/null +++ b/ElectronicObserver/Window/Dialog/DialogLocalAPILoader2.cs @@ -0,0 +1,213 @@ +using ElectronicObserver.Observer; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ElectronicObserver.Window.Dialog { + public partial class DialogLocalAPILoader2 : Form { + + + private string CurrentPath { get; set; } + + + public DialogLocalAPILoader2() { + InitializeComponent(); + } + + private void DialogLocalAPILoader2_Load( object sender, EventArgs e ) { + LoadFiles( Utility.Configuration.Config.Connection.SaveDataPath ); + } + + + private void Menu_File_OpenFolder_Click( object sender, EventArgs e ) { + + FolderBrowser.SelectedPath = Utility.Configuration.Config.Connection.SaveDataPath; + + if ( FolderBrowser.ShowDialog() == System.Windows.Forms.DialogResult.OK ) { + LoadFiles( FolderBrowser.SelectedPath ); + } + + } + + private void Menu_File_Reload_Click( object sender, EventArgs e ) { + if ( Directory.Exists( CurrentPath ) ) + LoadFiles( CurrentPath ); + else + MessageBox.Show( "フォルダが指定されていないか存在しません。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error ); + } + + private void ContextMenu_Execute_Click( object sender, EventArgs e ) { + + /*/ + var rows = APIView.SelectedRows.Cast().OrderBy( r => r.Cells[APIView_FileName.Index].Value ); + + foreach ( DataGridViewRow row in rows ) { + ExecuteAPI( (string)row.Cells[APIView_FileName.Index].Value ); + } + /*/ + if ( !APICaller.IsBusy ) + APICaller.RunWorkerAsync( APIView.SelectedRows.Cast().Select( row => row.Cells[APIView_FileName.Index].Value as string ).OrderBy( s => s ) ); + else + if ( MessageBox.Show( "既に実行中です。\n中断しますか?", "確認", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation ) + == System.Windows.Forms.DialogResult.Yes ) { + APICaller.CancelAsync(); + } + //*/ + } + + private void ContextMenu_Delete_Click( object sender, EventArgs e ) { + + foreach ( DataGridViewRow row in APIView.SelectedRows ) { + APIView.Rows.Remove( row ); + } + } + + + private void ButtonExecuteNext_Click( object sender, EventArgs e ) { + + if ( APIView.SelectedRows.Count == 1 ) { + + var row = APIView.SelectedRows[0]; + int index = APIView.SelectedRows[0].Index; + + ExecuteAPI( (string)row.Cells[APIView_FileName.Index].Value ); + + APIView.ClearSelection(); + if ( index < APIView.Rows.Count - 1 ) { + APIView.Rows[index + 1].Selected = true; + APIView.FirstDisplayedScrollingRowIndex = index + 1; + } + } else { + MessageBox.Show( "単一行を選択してください。", "情報", MessageBoxButtons.OK, MessageBoxIcon.Information ); + + } + + } + + + + private void LoadFiles( string path ) { + + CurrentPath = path; + + APIView.Rows.Clear(); + + var rows = new LinkedList(); + + foreach ( string file in Directory.GetFiles( path, "*.json", SearchOption.TopDirectoryOnly ) ) { + + var row = new DataGridViewRow(); + row.CreateCells( APIView ); + + row.SetValues( Path.GetFileName( file ) ); + rows.AddLast( row ); + + } + + APIView.Rows.AddRange( rows.ToArray() ); + APIView.Sort( APIView_FileName, ListSortDirection.Ascending ); + + } + + + //filename format: yyyyMMdd_hhmmssff[Q|S]@apipath@apiname.json + private string GetAPIName( string fileName ) { + int indexa = fileName.IndexOf( '@' ) + 1, indexb = fileName.LastIndexOf( '.' ); + return fileName.Substring( indexa ).Substring( 0, indexb - indexa ).Replace( '@', '/' ); + } + + private string GetAPITime( string filename ) { + return filename.Substring( 0, filename.IndexOf( '@' ) - 1 ); + } + + + private bool IsRequest( string filename ) { + return char.ToLower( filename[filename.IndexOf( '@' ) - 1] ) == 'q'; + } + + private bool IsResponse( string filename ) { + return char.ToLower( filename[filename.IndexOf( '@' ) - 1] ) == 's'; + } + + + private void ExecuteAPI( string filename ) { + + if ( APIObserver.Instance.APIList.ContainsKey( GetAPIName( filename ) ) ) { + + string data; + + try { + using ( var sr = new System.IO.StreamReader( CurrentPath + "\\" + filename ) ) { + data = sr.ReadToEnd(); + } + + } catch ( Exception ex ) { + Utility.Logger.Add( 3, string.Format( "APIファイル {0} の読み込みに失敗しました。{1}", filename, ex.Message ) ); + return; + } + + + if ( IsRequest( filename ) ) + APIObserver.Instance.LoadRequest( "/kcsapi/" + GetAPIName( filename ), data ); + + if ( IsResponse( filename ) ) + APIObserver.Instance.LoadResponse( "/kcsapi/" + GetAPIName( filename ), data ); + } + + } + + + + private void APICaller_DoWork( object sender, DoWorkEventArgs e ) { + + var files = e.Argument as IOrderedEnumerable; + var act = new Action( ExecuteAPI ); + + foreach ( var file in files ) { + Invoke( act, file ); + System.Threading.Thread.Sleep( 10 ); //ゆるして + + if ( APICaller.CancellationPending ) + break; + } + + } + + private void ButtonSearch_Click( object sender, EventArgs e ) { + + int count = APIView.Rows.Count; + int index; + int result = -1; + if ( APIView.SelectedRows.Count > 0 ) + index = APIView.SelectedRows[0].Index + 1; + else + index = 0; + + if ( index >= count ) + index = 0; + + for ( int i = index; i < count; i++ ) { + if ( APIView[APIView_FileName.Index, i].Value.ToString().ToLower().Contains( TextFilter.Text.ToLower() ) ) { + result = i; + break; + } + } + + if ( result != -1 ) { + APIView.ClearSelection(); + APIView.Rows[result].Selected = true; + APIView.FirstDisplayedScrollingRowIndex = result; + } else { + System.Media.SystemSounds.Asterisk.Play(); + } + } + + } +} diff --git a/ElectronicObserver/Window/Dialog/DialogLocalAPILoader2.resx b/ElectronicObserver/Window/Dialog/DialogLocalAPILoader2.resx new file mode 100644 index 000000000..dc5aa57d8 --- /dev/null +++ b/ElectronicObserver/Window/Dialog/DialogLocalAPILoader2.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + 139, 17 + + + 17, 17 + + + 353, 17 + + + 582, 17 + + \ No newline at end of file diff --git a/ElectronicObserver/Window/FormBattle.cs b/ElectronicObserver/Window/FormBattle.cs index 5816ef4cf..d8a5daad2 100644 --- a/ElectronicObserver/Window/FormBattle.cs +++ b/ElectronicObserver/Window/FormBattle.cs @@ -1,5 +1,6 @@ using ElectronicObserver.Data; using ElectronicObserver.Data.Battle; +using ElectronicObserver.Data.Battle.Phase; using ElectronicObserver.Observer; using ElectronicObserver.Resource; using ElectronicObserver.Window.Control; @@ -130,97 +131,89 @@ private void Updated( string apiname, dynamic data ) { case "api_req_sortie/battle": case "api_req_practice/battle": { - int[] hp = bm.BattleDay.EmulateBattle(); SetFormation( bm.BattleDay ); SetSearchingResult( bm.BattleDay ); - SetAerialWarfare( bm.BattleDay ); - SetHPNormal( hp, bm.BattleDay ); - SetDamageRateNormal( hp, bm.BattleDay ); + SetAerialWarfare( bm.BattleDay.AirBattle ); + SetHPNormal( bm.BattleDay ); + SetDamageRateNormal( bm.BattleDay, bm.BattleDay.Initial.InitialHPs ); BaseLayoutPanel.Visible = true; } break; case "api_req_battle_midnight/battle": case "api_req_practice/midnight_battle": { - int[] hp = bm.BattleNight.EmulateBattle(); - SetNightBattleEvent( bm.BattleNight.InitialHP.Skip( 1 ).ToArray(), false, bm.BattleNight ); - SetHPNormal( hp, bm.BattleNight ); - SetDamageRateNormal( hp, bm.BattleDay ); + SetNightBattleEvent( bm.BattleNight.NightBattle ); + SetHPNormal( bm.BattleNight ); + SetDamageRateNormal( bm.BattleNight, bm.BattleDay.Initial.InitialHPs ); BaseLayoutPanel.Visible = true; } break; case "api_req_battle_midnight/sp_midnight": { - int[] hp = bm.BattleNight.EmulateBattle(); SetFormation( bm.BattleNight ); ClearAerialWarfare(); ClearSearchingResult(); - SetNightBattleEvent( bm.BattleNight.InitialHP.Skip( 1 ).ToArray(), false, bm.BattleNight ); - SetHPNormal( hp, bm.BattleNight ); - SetDamageRateNormal( hp, bm.BattleNight ); + SetNightBattleEvent( bm.BattleNight.NightBattle ); + SetHPNormal( bm.BattleNight ); + SetDamageRateNormal( bm.BattleNight, bm.BattleNight.Initial.InitialHPs ); BaseLayoutPanel.Visible = true; } break; case "api_req_sortie/airbattle": { - int[] hp = bm.BattleDay.EmulateBattle(); SetFormation( bm.BattleDay ); SetSearchingResult( bm.BattleDay ); - SetAerialWarfareAirBattle( bm.BattleDay ); - SetHPNormal( hp, bm.BattleDay ); - SetDamageRateNormal( hp, bm.BattleDay ); + SetAerialWarfareAirBattle( bm.BattleDay.AirBattle, ( (BattleAirBattle)bm.BattleDay ).AirBattle2 ); + SetHPNormal( bm.BattleDay ); + SetDamageRateNormal( bm.BattleDay, bm.BattleDay.Initial.InitialHPs ); BaseLayoutPanel.Visible = true; } break; case "api_req_combined_battle/battle": case "api_req_combined_battle/battle_water": { - int[] hp = bm.BattleDay.EmulateBattle(); SetFormation( bm.BattleDay ); SetSearchingResult( bm.BattleDay ); - SetAerialWarfare( bm.BattleDay ); - SetHPCombined( hp, bm.BattleDay ); - SetDamageRateCombined( hp, bm.BattleDay ); + SetAerialWarfare( bm.BattleDay.AirBattle ); + SetHPCombined( bm.BattleDay ); + SetDamageRateCombined( bm.BattleDay, bm.BattleDay.Initial.InitialHPs ); BaseLayoutPanel.Visible = true; } break; case "api_req_combined_battle/airbattle": { - int[] hp = bm.BattleDay.EmulateBattle(); SetFormation( bm.BattleDay ); SetSearchingResult( bm.BattleDay ); - SetAerialWarfareAirBattle( bm.BattleDay ); - SetHPCombined( hp, bm.BattleDay ); - SetDamageRateCombined( hp, bm.BattleDay ); + SetAerialWarfareAirBattle( bm.BattleDay.AirBattle, ( (BattleCombinedAirBattle)bm.BattleDay ).AirBattle2 ); + SetHPCombined( bm.BattleDay ); + SetDamageRateCombined( bm.BattleDay, bm.BattleDay.Initial.InitialHPs ); BaseLayoutPanel.Visible = true; } break; case "api_req_combined_battle/midnight_battle": { - int[] hp = bm.BattleNight.EmulateBattle(); - SetNightBattleEvent( bm.BattleNight.InitialHP.Skip( 1 ).Concat( ( (BattleDataCombined)bm.BattleNight ).InitialHPCombined.Skip( 1 ) ).ToArray(), true, bm.BattleNight ); - SetHPCombined( hp, bm.BattleNight ); - SetDamageRateCombined( hp, bm.BattleDay ); + SetNightBattleEvent( bm.BattleNight.NightBattle ); + SetHPCombined( bm.BattleNight ); + SetDamageRateCombined( bm.BattleNight, bm.BattleDay.Initial.InitialHPs ); BaseLayoutPanel.Visible = true; } break; case "api_req_combined_battle/sp_midnight": { - int[] hp = bm.BattleNight.EmulateBattle(); SetFormation( bm.BattleNight ); ClearAerialWarfare(); ClearSearchingResult(); - SetNightBattleEvent( bm.BattleNight.InitialHP.Skip( 1 ).Concat( ( (BattleDataCombined)bm.BattleNight ).InitialHPCombined.Skip( 1 ) ).ToArray(), true, bm.BattleNight ); - SetHPCombined( hp, bm.BattleNight ); - SetDamageRateCombined( hp, bm.BattleNight ); + SetNightBattleEvent( bm.BattleNight.NightBattle ); + SetHPCombined( bm.BattleNight ); + SetDamageRateCombined( bm.BattleNight, bm.BattleNight.Initial.InitialHPs ); BaseLayoutPanel.Visible = true; } break; @@ -239,9 +232,9 @@ private void Updated( string apiname, dynamic data ) { /// private void SetFormation( BattleData bd ) { - FormationFriend.Text = Constants.GetFormationShort( bd.Data.api_formation[0] is string ? int.Parse( bd.Data.api_formation[0] ) : (int)bd.Data.api_formation[0] ); - FormationEnemy.Text = Constants.GetFormationShort( bd.Data.api_formation[1] is string ? int.Parse( bd.Data.api_formation[1] ) : (int)bd.Data.api_formation[1] ); - Formation.Text = Constants.GetEngagementForm( (int)bd.Data.api_formation[2] ); + FormationFriend.Text = Constants.GetFormationShort( bd.Searching.FormationFriend ); + FormationEnemy.Text = Constants.GetFormationShort( bd.Searching.FormationEnemy ); + Formation.Text = Constants.GetEngagementForm( bd.Searching.EngagementForm ); } @@ -250,13 +243,13 @@ private void SetFormation( BattleData bd ) { /// private void SetSearchingResult( BattleData bd ) { - int searchFriend = (int)bd.Data.api_search[0]; + int searchFriend = bd.Searching.SearchingFriend; SearchingFriend.Text = Constants.GetSearchingResultShort( searchFriend ); SearchingFriend.ImageAlign = ContentAlignment.MiddleLeft; SearchingFriend.ImageIndex = (int)( searchFriend < 4 ? ResourceManager.EquipmentContent.Seaplane : ResourceManager.EquipmentContent.Radar ); ToolTipInfo.SetToolTip( SearchingFriend, null ); - int searchEnemy = (int)bd.Data.api_search[1]; + int searchEnemy = bd.Searching.SearchingEnemy; SearchingEnemy.Text = Constants.GetSearchingResultShort( searchEnemy ); SearchingEnemy.ImageAlign = ContentAlignment.MiddleLeft; SearchingEnemy.ImageIndex = (int)( searchEnemy < 4 ? ResourceManager.EquipmentContent.Seaplane : ResourceManager.EquipmentContent.Radar ); @@ -285,14 +278,14 @@ private void ClearSearchingResult() { /// /// 航空戦情報を設定します。 /// - private void SetAerialWarfare( BattleData bd ) { + private void SetAerialWarfare( PhaseAirBattle pd ) { //空対空戦闘 - if ( (int)bd.Data.api_stage_flag[0] != 0 ) { + if ( pd.IsStage1Available ) { - AirSuperiority.Text = Constants.GetAirSuperiority( (int)bd.Data.api_kouku.api_stage1.api_disp_seiku ); + AirSuperiority.Text = Constants.GetAirSuperiority( pd.AirSuperiority ); - int[] planeFriend = { (int)bd.Data.api_kouku.api_stage1.api_f_lostcount, (int)bd.Data.api_kouku.api_stage1.api_f_count }; + int[] planeFriend = { pd.AircraftLostStage1Friend, pd.AircraftTotalStage1Friend }; AirStage1Friend.Text = string.Format( "-{0}/{1}", planeFriend[0], planeFriend[1] ); if ( planeFriend[1] > 0 && planeFriend[0] == planeFriend[1] ) @@ -300,7 +293,7 @@ private void SetAerialWarfare( BattleData bd ) { else AirStage1Friend.ForeColor = SystemColors.ControlText; - int[] planeEnemy = { (int)bd.Data.api_kouku.api_stage1.api_e_lostcount, (int)bd.Data.api_kouku.api_stage1.api_e_count }; + int[] planeEnemy = { pd.AircraftLostStage1Enemy, pd.AircraftTotalStage1Enemy }; AirStage1Enemy.Text = string.Format( "-{0}/{1}", planeEnemy[0], planeEnemy[1] ); if ( planeEnemy[1] > 0 && planeEnemy[0] == planeEnemy[1] ) @@ -310,7 +303,7 @@ private void SetAerialWarfare( BattleData bd ) { //触接 - int touchFriend = (int)bd.Data.api_kouku.api_stage1.api_touch_plane[0]; + int touchFriend = pd.TouchAircraftFriend; if ( touchFriend != -1 ) { AirStage1Friend.ImageAlign = ContentAlignment.MiddleLeft; AirStage1Friend.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane; @@ -321,7 +314,7 @@ private void SetAerialWarfare( BattleData bd ) { ToolTipInfo.SetToolTip( AirStage1Friend, null ); } - int touchEnemy = (int)bd.Data.api_kouku.api_stage1.api_touch_plane[1]; + int touchEnemy = pd.TouchAircraftEnemy; if ( touchEnemy != -1 ) { AirStage1Enemy.ImageAlign = ContentAlignment.MiddleLeft; AirStage1Enemy.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane; @@ -350,9 +343,9 @@ private void SetAerialWarfare( BattleData bd ) { } //艦対空戦闘 - if ( (int)bd.Data.api_stage_flag[1] != 0 ) { + if ( pd.IsStage2Available ) { - int[] planeFriend = { (int)bd.Data.api_kouku.api_stage2.api_f_lostcount, (int)bd.Data.api_kouku.api_stage2.api_f_count }; + int[] planeFriend = { pd.AircraftLostStage2Friend, pd.AircraftTotalStage2Friend }; AirStage2Friend.Text = string.Format( "-{0}/{1}", planeFriend[0], planeFriend[1] ); if ( planeFriend[1] > 0 && planeFriend[0] == planeFriend[1] ) @@ -360,7 +353,7 @@ private void SetAerialWarfare( BattleData bd ) { else AirStage2Friend.ForeColor = SystemColors.ControlText; - int[] planeEnemy = { (int)bd.Data.api_kouku.api_stage2.api_e_lostcount, (int)bd.Data.api_kouku.api_stage2.api_e_count }; + int[] planeEnemy = { pd.AircraftLostStage2Enemy, pd.AircraftTotalStage2Enemy }; AirStage2Enemy.Text = string.Format( "-{0}/{1}", planeEnemy[0], planeEnemy[1] ); if ( planeEnemy[1] > 0 && planeEnemy[0] == planeEnemy[1] ) @@ -370,16 +363,16 @@ private void SetAerialWarfare( BattleData bd ) { //対空カットイン - if ( bd.Data.api_kouku.api_stage2.api_air_fire() ) { - int cutinID = (int)bd.Data.api_kouku.api_stage2.api_air_fire.api_kind; - int cutinIndex = (int)bd.Data.api_kouku.api_stage2.api_air_fire.api_idx; + if ( pd.IsAACutinAvailable ) { + int cutinID = pd.AACutInKind; + int cutinIndex = pd.AACutInIndex; AACutin.Text = "#" + ( cutinIndex + 1 ); AACutin.ImageAlign = ContentAlignment.MiddleLeft; AACutin.ImageIndex = (int)ResourceManager.EquipmentContent.HighAngleGun; ToolTipInfo.SetToolTip( AACutin, string.Format( "対空カットイン: {0}\r\nカットイン種別: {1} ({2})", - KCDatabase.Instance.Fleet[cutinIndex >= 6 ? 2 : bd.FleetIDFriend].MembersInstance[cutinIndex % 6].NameWithLevel, + pd.AACutInShip.NameWithLevel, cutinID, Constants.GetAACutinKind( cutinID ) ) ); @@ -416,32 +409,27 @@ private void SetAerialWarfare( BattleData bd ) { /// 航空戦情報(航空戦)を設定します。 /// 通常艦隊・連合艦隊両用です。 /// - private void SetAerialWarfareAirBattle( BattleData bd ) { + private void SetAerialWarfareAirBattle( PhaseAirBattle pd1, PhaseAirBattle pd2 ) { //空対空戦闘 - if ( (int)bd.Data.api_stage_flag[0] != 0 ) { + if ( pd1.IsStage1Available ) { //二回目の空戦が存在するか - bool isBattle2Enabled = (int)bd.Data.api_stage_flag2[0] != 0; + bool isBattle2Enabled = pd2.IsStage1Available; - AirSuperiority.Text = Constants.GetAirSuperiority( (int)bd.Data.api_kouku.api_stage1.api_disp_seiku ); + AirSuperiority.Text = Constants.GetAirSuperiority( pd1.AirSuperiority ); if ( isBattle2Enabled ) { - ToolTipInfo.SetToolTip( AirSuperiority, "第2次: " + Constants.GetAirSuperiority( (int)bd.Data.api_kouku2.api_stage1.api_disp_seiku ) ); + ToolTipInfo.SetToolTip( AirSuperiority, "第2次: " + Constants.GetAirSuperiority( pd2.AirSuperiority ) ); } else { ToolTipInfo.SetToolTip( AirSuperiority, null ); } - /* - int[] planeFriend = { - (int)bd.Data.api_kouku.api_stage1.api_f_lostcount + ( isBattle2Enabled ? (int)bd.Data.api_kouku2.api_stage1.api_f_lostcount : 0 ), - (int)bd.Data.api_kouku.api_stage1.api_f_count }; - */ int[] planeFriend = { - (int)bd.Data.api_kouku.api_stage1.api_f_lostcount, - (int)bd.Data.api_kouku.api_stage1.api_f_count, - ( isBattle2Enabled ? (int)bd.Data.api_kouku2.api_stage1.api_f_lostcount : 0 ), - ( isBattle2Enabled ? (int)bd.Data.api_kouku2.api_stage1.api_f_count : 0 ), + pd1.AircraftLostStage1Friend, + pd1.AircraftTotalStage1Friend, + ( isBattle2Enabled ? pd2.AircraftLostStage1Friend : 0 ), + ( isBattle2Enabled ? pd2.AircraftTotalStage1Friend : 0 ), }; AirStage1Friend.Text = string.Format( "-{0}/{1}", planeFriend[0] + planeFriend[2], planeFriend[1] ); ToolTipInfo.SetToolTip( AirStage1Friend, string.Format( "第1次: -{0}/{1}\r\n第2次: -{2}/{3}\r\n", @@ -454,10 +442,10 @@ private void SetAerialWarfareAirBattle( BattleData bd ) { int[] planeEnemy = { - (int)bd.Data.api_kouku.api_stage1.api_e_lostcount, - (int)bd.Data.api_kouku.api_stage1.api_e_count, - ( isBattle2Enabled ? (int)bd.Data.api_kouku2.api_stage1.api_e_lostcount : 0 ), - ( isBattle2Enabled ? (int)bd.Data.api_kouku2.api_stage1.api_e_count : 0 ), + pd1.AircraftLostStage1Enemy, + pd1.AircraftTotalStage1Enemy, + ( isBattle2Enabled ? pd2.AircraftLostStage1Enemy : 0 ), + ( isBattle2Enabled ? pd2.AircraftTotalStage1Enemy : 0 ), }; AirStage1Enemy.Text = string.Format( "-{0}/{1}", planeEnemy[0] + planeEnemy[2], planeEnemy[1] ); ToolTipInfo.SetToolTip( AirStage1Enemy, string.Format( "第1次: -{0}/{1}\r\n第2次: -{2}/{3}\r\n", @@ -471,8 +459,8 @@ private void SetAerialWarfareAirBattle( BattleData bd ) { //触接 int[] touchFriend = { - (int)bd.Data.api_kouku.api_stage1.api_touch_plane[0], - isBattle2Enabled ? (int)bd.Data.api_kouku2.api_stage1.api_touch_plane[0] : -1 + pd1.TouchAircraftFriend, + isBattle2Enabled ? pd2.TouchAircraftFriend : -1 }; if ( touchFriend[0] != -1 || touchFriend[1] != -1 ) { AirStage1Friend.ImageAlign = ContentAlignment.MiddleLeft; @@ -492,8 +480,8 @@ private void SetAerialWarfareAirBattle( BattleData bd ) { } int[] touchEnemy = { - (int)bd.Data.api_kouku.api_stage1.api_touch_plane[1], - isBattle2Enabled ? (int)bd.Data.api_kouku2.api_stage1.api_touch_plane[1] : -1 + pd1.TouchAircraftFriend, + isBattle2Enabled ? pd2.TouchAircraftFriend : -1 }; if ( touchEnemy[0] != -1 || touchEnemy[1] != -1 ) { AirStage1Enemy.ImageAlign = ContentAlignment.MiddleLeft; @@ -524,17 +512,17 @@ private void SetAerialWarfareAirBattle( BattleData bd ) { } //艦対空戦闘 - if ( (int)bd.Data.api_stage_flag[1] != 0 ) { + if ( pd1.IsStage2Available ) { //二回目の空戦が存在するか - bool isBattle2Enabled = (int)bd.Data.api_stage_flag2[1] != 0; + bool isBattle2Enabled = pd2.IsStage2Available; int[] planeFriend = { - (int)bd.Data.api_kouku.api_stage2.api_f_lostcount, - (int)bd.Data.api_kouku.api_stage2.api_f_count, - ( isBattle2Enabled ? (int)bd.Data.api_kouku2.api_stage2.api_f_lostcount : 0 ), - ( isBattle2Enabled ? (int)bd.Data.api_kouku2.api_stage2.api_f_count : 0 ), + pd1.AircraftLostStage2Friend, + pd1.AircraftTotalStage2Friend, + ( isBattle2Enabled ? pd2.AircraftLostStage2Friend : 0 ), + ( isBattle2Enabled ? pd2.AircraftTotalStage2Friend : 0 ), }; AirStage2Friend.Text = string.Format( "-{0}/{1}", planeFriend[0] + planeFriend[2], planeFriend[1] ); ToolTipInfo.SetToolTip( AirStage2Friend, string.Format( "第1次: -{0}/{1}\r\n第2次: -{2}/{3}\r\n", @@ -547,10 +535,10 @@ private void SetAerialWarfareAirBattle( BattleData bd ) { int[] planeEnemy = { - (int)bd.Data.api_kouku.api_stage2.api_e_lostcount, - (int)bd.Data.api_kouku.api_stage2.api_e_count, - ( isBattle2Enabled ? (int)bd.Data.api_kouku2.api_stage2.api_e_lostcount : 0 ), - ( isBattle2Enabled ? (int)bd.Data.api_kouku2.api_stage2.api_e_count : 0 ), + pd1.AircraftLostStage2Enemy, + pd1.AircraftTotalStage2Enemy, + ( isBattle2Enabled ? pd2.AircraftLostStage2Enemy : 0 ), + ( isBattle2Enabled ? pd2.AircraftTotalStage2Enemy : 0 ), }; AirStage2Enemy.Text = string.Format( "-{0}/{1}", planeEnemy[0] + planeEnemy[2], planeEnemy[1] ); ToolTipInfo.SetToolTip( AirStage2Enemy, string.Format( "第1次: -{0}/{1}\r\n第2次: -{2}/{3}\r\n", @@ -564,14 +552,14 @@ private void SetAerialWarfareAirBattle( BattleData bd ) { //対空カットイン { - bool[] fire = new bool[] { bd.Data.api_kouku.api_stage2.api_air_fire(), isBattle2Enabled && bd.Data.api_kouku2.api_stage2.api_air_fire() }; + bool[] fire = new bool[] { pd1.IsAACutinAvailable, isBattle2Enabled && pd2.IsAACutinAvailable }; int[] cutinID = new int[] { - fire[0] ? (int)bd.Data.api_kouku.api_stage2.api_air_fire.api_kind : -1, - fire[1] ? (int)bd.Data.api_kouku2.api_stage2.api_air_fire.api_kind : -1, + fire[0] ? pd1.AACutInKind : -1, + fire[1] ? pd2.AACutInKind : -1, }; int[] cutinIndex = new int[] { - fire[0] ? (int)bd.Data.api_kouku.api_stage2.api_air_fire.api_idx : -1, - fire[1] ? (int)bd.Data.api_kouku2.api_stage2.api_air_fire.api_idx : -1, + fire[0] ? pd1.AACutInIndex : -1, + fire[1] ? pd2.AACutInIndex : -1, }; if ( fire[0] || fire[1] ) { @@ -586,7 +574,7 @@ private void SetAerialWarfareAirBattle( BattleData bd ) { if ( fire[i] ) { sb.AppendFormat( "第{0}次: {1}\r\nカットイン種別: {2} ({3})\r\n", i + 1, - KCDatabase.Instance.Fleet[cutinIndex[i] >= 6 ? 2 : bd.FleetIDFriend].MembersInstance[cutinIndex[i] % 6].NameWithLevel, + ( i == 0 ? pd1 : pd2 ).AACutInShip.NameWithLevel, cutinID[i], Constants.GetAACutinKind( cutinID[i] ) ); } else { @@ -658,19 +646,25 @@ private void ClearAerialWarfare() { ToolTipInfo.SetToolTip( AACutin, null ); } + /// /// 両軍のHPゲージを設定します。 /// - private void SetHPNormal( int[] hp, BattleData bd ) { + private void SetHPNormal( BattleData bd ) { KCDatabase db = KCDatabase.Instance; bool isPractice = ( bd.BattleType & BattleData.BattleTypeFlag.Practice ) != 0; + var initialHPs = bd.Initial.InitialHPs; + var maxHPs = bd.Initial.MaxHPs; + var resultHPs = bd.ResultHPs; + var attackDamages = bd.AttackDamages; + for ( int i = 0; i < 12; i++ ) { - if ( (int)bd.Data.api_nowhps[i + 1] != -1 ) { - HPBars[i].Value = hp[i]; - HPBars[i].PrevValue = (int)bd.Data.api_nowhps[i + 1]; - HPBars[i].MaximumValue = (int)bd.Data.api_maxhps[i + 1]; + if ( initialHPs[i] != -1 ) { + HPBars[i].Value = resultHPs[i]; + HPBars[i].PrevValue = initialHPs[i]; + HPBars[i].MaximumValue = maxHPs[i]; HPBars[i].BackColor = SystemColors.Control; HPBars[i].Visible = true; } else { @@ -680,31 +674,32 @@ private void SetHPNormal( int[] hp, BattleData bd ) { for ( int i = 0; i < 6; i++ ) { - if ( (int)bd.Data.api_nowhps[i + 1] != -1 ) { - ShipData ship = db.Ships[db.Fleet[bd.FleetIDFriend].Members[i]]; + if ( initialHPs[i] != -1 ) { + ShipData ship = bd.Initial.FriendFleet.MembersInstance[i]; ToolTipInfo.SetToolTip( HPBars[i], - string.Format( "{0} Lv. {1}\r\nHP: ({2} → {3})/{4} ({5}) [{6}]", + string.Format( "{0} Lv. {1}\r\nHP: ({2} → {3})/{4} ({5}) [{6}]\r\n与ダメージ: {7}", ship.MasterShip.NameWithClass, ship.Level, Math.Max( HPBars[i].PrevValue, 0 ), Math.Max( HPBars[i].Value, 0 ), HPBars[i].MaximumValue, HPBars[i].Value - HPBars[i].PrevValue, - Constants.GetDamageState( (double)HPBars[i].Value / HPBars[i].MaximumValue, isPractice, ship.MasterShip.IsLandBase ) + Constants.GetDamageState( (double)HPBars[i].Value / HPBars[i].MaximumValue, isPractice, ship.MasterShip.IsLandBase ), + attackDamages[i] ) ); } } for ( int i = 0; i < 6; i++ ) { - if ( (int)bd.Data.api_nowhps[i + 7] != -1 ) { - ShipDataMaster ship = db.MasterShips[bd.EnemyFleetMembers[i + 1]]; + if ( initialHPs[i + 6] != -1 ) { + ShipDataMaster ship = bd.Initial.EnemyMembersInstance[i]; ToolTipInfo.SetToolTip( HPBars[i + 6], string.Format( "{0} Lv. {1}\r\nHP: ({2} → {3})/{4} ({5}) [{6}]", ship.NameWithClass, - bd.EnemyLevels[i + 1], + bd.Initial.EnemyLevels[i], Math.Max( HPBars[i + 6].PrevValue, 0 ), Math.Max( HPBars[i + 6].Value, 0 ), HPBars[i + 6].MaximumValue, @@ -715,6 +710,7 @@ private void SetHPNormal( int[] hp, BattleData bd ) { } } + HPBars[bd.MVPShipIndex].BackColor = Color.Moccasin; FleetCombined.Visible = false; for ( int i = 12; i < 18; i++ ) { @@ -726,49 +722,45 @@ private void SetHPNormal( int[] hp, BattleData bd ) { /// /// 両軍のHPゲージを設定します。(連合艦隊用) /// - private void SetHPCombined( int[] hp, BattleData bd ) { + private void SetHPCombined( BattleData bd ) { KCDatabase db = KCDatabase.Instance; bool isPractice = ( bd.BattleType & BattleData.BattleTypeFlag.Practice ) != 0; - for ( int i = 0; i < 12; i++ ) { - if ( (int)bd.Data.api_nowhps[i + 1] != -1 ) { - HPBars[i].Value = hp[i]; - HPBars[i].PrevValue = (int)bd.Data.api_nowhps[i + 1]; - HPBars[i].MaximumValue = (int)bd.Data.api_maxhps[i + 1]; - HPBars[i].Visible = true; - } else { - HPBars[i].Visible = false; - } - } + var initialHPs = bd.Initial.InitialHPs; + var maxHPs = bd.Initial.MaxHPs; + var resultHPs = bd.ResultHPs; + var attackDamages = bd.AttackDamages; + FleetCombined.Visible = true; - for ( int i = 0; i < 6; i++ ) { - if ( (int)bd.Data.api_nowhps_combined[i + 1] != -1 ) { - HPBars[i + 12].Value = hp[i + 12]; - HPBars[i + 12].PrevValue = (int)bd.Data.api_nowhps_combined[i + 1]; - HPBars[i + 12].MaximumValue = (int)bd.Data.api_maxhps_combined[i + 1]; - HPBars[i + 12].Visible = true; + for ( int i = 0; i < 18; i++ ) { + if ( initialHPs[i] != -1 ) { + HPBars[i].Value = resultHPs[i]; + HPBars[i].PrevValue = initialHPs[i]; + HPBars[i].MaximumValue = maxHPs[i]; + HPBars[i].Visible = true; } else { - HPBars[i + 12].Visible = false; + HPBars[i].Visible = false; } } for ( int i = 0; i < 6; i++ ) { - if ( (int)bd.Data.api_nowhps[i + 1] != -1 ) { - ShipData ship = db.Ships[db.Fleet[bd.FleetIDFriend].Members[i]]; - bool isEscaped = db.Fleet[bd.FleetIDFriend].EscapedShipList.Contains( ship.MasterID ); + if ( initialHPs[i] != -1 ) { + ShipData ship = bd.Initial.FriendFleet.MembersInstance[i]; + bool isEscaped = bd.Initial.FriendFleet.EscapedShipList.Contains( ship.MasterID ); ToolTipInfo.SetToolTip( HPBars[i], - string.Format( "{0} Lv. {1}\r\nHP: ({2} → {3})/{4} ({5}) [{6}]", + string.Format( "{0} Lv. {1}\r\nHP: ({2} → {3})/{4} ({5}) [{6}]\r\n与ダメージ: {7}", ship.MasterShip.NameWithClass, ship.Level, Math.Max( HPBars[i].PrevValue, 0 ), Math.Max( HPBars[i].Value, 0 ), HPBars[i].MaximumValue, HPBars[i].Value - HPBars[i].PrevValue, - Constants.GetDamageState( (double)HPBars[i].Value / HPBars[i].MaximumValue, isPractice, ship.MasterShip.IsLandBase, isEscaped ) + Constants.GetDamageState( (double)HPBars[i].Value / HPBars[i].MaximumValue, isPractice, ship.MasterShip.IsLandBase, isEscaped ), + attackDamages[i] ) ); @@ -778,13 +770,13 @@ private void SetHPCombined( int[] hp, BattleData bd ) { } for ( int i = 0; i < 6; i++ ) { - if ( (int)bd.Data.api_nowhps[i + 7] != -1 ) { - ShipDataMaster ship = db.MasterShips[bd.EnemyFleetMembers[i + 1]]; + if ( initialHPs[i + 6] != -1 ) { + ShipDataMaster ship = bd.Initial.EnemyMembersInstance[i]; ToolTipInfo.SetToolTip( HPBars[i + 6], string.Format( "{0} Lv. {1}\r\nHP: ({2} → {3})/{4} ({5}) [{6}]", ship.NameWithClass, - bd.EnemyLevels[i + 1], + bd.Initial.EnemyLevels[i], Math.Max( HPBars[i + 6].PrevValue, 0 ), Math.Max( HPBars[i + 6].Value, 0 ), HPBars[i + 6].MaximumValue, @@ -796,19 +788,20 @@ private void SetHPCombined( int[] hp, BattleData bd ) { } for ( int i = 0; i < 6; i++ ) { - if ( (int)bd.Data.api_nowhps_combined[i + 1] != -1 ) { - ShipData ship = db.Ships[db.Fleet[2].Members[i]]; + if ( initialHPs[i + 12] != -1 ) { + ShipData ship = db.Fleet[2].MembersInstance[i]; bool isEscaped = db.Fleet[2].EscapedShipList.Contains( ship.MasterID ); ToolTipInfo.SetToolTip( HPBars[i + 12], - string.Format( "{0} Lv. {1}\r\nHP: ({2} → {3})/{4} ({5}) [{6}]", + string.Format( "{0} Lv. {1}\r\nHP: ({2} → {3})/{4} ({5}) [{6}]\r\n与ダメージ: {7}", ship.MasterShip.NameWithClass, ship.Level, Math.Max( HPBars[i + 12].PrevValue, 0 ), Math.Max( HPBars[i + 12].Value, 0 ), HPBars[i + 12].MaximumValue, HPBars[i + 12].Value - HPBars[i + 12].PrevValue, - Constants.GetDamageState( (double)HPBars[i + 12].Value / HPBars[i + 12].MaximumValue, ship.MasterShip.IsLandBase, isEscaped ) + Constants.GetDamageState( (double)HPBars[i + 12].Value / HPBars[i + 12].MaximumValue, ship.MasterShip.IsLandBase, isEscaped ), + attackDamages[i + 12] ) ); @@ -816,6 +809,10 @@ private void SetHPCombined( int[] hp, BattleData bd ) { else HPBars[i + 12].BackColor = SystemColors.Control; } } + + + HPBars[bd.MVPShipIndex].BackColor = Color.Moccasin; + HPBars[12 + bd.MVPShipCombinedIndex].BackColor = Color.Moccasin; } @@ -892,7 +889,7 @@ private static int GetWinRank( /// /// 損害率と戦績予測を設定します。 /// - private void SetDamageRateNormal( int[] hp, BattleData bd ) { + private void SetDamageRateNormal( BattleData bd, int[] initialHPs ) { int friendbefore = 0; int friendafter = 0; @@ -901,11 +898,13 @@ private void SetDamageRateNormal( int[] hp, BattleData bd ) { int enemyafter = 0; double enemyrate; + var resultHPs = bd.ResultHPs; + for ( int i = 0; i < 6; i++ ) { - friendbefore += Math.Max( (int)bd.Data.api_nowhps[i + 1], 0 ); - friendafter += Math.Max( hp[i], 0 ); - enemybefore += Math.Max( (int)bd.Data.api_nowhps[i + 7], 0 ); - enemyafter += Math.Max( hp[i + 6], 0 ); + friendbefore += Math.Max( initialHPs[i], 0 ); + friendafter += Math.Max( resultHPs[i], 0 ); + enemybefore += Math.Max( initialHPs[i + 6], 0 ); + enemyafter += Math.Max( resultHPs[i + 6], 0 ); } friendrate = ( (double)( friendbefore - friendafter ) / friendbefore ); @@ -916,12 +915,12 @@ private void SetDamageRateNormal( int[] hp, BattleData bd ) { //戦績判定 { - int countFriend = KCDatabase.Instance.Fleet[(int)bd.FleetIDFriend].Members.Count( v => v != -1 ); - int countEnemy = ( bd.EnemyFleetMembers.Skip( 1 ).Count( v => v != -1 ) ); - int sunkFriend = hp.Take( countFriend ).Count( v => v <= 0 ); - int sunkEnemy = hp.Skip( 6 ).Take( countEnemy ).Count( v => v <= 0 ); + int countFriend = bd.Initial.FriendFleet.Members.Count( v => v != -1 ); + int countEnemy = ( bd.Initial.EnemyMembers.Count( v => v != -1 ) ); + int sunkFriend = resultHPs.Take( countFriend ).Count( v => v <= 0 ); + int sunkEnemy = resultHPs.Skip( 6 ).Take( countEnemy ).Count( v => v <= 0 ); - int rank = GetWinRank( countFriend, countEnemy, sunkFriend, sunkEnemy, friendrate, enemyrate, hp[6] <= 0 ); + int rank = GetWinRank( countFriend, countEnemy, sunkFriend, sunkEnemy, friendrate, enemyrate, resultHPs[6] <= 0 ); WinRank.Text = Constants.GetWinRank( rank ); @@ -933,7 +932,7 @@ private void SetDamageRateNormal( int[] hp, BattleData bd ) { /// /// 損害率と戦績予測を設定します(連合艦隊用)。 /// - private void SetDamageRateCombined( int[] hp, BattleData bd ) { + private void SetDamageRateCombined( BattleData bd, int[] initialHPs ) { int friendbefore = 0; int friendafter = 0; @@ -942,15 +941,15 @@ private void SetDamageRateCombined( int[] hp, BattleData bd ) { int enemyafter = 0; double enemyrate; - BattleDataCombined bdc = bd as BattleDataCombined; + var resultHPs = bd.ResultHPs; for ( int i = 0; i < 6; i++ ) { - friendbefore += Math.Max( (int)bdc.Data.api_nowhps[i + 1], 0 ); - friendafter += Math.Max( hp[i], 0 ); - friendbefore += Math.Max( (int)bdc.Data.api_nowhps_combined[i + 1], 0 ); - friendafter += Math.Max( hp[i + 12], 0 ); - enemybefore += Math.Max( (int)bdc.Data.api_nowhps[i + 7], 0 ); - enemyafter += Math.Max( hp[i + 6], 0 ); + friendbefore += Math.Max( initialHPs[i], 0 ); + friendafter += Math.Max( resultHPs[i], 0 ); + friendbefore += Math.Max( initialHPs[i + 12], 0 ); + friendafter += Math.Max( resultHPs[i + 12], 0 ); + enemybefore += Math.Max( initialHPs[i + 6], 0 ); + enemyafter += Math.Max( resultHPs[i + 6], 0 ); } friendrate = ( (double)( friendbefore - friendafter ) / friendbefore ); @@ -961,13 +960,13 @@ private void SetDamageRateCombined( int[] hp, BattleData bd ) { //戦績判定 { - int countFriend = KCDatabase.Instance.Fleet[bdc.FleetIDFriend].Members.Count( v => v != -1 ); - int countFriendCombined = KCDatabase.Instance.Fleet[bdc.FleetIDFriendCombined].Members.Count( v => v != -1 ); - int countEnemy = ( bdc.EnemyFleetMembers.Skip( 1 ).Count( v => v != -1 ) ); - int sunkFriend = hp.Take( countFriend ).Count( v => v <= 0 ) + hp.Skip( 12 ).Take( countFriendCombined ).Count( v => v <= 0 ); - int sunkEnemy = hp.Skip( 6 ).Take( countEnemy ).Count( v => v <= 0 ); + int countFriend = bd.Initial.FriendFleet.Members.Count( v => v != -1 ); + int countFriendCombined = KCDatabase.Instance.Fleet[2].Members.Count( v => v != -1 ); + int countEnemy = ( bd.Initial.EnemyMembers.Count( v => v != -1 ) ); + int sunkFriend = resultHPs.Take( countFriend ).Count( v => v <= 0 ) + resultHPs.Skip( 12 ).Take( countFriendCombined ).Count( v => v <= 0 ); + int sunkEnemy = resultHPs.Skip( 6 ).Take( countEnemy ).Count( v => v <= 0 ); - int rank = GetWinRank( countFriend + countFriendCombined, countEnemy, sunkFriend, sunkEnemy, friendrate, enemyrate, hp[6] <= 0 ); + int rank = GetWinRank( countFriend + countFriendCombined, countEnemy, sunkFriend, sunkEnemy, friendrate, enemyrate, resultHPs[6] <= 0 ); WinRank.Text = Constants.GetWinRank( rank ); @@ -982,26 +981,17 @@ private void SetDamageRateCombined( int[] hp, BattleData bd ) { /// 戦闘開始前のHP。 /// 連合艦隊かどうか。 /// 戦闘データ。 - private void SetNightBattleEvent( int[] hp, bool isCombined, BattleData bd ) { + private void SetNightBattleEvent( PhaseNightBattle pd ) { - FleetData fleet = KCDatabase.Instance.Fleet[isCombined ? 2 : bd.FleetIDFriend]; + FleetData fleet = pd.FriendFleet; //味方探照灯判定 { - ShipData ship = null; - int index = -1; - for ( int i = 0; i < 6; i++ ) { - ShipData s = fleet.MembersWithoutEscaped[i]; - if ( s != null && - s.SlotInstanceMaster.Count( e => e != null && e.CategoryType == 29 ) > 0 && - hp[isCombined ? 12 + i : i] > 1 ) { - ship = s; - index = i; - break; - } - } + int index = pd.SearchlightIndexFriend; if ( index != -1 ) { + ShipData ship = fleet.MembersInstance[index]; + AirStage1Friend.Text = "#" + ( index + 1 ); AirStage1Friend.ImageAlign = ContentAlignment.MiddleLeft; AirStage1Friend.ImageIndex = (int)ResourceManager.EquipmentContent.Searchlight; @@ -1013,25 +1003,12 @@ private void SetNightBattleEvent( int[] hp, bool isCombined, BattleData bd ) { //敵探照灯判定 { - int index = -1; - for ( int i = 1; i < bd.EnemyFleetMembers.Count; i++ ) { - if ( bd.EnemyFleetMembers[i] == -1 ) continue; - if ( hp[i + 6 - 1] <= 1 ) continue; - - if ( ( (int[])bd.Data.api_eSlot[i - 1] ).Count( - id => KCDatabase.Instance.MasterEquipments.ContainsKey( id ) && - KCDatabase.Instance.MasterEquipments[id].CategoryType == 29 - ) > 0 ) { - index = i; - break; - } - } - + int index = pd.SearchlightIndexEnemy; if ( index != -1 ) { AirStage1Enemy.Text = "#" + ( index ); AirStage1Enemy.ImageAlign = ContentAlignment.MiddleLeft; AirStage1Enemy.ImageIndex = (int)ResourceManager.EquipmentContent.Searchlight; - ToolTipInfo.SetToolTip( AirStage1Enemy, "探照灯照射: " + KCDatabase.Instance.MasterShips[bd.EnemyFleetMembers[index]].NameWithClass ); + ToolTipInfo.SetToolTip( AirStage1Enemy, "探照灯照射: " + pd.SearchlightEnemyInstance.NameWithClass ); } else { ToolTipInfo.SetToolTip( AirStage1Enemy, null ); } @@ -1039,33 +1016,33 @@ private void SetNightBattleEvent( int[] hp, bool isCombined, BattleData bd ) { //夜間触接判定 - if ( (int)bd.Data.api_touch_plane[0] != -1 ) { + if ( pd.TouchAircraftFriend != -1 ) { SearchingFriend.Text = "夜間触接"; SearchingFriend.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane; SearchingFriend.ImageAlign = ContentAlignment.MiddleLeft; - ToolTipInfo.SetToolTip( SearchingFriend, "夜間触接中: " + KCDatabase.Instance.MasterEquipments[(int)bd.Data.api_touch_plane[0]].Name ); + ToolTipInfo.SetToolTip( SearchingFriend, "夜間触接中: " + KCDatabase.Instance.MasterEquipments[pd.TouchAircraftFriend].Name ); } else { ToolTipInfo.SetToolTip( SearchingFriend, null ); } - if ( (int)bd.Data.api_touch_plane[1] != -1 ) { + if ( pd.TouchAircraftEnemy != -1 ) { SearchingEnemy.Text = "夜間触接"; SearchingEnemy.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane; SearchingFriend.ImageAlign = ContentAlignment.MiddleLeft; - ToolTipInfo.SetToolTip( SearchingEnemy, "夜間触接中: " + KCDatabase.Instance.MasterEquipments[(int)bd.Data.api_touch_plane[1]].Name ); + ToolTipInfo.SetToolTip( SearchingEnemy, "夜間触接中: " + KCDatabase.Instance.MasterEquipments[pd.TouchAircraftEnemy].Name ); } else { ToolTipInfo.SetToolTip( SearchingEnemy, null ); } //照明弾投射判定 { - int index = (int)bd.Data.api_flare_pos[0]; + int index = pd.FlareIndexFriend; if ( index != -1 ) { - AirStage2Friend.Text = "#" + index; + AirStage2Friend.Text = "#" + ( index + 1 ); AirStage2Friend.ImageAlign = ContentAlignment.MiddleLeft; AirStage2Friend.ImageIndex = (int)ResourceManager.EquipmentContent.Flare; - ToolTipInfo.SetToolTip( AirStage2Friend, "照明弾投射: " + fleet.MembersInstance[index - 1].NameWithLevel ); + ToolTipInfo.SetToolTip( AirStage2Friend, "照明弾投射: " + fleet.MembersInstance[index].NameWithLevel ); } else { ToolTipInfo.SetToolTip( AirStage2Friend, null ); @@ -1073,13 +1050,13 @@ private void SetNightBattleEvent( int[] hp, bool isCombined, BattleData bd ) { } { - int index = (int)bd.Data.api_flare_pos[1]; + int index = pd.FlareIndexEnemy; if ( index != -1 ) { - AirStage2Enemy.Text = "#" + index; + AirStage2Enemy.Text = "#" + ( index + 1 ); AirStage2Enemy.ImageAlign = ContentAlignment.MiddleLeft; AirStage2Enemy.ImageIndex = (int)ResourceManager.EquipmentContent.Flare; - ToolTipInfo.SetToolTip( AirStage2Enemy, "照明弾投射: " + KCDatabase.Instance.MasterShips[bd.EnemyFleetMembers[index]].NameWithClass ); + ToolTipInfo.SetToolTip( AirStage2Enemy, "照明弾投射: " + pd.FlareEnemyInstance.NameWithClass ); } else { ToolTipInfo.SetToolTip( AirStage2Enemy, null ); } diff --git a/ElectronicObserver/Window/FormCompass.cs b/ElectronicObserver/Window/FormCompass.cs index bf6225805..de011580c 100644 --- a/ElectronicObserver/Window/FormCompass.cs +++ b/ElectronicObserver/Window/FormCompass.cs @@ -588,19 +588,23 @@ private void UpdateEnemyFleetInstant() { break; } - TextFormation.Text = Constants.GetFormationShort( (int)bd.Data.api_formation[1] ); + int[] enemies = bd.Initial.EnemyMembers; + int[][] slots = bd.Initial.EnemySlots; + int[] levels = bd.Initial.EnemyLevels; + int[][] parameters = bd.Initial.EnemyParameters; + + TextFormation.Text = Constants.GetFormationShort( (int)bd.Searching.FormationEnemy ); TextFormation.Visible = true; - TextAirSuperiority.Text = Calculator.GetAirSuperiority( ( (int[])bd.Data.api_ship_ke ).Skip( 1 ).ToArray(), (int[][])bd.Data.api_eSlot ).ToString(); + TextAirSuperiority.Text = Calculator.GetAirSuperiority( enemies, slots ).ToString(); TextAirSuperiority.Visible = true; TableEnemyMember.SuspendLayout(); for ( int i = 0; i < ControlMember.Length; i++ ) { - int shipID = (int)bd.Data.api_ship_ke[i + 1]; - ControlMember[i].Update( shipID, shipID != -1 ? (int[])bd.Data.api_eSlot[i] : null ); + int shipID = enemies[i]; + ControlMember[i].Update( shipID, shipID != -1 ? slots[i] : null ); if ( shipID != -1 ) - ControlMember[i].UpdateEquipmentToolTip( shipID, (int[])bd.Data.api_eSlot[i], (int)bd.Data.api_ship_lv[i + 1], - (int)bd.Data.api_eParam[i][0], (int)bd.Data.api_eParam[i][1], (int)bd.Data.api_eParam[i][2], (int)bd.Data.api_eParam[i][3] ); + ControlMember[i].UpdateEquipmentToolTip( shipID, slots[i], levels[i], parameters[i][0], parameters[i][1], parameters[i][2], parameters[i][3] ); } TableEnemyMember.ResumeLayout(); TableEnemyMember.Visible = true; diff --git a/ElectronicObserver/Window/FormHeadquarters.cs b/ElectronicObserver/Window/FormHeadquarters.cs index e4c5f8b0f..de887929e 100644 --- a/ElectronicObserver/Window/FormHeadquarters.cs +++ b/ElectronicObserver/Window/FormHeadquarters.cs @@ -163,17 +163,26 @@ void Updated( string apiname, dynamic data ) { //Fleet FlowPanelFleet.SuspendLayout(); - ShipCount.Text = string.Format( "{0}/{1}", db.Ships.Count, db.Admiral.MaxShipCount ); - if ( db.Ships.Count > db.Admiral.MaxShipCount - 5 ) - ShipCount.BackColor = Color.LightCoral; - else - ShipCount.BackColor = Color.Transparent; - - EquipmentCount.Text = string.Format( "{0}/{1}", db.Equipments.Count, db.Admiral.MaxEquipmentCount ); - if ( db.Equipments.Count > db.Admiral.MaxEquipmentCount + 3 - 20 ) - EquipmentCount.BackColor = Color.LightCoral; - else - EquipmentCount.BackColor = Color.Transparent; + { + int dropShips = 0; + int dropEqps = 0; + if ( db.Battle != null ) { + dropShips = db.Battle.DroppedShipCount; + dropEqps = db.Battle.DroppedEquipmentCount; + } + + ShipCount.Text = string.Format( "{0}/{1}", db.Ships.Count + dropShips, db.Admiral.MaxShipCount ); + if ( db.Ships.Count > db.Admiral.MaxShipCount - 5 ) + ShipCount.BackColor = Color.LightCoral; + else + ShipCount.BackColor = Color.Transparent; + + EquipmentCount.Text = string.Format( "{0}/{1}", db.Equipments.Count + dropEqps, db.Admiral.MaxEquipmentCount ); + if ( db.Equipments.Count > db.Admiral.MaxEquipmentCount + 3 - 20 ) + EquipmentCount.BackColor = Color.LightCoral; + else + EquipmentCount.BackColor = Color.Transparent; + } FlowPanelFleet.ResumeLayout(); //UseItems diff --git a/ElectronicObserver/Window/FormMain.cs b/ElectronicObserver/Window/FormMain.cs index d8e04316a..a7e0e0276 100644 --- a/ElectronicObserver/Window/FormMain.cs +++ b/ElectronicObserver/Window/FormMain.cs @@ -170,6 +170,7 @@ private void ConfigurationChanged() { private void StripMenu_Debug_LoadAPIFromFile_Click( object sender, EventArgs e ) { + /*/ using ( var dialog = new DialogLocalAPILoader() ) { if ( dialog.ShowDialog( this ) == System.Windows.Forms.DialogResult.OK ) { @@ -185,7 +186,9 @@ private void StripMenu_Debug_LoadAPIFromFile_Click( object sender, EventArgs e ) } } } - + /*/ + new DialogLocalAPILoader2().Show( this ); + //*/ } diff --git a/ElectronicObserver/Window/FormShipGroup.Designer.cs b/ElectronicObserver/Window/FormShipGroup.Designer.cs index bb47aae63..4beaa34b9 100644 --- a/ElectronicObserver/Window/FormShipGroup.Designer.cs +++ b/ElectronicObserver/Window/FormShipGroup.Designer.cs @@ -68,8 +68,8 @@ private void InitializeComponent() { this.ShipView_SallyArea = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.MenuMember = new System.Windows.Forms.ContextMenuStrip(this.components); this.MenuMember_AddToGroup = new System.Windows.Forms.ToolStripMenuItem(); - this.MenuMember_AddCurrentFleet_Group = new System.Windows.Forms.ToolStripMenuItem(); this.MenuMember_CreateGroup = new System.Windows.Forms.ToolStripMenuItem(); + this.MenuMember_AddCurrentFleet_Group = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.MenuMember_ColumnFilter = new System.Windows.Forms.ToolStripMenuItem(); this.MenuMember_ColumnAutoSize = new System.Windows.Forms.ToolStripMenuItem(); @@ -157,7 +157,7 @@ private void InitializeComponent() { this.ShipView.ReadOnly = true; this.ShipView.RowHeadersVisible = false; this.ShipView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.ShipView.Size = new System.Drawing.Size(300, 134); + this.ShipView.Size = new System.Drawing.Size(300, 118); this.ShipView.TabIndex = 0; this.ShipView.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.ShipView_CellFormatting); this.ShipView.SortCompare += new System.Windows.Forms.DataGridViewSortCompareEventHandler(this.ShipView_SortCompare); @@ -430,41 +430,41 @@ private void InitializeComponent() { this.toolStripSeparator3, this.MenuMember_Delete}); this.MenuMember.Name = "MenuMember"; - this.MenuMember.Size = new System.Drawing.Size(300, 220); + this.MenuMember.Size = new System.Drawing.Size(502, 294); this.MenuMember.Opening += new System.ComponentModel.CancelEventHandler(this.MenuMember_Opening); // // MenuMember_AddToGroup // this.MenuMember_AddToGroup.Name = "MenuMember_AddToGroup"; this.MenuMember_AddToGroup.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D))); - this.MenuMember_AddToGroup.Size = new System.Drawing.Size(299, 22); + this.MenuMember_AddToGroup.Size = new System.Drawing.Size(501, 34); this.MenuMember_AddToGroup.Text = "グループへ追加(&A)..."; this.MenuMember_AddToGroup.Click += new System.EventHandler(this.MenuMember_AddToGroup_Click); // - // MenuMember_AddCurrentFleet_Group - // - this.MenuMember_AddCurrentFleet_Group.Name = "MenuMember_AddCurrentFleet_Group"; - this.MenuMember_AddCurrentFleet_Group.Size = new System.Drawing.Size(299, 22); - this.MenuMember_AddCurrentFleet_Group.Text = "現在の艦隊を追加(&G)"; - // // MenuMember_CreateGroup // this.MenuMember_CreateGroup.Name = "MenuMember_CreateGroup"; this.MenuMember_CreateGroup.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) | System.Windows.Forms.Keys.D))); - this.MenuMember_CreateGroup.Size = new System.Drawing.Size(299, 22); + this.MenuMember_CreateGroup.Size = new System.Drawing.Size(501, 34); this.MenuMember_CreateGroup.Text = "新規グループを作成(&C)..."; this.MenuMember_CreateGroup.Click += new System.EventHandler(this.MenuMember_CreateGroup_Click); // + // MenuMember_AddCurrentFleet_Group + // + this.MenuMember_AddCurrentFleet_Group.Name = "MenuMember_AddCurrentFleet_Group"; + this.MenuMember_AddCurrentFleet_Group.Size = new System.Drawing.Size(501, 34); + this.MenuMember_AddCurrentFleet_Group.Text = "現在の艦隊を追加(&G)"; + // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(296, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(498, 6); // // MenuMember_ColumnFilter // this.MenuMember_ColumnFilter.Name = "MenuMember_ColumnFilter"; - this.MenuMember_ColumnFilter.Size = new System.Drawing.Size(299, 22); + this.MenuMember_ColumnFilter.Size = new System.Drawing.Size(501, 34); this.MenuMember_ColumnFilter.Text = "列フィルタ(&F)..."; this.MenuMember_ColumnFilter.Click += new System.EventHandler(this.MenuMember_ColumnFilter_Click); // @@ -472,7 +472,7 @@ private void InitializeComponent() { // this.MenuMember_ColumnAutoSize.CheckOnClick = true; this.MenuMember_ColumnAutoSize.Name = "MenuMember_ColumnAutoSize"; - this.MenuMember_ColumnAutoSize.Size = new System.Drawing.Size(299, 22); + this.MenuMember_ColumnAutoSize.Size = new System.Drawing.Size(501, 34); this.MenuMember_ColumnAutoSize.Text = "列の自動調整(&D)"; this.MenuMember_ColumnAutoSize.Click += new System.EventHandler(this.MenuMember_ColumnAutoSize_Click); // @@ -480,32 +480,32 @@ private void InitializeComponent() { // this.MenuMember_LockShipNameScroll.CheckOnClick = true; this.MenuMember_LockShipNameScroll.Name = "MenuMember_LockShipNameScroll"; - this.MenuMember_LockShipNameScroll.Size = new System.Drawing.Size(299, 22); + this.MenuMember_LockShipNameScroll.Size = new System.Drawing.Size(501, 34); this.MenuMember_LockShipNameScroll.Text = "艦名をスクロールしない(&S)"; this.MenuMember_LockShipNameScroll.Click += new System.EventHandler(this.MenuMember_LockShipNameScroll_Click); // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(296, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(498, 6); // // MenuMember_CSVOutput // this.MenuMember_CSVOutput.Name = "MenuMember_CSVOutput"; - this.MenuMember_CSVOutput.Size = new System.Drawing.Size(299, 22); + this.MenuMember_CSVOutput.Size = new System.Drawing.Size(501, 34); this.MenuMember_CSVOutput.Text = "CSV出力(&O)..."; this.MenuMember_CSVOutput.Click += new System.EventHandler(this.MenuMember_CSVOutput_Click); // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(296, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(498, 6); // // MenuMember_Delete // this.MenuMember_Delete.Name = "MenuMember_Delete"; this.MenuMember_Delete.ShortcutKeys = System.Windows.Forms.Keys.Delete; - this.MenuMember_Delete.Size = new System.Drawing.Size(299, 22); + this.MenuMember_Delete.Size = new System.Drawing.Size(501, 34); this.MenuMember_Delete.Text = "削除(&D)"; this.MenuMember_Delete.Click += new System.EventHandler(this.MenuMember_Delete_Click); // @@ -519,40 +519,40 @@ private void InitializeComponent() { this.MenuGroup_AutoUpdate, this.MenuGroup_ShowStatusBar}); this.MenuGroup.Name = "MenuGroup"; - this.MenuGroup.Size = new System.Drawing.Size(221, 120); + this.MenuGroup.Size = new System.Drawing.Size(322, 200); this.MenuGroup.Opening += new System.ComponentModel.CancelEventHandler(this.MenuGroup_Opening); // // MenuGroup_Add // this.MenuGroup_Add.Name = "MenuGroup_Add"; - this.MenuGroup_Add.Size = new System.Drawing.Size(220, 22); + this.MenuGroup_Add.Size = new System.Drawing.Size(321, 38); this.MenuGroup_Add.Text = "グループを追加(&A)"; this.MenuGroup_Add.Click += new System.EventHandler(this.MenuGroup_Add_Click); // // MenuGroup_Rename // this.MenuGroup_Rename.Name = "MenuGroup_Rename"; - this.MenuGroup_Rename.Size = new System.Drawing.Size(220, 22); + this.MenuGroup_Rename.Size = new System.Drawing.Size(321, 38); this.MenuGroup_Rename.Text = "グループ名の変更(&R)..."; this.MenuGroup_Rename.Click += new System.EventHandler(this.MenuGroup_Rename_Click); // // MenuGroup_Delete // this.MenuGroup_Delete.Name = "MenuGroup_Delete"; - this.MenuGroup_Delete.Size = new System.Drawing.Size(220, 22); + this.MenuGroup_Delete.Size = new System.Drawing.Size(321, 38); this.MenuGroup_Delete.Text = "グループを削除(&D)"; this.MenuGroup_Delete.Click += new System.EventHandler(this.MenuGroup_Delete_Click); // // toolStripSeparator4 // this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(217, 6); + this.toolStripSeparator4.Size = new System.Drawing.Size(318, 6); // // MenuGroup_AutoUpdate // this.MenuGroup_AutoUpdate.CheckOnClick = true; this.MenuGroup_AutoUpdate.Name = "MenuGroup_AutoUpdate"; - this.MenuGroup_AutoUpdate.Size = new System.Drawing.Size(220, 22); + this.MenuGroup_AutoUpdate.Size = new System.Drawing.Size(321, 38); this.MenuGroup_AutoUpdate.Text = "自動更新する"; // // MenuGroup_ShowStatusBar @@ -561,7 +561,7 @@ private void InitializeComponent() { this.MenuGroup_ShowStatusBar.CheckOnClick = true; this.MenuGroup_ShowStatusBar.CheckState = System.Windows.Forms.CheckState.Checked; this.MenuGroup_ShowStatusBar.Name = "MenuGroup_ShowStatusBar"; - this.MenuGroup_ShowStatusBar.Size = new System.Drawing.Size(220, 22); + this.MenuGroup_ShowStatusBar.Size = new System.Drawing.Size(321, 38); this.MenuGroup_ShowStatusBar.Text = "ステータスバーを表示する"; this.MenuGroup_ShowStatusBar.CheckedChanged += new System.EventHandler(this.MenuGroup_ShowStatusBar_CheckedChanged); // @@ -587,6 +587,7 @@ private void InitializeComponent() { // // TabPanel // + this.TabPanel.AllowDrop = true; this.TabPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); @@ -607,9 +608,9 @@ private void InitializeComponent() { this.Status_ShipCount, this.Status_LevelTotal, this.Status_LevelAverage}); - this.StatusBar.Location = new System.Drawing.Point(0, 134); + this.StatusBar.Location = new System.Drawing.Point(0, 118); this.StatusBar.Name = "StatusBar"; - this.StatusBar.Size = new System.Drawing.Size(300, 22); + this.StatusBar.Size = new System.Drawing.Size(300, 38); this.StatusBar.SizingGrip = false; this.StatusBar.TabIndex = 1; this.StatusBar.Text = "statusStrip1"; @@ -617,17 +618,17 @@ private void InitializeComponent() { // Status_ShipCount // this.Status_ShipCount.Name = "Status_ShipCount"; - this.Status_ShipCount.Size = new System.Drawing.Size(0, 17); + this.Status_ShipCount.Size = new System.Drawing.Size(0, 33); // // Status_LevelTotal // this.Status_LevelTotal.Name = "Status_LevelTotal"; - this.Status_LevelTotal.Size = new System.Drawing.Size(0, 17); + this.Status_LevelTotal.Size = new System.Drawing.Size(0, 33); // // Status_LevelAverage // this.Status_LevelAverage.Name = "Status_LevelAverage"; - this.Status_LevelAverage.Size = new System.Drawing.Size(0, 17); + this.Status_LevelAverage.Size = new System.Drawing.Size(0, 33); // // FormShipGroup // diff --git a/ElectronicObserver/Window/FormShipGroup.cs b/ElectronicObserver/Window/FormShipGroup.cs index 63d1788f8..b02ea5439 100644 --- a/ElectronicObserver/Window/FormShipGroup.cs +++ b/ElectronicObserver/Window/FormShipGroup.cs @@ -46,6 +46,8 @@ public partial class FormShipGroup : DockContent { /// 選択中のタブ private ImageLabel SelectedTab = null; + /// 艦これ起動前にタブを選択した場合はtrue + private bool IsTabSelectedBeforeBoot = false; public FormShipGroup( FormMain parent ) { InitializeComponent(); @@ -226,7 +228,13 @@ void TabLabel_Click( object sender, EventArgs e ) { } private void APIUpdated( string apiname, dynamic data ) { - if ( MenuGroup_AutoUpdate.Checked ) + if ( IsTabSelectedBeforeBoot ) { + // 空のShipViewでKCDatabase.Instance.ShipGroupを上書きしてしまうのを防ぐため、 + // 艦これ起動前にタブを選択した後の最初の艦船データ受信時は、ShipViewの構築を行う + BuildShipView( SelectedTab ); + IsTabSelectedBeforeBoot = false; + + } else if ( MenuGroup_AutoUpdate.Checked ) ChangeShipView( SelectedTab ); } @@ -459,7 +467,12 @@ private void ChangeShipView( ImageLabel target ) { if ( SelectedTab != null ) SelectedTab.BackColor = TabInactiveColor; + SelectedTab = target; + // 艦これ起動前にタブを選択した場合はフラグを立てておく(APIUpdatedで使う) + if ( KCDatabase.Instance.Ships.Count == 0 ) + IsTabSelectedBeforeBoot = true; + BuildShipView( SelectedTab ); SelectedTab.BackColor = TabActiveColor; diff --git a/ElectronicObserver/Window/FormShipGroup.resx b/ElectronicObserver/Window/FormShipGroup.resx index ae1c08a05..628ea8877 100644 --- a/ElectronicObserver/Window/FormShipGroup.resx +++ b/ElectronicObserver/Window/FormShipGroup.resx @@ -217,7 +217,7 @@ True - 138, 17 + 132, 17 17, 17 diff --git a/README.md b/README.md index 6f52d258c..af6730dba 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ *このリンクの更新は遅れる可能性があります。最新版は[こちら](http://electronicobserver.blog.fc2.com/)で確認してください。* -[ver. 1.2.6 (2015/05/18)](http://bit.ly/1HpDM2i) +[ver. 1.3.0 (2015/05/26)](http://bit.ly/1HsatH4) 更新内容・履歴は[こちら](https://github.com/andanteyk/ElectronicObserver/wiki/ChangeLog)で確認できます。