Skip to content

Commit

Permalink
Merged develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
KodamaSakuno committed Aug 21, 2016
2 parents fa57c5a + 7649f6a commit b49490b
Show file tree
Hide file tree
Showing 75 changed files with 785 additions and 298 deletions.
16 changes: 16 additions & 0 deletions HeavenlyWind.Base/CoreDatabase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Data.SQLite;
using System.Diagnostics;

namespace Sakuno.KanColle.Amatsukaze
{
static class CoreDatabase
{
public static SQLiteConnection Connection { get; private set; }

public static void Initialize()
{
Connection = new SQLiteConnection("Data Source=:memory:").OpenAndReturn();
Connection.Update += (s, e) => Debug.WriteLine($"Core: {e.Event} - {e.Table} - {e.RowId}");
}
}
}
1 change: 1 addition & 0 deletions HeavenlyWind.Base/HeavenlyWind.Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<Compile Include="Browser\ScreenshotData.cs" />
<Compile Include="CollapsedIfNullExtension.cs" />
<Compile Include="CollapsedIfZeroExtension.cs" />
<Compile Include="CoreDatabase.cs" />
<Compile Include="CurrentDockExtension.cs" />
<Compile Include="EnumerationExtension.cs" />
<Compile Include="EnumToStringResourceExtension.cs" />
Expand Down
2 changes: 1 addition & 1 deletion HeavenlyWind.Base/Models/Preferences/Property`T.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public override void Save()
{
using (var rCommand = Preference.Instance.Connection.CreateCommand())
{
rCommand.CommandText = "INSERT OR REPLACE INTO preference(key, value) VALUES(@key, @value);";
rCommand.CommandText = "INSERT OR REPLACE INTO preference.preference(key, value) VALUES(@key, @value);";
rCommand.Parameters.AddWithValue("@key", Key);

object rValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class UserInterfacePreference
public Property<Dock> LandscapeDock { get; } = new Property<Dock>("ui.layout.lanscape", Dock.Left);
public Property<Dock> PortraitDock { get; } = new Property<Dock>("ui.layout.portrait", Dock.Top);

public Property<bool> LockTabs { get; } = new Property<bool>("ui.layout.lock_tabs", false);

public Property<double> Zoom { get; } = new Property<double>("ui.zoom", 1.0);

public HeavyDamageLinePreference HeavyDamageLine { get; } = new HeavyDamageLinePreference();
Expand Down
19 changes: 12 additions & 7 deletions HeavenlyWind.Base/Preference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Sakuno.KanColle.Amatsukaze.Models.Preferences;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
Expand All @@ -27,11 +26,10 @@ static Preference()

public void Initialize()
{
Connection = new SQLiteConnection(@"Data Source=Roaming\Preferences\Main.db; Page Size=8192").OpenAndReturn();

using (var rTransaction = Connection.BeginTransaction())
using (var rConnection = new SQLiteConnection(@"Data Source=Roaming\Preferences\Main.db; Page Size=8192").OpenAndReturn())
using (var rTransaction = rConnection.BeginTransaction())
{
using (var rCommand = Connection.CreateCommand())
using (var rCommand = rConnection.CreateCommand())
{
rCommand.CommandText =
"CREATE TABLE IF NOT EXISTS metadata(key TEXT PRIMARY KEY NOT NULL, value) WITHOUT ROWID; " +
Expand All @@ -47,7 +45,14 @@ public void Initialize()
rTransaction.Commit();
}

Connection.Update += (s, e) => Debug.WriteLine($"Preference: {e.Event} - {e.Table} - {e.RowId}");
Connection = CoreDatabase.Connection;
using (var rCommand = Connection.CreateCommand())
{
rCommand.CommandText = "ATTACH @filename AS preference;";
rCommand.Parameters.AddWithValue("@filename", new FileInfo(@"Roaming\Preferences\Main.db").FullName);

rCommand.ExecuteNonQuery();
}
}

public void Reload()
Expand All @@ -60,7 +65,7 @@ public void Reload()

using (var rCommand = Connection.CreateCommand())
{
rCommand.CommandText = "SELECT key, value FROM preference;";
rCommand.CommandText = "SELECT key, value FROM preference.preference;";

using (var rReader = rCommand.ExecuteReader())
while (rReader.Read())
Expand Down
4 changes: 2 additions & 2 deletions HeavenlyWind.Base/ProductInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ public static class ProductInfo
public const string AppName = "いんてりじぇんと連装砲くん";
public const string ProductName = "Intelligent Naval Gun";

public const string AssemblyVersionString = "0.1.11.4";
public const string AssemblyVersionString = "0.1.12";

public static string Version => AssemblyVersionString;
public static string ReleaseCodeName => "Kraken";
public static string ReleaseCodeName => "Hopespeak";

public const string UserAgent = "ING/" + AssemblyVersionString;
}
Expand Down
4 changes: 4 additions & 0 deletions HeavenlyWind.Base/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Sakuno.KanColle.Amatsukaze;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
Expand Down Expand Up @@ -30,3 +31,6 @@
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(ProductInfo.AssemblyVersionString)]

[assembly: InternalsVisibleTo("HeavenlyWind")]
[assembly: InternalsVisibleTo("HeavenlyWind.Game")]
11 changes: 10 additions & 1 deletion HeavenlyWind.Base/StringResources.Items.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ partial class StringResourcesItems
public string Log_Screenshot_Failed_NoData => GetString(nameof(Log_Screenshot_Failed_NoData));
public string Log_Screenshot_Succeeded_Clipboard => GetString(nameof(Log_Screenshot_Succeeded_Clipboard));
public string Log_Screenshot_Succeeded_File => GetString(nameof(Log_Screenshot_Succeeded_File));
public string Log_Modernization_Success => GetString(nameof(Log_Modernization_Success));
public string Log_Modernization_Failure => GetString(nameof(Log_Modernization_Failure));
public string Log_EquipmentImprovement_Ready => GetString(nameof(Log_EquipmentImprovement_Ready));
public string Log_EquipmentImprovement_Success => GetString(nameof(Log_EquipmentImprovement_Success));
public string Log_EquipmentImprovement_Upgrade => GetString(nameof(Log_EquipmentImprovement_Upgrade));
public string Log_EquipmentImprovement_Failure => GetString(nameof(Log_EquipmentImprovement_Failure));

public string Notification_Expedition => GetString(nameof(Notification_Expedition));
public string Notification_Expedition_Content => GetString(nameof(Notification_Expedition_Content));
Expand Down Expand Up @@ -72,14 +78,16 @@ partial class StringResourcesItems
public string GameInfomation_Waiting => GetString(nameof(GameInfomation_Waiting));

public string Browser_Navigator_ResizeBrowserToFitGame => GetString(nameof(Browser_Navigator_ResizeBrowserToFitGame));
public string Browser_Navigator_SetCookie => GetString(nameof(Browser_Navigator_SetCookie));
public string Browser_Navigator_SetCookie_Instruction => GetString(nameof(Browser_Navigator_SetCookie_Instruction));
public string Browser_RestartConfirmation_Instruction => GetString(nameof(Browser_RestartConfirmation_Instruction));
public string Browser_RestartConfirmation_Button_Refresh => GetString(nameof(Browser_RestartConfirmation_Button_Refresh));
public string Browser_RestartConfirmation_Button_Stay => GetString(nameof(Browser_RestartConfirmation_Button_Stay));
public string Browser_Zoom_ZoomIn => GetString(nameof(Browser_Zoom_ZoomIn));
public string Browser_Zoom_ZoomOut => GetString(nameof(Browser_Zoom_ZoomOut));

public string Tab_Overview => GetString(nameof(Tab_Overview));
public string Tab_Fleets => GetString(nameof(Tab_Fleets));
public string Tab_Maps => GetString(nameof(Tab_Maps));
public string Tab_Sortie => GetString(nameof(Tab_Sortie));
public string Tab_Quests => GetString(nameof(Tab_Quests));
public string Tab_ExpeditionOverview => GetString(nameof(Tab_ExpeditionOverview));
Expand Down Expand Up @@ -333,6 +341,7 @@ partial class StringResourcesItems
public string PreferenceWindow_Window_Layout_Portrait => GetString(nameof(PreferenceWindow_Window_Layout_Portrait));
public string PreferenceWindow_Window_Layout_Game => GetString(nameof(PreferenceWindow_Window_Layout_Game));
public string PreferenceWindow_Window_Layout_Information => GetString(nameof(PreferenceWindow_Window_Layout_Information));
public string PreferenceWindow_Window_Layout_LockTabs => GetString(nameof(PreferenceWindow_Window_Layout_LockTabs));
public string PreferenceWindow_UI => GetString(nameof(PreferenceWindow_UI));
public string PreferenceWindow_UI_HeavyDamageLine => GetString(nameof(PreferenceWindow_UI_HeavyDamageLine));
public string PreferenceWindow_UI_HeavyDamageLine_Type_Hide => GetString(nameof(PreferenceWindow_UI_HeavyDamageLine_Type_Hide));
Expand Down
4 changes: 3 additions & 1 deletion HeavenlyWind.Game/AirBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal AirBase()
var rData = r.GetData<RawAirForceGroupOrganization>();
foreach (var rSquadron in rData.Squadrons)
rGroup.Squadrons[rSquadron.ID].Update(rSquadron);
rGroup.UpdateCombatRadius();
rGroup.CombatRadius = rData.CombatRadius;
});

SessionService.Instance.Subscribe("api_req_air_corps/supply", r =>
Expand All @@ -45,6 +45,8 @@ internal AirBase()
var rData = r.GetData<RawAirForceSquadronResupplyResult>();
foreach (var rSquadron in rData.Squadrons)
rGroup.Squadrons[rSquadron.ID].Update(rSquadron);
rGroup.UpdateFighterPower();
});
}

Expand Down
3 changes: 2 additions & 1 deletion HeavenlyWind.Game/HeavenlyWind.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
<Compile Include="Models\Battle\Stages\NightOnlyStage.cs" />
<Compile Include="Models\ConstructionDock.cs" />
<Compile Include="Models\CombinedFleetType.cs" />
<Compile Include="Models\CommonProperty.cs" />
<Compile Include="Models\CountdownModelBase.cs" />
<Compile Include="Models\CutInType.cs" />
<Compile Include="Models\EnemyFleet.cs" />
Expand Down Expand Up @@ -302,7 +303,7 @@
<Compile Include="Parsers\Root\Map\ExplorationParser.cs" />
<Compile Include="Parsers\Root\Map\StartSortieParser.cs" />
<Compile Include="Parsers\Root\Member\PracticeOpponentsParser.cs" />
<Compile Include="Parsers\Root\Upgrading\ModernizationParser.cs" />
<Compile Include="Parsers\Root\Upgrade\ModernizationParser.cs" />
<Compile Include="Parsers\Root\PortParser.cs" />
<Compile Include="Port.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
3 changes: 2 additions & 1 deletion HeavenlyWind.Game/KanColleGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ internal set
{
var rMap = Maps[int.Parse(r.Parameters["api_maparea_id"]) * 10 + int.Parse(r.Parameters["api_map_no"])];
rMap.Difficulty = (EventMapDifficulty)int.Parse(r.Parameters["api_rank"]);
rMap.HP = new ClampedValue(9999, 9999);
});

SessionService.Instance.Subscribe(new[] { "api_req_sortie/battleresult", "api_req_combined_battle/battleresult" }, r =>
Expand All @@ -76,7 +77,7 @@ internal set
rSortieMap.HP -= rData.TransportMissionResult.Point;
else
{
var rCurrentHP = rSortieMap.HP.Current - (rEnemyFlagship.Maximum - rEnemyFlagship.Current);
var rCurrentHP = rSortieMap.HP.Current - (rEnemyFlagship.Maximum - Math.Max(rEnemyFlagship.Current, 0));
if (rEnemyFlagship.State == BattleParticipantState.Sunk)
rSortieMap.HP = rSortieMap.HP.Update(Math.Max(rCurrentHP, 0));
else
Expand Down
96 changes: 73 additions & 23 deletions HeavenlyWind.Game/Models/AirForceGroup.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
using System.Linq;
using Sakuno.KanColle.Amatsukaze.Game.Models.Raw;
using Sakuno.KanColle.Amatsukaze.Game.Models.Raw;
using System;

namespace Sakuno.KanColle.Amatsukaze.Game.Models
{
public class AirForceGroup : RawDataWrapper<RawAirForceGroup>, IID
{
static int[] r_FighterFPBouns = { 0, 0, 2, 5, 9, 14, 14, 22 };
static int[] r_SeaplaneBomberFPBouns = { 0, 0, 1, 1, 1, 3, 3, 6 };
static int[] r_InternalFPBonus = { 10, 25, 40, 55, 70, 85, 100, 120 };

public int ID => RawData.ID;

string r_Name;
Expand All @@ -21,29 +25,30 @@ internal set
}
}

int r_MinCombatRadius;
public int MinCombatRadius
int r_CombatRadius;
public int CombatRadius
{
get { return r_MinCombatRadius; }
set
get { return r_CombatRadius; }
internal set
{
if (r_MinCombatRadius != value)
if (r_CombatRadius != value)
{
r_MinCombatRadius = value;
OnPropertyChanged(nameof(MinCombatRadius));
r_CombatRadius = value;
OnPropertyChanged(nameof(CombatRadius));
}
}
}
int r_MaxCombatRadius;
public int MaxCombatRadius

int r_FighterPower;
public int FighterPower
{
get { return r_MaxCombatRadius; }
set
get { return r_FighterPower; }
internal set
{
if (r_MaxCombatRadius != value)
if (r_FighterPower != value)
{
r_MaxCombatRadius = value;
OnPropertyChanged(nameof(MaxCombatRadius));
r_FighterPower = value;
OnPropertyChanged(nameof(FighterPower));
}
}
}
Expand Down Expand Up @@ -76,17 +81,62 @@ protected override void OnRawDataUpdated()

Squadrons.UpdateRawData(RawData.Squadrons, r => new AirForceSquadron(r), (rpData, rpRawData) => rpData.Update(rpRawData));

UpdateCombatRadius();
CombatRadius = RawData.CombatRadius;

UpdateFighterPower();
}

internal void UpdateCombatRadius()
internal void UpdateFighterPower()
{
var rSquadrons = Squadrons.Values.Where(r => r.State == AirForceSquadronState.Idle);
if (!rSquadrons.Any())
return;
var rFighterPower = 0;

foreach (var rSquadron in Squadrons.Values)
{
if (rSquadron.State != AirForceSquadronState.Idle)
continue;

var rPlane = rSquadron.Plane;
var rInfo = rPlane.Info;

if (!rInfo.CanParticipateInFighterCombat)
continue;

var rResult = (rInfo.AA + rInfo.Interception * 1.5) * Math.Sqrt(rSquadron.Count);
rFighterPower += (int)rResult;

switch (rInfo.Type)
{
case EquipmentType.CarrierBasedFighter:
rResult += rPlane.Level * .2 * Math.Sqrt(rSquadron.Count);
break;
case EquipmentType.CarrierBasedDiveBomber:
rResult += rPlane.Level * .25 * Math.Sqrt(rSquadron.Count);
break;
}

if (rSquadron.Count > 0)
{
var rProficiency = rPlane.Proficiency;

switch (rInfo.Type)
{
case EquipmentType.CarrierBasedFighter:
case EquipmentType.SeaplaneFighter:
case EquipmentType.InterceptorFighter:
rResult += r_FighterFPBouns[rProficiency];
break;

case EquipmentType.SeaplaneBomber:
rResult += r_SeaplaneBomberFPBouns[rProficiency];
break;
}

rResult += Math.Sqrt(r_InternalFPBonus[rProficiency] / 10.0);
}
rFighterPower += (int)rResult;
}

MinCombatRadius = rSquadrons.Min(r => r.Plane.Info.CombatRadius);
MaxCombatRadius = rSquadrons.Max(r => r.Plane.Info.CombatRadius);
FighterPower = rFighterPower;
}
}
}
2 changes: 1 addition & 1 deletion HeavenlyWind.Game/Models/AirForceSquadron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal protected AirForceSquadron(RawAirForceSquadron rpRawData) : base(rpRawD
protected override void OnRawDataUpdated()
{
if (State == AirForceSquadronState.Relocating && r_Relocating == null)
r_Relocating = Observable.Interval(TimeSpan.FromMinutes(20.0)).Subscribe(delegate
r_Relocating = Observable.Interval(TimeSpan.FromMinutes(12.0)).Subscribe(delegate
{
RawData.State = AirForceSquadronState.Empty;
RawData.EquipmentID = 0;
Expand Down
2 changes: 1 addition & 1 deletion HeavenlyWind.Game/Models/Battle/BattleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void SetEnemy(RawBattleBase rpData)
var rEquipment = rpData.EnemyEquipment[i];
return new EnemyShip(r, rLevel, rEquipment);
}).ToList<IParticipant>().AsReadOnly();
}).ToArray<IParticipant>();
}
void SetFormationAndEngagementForm(ApiData rpData)
{
Expand Down
Loading

0 comments on commit b49490b

Please sign in to comment.