private Dictionary<int, int> MakeShipTypeTable(ShipViewModel[] source) { if (source.Count() <= 0) return new Dictionary<int, int>(); Dictionary<int, int> temp = new Dictionary<int, int>(); List<int> rawList = new List<int>(); List<int> DistinctList = new List<int>(); foreach (var ship in source) { int ID = ship.Ship.Info.ShipType.Id; rawList.Add(ID); } for (int i = 0; i < rawList.Count; i++) { if (DistinctList.Contains(rawList[i])) continue; DistinctList.Add(rawList[i]); } for (int i = 0; i < DistinctList.Count; i++) { temp.Add(DistinctList[i], rawList.Where(x => x == DistinctList[i]).Count()); } return temp; }
private bool DrumCount(int Mission, ShipViewModel[] fleet) { bool result = false; var NeedDrumRaw = KanColleClient.Current.Translations.GetExpeditionData("DrumCount", Mission); var sNeedDrumRaw = NeedDrumRaw.Split(';'); int nTotalDrum = Convert.ToInt32(sNeedDrumRaw[0]); int nHasDrumShip = Convert.ToInt32(sNeedDrumRaw[1]); this.nDrum = "총" + sNeedDrumRaw[0] + "개, " + "장착칸무스 최소 " + sNeedDrumRaw[1] + "척"; this.vDrum = Visibility.Visible; int rTotalDrum = 0; int rHasDrumShip = 0; bool shipCheck = false; for (int i = 0; i < fleet.Count(); i++) { for (int j = 0; j < fleet[i].Ship.Slots.Count(); j++) { if (fleet[i].Ship.Slots[j].Equipped && fleet[i].Ship.Slots[j].Item.Info.CategoryId == 30) { rTotalDrum++; if (!shipCheck) { rHasDrumShip++; shipCheck = true; } } } shipCheck = false; } if (rTotalDrum >= nTotalDrum && rHasDrumShip >= nHasDrumShip) result = true; return result; }
/// <summary> /// /// </summary> /// <param name="total"></param> /// <param name="MissonNum"></param> /// <param name="ResourceType">0=연료 1=탄</param> /// <returns></returns> private int LossResource(ShipViewModel[] fleet, int MissionNum, int ResourceType = 0) { double total = 0; string losstype = "FuelLoss"; if (ResourceType == 1) losstype = "ArmoLoss"; var percent = KanColleClient.Current.Translations.GetExpeditionData(losstype, MissionNum); if (percent == string.Empty) return -1; double LossPercent = (double)Convert.ToInt32(percent) / 100d; for (int i = 0; i < fleet.Count(); i++) { double temp = 0; if (ResourceType == 1) temp = Convert.ToInt32(Math.Truncate((double)fleet[i].Ship.Bull.Maximum * LossPercent)); else temp = Convert.ToInt32(Math.Truncate((double)fleet[i].Ship.Fuel.Maximum * LossPercent)); total += temp; } if (ResourceType == 1) this.vArmo = Visibility.Visible; else this.vFuel = Visibility.Visible; this.vResource = Visibility.Visible; return Convert.ToInt32(total); }
private bool CompareExpeditionData(string Mission, ShipViewModel[] fleet) { this.vFlag = Visibility.Collapsed; this.vFlagType = Visibility.Collapsed; this.vNeed = Visibility.Collapsed; this.vTotal = Visibility.Collapsed; this.vDrum = Visibility.Collapsed; this.vFuel = Visibility.Collapsed; this.vArmo = Visibility.Collapsed; this.vResource = Visibility.Collapsed; if (fleet.Count() <= 0) return false; if (Mission == null) return false; bool Chk = true; int MissionNum = 0; try { MissionNum = Convert.ToInt32(Mission); } catch { return false; } if (this.ShipTypeTable.Count <= 0) Chk = false; if (MissionNum < 1) return false; this.ShipTypeTable = this.ChangeSpecialType(this.ShipTypeTable, MissionNum); this.nArmoLoss = LossResource(fleet, MissionNum, 1); this.nFuelLoss = LossResource(fleet, MissionNum); var NeedShipRaw = KanColleClient.Current.Translations.GetExpeditionData("FormedNeedShip", MissionNum).Split(';'); var FLv = KanColleClient.Current.Translations.GetExpeditionData("FlagLv", MissionNum); var TotalLevel = KanColleClient.Current.Translations.GetExpeditionData("TotalLv", MissionNum); var FlagShipType = KanColleClient.Current.Translations.GetExpeditionData("FlagShipType", MissionNum); StringBuilder strb = new StringBuilder(); if (KanColleClient.Current.Translations.GetExpeditionData("DrumCount", MissionNum) != string.Empty) Chk = this.DrumCount(MissionNum, fleet); if (NeedShipRaw[0] == string.Empty) return false; else strb.Append("총" + Convert.ToInt32(NeedShipRaw[0]) + "("); if (fleet.Count() < Convert.ToInt32(NeedShipRaw[0])) Chk = false; if (FLv != string.Empty && FLv != "-") { int lv = Convert.ToInt32(FLv); if (fleet[0] != null && fleet[0].Ship.Level < lv) Chk = false; this.FlagLv = ("Lv" + lv); this.vFlag = Visibility.Visible; } if (TotalLevel != string.Empty) { int totallv = Convert.ToInt32(TotalLevel); if (fleet.Sum(x => x.Ship.Level) < totallv) Chk = false; this.TotalLv = ("Lv" + totallv); this.vTotal = Visibility.Visible; } if (FlagShipType != string.Empty) { int flagship = Convert.ToInt32(FlagShipType); if (fleet[0].Ship.Info.ShipType.Id != flagship) Chk = false; this.FlagType = (KanColleClient.Current.Translations.GetTranslation("", TranslationType.ShipTypes, false, null, flagship)); this.vFlagType = Visibility.Visible; } Dictionary<int, int> ExpeditionTable = new Dictionary<int, int>(); if (NeedShipRaw.Count() > 1) { var Ships = NeedShipRaw[1].Split(','); for (int i = 0; i < Ships.Count(); i++) { var shipInfo = Ships[i].Split('*'); if (shipInfo.Count() > 1) ExpeditionTable.Add(Convert.ToInt32(shipInfo[0]), Convert.ToInt32(shipInfo[1])); } var list = ExpeditionTable.ToList(); for (int i = 0; i < ExpeditionTable.Count; i++) { if (i == 0) { strb.Append(KanColleClient.Current.Translations.GetTranslation("", TranslationType.ShipTypes, false, null, list[i].Key) + "×" + list[i].Value); } else strb.Append("・" + KanColleClient.Current.Translations.GetTranslation("", TranslationType.ShipTypes, false, null, list[i].Key) + "×" + list[i].Value); } strb.Append(")"); strb = strb.Replace("()", ""); this.ShipTypeString = strb.ToString(); if (this.ShipTypeString.Count() > 0) this.vNeed = Visibility.Visible; for (int i = 0; i < ExpeditionTable.Count; i++) { var test = ExpeditionTable.ToList(); if (this.ShipTypeTable.ContainsKey(test[i].Key)) { var Count = this.ShipTypeTable[test[i].Key]; if (ExpeditionTable[test[i].Key] > this.ShipTypeTable[test[i].Key]) Chk = false; } else Chk = false; } } return Chk; }