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 4, 2015
2 parents 7071af5 + 01bf3a6 commit 9c08422
Show file tree
Hide file tree
Showing 18 changed files with 120 additions and 59 deletions.
2 changes: 1 addition & 1 deletion ElectronicObserver/Data/Battle/BattleCombinedAirBattle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override int[] EmulateBattle() {
Action<int, int> DealDamageFriend = ( int index, int damage ) => {
//if ( hp[index] == -1 ) return;
hp[index] -= Math.Max( damage, 0 );
if ( hp[index] == 0 ) {
if ( hp[index] <= 0 ) {
ShipData ship = db.Ships[db.Fleet[ index < 6 ? 1 : 2 ].Members[index]];
if ( ship == null ) return;

Expand Down
2 changes: 1 addition & 1 deletion ElectronicObserver/Data/Battle/BattleCombinedNightOnly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override int[] EmulateBattle() {
Action<int, int> DealDamageFriend = ( int index, int damage ) => {
//if ( hp[index] == -1 ) return;
hp[index] -= Math.Max( damage, 0 );
if ( hp[index] == 0 ) {
if ( hp[index] <= 0 ) {
ShipData ship = db.Ships[db.Fleet[index < 6 ? 1 : 2].Members[index]];
if ( ship == null ) return;

Expand Down
2 changes: 1 addition & 1 deletion ElectronicObserver/Data/Battle/BattleCombinedNormalDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override int[] EmulateBattle() {
Action<int, int> DealDamageFriend = ( int index, int damage ) => {
//if ( hp[index] == -1 ) return;
hp[index] -= Math.Max( damage, 0 );
if ( hp[index] == 0 ) {
if ( hp[index] <= 0 ) {
ShipData ship = db.Ships[db.Fleet[index < 6 ? 1 : 2].Members[index]];
if ( ship == null ) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override int[] EmulateBattle() {
Action<int, int> DealDamageFriend = ( int index, int damage ) => {
//if ( hp[index] == -1 ) return;
hp[index] -= Math.Max( damage, 0 );
if ( hp[index] == 0 ) {
if ( hp[index] <= 0 ) {
ShipData ship = db.Ships[db.Fleet[index < 6 ? 1 : 2].Members[index]];
if ( ship == null ) return;

Expand Down
2 changes: 1 addition & 1 deletion ElectronicObserver/Data/Battle/BattleCombinedWater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override int[] EmulateBattle() {
Action<int, int> DealDamageFriend = ( int index, int damage ) => {
//if ( hp[index] == -1 ) return;
hp[index] -= Math.Max( damage, 0 );
if ( hp[index] == 0 ) {
if ( hp[index] <= 0 ) {
ShipData ship = db.Ships[db.Fleet[index < 6 ? 1 : 2].Members[index]];
if ( ship == null ) return;

Expand Down
35 changes: 27 additions & 8 deletions ElectronicObserver/Data/FleetData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ private int GetConditionRecoveryMinute( int cond ) {
return Math.Max( (int)Math.Ceiling( ( Utility.Configuration.Config.Control.ConditionBorder - cond ) / 3.0 ) * 3, 0 );
}

/*/
private void SetConditionTimer() {
int minute = GetConditionRecoveryMinute( MembersInstance.Min( s => s != null ? s.Condition : 100 ) );
Expand All @@ -339,6 +340,26 @@ private void SetConditionTimer() {
//Utility.Logger.Add( 1, string.Format( "Fleet #{0}: 疲労 再設定 {1:D2}:00", FleetID, minute ) );
}
/*/

private void SetConditionTimer() {

int minute = GetConditionRecoveryMinute( MembersInstance.Min( s => s != null ? s.Condition : 100 ) );

if ( minute <= 0 ) {
ConditionTime = null;

} else if ( ConditionTime != null ) {
TimeSpan ts = (DateTime)ConditionTime - DateTime.Now;

ConditionTime = DateTime.Now + ts.Add( TimeSpan.FromMinutes( minute - 3 - (int)( ts.TotalMinutes / 3 ) * 3 ) );

} else {
ConditionTime = DateTime.Now.AddMinutes( minute );
}

}
//*/

private void ShortenConditionTimer() {

Expand Down Expand Up @@ -673,19 +694,17 @@ public static void RefreshFleetState( ImageLabel label, FleetStates state, DateT
private bool CanAnchorageRepair {
get {
KCDatabase db = KCDatabase.Instance;
ShipData flagship = db.Ships[Members[0]];
ShipData flagship = MembersInstance[0];
return (
ExpeditionState == 0 &&
flagship != null &&
flagship.MasterShip.ShipType == 19 && //旗艦工作艦
(double)flagship.HPCurrent / flagship.HPMax > 0.5 && //旗艦が中破未満
flagship.RepairingDockID == -1 && //旗艦が入渠中でない
Members.Take( 2 + flagship.SlotInstanceMaster.Count( eq => eq != null && eq.EquipmentType[2] == 31 ) ).Count( id => { //(2+装備)以内に50%<HP<100%&&非入渠中の艦がいる
ShipData ship = db.Ships[id];
flagship.MasterShip.ShipType == 19 && //旗艦工作艦
flagship.HPRate > 0.5 && //旗艦が中破未満
flagship.RepairingDockID == -1 && //旗艦が入渠中でない
MembersInstance.Take( 2 + flagship.SlotInstanceMaster.Count( eq => eq != null && eq.EquipmentType[2] == 31 ) ).Count( ship => { //(2+装備)以内に50%<HP<100%&&非入渠中の艦がいる
if ( ship == null ) return false;
if ( ship.RepairingDockID != -1 ) return false;
double rate = (double)ship.HPCurrent / ship.HPMax;
return 0.5 < rate && rate < 1.0;
return 0.5 < ship.HPRate && ship.HPRate < 1.0;
} ) > 0 );
}
}
Expand Down
36 changes: 22 additions & 14 deletions ElectronicObserver/Notifier/NotifierDamage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ private void Initialize() {
private void BeforeSortie( string apiname, dynamic data ) {
if ( NotifiesNow || NotifiesBefore ) {

string[] array = GetDamagedShips( KCDatabase.Instance.Fleet.Fleets.Values.SelectMany( f => f.MembersWithoutEscaped ) );
string[] array = GetDamagedShips(
KCDatabase.Instance.Fleet.Fleets.Values
.Where( f => f.ExpeditionState == 0 )
.SelectMany( f => f.MembersWithoutEscaped.Skip( !ContainsFlagship ? 1 : 0 ) ) );

if ( array != null && array.Length > 0 ) {
Notify( array );
Expand All @@ -119,7 +122,9 @@ private void BeforeSortie( string apiname, dynamic data ) {
private void InSortie( string apiname, dynamic data ) {
if ( NotifiesAfter ) {

string[] array = GetDamagedShips( KCDatabase.Instance.Fleet.Fleets.Values.Where( f => f.IsInSortie ).SelectMany( f => f.MembersWithoutEscaped ) );
string[] array = GetDamagedShips( KCDatabase.Instance.Fleet.Fleets.Values
.Where( f => f.IsInSortie )
.SelectMany( f => f.MembersWithoutEscaped.Skip( !ContainsFlagship ? 1 : 0 ) ) );


if ( array != null && array.Length > 0 ) {
Expand All @@ -146,7 +151,7 @@ private void BattleFinished( string apiname, dynamic data ) {
private void CheckBattle() {

BattleManager bm = KCDatabase.Instance.Battle;

if ( bm.Compass.IsEndPoint && !NotifiesAtEndpoint )
return;

Expand Down Expand Up @@ -203,15 +208,20 @@ private void CheckBattle() {
}



// 注: 退避中かどうかまではチェックしない
private bool IsShipDamaged( ShipData ship, int hp ) {
return ship != null &&
hp > 0 &&
(double)hp / ship.HPMax <= 0.25 &&
ship.RepairingDockID == -1 &&
ship.Level >= LevelBorder &&
( ContainsNotLockedShip ? true : ( ship.IsLocked || ship.SlotInstance.Count( q => q != null && q.IsLocked ) > 0 ) ) &&
( ContainsSafeShip ? true : !ship.SlotInstanceMaster.Select( e => e != null ? e.CategoryType == 23 : false ).Contains( true ) );
}

private string[] GetDamagedShips( IEnumerable<ShipData> ships ) {
return ships.Where( s => s != null && s.HPCurrent > 0 && s.HPRate <= 0.25 && s.RepairingDockID == -1 &&
s.Level >= LevelBorder &&
( ContainsNotLockedShip ? true : ( s.IsLocked || s.SlotInstance.Count( q => q != null && q.IsLocked ) > 0 ) ) &&
( ContainsSafeShip ? true : !s.SlotInstanceMaster.Select( e => e != null ? e.EquipmentType[2] == 23 : false ).Contains( true ) )
).Select( s => string.Format( "{0} ({1}/{2})", s.NameWithLevel, s.HPCurrent, s.HPMax ) ).ToArray();
return ships.Where( s => IsShipDamaged( s, s != null ? s.HPCurrent : 0 ) ).Select( s => string.Format( "{0} ({1}/{2})", s.NameWithLevel, s.HPCurrent, s.HPMax ) ).ToArray();
}


private string[] GetDamagedShips( FleetData fleet, int[] hps ) {

Expand All @@ -223,10 +233,8 @@ private string[] GetDamagedShips( FleetData fleet, int[] hps ) {

ShipData s = fleet.MembersInstance[i];

if ( s != null && hps[i] > 0 && (double)hps[i] / s.HPMax <= 0.25 &&
s.Level >= LevelBorder && !fleet.EscapedShipList.Contains( s.MasterID ) &&
( ContainsNotLockedShip ? true : ( s.IsLocked || s.SlotInstance.Count( q => q != null && q.IsLocked ) > 0 ) ) &&
( ContainsSafeShip ? true : !s.SlotInstanceMaster.Select( e => e != null ? e.EquipmentType[2] == 23 : false ).Contains( true ) ) ) {
if ( s != null && !fleet.EscapedShipList.Contains( s.MasterID ) &&
IsShipDamaged( s, hps[i] ) ) {

list.AddLast( string.Format( "{0} ({1}/{2})", s.NameWithLevel, hps[i], s.HPMax ) );
}
Expand Down
2 changes: 1 addition & 1 deletion ElectronicObserver/Observer/APIObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private void FiddlerApplication_BeforeRequest( Fiddler.Session oSession ) {

// 上流プロキシ設定
if ( c.UseUpstreamProxy ) {
oSession["X-OverrideGateway"] = string.Format( "localhost:{0}", c.UpstreamProxyPort );
oSession["X-OverrideGateway"] = string.Format( "127.0.0.1:{0}", c.UpstreamProxyPort );
}


Expand Down
4 changes: 4 additions & 0 deletions ElectronicObserver/Other/Information/kcmemo.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ C敗北判定の 敵損害率 >= 50 は試験実装。

* E-1 : 440 (旗艦HP88; 最低5回撃破)
* E-2 : 1620 (旗艦HP270; 最低6回撃破)
* E-3 : 910 (旗艦HP130; 最低7回撃破)
* E-4 : 3200 (旗艦HP450(最終形態500); 最低7回撃破)
* E-5 : 2410 (旗艦HP330(最終形態430); 最低7回撃破)
* E-6 : 3405 (旗艦HP500; 最低7回撃破)

#### 海域HPゲージ
わずかでもダメージを与えないと正常な値にならない。
Expand Down
3 changes: 2 additions & 1 deletion ElectronicObserver/Utility/Data/Calculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ public static int GetAACutinKind( int shipID, int[] slot ) {
if ( eq == null ) continue;

if ( eq.IconType == 16 ) { //高角砲
if ( eq.EquipmentID == 122 || eq.EquipmentID == 130 ) { //10cm連装高角砲+高射装置 or 12.7cm高角砲+高射装置
// 10cm連装高角砲+高射装置 or 12.7cm高角砲+高射装置 or 90mm単装高角砲
if ( eq.EquipmentID == 122 || eq.EquipmentID == 130 || eq.EquipmentID == 135 ) {
highangle_director++;
}
highangle++;
Expand Down
6 changes: 3 additions & 3 deletions ElectronicObserver/Utility/SoftwareInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static string SoftwareNameEnglish {
/// </summary>
public static string VersionJapanese {
get {
return SoftwareNameJapanese + "一二型改三甲";
return SoftwareNameJapanese + "一二型改四";
}
}

Expand All @@ -44,7 +44,7 @@ public static string VersionJapanese {
/// </summary>
public static string VersionEnglish {
get {
return "1.2.3.1";
return "1.2.4";
}
}

Expand All @@ -54,7 +54,7 @@ public static string VersionEnglish {
/// </summary>
public static DateTime UpdateTime {
get {
return DateTimeHelper.CSVStringToTime( "2015/05/01 23:00:00" );
return DateTimeHelper.CSVStringToTime( "2015/05/04 22:00:00" );
}
}

Expand Down
4 changes: 2 additions & 2 deletions ElectronicObserver/Window/Control/ShipStatusEquipment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ private void ShipStatusEquipment_Paint( object sender, PaintEventArgs e ) {
Rectangle textarea = new Rectangle( basearea.X + sz_unit.Width * slotindex, basearea.Y, sz_unit.Width - SlotMargin, sz_unit.Height );

if ( OverlayAircraft ) {
using ( SolidBrush b = new SolidBrush( Color.FromArgb( 0x80, 0xFF, 0xFF, 0xFF ) ) ) {
using ( SolidBrush b = new SolidBrush( Color.FromArgb( 0xC0, 0xF0, 0xF0, 0xF0 ) ) ) {
e.Graphics.FillRectangle( b, new Rectangle( textarea.X, textarea.Y, sz_eststr.Width, sz_eststr.Height ) );
}

Expand All @@ -398,7 +398,7 @@ private void ShipStatusEquipment_Paint( object sender, PaintEventArgs e ) {
Size sz_realstr = TextRenderer.MeasureText( slot.AircraftCurrent.ToString(), Font, new Size( int.MaxValue, int.MaxValue ), textformat );
sz_realstr.Width -= (int)( Font.Size / 2.0 );

using ( SolidBrush b = new SolidBrush( Color.FromArgb( 0x80, 0xFF, 0xFF, 0xFF ) ) ) {
using ( SolidBrush b = new SolidBrush( Color.FromArgb( 0xC0, 0xF0, 0xF0, 0xF0 ) ) ) {
e.Graphics.FillRectangle( b, new Rectangle(
textarea.X + sz_unit.Width - sz_realstr.Width,
textarea.Y + sz_unit.Height - sz_realstr.Height,
Expand Down
1 change: 1 addition & 0 deletions ElectronicObserver/Window/FormBattle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ private void SetHPNormal( int[] hp, BattleData bd ) {
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].BackColor = SystemColors.Control;
HPBars[i].Visible = true;
} else {
HPBars[i].Visible = false;
Expand Down
35 changes: 24 additions & 11 deletions ElectronicObserver/Window/FormCompass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ private string GetShipString( int shipID, int[] slot ) {
if ( ship == null ) return null;

return GetShipString( shipID, slot, -1, ship.HPMin, ship.FirepowerMax, ship.TorpedoMax, ship.AAMax, ship.ArmorMax,
ship.ASW != null && !ship.ASW.IsMaximumDefault ? ship.ASW.Maximum : 0,
ship.Evasion != null && !ship.Evasion.IsMaximumDefault ? ship.Evasion.Maximum : 0,
ship.LOS != null && !ship.LOS.IsMaximumDefault ? ship.LOS.Maximum : 0,
ship.ASW != null && !ship.ASW.IsMaximumDefault ? ship.ASW.Maximum : -1,
ship.Evasion != null && !ship.Evasion.IsMaximumDefault ? ship.Evasion.Maximum : -1,
ship.LOS != null && !ship.LOS.IsMaximumDefault ? ship.LOS.Maximum : -1,
ship.LuckMin );
}

Expand All @@ -158,9 +158,9 @@ private string GetShipString( int shipID, int[] slot, int level, int firepower,
if ( ship == null ) return null;

return GetShipString( shipID, slot, level, level > 99 ? ship.HPMaxMarried : ship.HPMin, firepower, torpedo, aa, armor,
ship.ASW != null && ship.ASW.IsAvailable ? ship.ASW.GetParameter( level ) : 0,
ship.Evasion != null && ship.Evasion.IsAvailable ? ship.Evasion.GetParameter( level ) : 0,
ship.LOS != null && ship.LOS.IsAvailable ? ship.LOS.GetParameter( level ) : 0,
ship.ASW != null && ship.ASW.IsAvailable ? ship.ASW.GetParameter( level ) : -1,
ship.Evasion != null && ship.Evasion.IsAvailable ? ship.Evasion.GetParameter( level ) : -1,
ship.LOS != null && ship.LOS.IsAvailable ? ship.LOS.GetParameter( level ) : -1,
level > 99 ? Math.Min( ship.LuckMin + 3, ship.LuckMax ) : ship.LuckMin );
}

Expand All @@ -173,10 +173,15 @@ private string GetShipString( int shipID, int[] slot, int level, int hp, int fir
int torpedo_c = torpedo;
int aa_c = aa;
int armor_c = armor;
int asw_c = Math.Max( asw, 0 );
int evasion_c = Math.Max( evasion, 0 );
int los_c = Math.Max( los, 0 );
int asw_c = asw;
int evasion_c = evasion;
int los_c = los;
int luck_c = luck;
int range = ship.Range;

asw = Math.Max( asw, 0 );
evasion = Math.Max( evasion, 0 );
los = Math.Max( los, 0 );

if ( slot != null ) {
int count = slot.Length;
Expand All @@ -192,11 +197,12 @@ private string GetShipString( int shipID, int[] slot, int level, int hp, int fir
evasion += eq.Evasion;
los += eq.LOS;
luck += eq.Luck;
range = Math.Max( range, eq.Range );
}
}

return string.Format(
"{0} {1}{2}\n耐久: {3}\n火力: {4}/{5}\n雷装: {6}/{7}\n対空: {8}/{9}\n装甲: {10}/{11}\n対潜: {12}/{13}\n回避: {14}/{15}\n索敵: {16}/{17}\n運: {18}/{19}\n(右クリックで図鑑)\n",
"{0} {1}{2}\n耐久: {3}\n火力: {4}/{5}\n雷装: {6}/{7}\n対空: {8}/{9}\n装甲: {10}/{11}\n対潜: {12}/{13}\n回避: {14}/{15}\n索敵: {16}/{17}\n運: {18}/{19}\n射程: {20}\n(右クリックで図鑑)\n",
ship.ShipTypeName, ship.NameWithClass, level < 1 ? "" : string.Format( " Lv. {0}", level ),
hp,
firepower_c, firepower,
Expand All @@ -206,7 +212,8 @@ private string GetShipString( int shipID, int[] slot, int level, int hp, int fir
asw_c == -1 ? "???" : asw_c.ToString(), asw,
evasion_c == -1 ? "???" : evasion_c.ToString(), evasion,
los_c == -1 ? "???" : los_c.ToString(), los,
luck_c, luck
luck_c, luck,
Constants.GetRange( range )
);
}

Expand All @@ -231,6 +238,12 @@ private string GetEquipmentString( int shipID, int[] slot ) {
sb.AppendFormat( "対空: {0}\r\n", Constants.GetAACutinKind( aacutin ) );
}
}
{
int airsup = Calculator.GetAirSuperiority( slot, ship.Aircraft.ToArray() );
if ( airsup > 0 ) {
sb.AppendFormat( "制空戦力: {0}\r\n", airsup );
}
}

return sb.ToString();
}
Expand Down
12 changes: 9 additions & 3 deletions ElectronicObserver/Window/FormFleet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public void Update( int shipMasterID ) {
Name.Tag = ship.ShipID;
ToolTipInfo.SetToolTip( Name,
string.Format(
"{0} {1}\n火力: {2}/{3}\n雷装: {4}/{5}\n対空: {6}/{7}\n装甲: {8}/{9}\n対潜: {10}/{11}\n回避: {12}/{13}\n索敵: {14}/{15}\n運: {16}\n(右クリックで図鑑)\n",
"{0} {1}\n火力: {2}/{3}\n雷装: {4}/{5}\n対空: {6}/{7}\n装甲: {8}/{9}\n対潜: {10}/{11}\n回避: {12}/{13}\n索敵: {14}/{15}\n運: {16}\n射程: {17}\n(右クリックで図鑑)\n",
ship.MasterShip.ShipTypeName, ship.NameWithLevel,
ship.FirepowerBase, ship.FirepowerTotal,
ship.TorpedoBase, ship.TorpedoTotal,
Expand All @@ -349,7 +349,8 @@ public void Update( int shipMasterID ) {
ship.ASWBase, ship.ASWTotal,
ship.EvasionBase, ship.EvasionTotal,
ship.LOSBase, ship.LOSTotal,
ship.LuckTotal
ship.LuckTotal,
Constants.GetRange( ship.Range )
) );


Expand Down Expand Up @@ -490,7 +491,12 @@ private string GetEquipmentString( ShipData ship ) {
sb.AppendFormat( "対空: {0}\r\n", Constants.GetAACutinKind( aacutin ) );
}
}

{
int airsup = Calculator.GetAirSuperiority( ship );
if ( airsup > 0 ) {
sb.AppendFormat( "制空戦力: {0}\r\n", airsup );
}
}

return sb.ToString();
}
Expand Down
4 changes: 2 additions & 2 deletions ElectronicObserver/Window/FormInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ private string GetAlbumInfo( dynamic data ) {
StringBuilder sb = new StringBuilder();

if ( data.api_list != null ) {
int startIndex = (int)data.api_list[0].api_index_no;
int bound = 50;
const int bound = 50;
int startIndex = ( ( (int)data.api_list[0].api_index_no - 1 ) / bound ) * bound + 1;
bool[] flags = Enumerable.Repeat<bool>( false, bound ).ToArray();

if ( data.api_list[0].api_yomi() ) {
Expand Down
Loading

0 comments on commit 9c08422

Please sign in to comment.