public UpgradeInfo(ShipItemViewModel parent, KanColleWrapper.Models.ShipInfo ShipData, int Level, bool NeedPaper = false, bool NeedCatapult = false) { this.Parent = parent; if (ShipData == null) { return; } this.Id = ShipData.Id; this.RequiredLevel = Level; this.Name = ShipData?.Name ?? "???"; this.Requires = string.Join( ", ", new string[] { NeedPaper ? "개장설계도" : "", NeedCatapult ? "캐터펄트" : "" }.Where(x => x.Length > 0).ToArray() ); }
public ShipItemViewModel(DictionaryShipViewModel parent, KanColleWrapper.Models.ShipInfo ShipData) { this.Parent = parent; this.Ship = ShipData; this._Name = this.Ship?.Name ?? "???"; this._Id = this.Ship?.Id.ToString() ?? "???"; this._ShipType = this.Ship?.ShipType.Name ?? "???"; if (this.Ship == null) { this.Upgrades = new UpgradeInfo[0]; } else { // Find root var master = KanColleClient.Current.Master; var root = this.Ship; while (master.Ships.Any(x => x.Value.RawData.api_aftershipid == root.Id.ToString())) { root = master.Ships.FirstOrDefault(x => x.Value.RawData.api_aftershipid == root.Id.ToString()).Value; } List <UpgradeInfo> list = new List <UpgradeInfo>(); var reqLv = 1; while (!list.Any(x => x.Id == root.Id)) { bool NeedPaper, NeedCatapult; NeedPaper = master.RawData.api_mst_shipupgrade .FirstOrDefault(x => x.api_id == root.Id) ?.api_drawing_count > 0; NeedCatapult = master.RawData.api_mst_shipupgrade .FirstOrDefault(x => x.api_id == root.Id) ?.api_catapult_count > 0; list.Add(new UpgradeInfo(this, root, reqLv, NeedPaper, NeedCatapult)); if (!root.RemodelingExists) { break; } int after; if (!int.TryParse(root.RawData.api_aftershipid, out after)) { break; } if (after == 0) { break; } reqLv = root.NextRemodelingLevel ?? 1; root = master.Ships.FirstOrDefault(x => x.Value.Id == after).Value; } this.Upgrades = list.ToArray(); } this.Update(); }