private List <ShipInfo> MakeShipList(XElement Context, bool IsImprovementList = false) { List <ShipInfo> ShipList = new List <ShipInfo>(); bool Checker = true; int ShipCount = 1; while (Checker) { //이름작성 string ShipElement = "ShipName"; var temp = ShipElement + ShipCount.ToString(); ShipInfo Ship = new ShipInfo(); Ship.IsSameUpgradeExist = false; if (Context.Element(temp) != null) { Ship.ShipName = Context.Element(temp).Value; Ship.ShipName = KanColleClient.Current.Translations.GetTranslation(Ship.ShipName, TranslationType.Ships, false); } else { Ship.ShipName = string.Empty; } //업그레이드 부분 ShipElement = "Upgrade"; temp = ShipElement + ShipCount.ToString(); if (Context.Element(temp) != null) { Ship.Upgrade = Context.Element(temp).Value; Ship.Upgrade = KanColleClient.Current.Translations.GetTranslation(Ship.Upgrade, TranslationType.Equipment, false); //슬롯 아이템 Master목록에서 해당되는 아이콘을 찾아 삽입 foreach (var slotitem in KanColleClient.Current.Master.SlotItems) { if (slotitem.Value.Name == Ship.Upgrade) { Ship.UpgradeIconType = slotitem.Value.IconType; } } } else { Ship.Upgrade = null; Ship.UpgradeIconType = null; } ShipElement = "WeekDays"; temp = ShipElement + ShipCount.ToString(); if (Context.Element(temp) != null) { int weekday = Convert.ToInt32(Context.Element(temp).Value); Ship.Weekday = WeekDaySetter(weekday); } else { Ship.Weekday = WeekDayFlag.None; } if (Ship.Weekday == WeekDayFlag.None && Ship.Upgrade == null && Ship.ShipName == string.Empty) { Checker = false; } else { if (Ship.ShipName != string.Empty) { if (Ship.Weekday.HasFlag(today)) { if (IsImprovementList) { if (Ship.Upgrade != null) { ShipList.Add(Ship); ShipCount++; } else { ShipCount++; } } else { ShipList.Add(Ship); ShipCount++; } } else { ShipCount++; } } else { if (IsImprovementList) { if (Ship.Upgrade != null) { Ship.ShipName = "없음"; ShipList.Add(Ship); ShipCount++; } else { ShipCount++; } } else { ShipCount++; } } } } //while구문 종료 return(ShipList); }
/// <summary> /// 개수 가능 함선 목록 작성 /// </summary> private List <ShipInfo> MakeShipList(XElement Context) { List <ShipInfo> ShipList = new List <ShipInfo>(); for (int ShipCount = 1; ; ShipCount++) { // 이름작성 string ShipElement; ShipInfo Ship = new ShipInfo(); // 함선명 ShipElement = string.Format("ShipName{0}", ShipCount); Ship.ShipName = Context.Element(ShipElement)?.Value ?? null; if (Ship.ShipName != null) { Ship.ShipName = Ship.ShipName.StartsWith("※") ? Ship.ShipName : KanColleClient.Current.Translations.GetTranslation(Ship.ShipName, TranslationType.Ships, false); } else { break; } // 업그레이드 부분 ShipElement = string.Format("Upgrade{0}", ShipCount); Ship.Upgrade = Context.Element(ShipElement)?.Value ?? null; if (Ship.Upgrade != null) { Ship.Upgrade = KanColleClient.Current.Translations.GetTranslation(Ship.Upgrade, TranslationType.Equipment, false); //슬롯 아이템 Master목록에서 해당되는 아이콘을 찾아 삽입 Ship.UpgradeIconType = KanColleClient.Current.Master.SlotItems .Where(x => x.Value.Name == Ship.Upgrade) .Select(x => x.Value.IconType) .FirstOrDefault(); } // 개수 가능일 ShipElement = string.Format("WeekDays{0}", ShipCount); var weekDays = Context.Element(ShipElement)?.Value ?? null; if (weekDays != null) { int weekday = Convert.ToInt32(weekDays); Ship.Weekday = WeekDaySetter(weekday); } if (Ship.Weekday == WeekDayFlag.None && Ship.Upgrade == null && Ship.ShipName == null) { break; } if (Ship.Weekday.HasFlag(today)) { ShipList.Add(Ship); } /* Upgrade 항목은 있지만 ShipName 은 없는 경우. 존재하지 않을테니 주석으로 * // * 사용한다면 상단 함선명의 else continue; 를 주석으로 * else if (IsImprovementList && Ship.Upgrade != null) * { * Ship.ShipName = "없음"; * ShipList.Add(Ship); * } * // */ } // while구문 종료 return(ShipList); }