Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
andanteyk committed Apr 11, 2015
2 parents cd577bf + 76236ff commit d4ad747
Show file tree
Hide file tree
Showing 30 changed files with 759 additions and 209 deletions.
99 changes: 99 additions & 0 deletions ElectronicObserver/Data/Battle/BattleAirBattle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
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] );
}
}


//*/ //今のところ未実装だけど念のため
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] );
}
}

//支援艦隊(砲雷撃)
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] );
}
}

return hp;

}

public override string APIName {
get { return "api_req_sortie/airbattle"; }
}

public override BattleData.BattleTypeFlag BattleType {
get { return BattleTypeFlag.Day; }
}
}
}
6 changes: 6 additions & 0 deletions ElectronicObserver/Data/Battle/BattleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ public override void LoadFromResponse( string apiname, dynamic data ) {
BattleNight.LoadFromResponse( apiname, data );
break;

case "api_req_sortie/airbattle":
BattleMode = BattleModes.AirBattle;
BattleDay = new BattleAirBattle();
BattleDay.LoadFromResponse( apiname, data );
break;

case "api_req_combined_battle/battle":
BattleMode = BattleModes.Normal | BattleModes.CombinedTaskForce;
BattleDay = new BattleCombinedNormalDay();
Expand Down
2 changes: 1 addition & 1 deletion ElectronicObserver/Data/Battle/BattleNormalDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ElectronicObserver.Data.Battle {

public class BattleNormalDay : BattleData {


public override int[] EmulateBattle() {

int[] hp = new int[12];
Expand Down
42 changes: 40 additions & 2 deletions ElectronicObserver/Data/CompassData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ public int Destination {
get { return (int)RawData.api_no; }
}

/// <summary>
/// 次のセルのグラフィック
/// </summary>
public int ColorID {
get { return (int)RawData.api_color_no; }
}

/// <summary>
/// イベントID
/// 0=初期位置, 2=資源, 3=渦潮, 4=通常戦闘, 5=ボス戦闘, 6=気のせいだった, 7=連合艦隊航空戦
/// 0=初期位置, 2=資源, 3=渦潮, 4=通常戦闘, 5=ボス戦闘, 6=気のせいだった, 7=航空戦, 8=船団護衛成功
/// </summary>
public int EventID {
get { return (int)RawData.api_event_id; }
Expand Down Expand Up @@ -62,6 +69,31 @@ public bool IsEndPoint {
get { return NextBranchCount == 0; }
}

/// <summary>
/// 吹き出しの内容
/// 0=なし, 1="敵艦隊発見!", 2="攻撃目標発見!"
/// </summary>
public int CommentID {
get {
if ( RawData.api_comment_kind() ) //startには存在しないため
return (int)RawData.api_comment_kind;
else
return 0;
}
}

/// <summary>
/// 索敵に成功したか 0=失敗, 1=成功(索敵機発艦)
/// </summary>
public int LaunchedRecon {
get {
if ( RawData.api_production_kind() )
return (int)RawData.api_production_kind;
else
return 0;
}
}


/// <summary>
/// 交戦する敵艦隊ID
Expand All @@ -83,7 +115,9 @@ public int GetItemID {
get {
if ( RawData.api_itemget() ) {
return (int)RawData.api_itemget.api_usemst;
} else {
} else if ( RawData.api_itemget_eo_comment() ) {
return (int)RawData.api_itemget_eo_comment.api_usemst;
} else {
return -1;
}
}
Expand All @@ -97,6 +131,8 @@ public int GetItemIDMetadata {
get {
if ( RawData.api_itemget() ) {
return (int)RawData.api_itemget.api_id;
} else if ( RawData.api_itemget_eo_comment() ) {
return (int)RawData.api_itemget_eo_comment.api_id;
} else {
return 0;
}
Expand All @@ -110,6 +146,8 @@ public int GetItemAmount {
get {
if ( RawData.api_itemget() ) {
return (int)RawData.api_itemget.api_getcount;
} else if ( RawData.api_itemget_eo_comment() ) {
return (int)RawData.api_itemget_eo_comment.api_getcount;
} else {
return 0;
}
Expand Down
4 changes: 3 additions & 1 deletion ElectronicObserver/Data/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ public static string GetMapEventID( int value ) {
case 6:
return "気のせいだった";
case 7:
return "機動部隊航空戦";
return "航空戦";
case 8:
return "船団護衛成功";
default:
return "不明";
}
Expand Down
4 changes: 2 additions & 2 deletions ElectronicObserver/Data/DockData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public override void LoadFromResponse( string apiname, dynamic data ) {
} break;
}


}


Expand All @@ -81,7 +81,7 @@ public override string ToString() {
case 0:
sb.Append( "<Empty>" ); break;
case 1:
sb.Append( KCDatabase.Instance.MasterShips[ShipID].Name + ", at " + CompletionTime.ToString() ); break;
sb.Append( KCDatabase.Instance.Ships[ShipID].MasterShip.Name + ", at " + CompletionTime.ToString() ); break;
}

return sb.ToString();
Expand Down
24 changes: 19 additions & 5 deletions ElectronicObserver/Data/FleetData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public override void LoadFromRequest( string apiname, Dictionary<string, string>
}
}


}


Expand All @@ -236,7 +236,7 @@ public override void LoadFromRequest( string apiname, Dictionary<string, string>
_members[i] = replacedID;
else
RemoveShip( i );

break;
}
}
Expand Down Expand Up @@ -404,20 +404,34 @@ public double GetSearchingAbility() {

case 1:
return Calculator.GetSearchingAbility_Autumn( this );

case 2:
return Calculator.GetSearchingAbility_TinyAutumn( this );
}
}

/// <summary>
/// 現在の設定に応じて、索敵能力を表す文字列を取得します。
/// </summary>
public string GetSearchingAbilityString() {
switch ( Utility.Configuration.Config.FormFleet.SearchingAbilityMethod ) {
return this.GetSearchingAbilityString( Utility.Configuration.Config.FormFleet.SearchingAbilityMethod );
}

/// <summary>
/// 指定の計算式で、索敵能力を表す文字列を取得します。
/// </summary>
/// <param name="index">計算式。0-2</param>
public string GetSearchingAbilityString( int index ) {
switch ( index ) {
default:
case 0:
return Calculator.GetSearchingAbility_Old( this ).ToString();

case 1:
return Calculator.GetSearchingAbility_Autumn( this ).ToString( "F1" );

case 2:
return Calculator.GetSearchingAbility_TinyAutumn( this ).ToString();
}
}

Expand Down Expand Up @@ -473,14 +487,14 @@ public static FleetStates UpdateFleetState( FleetData fleet, ImageLabel label, T
long ntime = db.Docks.Values.Max(
dock => {
if ( dock.State == 1 && fleet.Members.Count( ( id => id == dock.ShipID ) ) > 0 )
return dock.CompletionTime.ToBinary();
return dock.CompletionTime.Ticks;
else return 0;
}
);

if ( ntime > 0 ) { //入渠中

timer = DateTime.FromBinary( ntime );
timer = new DateTime( ntime );
label.Text = "入渠中 " + DateTimeHelper.ToTimeRemainString( timer );
label.ImageIndex = (int)ResourceManager.IconContent.FleetDocking;

Expand Down
2 changes: 2 additions & 0 deletions ElectronicObserver/ElectronicObserver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<ItemGroup>
<Compile Include="Data\AdmiralData.cs" />
<Compile Include="Data\ArsenalData.cs" />
<Compile Include="Data\Battle\BattleAirBattle.cs" />
<Compile Include="Data\Battle\BattleCombinedAirBattle.cs" />
<Compile Include="Data\Battle\BattleCombinedNightOnly.cs" />
<Compile Include="Data\Battle\BattleCombinedNormalDay.cs" />
Expand Down Expand Up @@ -147,6 +148,7 @@
<Compile Include="Observer\kcsapi\api_get_member\material.cs" />
<Compile Include="Observer\kcsapi\api_req_mission\result.cs" />
<Compile Include="Observer\kcsapi\api_req_ranking\getlist.cs" />
<Compile Include="Observer\kcsapi\api_req_sortie\airbattle.cs" />
<Compile Include="Resource\Record\ResourceRecord.cs" />
<Compile Include="Utility\PathHelper.cs" />
<Compile Include="Utility\Storage\DataStorage.cs" />
Expand Down
1 change: 1 addition & 0 deletions ElectronicObserver/Notifier/NotifierDamage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ private void Initialize() {
o["api_req_sortie/battle"].ResponseReceived += BattleStarted;
o["api_req_battle_midnight/battle"].ResponseReceived += BattleStarted;
o["api_req_battle_midnight/sp_midnight"].ResponseReceived += BattleStarted;
o["api_req_sortie/airbattle"].ResponseReceived += BattleStarted;
o["api_req_combined_battle/battle"].ResponseReceived += BattleStarted;
o["api_req_combined_battle/battle_water"].ResponseReceived += BattleStarted;
o["api_req_combined_battle/airbattle"].ResponseReceived += BattleStarted;
Expand Down
1 change: 1 addition & 0 deletions ElectronicObserver/Observer/APIObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private APIObserver() {
APIList.Add( new kcsapi.api_get_member.material() );
APIList.Add( new kcsapi.api_req_mission.result() );
APIList.Add( new kcsapi.api_req_ranking.getlist() );
APIList.Add( new kcsapi.api_req_sortie.airbattle() );

APIList.Add( new kcsapi.api_req_quest.clearitemget() );
APIList.Add( new kcsapi.api_req_nyukyo.start() );
Expand Down
25 changes: 25 additions & 0 deletions ElectronicObserver/Observer/kcsapi/api_req_sortie/airbattle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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_sortie {

public class airbattle : APIBase {

public override void OnResponseReceived( dynamic data ) {

KCDatabase.Instance.Battle.LoadFromResponse( APIName, data );


base.OnResponseReceived( (object)data );
}

public override string APIName {
get { return "api_req_sortie/airbattle"; }
}

}
}
Loading

0 comments on commit d4ad747

Please sign in to comment.