Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
andanteyk committed Aug 7, 2017
2 parents 2470267 + 90be613 commit 539dd04
Show file tree
Hide file tree
Showing 39 changed files with 1,234 additions and 744 deletions.
2 changes: 1 addition & 1 deletion Browser/FormBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ private void ToolMenu_Other_LastScreenShot_CopyToClipboard_Click( object sender,
}
} catch ( Exception ex ) {
BrowserHost.AsyncRemoteRun( () =>
BrowserHost.Proxy.SendErrorReport( ex.ToString(), "スクリーンショットのクリップボードへのコピーに失敗しました。" ) );
BrowserHost.Proxy.SendErrorReport( ex.Message, "スクリーンショットのクリップボードへのコピーに失敗しました。" ) );
}
}
}
Expand Down
Binary file modified ElectronicObserver/Assets.zip
Binary file not shown.
Binary file modified ElectronicObserver/Assets/Fleet/AnchorageRepairing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 28 additions & 10 deletions ElectronicObserver/Data/Battle/Detail/BattleDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ namespace ElectronicObserver.Data.Battle.Detail {
/// </summary>
public abstract class BattleDetail {

public double[] RawDamages { get; protected set; }
public int[] Damages { get; protected set; }
public bool[] GuardsFlagship { get; protected set; }
public CriticalType[] CriticalTypes { get; protected set; }
public int AttackType { get; protected set; }
public int[] EquipmentIDs { get; protected set; }
public int DefenderHP { get; protected set; }

public ShipDataMaster Attacker { get; protected set; }
Expand Down Expand Up @@ -42,13 +45,16 @@ public enum CriticalType {
/// <param name="criticalTypes">命中判定の配列。</param>
/// <param name="attackType">攻撃種別。</param>
/// <param name="defenderHP">防御側の攻撃を受ける直前のHP。</param>
public BattleDetail( BattleData bd, int attackerIndex, int defenderIndex, int[] damages, int[] criticalTypes, int attackType, int defenderHP ) {
public BattleDetail( BattleData bd, int attackerIndex, int defenderIndex, double[] damages, int[] criticalTypes, int attackType, int[] equipmentIDs, int defenderHP ) {

AttackerIndex = attackerIndex;
DefenderIndex = defenderIndex;
Damages = damages;
RawDamages = damages;
Damages = damages.Select( dmg => (int)dmg ).ToArray();
GuardsFlagship = damages.Select( dmg => dmg != Math.Floor( dmg ) ).ToArray();
CriticalTypes = criticalTypes.Select( i => (CriticalType)i ).ToArray();
AttackType = attackType;
EquipmentIDs = equipmentIDs;
DefenderHP = defenderHP;

int[] slots;
Expand Down Expand Up @@ -107,13 +113,24 @@ public override string ToString() {
if ( AttackType >= 0 )
builder.Append( "[" ).Append( GetAttackKind() ).Append( "] " );

/*// it may be useless
if ( EquipmentIDs != null ) {
var eqs = EquipmentIDs.Select( id => KCDatabase.Instance.MasterEquipments[id] ).Where( eq => eq != null ).Select( eq => eq.Name );
if ( eqs.Any() )
builder.Append( "(" ).Append( string.Join( ", ", eqs ) ).Append( ") " );
}
//*/

for ( int i = 0; i < Damages.Length; i++ ) {
if ( CriticalTypes[i] == CriticalType.Invalid ) // カットイン(主砲/主砲)、カットイン(主砲/副砲)時に発生する
continue;

if ( i > 0 )
builder.Append( " , " );

if ( GuardsFlagship[i] )
builder.Append( "<かばう> " );

switch ( CriticalTypes[i] ) {
case CriticalType.Miss:
builder.Append( "Miss" );
Expand All @@ -125,6 +142,7 @@ public override string ToString() {
builder.Append( Damages[i] ).Append( " Critical!" );
break;
}

}

{
Expand Down Expand Up @@ -175,8 +193,8 @@ protected virtual string GetDefenderName() {
/// </summary>
public class BattleDayDetail : BattleDetail {

public BattleDayDetail( BattleData bd, int attackerId, int defenderId, int[] damages, int[] criticalTypes, int attackType, int defenderHP )
: base( bd, attackerId, defenderId, damages, criticalTypes, attackType, defenderHP ) {
public BattleDayDetail( BattleData bd, int attackerId, int defenderId, double[] damages, int[] criticalTypes, int attackType, int[] equipmentIDs, int defenderHP )
: base( bd, attackerId, defenderId, damages, criticalTypes, attackType, equipmentIDs, defenderHP ) {
}

protected override int CaclulateAttackKind( int[] slots, int attackerShipID, int defenderShipID ) {
Expand All @@ -193,8 +211,8 @@ protected override string GetAttackKind() {
/// </summary>
public class BattleSupportDetail : BattleDetail {

public BattleSupportDetail( BattleData bd, int defenderId, int damage, int criticalType, int attackType, int defenderHP )
: base( bd, -1, defenderId, new int[] { damage }, new int[] { criticalType }, attackType, defenderHP ) {
public BattleSupportDetail( BattleData bd, int defenderId, double damage, int criticalType, int attackType, int defenderHP )
: base( bd, -1, defenderId, new double[] { damage }, new int[] { criticalType }, attackType, null, defenderHP ) {
}

protected override string GetAttackerName() {
Expand Down Expand Up @@ -225,8 +243,8 @@ protected override string GetAttackKind() {
/// </summary>
public class BattleNightDetail : BattleDetail {

public BattleNightDetail( BattleData bd, int attackerId, int defenderId, int[] damages, int[] criticalTypes, int attackType, int defenderHP )
: base( bd, attackerId, defenderId, damages, criticalTypes, attackType, defenderHP ) {
public BattleNightDetail( BattleData bd, int attackerId, int defenderId, double[] damages, int[] criticalTypes, int attackType, int[] equipmentIDs, int defenderHP )
: base( bd, attackerId, defenderId, damages, criticalTypes, attackType, equipmentIDs, defenderHP ) {
}

protected override int CaclulateAttackKind( int[] slots, int attackerShipID, int defenderShipID ) {
Expand All @@ -245,8 +263,8 @@ public class BattleAirDetail : BattleDayDetail {

public int WaveIndex { get; protected set; }

public BattleAirDetail( BattleData bd, int waveIndex, int defenderId, int damage, int criticalType, int attackType, int defenderHP )
: base( bd, -1, defenderId, new int[] { damage }, new int[] { criticalType }, attackType, defenderHP ) {
public BattleAirDetail( BattleData bd, int waveIndex, int defenderId, double damage, int criticalType, int attackType, int defenderHP )
: base( bd, -1, defenderId, new double[] { damage }, new int[] { criticalType }, attackType, null, defenderHP ) {
WaveIndex = waveIndex;
}

Expand Down
10 changes: 5 additions & 5 deletions ElectronicObserver/Data/Battle/Phase/PhaseAirBattle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public PhaseAirBattle( BattleData data, string title, string suffix = "" )
LaunchedShipIndexFriend = GetLaunchedShipIndex( 0 );
LaunchedShipIndexEnemy = GetLaunchedShipIndex( 1 );

TorpedoFlags = ConcatStage3Array( "api_frai_flag", "api_erai_flag" );
BomberFlags = ConcatStage3Array( "api_fbak_flag", "api_ebak_flag" );
Criticals = ConcatStage3Array( "api_fcl_flag", "api_ecl_flag" );
Damages = ConcatStage3Array( "api_fdam", "api_edam" );
TorpedoFlags = ConcatStage3Array<int>( "api_frai_flag", "api_erai_flag" );
BomberFlags = ConcatStage3Array<int>( "api_fbak_flag", "api_ebak_flag" );
Criticals = ConcatStage3Array<int>( "api_fcl_flag", "api_ecl_flag" );
Damages = ConcatStage3Array<double>( "api_fdam", "api_edam" );
}


Expand Down Expand Up @@ -84,7 +84,7 @@ private void CalculateAttackDamage( int[] damages ) {
}

int totalFirepower = firepower.Sum();
int totalDamage = Damages.Skip( 6 ).Take( 6 ).Sum() + damages.Skip( 18 ).Take( 6 ).Sum();
int totalDamage = Damages.Select( dmg => (int)dmg ).Skip( 6 ).Take( 6 ).Sum() + damages.Skip( 18 ).Take( 6 ).Sum();

for ( int i = 0; i < firepower.Length; i++ ) {
damages[( i < 6 ? i : ( i + 6 ) )] += (int)Math.Round( (double)totalDamage * firepower[i] / Math.Max( totalFirepower, 1 ) );
Expand Down
37 changes: 19 additions & 18 deletions ElectronicObserver/Data/Battle/Phase/PhaseAirBattleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected void CalculateAttack( int waveIndex, int[] hps ) {

// 航空戦は miss/hit=0, critical=1 のため +1 する(通常は miss=0, hit=1, critical=2)
BattleDetails.Add( new BattleAirDetail( _battleData, waveIndex, i, Damages[i], Criticals[i] + 1, attackType, hps[i] ) );
AddDamage( hps, i, Damages[i] );
AddDamage( hps, i, (int)Damages[i] );
}
}
}
Expand Down Expand Up @@ -81,7 +81,7 @@ protected int[] GetLaunchedShipIndex( int index ) {
if ( data == null || !data.IsArray )
return new int[0];

var planes = ( dynamic[] )data;
var planes = (dynamic[])data;
if ( planes.Length > index ) {
return ( (int[])planes[index] ).Where( i => i > 0 ).Select( i => i - 1 ).ToArray();
}
Expand Down Expand Up @@ -202,32 +202,33 @@ public ShipData AACutInShip {
public bool IsStage3CombinedAvailable { get { return StageFlag != null && StageFlag[2] != 0 && AirBattleData.api_stage3_combined() && AirBattleData.api_stage3_combined != null; } }


protected int[] ConcatStage3Array( string friendName, string enemyName ) {
protected T[] ConcatStage3Array<T>( string friendName, string enemyName ) where T : struct, IComparable {

int[] ret = new int[24];
T[] ret = new T[24];
Func<T, T> toPositive = ( a ) => a.CompareTo( default(T) ) >= 0 ? a : default(T); // => Math.Max( a, 0 );

if ( IsStage3CombinedAvailable ) {

int[] friend = AirBattleData.api_stage3.IsDefined( friendName ) ? (int[])AirBattleData.api_stage3[friendName] : new int[7];
int[] enemy = AirBattleData.api_stage3.IsDefined( enemyName ) ? (int[])AirBattleData.api_stage3[enemyName] : new int[7];
int[] friendescort = AirBattleData.api_stage3_combined.IsDefined( friendName ) ? (int[])AirBattleData.api_stage3_combined[friendName] : new int[7];
int[] enemyescort = AirBattleData.api_stage3_combined.IsDefined( enemyName ) ? (int[])AirBattleData.api_stage3_combined[enemyName] : new int[7];
T[] friend = AirBattleData.api_stage3.IsDefined( friendName ) ? (T[])AirBattleData.api_stage3[friendName] : new T[7];
T[] enemy = AirBattleData.api_stage3.IsDefined( enemyName ) ? (T[])AirBattleData.api_stage3[enemyName] : new T[7];
T[] friendescort = AirBattleData.api_stage3_combined.IsDefined( friendName ) ? (T[])AirBattleData.api_stage3_combined[friendName] : new T[7];
T[] enemyescort = AirBattleData.api_stage3_combined.IsDefined( enemyName ) ? (T[])AirBattleData.api_stage3_combined[enemyName] : new T[7];

for ( int i = 0; i < 6; i++ ) {
ret[i] = Math.Max( friend[i + 1], 0 );
ret[i + 6] = Math.Max( enemy[i + 1], 0 );
ret[i + 12] = Math.Max( friendescort[i + 1], 0 );
ret[i + 18] = Math.Max( enemyescort[i + 1], 0 );
ret[i] = toPositive(friend[i + 1]);
ret[i + 6] = toPositive( enemy[i + 1] );
ret[i + 12] = toPositive( friendescort[i + 1] );
ret[i + 18] = toPositive( enemyescort[i + 1] );
}

} else if ( IsStage3Available ) {
int[] friend = AirBattleData.api_stage3.IsDefined( friendName ) ? (int[])AirBattleData.api_stage3[friendName] : new int[7];
int[] enemy = AirBattleData.api_stage3.IsDefined( enemyName ) ? (int[])AirBattleData.api_stage3[enemyName] : new int[7];
T[] friend = AirBattleData.api_stage3.IsDefined( friendName ) ? (T[])AirBattleData.api_stage3[friendName] : new T[7];
T[] enemy = AirBattleData.api_stage3.IsDefined( enemyName ) ? (T[])AirBattleData.api_stage3[enemyName] : new T[7];

for ( int i = 0; i < 6; i++ ) {
ret[i] = Math.Max( friend[i + 1], 0 );
ret[i + 6] = Math.Max( enemy[i + 1], 0 );
ret[i + 12] = ret[i + 18] = 0;
ret[i] = toPositive( friend[i + 1] );
ret[i + 6] = toPositive( enemy[i + 1] );
ret[i + 12] = ret[i + 18] = default(T);
}

}
Expand All @@ -254,6 +255,6 @@ protected int[] ConcatStage3Array( string friendName, string enemyName ) {
/// <summary>
/// 各艦の被ダメージ
/// </summary>
public int[] Damages { get; protected set; }
public double[] Damages { get; protected set; }
}
}
8 changes: 4 additions & 4 deletions ElectronicObserver/Data/Battle/Phase/PhaseBaseAirAttack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public PhaseBaseAirAttackUnit( BattleData data, string title, int index )

_squadrons = GetSquadrons().ToArray();

TorpedoFlags = ConcatStage3Array( "api_frai_flag", "api_erai_flag" );
BomberFlags = ConcatStage3Array( "api_fbak_flag", "api_ebak_flag" );
Criticals = ConcatStage3Array( "api_fcl_flag", "api_ecl_flag" );
Damages = ConcatStage3Array( "api_fdam", "api_edam" );
TorpedoFlags = ConcatStage3Array<int>( "api_frai_flag", "api_erai_flag" );
BomberFlags = ConcatStage3Array<int>( "api_fbak_flag", "api_ebak_flag" );
Criticals = ConcatStage3Array<int>( "api_fcl_flag", "api_ecl_flag" );
Damages = ConcatStage3Array<double>( "api_fdam", "api_edam" );
}


Expand Down
8 changes: 4 additions & 4 deletions ElectronicObserver/Data/Battle/Phase/PhaseBaseAirRaid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public PhaseBaseAirRaid( BattleData data, string title )

_squadrons = GetSquadrons().ToArray();

TorpedoFlags = ConcatStage3Array( "api_frai_flag", "api_erai_flag" );
BomberFlags = ConcatStage3Array( "api_fbak_flag", "api_ebak_flag" );
Criticals = ConcatStage3Array( "api_fcl_flag", "api_ecl_flag" );
Damages = ConcatStage3Array( "api_fdam", "api_edam" );
TorpedoFlags = ConcatStage3Array<int>( "api_frai_flag", "api_erai_flag" );
BomberFlags = ConcatStage3Array<int>( "api_fbak_flag", "api_ebak_flag" );
Criticals = ConcatStage3Array<int>( "api_fcl_flag", "api_ecl_flag" );
Damages = ConcatStage3Array<double>( "api_fdam", "api_edam" );
}

public override void EmulateBattle( int[] hps, int[] damages ) {
Expand Down
10 changes: 5 additions & 5 deletions ElectronicObserver/Data/Battle/Phase/PhaseJetAirBattle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public PhaseJetAirBattle( BattleData data, string title )
LaunchedShipIndexFriend = GetLaunchedShipIndex( 0 );
LaunchedShipIndexEnemy = GetLaunchedShipIndex( 1 );

TorpedoFlags = ConcatStage3Array( "api_frai_flag", "api_erai_flag" );
BomberFlags = ConcatStage3Array( "api_fbak_flag", "api_ebak_flag" );
Criticals = ConcatStage3Array( "api_fcl_flag", "api_ecl_flag" );
Damages = ConcatStage3Array( "api_fdam", "api_edam" );
TorpedoFlags = ConcatStage3Array<int>( "api_frai_flag", "api_erai_flag" );
BomberFlags = ConcatStage3Array<int>( "api_fbak_flag", "api_ebak_flag" );
Criticals = ConcatStage3Array<int>( "api_fcl_flag", "api_ecl_flag" );
Damages = ConcatStage3Array<double>( "api_fdam", "api_edam" );
}

public override void EmulateBattle( int[] hps, int[] damages ) {
Expand Down Expand Up @@ -85,7 +85,7 @@ private void CalculateAttackDamage( int[] damages ) {
}

int totalFirepower = firepower.Sum();
int totalDamage = Damages.Skip( 6 ).Take( 6 ).Sum() + damages.Skip( 18 ).Take( 6 ).Sum();
int totalDamage = Damages.Select( dmg => (int)dmg ).Skip( 6 ).Take( 6 ).Sum() + damages.Skip( 18 ).Take( 6 ).Sum();

for ( int i = 0; i < firepower.Length; i++ ) {
damages[( i < 6 ? i : ( i + 6 ) )] += (int)Math.Round( (double)totalDamage * firepower[i] / Math.Max( totalFirepower, 1 ) );
Expand Down
8 changes: 4 additions & 4 deletions ElectronicObserver/Data/Battle/Phase/PhaseJetBaseAirAttack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public PhaseJetBaseAirAttackUnit( BattleData data, string title, int index )

_squadrons = GetSquadrons().ToArray();

TorpedoFlags = ConcatStage3Array( "api_frai_flag", "api_erai_flag" );
BomberFlags = ConcatStage3Array( "api_fbak_flag", "api_ebak_flag" );
Criticals = ConcatStage3Array( "api_fcl_flag", "api_ecl_flag" );
Damages = ConcatStage3Array( "api_fdam", "api_edam" );
TorpedoFlags = ConcatStage3Array<int>( "api_frai_flag", "api_erai_flag" );
BomberFlags = ConcatStage3Array<int>( "api_fbak_flag", "api_ebak_flag" );
Criticals = ConcatStage3Array<int>( "api_fcl_flag", "api_ecl_flag" );
Damages = ConcatStage3Array<double>( "api_fdam", "api_edam" );
}


Expand Down
19 changes: 13 additions & 6 deletions ElectronicObserver/Data/Battle/Phase/PhaseNightBattle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,25 @@ public PhaseNightBattle( BattleData data, string title, bool isEscort )
int[] attackers = ( (int[])ShellingData.api_at_list ).Skip( 1 ).ToArray();
int[] attackTypes = ( (int[])ShellingData.api_sp_list ).Skip( 1 ).ToArray();
int[][] defenders = ( (dynamic[])ShellingData.api_df_list ).Skip( 1 ).Select( elem => ( (int[])elem ).Where( e => e != -1 ).ToArray() ).ToArray();
int[][] attackEquipments = ( (dynamic[])ShellingData.api_si_list ).Skip( 1 ).Select( elem => ( (dynamic[])elem ).Select<dynamic, int>( ch => ch is string ? int.Parse( ch ) : (int)ch ).ToArray() ).ToArray();
int[][] criticals = ( (dynamic[])ShellingData.api_cl_list ).Skip( 1 ).Select( elem => ( (int[])elem ).Where( e => e != -1 ).ToArray() ).ToArray();
int[][] damages = ( (dynamic[])ShellingData.api_damage ).Skip( 1 ).Select( elem => ( (int[])elem ).Where( e => e != -1 ).ToArray() ).ToArray();

double[][] rawDamages = ( (dynamic[])ShellingData.api_damage ).Skip( 1 ).Select( elem => ( (double[])elem ).Where( e => e != -1 ).ToArray() ).ToArray();
Attacks = new List<PhaseNightBattleAttack>();

for ( int i = 0; i < attackers.Length; i++ ) {
var attack = new PhaseNightBattleAttack();

attack.Attacker = GetIndex( attackers[i] );
attack.AttackType = attackTypes[i];
attack.EquipmentIDs = attackEquipments[i];

attack.Defenders = new List<PhaseNightBattleDefender>();
for ( int k = 0; k < defenders[i].Length; k++ ) {
var defender = new PhaseNightBattleDefender();
defender.Defender = GetIndex( defenders[i][k] );
defender.CriticalFlag = criticals[i][k];
defender.Damage = damages[i][k];
defender.RawDamage = rawDamages[i][k];
attack.Defenders.Add( defender );
}

Expand All @@ -66,7 +68,7 @@ public override void EmulateBattle( int[] hps, int[] damages ) {
foreach ( var attack in Attacks ) {

foreach ( var defs in attack.Defenders.GroupBy( d => d.Defender ) ) {
BattleDetails.Add( new BattleNightDetail( _battleData, attack.Attacker, defs.Key, defs.Select( d => d.Damage ).ToArray(), defs.Select( d => d.CriticalFlag ).ToArray(), attack.AttackType, hps[defs.Key] ) );
BattleDetails.Add( new BattleNightDetail( _battleData, attack.Attacker, defs.Key, defs.Select( d => d.RawDamage ).ToArray(), defs.Select( d => d.CriticalFlag ).ToArray(), attack.AttackType, attack.EquipmentIDs, hps[defs.Key] ) );
AddDamage( hps, defs.Key, defs.Sum( d => d.Damage ) );
}

Expand All @@ -81,6 +83,7 @@ public class PhaseNightBattleAttack {
public int Attacker;
public int AttackType;
public List<PhaseNightBattleDefender> Defenders;
public int[] EquipmentIDs;

public PhaseNightBattleAttack() { }

Expand All @@ -91,10 +94,14 @@ public override string ToString() {
public class PhaseNightBattleDefender {
public int Defender;
public int CriticalFlag;
public int Damage;
public double RawDamage;
public bool GuardsFlagship { get { return RawDamage != Math.Floor( RawDamage ); } }
public int Damage { get { return (int)RawDamage; } }

public override string ToString() {
return string.Format( "{0};{1}-{2}", Defender, Damage, CriticalFlag == 0 ? "miss" : CriticalFlag == 1 ? "dmg" : CriticalFlag == 2 ? "crit" : "INVALID" );
return string.Format( "{0};{1}-{2}{3}", Defender, Damage,
CriticalFlag == 0 ? "miss" : CriticalFlag == 1 ? "dmg" : CriticalFlag == 2 ? "crit" : "INVALID",
GuardsFlagship ? " (guard)" : "" );
}
}

Expand Down
Loading

0 comments on commit 539dd04

Please sign in to comment.