Skip to content

Commit

Permalink
增加改修时的消耗数据
Browse files Browse the repository at this point in the history
改正之前搞错的英文单词(
  • Loading branch information
Yoctillion committed Feb 26, 2016
1 parent add50a1 commit 9384cb8
Show file tree
Hide file tree
Showing 17 changed files with 571 additions and 160 deletions.
17 changes: 17 additions & 0 deletions RemodelHelper/Models/ConsumptionData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RemodelHelper.Models
{
public class ConsumptionData
{
public int Lv { get; set; }
public int[] BKit { get; set; }
public int[] RKit { get; set; }
public int CId { get; set; }
public int Count { get; set; }
}
}
33 changes: 33 additions & 0 deletions RemodelHelper/Models/ConsumptionInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Grabacr07.KanColleWrapper.Models;

namespace RemodelHelper.Models
{
public class ConsumptionInfo
{
public int Level { get; internal set; }

public KitCount BuildKit { get; internal set; }
public KitCount RemodelKit { get; internal set; }

public SlotItemInfo ConsumeSlotItem { get; internal set; }
public int ConsumeCount { get; internal set; }
}

public class KitCount
{
public int Normal { get; internal set; }
public int Ensure { get; internal set; }

public override string ToString()
{
var n = this.Normal >= 0 ? this.Normal.ToString() : "-";
var e = this.Ensure >= 0 ? this.Ensure.ToString() : "-";
return $"{n}/{e}";
}
}
}
72 changes: 72 additions & 0 deletions RemodelHelper/Models/ItemInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
using Grabacr07.KanColleWrapper.Models;

namespace RemodelHelper.Models
{
public abstract class ItemInfo : IIdentifiable
{
public int Id => this.Info?.Id ?? 0;

public SlotItemInfo Info { get; }


internal ItemInfo(SlotItemInfo info)
{
this.Info = info;
}
}


public class BaseSlotItemInfo : ItemInfo
{
public IdentifiableTable<UpgradeSlotItemInfo> UpgradeSlotItems { get; } = new IdentifiableTable<UpgradeSlotItemInfo>();


internal BaseSlotItemInfo(Item item) : base(item.GetBaseSlotInfo())
{
this.AddUpgradeSlotItem(item);
}

internal void AddUpgradeSlotItem(Item item)
{
if (!this.UpgradeSlotItems.ContainsKey(item.NewId))
this.UpgradeSlotItems.Add(new UpgradeSlotItemInfo(item));
else
this.UpgradeSlotItems[item.NewId].AddAssistant(item);
}

public bool IsAvailable(DayOfWeek day) => this.UpgradeSlotItems.Values.Any(newSlot => newSlot.IsAvailable(day));
}


public class UpgradeSlotItemInfo : ItemInfo
{
public IdentifiableTable<AssistantInfo> Assistants { get; } = new IdentifiableTable<AssistantInfo>();

public int Level { get; set; }

public int Fuel { get; internal set; }
public int Ammo { get; internal set; }
public int Steel { get; internal set; }
public int Bauxite { get; internal set; }

public ConsumptionInfo[] Consumptions { get; internal set; }

internal UpgradeSlotItemInfo(Item item) : base(item.GetUpgradeSlotInfo())
{
this.AddAssistant(item);
}

internal void AddAssistant(Item item)
{
this.Assistants.Add(new AssistantInfo(item));
}

public bool IsAvailable(DayOfWeek day) => this.Assistants.Values.Any(ship => ship.IsAvailable(day));
}
}
34 changes: 26 additions & 8 deletions RemodelHelper/Models/RemodelDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ private RemodelData RawData

public string Version => this.RawData?.Version;

private IdentifiableTable<BaseSlotInfo> _items = new IdentifiableTable<BaseSlotInfo>();
private IdentifiableTable<BaseSlotItemInfo> _items = new IdentifiableTable<BaseSlotItemInfo>();

public IdentifiableTable<BaseSlotInfo> Items
public IdentifiableTable<BaseSlotItemInfo> Items
{
get { return this._items; }
private set
Expand Down Expand Up @@ -125,20 +125,38 @@ private void ParseData()
{
this.IsReady = false;

var newItems = new IdentifiableTable<BaseSlotInfo>();
var newItems = new IdentifiableTable<BaseSlotItemInfo>();

foreach (var item in this.RawData.Items.Where(item => item.GetBaseSlotInfo() != null))
{
if (!newItems.ContainsKey(item.SlotId))
newItems.Add(new BaseSlotInfo(item));
newItems.Add(new BaseSlotItemInfo(item));
else
newItems[item.SlotId].AddUpgradeSlot(item);
newItems[item.SlotId].AddUpgradeSlotItem(item);
}

foreach (var item in newItems.Values)
foreach (var newSlot in item.UpgradeSlots.Values)
newSlot.Level =
this.RawData.NewSlots.FirstOrDefault(s => s.Id == item.Id && s.NewId == newSlot.Id)?.Lv ?? 0;
foreach (var newItem in item.UpgradeSlotItems.Values)
{
var rawData = this.RawData.NewSlots.First(s => s.Id == item.Id && s.NewId == newItem.Id);
newItem.Level = rawData.Lv;

newItem.Fuel = rawData.Meterials[0];
newItem.Ammo = rawData.Meterials[1];
newItem.Steel = rawData.Meterials[2];
newItem.Bauxite = rawData.Meterials[3];

newItem.Consumptions = rawData.Consumption
.Select(c => new ConsumptionInfo
{
Level = c.Lv,
BuildKit = new KitCount { Normal = c.BKit[0], Ensure = c.BKit[1] },
RemodelKit = new KitCount { Normal = c.RKit[0], Ensure = c.RKit[1] },
ConsumeSlotItem = KanColleClient.Current.Master.SlotItems[c.CId],
ConsumeCount = c.Count,
})
.ToArray();
}

this.Items = newItems;

Expand Down
65 changes: 0 additions & 65 deletions RemodelHelper/Models/SlotInfo.cs

This file was deleted.

4 changes: 4 additions & 0 deletions RemodelHelper/Models/UpgradeData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ public class UpgradeData
public int NewId { get; set; }

public int Lv { get; set; }

public int[] Meterials { get; set; }

public ConsumptionData[] Consumption { get; set; }
}
}
2 changes: 1 addition & 1 deletion RemodelHelper/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace RemodelHelper
[Export(typeof(IPlugin))]
[ExportMetadata("Title", "改修助手")]
[ExportMetadata("Description", "改修工厂辅助插件")]
[ExportMetadata("Version", "1.0.1")]
[ExportMetadata("Version", "1.1.0")]
[ExportMetadata("Author", "Yoctillion")]
[ExportMetadata("Guid", "71C1EE7A-A153-437F-B75F-E3E22ED833F1")]
public class Plugin : ITool, IPlugin
Expand Down
2 changes: 1 addition & 1 deletion RemodelHelper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1")]
[assembly: AssemblyVersion("1.1.0")]
9 changes: 6 additions & 3 deletions RemodelHelper/RemodelHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,23 @@
<Compile Include="Controls\WeekPresenter.cs" />
<Compile Include="Converters\DayOfWeekAndIntConverter.cs" />
<Compile Include="IdentifiableTable.cs" />
<Compile Include="Models\ConsumptionData.cs" />
<Compile Include="Models\ConsumptionInfo.cs" />
<Compile Include="Models\DateChangeTrigger.cs" />
<Compile Include="Models\Item.cs" />
<Compile Include="Models\UpgradeData.cs" />
<Compile Include="Models\RemodelData.cs" />
<Compile Include="Models\RemodelDataProvider.cs" />
<Compile Include="Models\AssistantInfo.cs" />
<Compile Include="Models\SlotInfo.cs" />
<Compile Include="Models\ItemInfo.cs" />
<Compile Include="Models\Week.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="ViewModels\AssistantGroupViewModel.cs" />
<Compile Include="ViewModels\ConsumptionViewModel.cs" />
<Compile Include="ViewModels\DetailViewModel.cs" />
<Compile Include="ViewModels\ItemsViewModel.cs" />
<Compile Include="ViewModels\SlotTypeViewModel.cs" />
<Compile Include="ViewModels\SlotViewModel.cs" />
<Compile Include="ViewModels\SlotItemTypeViewModel.cs" />
<Compile Include="ViewModels\SlotItemViewModel.cs" />
<Compile Include="ViewModels\ToolViewModel.cs" />
<Compile Include="Views\DetailWindow.xaml.cs">
<DependentUpon>DetailWindow.xaml</DependentUpon>
Expand Down
66 changes: 66 additions & 0 deletions RemodelHelper/ViewModels/ConsumptionViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Grabacr07.KanColleWrapper.Models;
using Livet;
using RemodelHelper.Models;

namespace RemodelHelper.ViewModels
{
public class ConsumptionViewModel : ViewModel
{
public string Name
{
get
{
if (this.Info != null)
{
switch (this.Info.Level)
{
case 0:
return "初期";
case 6:
return "★6";
case 10:
return "★max";
}
}

return string.Empty;
}
}

private bool _isDifferent;

public bool IsDifferent
{
get { return this._isDifferent; }
set
{
if (this._isDifferent != value)
{
this._isDifferent = value;
this.RaisePropertyChanged();
}
}
}

private ConsumptionInfo _info;

public ConsumptionInfo Info
{
get { return this._info; }
set
{
if (this._info != value)
{
this._info = value;
this.RaisePropertyChanged();
this.RaisePropertyChanged(nameof(this.Name));
}
}
}
}
}
Loading

0 comments on commit 9384cb8

Please sign in to comment.