public ObjectVsObjectDO(ObjectScore objScore, string tourId, string tourType, int tourNumber) { _ObjScore = objScore; _TourType = tourType; _TourId = tourId; _TourNumber = tourNumber; _killsOf = _ObjScore.KillsOf; _killsIn = _ObjScore.KillsIn; _killedBy = _ObjScore.KilledBy; _diedIn = _ObjScore.DiedIn; }
/// <summary> /// /// </summary> /// <param name="pilots"></param> /// <param name="squadName"></param> /// <param name="tourNumber"></param> /// <param name="modelList"></param> /// <returns></returns> public AcesHighPilotStats BuildSquadStatsObject(Squad squad, int tourNumber, ref bool reloadPilotsRequired) { string tourIdentifier = ""; string tourType = ""; Dictionary<string, ObjectScore> tourStats = new Dictionary<string, ObjectScore>(); // FOR EACH PILOT IN SQUAD foreach (Squad.SquadMember squadMember in squad.Members) { if (!Registry.Instance.PilotStatsContains(squadMember.PilotName)) continue; // get pilot's registry. Registry.PilotStatsRegistry pilotReg = Registry.Instance.GetPilotStats(squadMember.PilotName); // If Pilot wasnt in this sqaud for this tour, dont count their data if (!squad.WasPilotInSquadForThisTour(tourNumber, squadMember)) continue; // FOR EACH MODEL foreach (ObjectVsObjectDO objVsObj in pilotReg.ObjVsObjCompleteList) { // only for the tour we're interested in if (objVsObj.TourNumber == tourNumber) { if (tourIdentifier == "") tourIdentifier = objVsObj.TourIdentfier; if(tourType == "") tourType = objVsObj.TourType; if (!tourStats.ContainsKey(objVsObj.Model)) { // doesnt exist yet? create new one and add. ObjectScore thisObjvObj = new ObjectScore(); thisObjvObj.Model = objVsObj.Model; thisObjvObj.KilledBy = objVsObj.KilledBy; thisObjvObj.KillsIn = objVsObj.KillsIn; thisObjvObj.KillsOf = objVsObj.KillsOf; thisObjvObj.DiedIn = objVsObj.DiedIn; if (objVsObj.DiedIn == null) reloadPilotsRequired = true; tourStats.Add(thisObjvObj.Model, thisObjvObj); } else { // get existing objects reference and add to it. ObjectScore thisObjvObj = tourStats[objVsObj.Model]; thisObjvObj.KilledBy += objVsObj.KilledBy; thisObjvObj.KillsIn += objVsObj.KillsIn; thisObjvObj.KillsOf += objVsObj.KillsOf; thisObjvObj.DiedIn += objVsObj.DiedIn; if (objVsObj.DiedIn == null) reloadPilotsRequired = true; } } } } AcesHighPilotStats squadStatsObj = new AcesHighPilotStats(); Utility.ConstructAcesHighPilotStatsInnerObjects(ref squadStatsObj, tourStats.Count); squadStatsObj.GameId = squad.SquadName; squadStatsObj.TourId = tourNumber.ToString(); squadStatsObj.TourType = tourType; squadStatsObj.TourDetails = tourIdentifier; // copy the list content to bounded sized array. int i = 0; foreach(ObjectScore obj in tourStats.Values) { squadStatsObj.VsObjects.ObjectScore[i++] = obj; } return squadStatsObj; }