private void AddScores(Dictionary <string, Player> homePlayerMap, Dictionary <string, Player> awayPlayerMap, IList <Jam> jams, IList <JamScoreModel> scores) { JammerGateway jammerGateway = new JammerGateway(_connection, _transaction); foreach (JamScoreModel jamScoreModel in scores) { Jam jam = jams.First(j => j.IsFirstHalf == jamScoreModel.IsFirstHalf && j.JamNumber == jamScoreModel.JamNumber); if (jamScoreModel.HomeStarPass == null) { AddJammer(jammerGateway, homePlayerMap, jam, jamScoreModel.HomeJammer, false, false); } else { AddJammer(jammerGateway, homePlayerMap, jam, jamScoreModel.HomeJammer, true, false); AddJammer(jammerGateway, homePlayerMap, jam, jamScoreModel.HomeStarPass, false, true); } if (jamScoreModel.AwayStarPass == null) { AddJammer(jammerGateway, awayPlayerMap, jam, jamScoreModel.AwayJammer, false, false); } else { AddJammer(jammerGateway, awayPlayerMap, jam, jamScoreModel.AwayJammer, true, false); AddJammer(jammerGateway, awayPlayerMap, jam, jamScoreModel.AwayStarPass, false, true); } } }
public ActionResult DeleteConfirmed(int id) { Jam jam = db.Jams.Find(id); db.Jams.Remove(jam); db.SaveChanges(); return(RedirectToAction("Index")); }
static void AddNew(Slot slot, string type) { Jam jam = ContentAssistant.main.GetItem <Jam>("Jam"); jam.type = type; jam.transform.SetParent(slot.transform); jam.transform.localPosition = Vector3.zero; jam.name = "Jam_" + slot.coord.x + "x" + slot.coord.y; slot.jam = jam; }
public PenaltyProcessor(IList <Jam> jams, Dictionary <string, Player> homePlayers, Dictionary <string, Player> awayPlayers) { _jams = jams; _players = homePlayers.Values.ToDictionary(p => p.ID); foreach (Player player in awayPlayers.Values) { _players[player.ID] = player; } _lastJam = _jams.Last(); }
internal Jam ReadData(SqlDataReader reader) { Jam jam = new Jam(); jam.BoutID = reader.GetInt32(reader.GetOrdinal("BoutID")); jam.ID = reader.GetInt32(reader.GetOrdinal("ID")); jam.IsFirstHalf = reader.GetBoolean(reader.GetOrdinal("IsFirstHalf")); jam.JamNumber = reader.GetInt32(reader.GetOrdinal("JamNum")); return(jam); }
// ※ この問題はJam、Toastクラスを完成させてから実施してください public static void Main(string[] args) { // TODO Jam型のインスンタンスを引数 ブルーベリー で作成してください var jam = new Jam("ブルーベリー"); // TODO Toast型のインスンタンスを作成してください。 var toast = new Toast(jam); // TODO 作成したToast型インスタンスからTasteメソッドを呼び出してください toast.Taste(); }
// Coroutine of special control mode public override IEnumerator Logic() { spoon.gameObject.SetActive(false); yield return(StartCoroutine(Utils.WaitFor(SessionAssistant.main.CanIWait, 0.1f))); Slot target = null; while (true) { if (Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)) { target = ControlAssistant.main.GetSlotFromTouch(); } if (target != null && (!target.chip || target.chip.chipType != "Sugar")) { spoon.transform.position = target.transform.position; spoon.gameObject.SetActive(true); spoon.Play(); CPanel.uiAnimation++; yield return(new WaitForSeconds(0.91f)); ProfileAssistant.main.local_profile["spoon"]--; ItemCounter.RefreshAll(); FieldAssistant.main.BlockCrush(target.coord, false); FieldAssistant.main.JellyCrush(target.coord); SessionAssistant.main.EventCounter(); if (target.chip) { target.chip.jamType = Jam.GetType(target); target.chip.DestroyChip(); } while (spoon.isPlaying) { yield return(0); } spoon.gameObject.SetActive(false); CPanel.uiAnimation--; break; } yield return(0); } UIAssistant.main.ShowPage("Field"); }
public bool IsOneJamBefore(Jam jam, int lastP1Jam) { if (IsFirstHalf == jam.IsFirstHalf) { return(JamNumber == jam.JamNumber - 1); } else if (IsFirstHalf && JamNumber == lastP1Jam) { return(!jam.IsFirstHalf && jam.JamNumber == 1); } return(false); }
private int GetNextJamID(int jamID) { Jam currentJam = _jams.First(j => j.ID == jamID); var nextJam = _jams.FirstOrDefault(j => j.IsFirstHalf == currentJam.IsFirstHalf && j.JamNumber == currentJam.JamNumber + 1); if (nextJam == null && currentJam.IsFirstHalf) { nextJam = _jams.First(j => !j.IsFirstHalf && j.JamNumber == 1); } return(nextJam == null ? -1 : nextJam.ID); }
public bool IsOneJamBefore(Jam jam, int lastP1Jam) { if (IsFirstHalf == jam.IsFirstHalf) { return JamNumber == jam.JamNumber - 1; } else if (IsFirstHalf && JamNumber == lastP1Jam) { return !jam.IsFirstHalf && jam.JamNumber == 1; } return false; }
public ActionResult Edit([Bind(Include = "JamID,TrajectID,RegionID,JamText")] Jam jam) { if (ModelState.IsValid) { db.Entry(jam).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RegionID = new SelectList(db.Regions, "RegionID", "RegionName", jam.RegionID); ViewBag.TrajectID = new SelectList(db.Trajects, "ID", "TrajectName", jam.TrajectID); return(View(jam)); }
public Jam Put([FromBody] Jam value) { Jam existingJam = jamRepo.GetById(value.JamId); existingJam.Name = value.Name; existingJam.Description = value.Description; existingJam.MaxNumberOfAttendees = value.MaxNumberOfAttendees; existingJam.EventDate = value.EventDate; jamRepo.Update(existingJam); return(jamRepo.GetById(value.JamId)); }
public bool IsBetweenJams(Jam startJam, Jam endJam) { if (endJam == null) { return((startJam.IsFirstHalf && !IsFirstHalf) || (startJam.IsFirstHalf == IsFirstHalf && startJam.JamNumber <= JamNumber)); } else { return ((IsFirstHalf && startJam.IsFirstHalf && JamNumber >= startJam.JamNumber && (!endJam.IsFirstHalf || endJam.JamNumber >= JamNumber)) || (!IsFirstHalf && !endJam.IsFirstHalf && endJam.JamNumber >= JamNumber && (startJam.IsFirstHalf || startJam.JamNumber <= JamNumber))); } }
public bool IsBetweenJams(Jam startJam, Jam endJam) { if (endJam == null) { return (startJam.IsFirstHalf && !IsFirstHalf) || (startJam.IsFirstHalf == IsFirstHalf && startJam.JamNumber <= JamNumber); } else { return (IsFirstHalf && startJam.IsFirstHalf && JamNumber >= startJam.JamNumber && (!endJam.IsFirstHalf || endJam.JamNumber >= JamNumber)) || (!IsFirstHalf && !endJam.IsFirstHalf && endJam.JamNumber >= JamNumber && (startJam.IsFirstHalf || startJam.JamNumber <= JamNumber)); } }
// GET: Jams/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Jam jam = db.Jams.Find(id); if (jam == null) { return(HttpNotFound()); } return(View(jam)); }
private Dictionary <int, List <JamPlayer> > CreateJamPlayerMap(Dictionary <string, Player> homePlayerMap, Dictionary <string, Player> awayPlayerMap, IList <Jam> jamList, IList <JamLineupModel> lineups) { Dictionary <int, List <JamPlayer> > map = new Dictionary <int, List <JamPlayer> >(); JamPlayerGateway jamPlayerGateway = new JamPlayerGateway(_connection, _transaction); foreach (JamLineupModel jamLineup in lineups) { Jam jam = jamList.First(j => j.IsFirstHalf == jamLineup.IsFirstHalf && j.JamNumber == jamLineup.JamNumber); List <JamPlayer> list = AddJamPlayers(homePlayerMap, jam, jamLineup.HomeLineup, jamPlayerGateway); list.AddRange(AddJamPlayers(awayPlayerMap, jam, jamLineup.AwayLineup, jamPlayerGateway)); map[jam.ID] = list; } return(map); }
public static void Initialize() { words.Add("CurrentLevel", () => { return(LevelProfile.main.level.ToString()); }); words.Add("CurrentScore", () => { return(SessionAssistant.main.score.ToString()); }); words.Add("FirstStarScore", () => { return(LevelProfile.main.firstStarScore.ToString()); }); words.Add("SecondStarScore", () => { return(LevelProfile.main.secondStarScore.ToString()); }); words.Add("ThirdStarScore", () => { return(LevelProfile.main.thirdStarScore.ToString()); }); words.Add("BestScore", () => { return(ProfileAssistant.main.local_profile.GetScore(LevelProfile.main.level).ToString()); }); words.Add("BlockCount", () => { return(GameObject.FindObjectsOfType <Block> ().Length.ToString()); }); words.Add("BlockCountTotal", () => { return(SessionAssistant.main.blockCountTotal.ToString()); }); words.Add("JellyCount", () => { return(Slot.all.Count(x => x.Value.jelly).ToString()); }); words.Add("JellyCountTotal", () => { return(SessionAssistant.main.jellyCountTotal.ToString()); }); words.Add("JamCount", () => { return(Slot.all.Count(x => Jam.GetType(x.Value) == "Jam A").ToString()); }); words.Add("JamCountTotal", () => { return(Slot.all.Count.ToString()); }); words.Add("SugarCount", () => { return(SessionAssistant.main.targetSugarDropsCount.ToString()); }); words.Add("SugarCountTotal", () => { return(LevelProfile.main.targetSugarDropsCount.ToString()); }); words.Add("CurrentMoves", () => { return(SessionAssistant.main.movesCount.ToString()); }); words.Add("CurrentTime", () => { return(Utils.ToTimerFormat(SessionAssistant.main.timeLeft)); }); words.Add("WaitingStatus", () => { return(Utils.waitingStatus); }); words.Add("TargetModeName", () => { return(LocalizationAssistant.main["targetmodename_" + LevelProfile.main.target]); }); words.Add("BoosterSelectedName", () => { return(BerryStoreAssistant.main.GetItemByID(BoosterButton.boosterSelectedId).name); }); words.Add("BoosterSelectedPackDescription", () => { return(LocalizationAssistant.main[BerryStoreAssistant.main.GetItemByID(BoosterButton.boosterSelectedId).localization_description]); }); words.Add("LifesCount", () => { return(ProfileAssistant.main.local_profile["life"].ToString()); }); words.Add("SpinCost", () => { return(SpinWheel._spinCost.ToString()); }); words.Add("LastReward", () => { return(SpinWheel.lastReward); }); words.Add("ColorCollections", () => { string r = ""; foreach (int i in SessionAssistant.main.countOfEachTargetCount) { r += (r.Length > 0 ? "," : "") + Mathf.Max(0, i).ToString(); } return(r); }); words.Add("NextLifeTimer", () => { if (ProfileAssistant.main.local_profile["life"] >= ProjectParameters.main.lifes_limit) { return(LocalizationAssistant.main["full"]); } System.TimeSpan span = ProfileAssistant.main.local_profile.next_life_time - System.DateTime.Now; if (span.TotalSeconds <= 0) { return("00:00"); } return(string.Format("{0:00}:{1:00}", span.Minutes, span.Seconds)); }); initialized = true; }
// GET: Jams/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Jam jam = db.Jams.Find(id); if (jam == null) { return(HttpNotFound()); } ViewBag.RegionID = new SelectList(db.Regions, "RegionID", "RegionName", jam.RegionID); ViewBag.TrajectID = new SelectList(db.Trajects, "ID", "TrajectName", jam.TrajectID); return(View(jam)); }
private void AddPenaltyServices(Dictionary <string, Player> homePlayerMap, Dictionary <string, Player> awayPlayerMap, IList <Jam> jams, IList <JamLineupModel> lineups, PenaltiesModel penalties) { Dictionary <int, Dictionary <int, IList <Models.BoxTimeModel> > > homePlayerBoxTimeMap = new Dictionary <int, Dictionary <int, IList <Models.BoxTimeModel> > >(); Dictionary <int, Dictionary <int, IList <Models.BoxTimeModel> > > awayPlayerBoxTimeMap = new Dictionary <int, Dictionary <int, IList <Models.BoxTimeModel> > >(); foreach (JamLineupModel jamLineup in lineups) { Jam jam = jams.First(j => j.IsFirstHalf == jamLineup.IsFirstHalf && j.JamNumber == jamLineup.JamNumber); foreach (PlayerLineupModel playerLineup in jamLineup.HomeLineup) { if (playerLineup == null) { continue; } if (playerLineup.BoxTimes != null && playerLineup.BoxTimes.Any()) { int playerID = homePlayerMap[playerLineup.PlayerNumber].ID; if (!homePlayerBoxTimeMap.ContainsKey(playerID)) { homePlayerBoxTimeMap[playerID] = new Dictionary <int, IList <Models.BoxTimeModel> >(); } homePlayerBoxTimeMap[playerID][jam.ID] = playerLineup.BoxTimes; } } foreach (PlayerLineupModel playerLineup in jamLineup.AwayLineup) { if (playerLineup.BoxTimes != null && playerLineup.BoxTimes.Any()) { int playerID = awayPlayerMap[playerLineup.PlayerNumber].ID; if (!awayPlayerBoxTimeMap.ContainsKey(playerID)) { awayPlayerBoxTimeMap[playerID] = new Dictionary <int, IList <Models.BoxTimeModel> >(); } awayPlayerBoxTimeMap[playerID][jam.ID] = playerLineup.BoxTimes; } } } Dictionary <int, PlayerPenaltiesModel> homePlayerPenalties = penalties.HomePlayerPenalties.ToDictionary(pp => homePlayerMap[pp.PlayerNumber].ID); Dictionary <int, PlayerPenaltiesModel> awayPlayerPenalties = penalties.AwayPlayerPenalties.ToDictionary(pp => awayPlayerMap[pp.PlayerNumber].ID); AddTeamPenaltyServices(jams, homePlayerMap, homePlayerBoxTimeMap, homePlayerPenalties); AddTeamPenaltyServices(jams, awayPlayerMap, awayPlayerBoxTimeMap, awayPlayerPenalties); }
public void Crush(int2 coord) { Slot s = Slot.GetSlot(coord); FieldAssistant.main.BlockCrush(coord, false, true); FieldAssistant.main.JellyCrush(coord); if (s) { Jam.JamIt(s, chip.jamType); } if (s && s.chip) { Chip c = s.chip; c.SetScore(0.3f); c.jamType = chip.jamType; c.DestroyChip(); } }
private void RemoveLastJamPenalties(Dictionary <int, List <Penalty> > playerPenaltyMap, Dictionary <int, List <BoxTime> > playerBoxTimeMap, List <PenaltyService> services) { var endGame = playerPenaltyMap.Values.SelectMany(p => p).Where(p => p.JamID == _lastJam.ID).ToList(); foreach (Penalty penalty in endGame) { if (playerBoxTimeMap.ContainsKey(penalty.PlayerID) && playerBoxTimeMap[penalty.PlayerID].Any() && playerBoxTimeMap[penalty.PlayerID].Last().JamID == _lastJam.ID) { continue; } Jam penaltyJam = _jams.First(j => j.ID == penalty.JamID); Player penaltyPlayer = _players[penalty.PlayerID]; Console.WriteLine(penaltyJam.ToString() + ": penalty by #" + penaltyPlayer.Number + " in last jam assumed to not have been served"); playerPenaltyMap[penalty.PlayerID].Remove(penalty); PenaltyService service = new PenaltyService(); service.Penalties.Add(penalty); services.Add(service); } }
private Dictionary <int, List <JamPlayer> > CreateJamPlayerMap(Dictionary <string, Player> homePlayerMap, Dictionary <string, Player> awayPlayerMap, IList <Jam> jamList, IList <JamLineupModel> lineups) { Dictionary <int, List <JamPlayer> > map = new Dictionary <int, List <JamPlayer> >(); JamPlayerGateway jamPlayerGateway = new JamPlayerGateway(_connection, _transaction); bool dupes = false; foreach (JamLineupModel jamLineup in lineups) { Jam jam = jamList.First(j => j.IsFirstHalf == jamLineup.IsFirstHalf && j.JamNumber == jamLineup.JamNumber); List <JamPlayer> list = AddJamPlayers(homePlayerMap, jam, jamLineup.HomeLineup, jamPlayerGateway, ref dupes); list.AddRange(AddJamPlayers(awayPlayerMap, jam, jamLineup.AwayLineup, jamPlayerGateway, ref dupes)); map[jam.ID] = list; } if (dupes) { throw new InvalidOperationException("Lineup dupes"); } return(map); }
public static bool Crush(int2 coord, string jamType = "") { Slot s = Slot.GetSlot(coord); FieldAssistant.main.BlockCrush(coord, false, true); FieldAssistant.main.JellyCrush(coord); if (s) { Jam.JamIt(s, jamType); } if (s && s.chip) { Chip c = s.chip; c.SetScore(0.3f); c.jamType = jamType; c.DestroyChip(); AnimationAssistant.main.Explode(s.transform.position, 3, 20); } return(coord.IsItHit(0, 0, LevelProfile.main.width - 1, LevelProfile.main.height - 1)); }
private int GetPreviousJamID(int jamID) { Jam currentJam = _jams.First(j => j.ID == jamID); if (currentJam.JamNumber == 1) { if (currentJam.IsFirstHalf) { return(-1); } else { // we need the last jam of the first half int lastJamNumber = _jams.Where(j => j.IsFirstHalf).Select(j => j.JamNumber).Max(); return(_jams.First(j => j.IsFirstHalf && j.JamNumber == lastJamNumber).ID); } } else { return(_jams.First(j => j.IsFirstHalf == currentJam.IsFirstHalf && j.JamNumber == currentJam.JamNumber - 1).ID); } }
private List <PenaltyService> ConvertBoxTimeList(List <BoxTime> playerBoxTimes) { List <PenaltyService> penaltyService = new List <PenaltyService>(); int boxTimeIndex = 0; while (boxTimeIndex < playerBoxTimes.Count) { PenaltyService service = new PenaltyService(); BoxTime lastBoxTime = playerBoxTimes[boxTimeIndex]; service.BoxTimes.Add(lastBoxTime); if (lastBoxTime.MatchingKey != null) { service.ServiceKey = lastBoxTime.MatchingKey; } boxTimeIndex++; while (lastBoxTime.EndedJamInBox && boxTimeIndex < playerBoxTimes.Count) { int nextJamID = GetNextJamID(lastBoxTime.JamID); BoxTime nextBoxTime = playerBoxTimes[boxTimeIndex]; if (nextBoxTime.JamID == nextJamID && (nextBoxTime.StartedJamInBox == null || nextBoxTime.StartedJamInBox == true)) { nextBoxTime.StartedJamInBox = true; service.BoxTimes.Add(nextBoxTime); lastBoxTime = nextBoxTime; boxTimeIndex++; } else { Jam jam = _jams.First(j => j.ID == lastBoxTime.JamID); Player player = _players[lastBoxTime.PlayerID]; Console.WriteLine(string.Format("{0}: No box time continuation for {1} {2}", jam.ToString(), player.Number, player.Name)); break; } } penaltyService.Add(service); } return(penaltyService); }
private void AddTeamPenalties(IList <Jam> jams, Dictionary <string, Player> players, Dictionary <int, PlayerPenaltiesModel> playerPenalties) { //PenaltyProcessor processor = new PenaltyProcessor(jams, players); PenaltyGateway penaltyGateway = new PenaltyGateway(_connection, _transaction); bool isSuccess = true; foreach (KeyValuePair <int, PlayerPenaltiesModel> kvp in playerPenalties) { int penaltyCount = 0; foreach (PenaltyModel penalty in kvp.Value.Penalties) { Jam jam = jams.FirstOrDefault(j => j.IsFirstHalf == penalty.IsFirstHalf && j.JamNumber == penalty.JamNumber); if (jam == null) { Console.WriteLine(string.Format("Unknown jam number {0} on penalty for player {1}.", penalty.JamNumber, kvp.Value.PlayerNumber)); isSuccess = false; } penaltyCount++; Penalty pen = new Penalty { JamID = jam.ID, PlayerID = kvp.Key, PenaltyCode = penalty.PenaltyCode, PenaltyNumber = penaltyCount, MatchingKey = penalty.SpecificKey }; if (pen.MatchingKey != null) { Console.WriteLine(string.Format("Special case penalty {0}{1} encountered in {2}", penalty.PenaltyCode, penalty.SpecificKey, penalty.JamNumber)); } penaltyGateway.AddBasicPenalty(pen); } } if (!isSuccess) { throw new InvalidOperationException("Bad penalty data"); } }
private int CompareJams(Jam jam1, Jam jam2) { if (jam1.IsFirstHalf && !jam2.IsFirstHalf) { return(-1); } else if (jam2.IsFirstHalf && !jam1.IsFirstHalf) { return(1); } else if (jam1.JamNumber < jam2.JamNumber) { return(-1); } else if (jam2.JamNumber < jam1.JamNumber) { return(1); } else { return(0); } }
private void CheckForBadFoulOuts(List <PenaltyService> services) { var returnedSeventh = services.Where(s => s.Penalties.Count > 0 && s.BoxTimes.Count > 0 && s.Penalties.Last().PenaltyNumber > 6 && !s.BoxTimes.Last().EndedJamInBox&& s.BoxTimes.Last().PlayerID == s.Penalties.Last().PlayerID); foreach (PenaltyService service in returnedSeventh) { Jam penaltyJam = _jams.First(j => j.ID == service.Penalties.Last().JamID); Player penaltyPlayer = _players[service.Penalties.Last().PlayerID]; // there is a possibility that a player was accidentally allowed to continue to play // if this is a multi-jam penalty service, log a warning and do nothing if (service.BoxTimes.Count > 1) { Console.WriteLine(string.Format("{0}: penalty by {1} {2} was 7th, but continued service in the next jam?", penaltyJam.ToString(), penaltyPlayer.Number, penaltyPlayer.Name)); } else { Console.WriteLine(string.Format("{0}: penalty by {1} {2} was 7th, but returned to track!", penaltyJam.ToString(), penaltyPlayer.Number, penaltyPlayer.Name)); service.BoxTimes.Last().EndedJamInBox = true; service.BoxTimes.Last().Finished = true; } } }
IEnumerator DestroyChipRoutine() { if (jamType == "") { jamType = Jam.GetType(slot); } Jam.JamIt(slot, jamType); yield return(StartCoroutine(logic.Destroying())); if (!destroying) { yield break; } if (IsColored()) { SessionAssistant.main.countOfEachTargetCount[id]--; } Destroy(gameObject); }
public JamUpdatedEvent(Guid boutId, Jam jam) : base(boutId) { Jam = jam; }
private bool IsBoxTimePossibleForPenalty(Jam penaltyJam, Jam boxTimeJam) { return(CompareJams(penaltyJam, boxTimeJam) >= 0); }
public bool Matches(Jam jam) { return IsFirstHalf == jam.IsFirstHalf && JamNumber == jam.JamNumber; }
private void HandleLeftoverPenalties(Dictionary <int, List <Penalty> > playerPenaltyMap, Dictionary <int, List <BoxTime> > playerBoxMap, Dictionary <int, bool> jamFullBoxMap, Dictionary <int, int> endJammerMap, List <PenaltyService> services) { var leftoverPenalties = playerPenaltyMap.Values.SelectMany(p => p).ToList(); var leftoverBoxes = playerBoxMap.Values.SelectMany(p => p).ToList(); // handle penalties with no time served while (leftoverPenalties.Count > 0) { Penalty penalty = leftoverPenalties[0]; Jam penaltyJam = _jams.First(j => j.ID == penalty.JamID); Player penaltyPlayer = _players[penalty.PlayerID]; bool wasEndJammer = endJammerMap.ContainsKey(penaltyJam.ID) && endJammerMap[penaltyJam.ID] == penaltyPlayer.ID; PenaltyService service = new PenaltyService(); service.Penalties.Add(penalty); // if no time was served, it's conceivable the penalty didn't get served until later on // TODO: confirm jammer penalty+service matching var matchingBoxes = leftoverBoxes .Where(bt => (bt.JamID > penalty.JamID && bt.IsJammer == wasEndJammer) || (bt.JamID == penalty.JamID && bt.PlayerID == penalty.PlayerID)) .OrderBy(bt => bt.JamID); if (matchingBoxes.Any()) { BoxTime bestBox = matchingBoxes.First(); Jam boxTimeJam = _jams.First(j => j.ID == bestBox.JamID); Player boxTimePlayer = _players[bestBox.PlayerID]; int nextJamID = GetNextJamID(penaltyJam.ID); if (boxTimeJam.ID - penaltyJam.ID > 1 && (!jamFullBoxMap.ContainsKey(nextJamID) || !jamFullBoxMap[nextJamID])) { string errorString = string.Format("{0}: penalty by {1} {2} does not appear correctly served.", penaltyJam.ToString(), penaltyPlayer.Number, penaltyPlayer.Name); Console.WriteLine(errorString); throw new InvalidDataException(errorString); } Console.WriteLine(string.Format("{0}: penalty by {1} {2} served by {3} {4}", penaltyJam.ToString(), penaltyPlayer.Number, penaltyPlayer.Name, boxTimePlayer.Number, boxTimePlayer.Name)); service.BoxTimes.Add(bestBox); leftoverBoxes.Remove(bestBox); playerBoxMap[bestBox.PlayerID].Remove(bestBox); leftoverPenalties.Remove(penalty); playerPenaltyMap[penalty.PlayerID].Remove(penalty); // see if this penalty has friends var hangersOn = leftoverPenalties.Where(p => p.JamID == penalty.JamID && p.PlayerID == penalty.PlayerID && p.PenaltyNumber != penalty.PenaltyNumber).ToList(); foreach (Penalty extra in hangersOn) { service.Penalties.Add(extra); leftoverPenalties.Remove(extra); playerPenaltyMap[extra.PlayerID].Remove(extra); } // get the ending jam of the service while (bestBox.EndedJamInBox && bestBox.JamID < _lastJam.ID) { BoxTime previousBox = bestBox; bestBox = leftoverBoxes.Where(bt => bt.StartedJamInBox == true && bt.JamID == bestBox.JamID + 1 && bt.PlayerID == bestBox.PlayerID).FirstOrDefault(); if (bestBox == null) { boxTimeJam = _jams.First(j => j.ID == previousBox.JamID); throw new InvalidDataException(boxTimeJam.ToString() + ": box time by #" + boxTimePlayer.Number + " does not appear correctly finished."); } service.BoxTimes.Add(bestBox); leftoverBoxes.Remove(bestBox); playerBoxMap[bestBox.PlayerID].Remove(bestBox); } services.Add(service); } else { Jam jam = _jams.First(j => j.ID == penalty.JamID); Player player = _players[penalty.PlayerID]; Console.WriteLine(string.Format("{0}: Unhandled Penalty for {1} {2}.", jam.ToString(), player.Number, player.Name)); throw new InvalidDataException(string.Format("{0}: Unhandled Penalty for {1} {2}.", jam.ToString(), player.Number, player.Name)); } } }
public void AddJamPass(Jam.JamPass pass) { try { int passNumber = 1; var lastPass = this.JamPasses.Where(x => x.Team == pass.Team).OrderByDescending(x => x.PassNumber).FirstOrDefault(); if (lastPass != null) { passNumber = lastPass.PassNumber; passNumber += 1; } pass.SetPassNumber(passNumber); this.JamPasses.Add(pass); } catch (Exception e) { ErrorViewModel.Save(e, this.GetType(), ErrorGroupEnum.UI, additionalInformation: Logger.Instance.getLoggedMessages()); } }
public bool IsBefore(Jam jam) { return IsFirstHalf && !jam.IsFirstHalf || (IsFirstHalf == jam.IsFirstHalf && JamNumber < jam.JamNumber); }