Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
andanteyk committed May 25, 2015
2 parents 0e903a7 + 15ecf61 commit 8e65daf
Show file tree
Hide file tree
Showing 49 changed files with 2,201 additions and 1,484 deletions.
2 changes: 1 addition & 1 deletion ElectronicObserver/Data/APIWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ElectronicObserver.Data {
/// </summary>
public abstract class APIWrapper : ResponseWrapper {

protected Dictionary<string, string> RequestData { get; private set; }
public Dictionary<string, string> RequestData { get; private set; }


public APIWrapper()
Expand Down
91 changes: 15 additions & 76 deletions ElectronicObserver/Data/Battle/BattleAirBattle.cs
Original file line number Diff line number Diff line change
@@ -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<int, int> 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<int, int> 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] );
}
}

/// <summary>
/// 通常艦隊航空戦
/// </summary>
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 );

}

Expand Down
103 changes: 15 additions & 88 deletions ElectronicObserver/Data/Battle/BattleCombinedAirBattle.cs
Original file line number Diff line number Diff line change
@@ -1,100 +1,34 @@
using System;
using ElectronicObserver.Data.Battle.Phase;
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 class BattleCombinedAirBattle : BattleDataCombined {

public override int[] EmulateBattle() {
/// <summary>
/// 連合艦隊航空戦
/// </summary>
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<int, int> 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<int, int> DealDamageEnemy = ( int index, int damage ) => {
//if ( hp[index + 6] == -1 ) return;
hp[index + 6] -= Math.Max( damage, 0 );
};

Action<int, int> 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"; }
}
Expand All @@ -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; }
}
}

}
88 changes: 10 additions & 78 deletions ElectronicObserver/Data/Battle/BattleCombinedNightOnly.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using ElectronicObserver.Data.Battle.Phase;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
Expand All @@ -7,83 +8,21 @@

namespace ElectronicObserver.Data.Battle {

public class BattleCombinedNightOnly : BattleDataCombined {
/// <summary>
/// 連合艦隊開幕夜戦
/// </summary>
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<int, int> 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<int, int> DealDamageEnemy = ( int index, int damage ) => {
//if ( hp[index + 6] == -1 ) return;
hp[index + 6] -= Math.Max( damage, 0 );
};

Action<int, int> 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"; }
Expand All @@ -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; }
}
}

}
Loading

0 comments on commit 8e65daf

Please sign in to comment.