public void startTeam(HOHTeam selectedTeam, DateTime startTime) { this.gameModel.startTeam(selectedTeam, startTime); this.dataModelHasChanged(); }
private int calculatePuzzlesTakenForTeam(HOHTeam team, HOHGameRules gameRules) { int puzzlesTakenCount = 0; List<HOHPuzzle> puzzlesTaken = new List<HOHPuzzle>(); foreach (HOHEvent oneEvent in team.events) { if (oneEvent.eventType == HOHEvent.HOHEventType.SolutionEventType && !puzzlesTaken.Contains(oneEvent.puzzle)) { puzzlesTaken.Add(oneEvent.puzzle); puzzlesTakenCount++; } } return puzzlesTakenCount; }
private int calculateStandingsTakenForTeam(HOHTeam team, HOHGameRules gameRules) { int standingsTaken = 0; foreach (HOHEvent oneEvent in team.events) { if (oneEvent.eventType == HOHEvent.HOHEventType.StandingsReplyEventType) { standingsTaken++; } } return standingsTaken; }
private decimal calculatePointsForTeam(HOHTeam team) { return calculatePointsForTeam(team, this.gameRules); }
private decimal calculatePointsForTeamAtPuzzle(HOHTeam team, HOHPuzzle puzzle) { HOHPuzzle firstPuzzle = null; foreach (HOHEvent oneEvent in team.events) { if (oneEvent.eventType == HOHEvent.HOHEventType.SolutionEventType || oneEvent.eventType == HOHEvent.HOHEventType.HintReplyEventType) if (oneEvent.puzzle.standpoint == puzzle.standpoint) { firstPuzzle = oneEvent.puzzle; break; } } if (firstPuzzle == null) return 0; decimal points = 0; bool hintHasBeenTaken = false; bool answered = false; foreach (HOHEvent oneEvent in team.events) { if (!(oneEvent.eventType == HOHEvent.HOHEventType.SolutionEventType) && !(oneEvent.eventType == HOHEvent.HOHEventType.HintReplyEventType)) continue; if (oneEvent.puzzle != puzzle || oneEvent.puzzle != firstPuzzle) continue; /* ODP SPR NAP KOEF 1 1 1 0,5 1 1 0 BON 1 0 1 -1 1 0 0 -0,5 0 0 1 -0,5 0 0 0 0 */ if (oneEvent.eventType == HOHEvent.HOHEventType.SolutionEventType) { answered = true; if (oneEvent.hasCorrectSolution()) { if (hintHasBeenTaken) points += puzzle.points * puzzle.pointMultiplierForHint; else points += puzzle.points * puzzle.getPointMultipierForPlace(getCorrectPlaceForTeamAtPuzzle(team, puzzle)); } else { if (hintHasBeenTaken) points -= puzzle.points * 1; else points -= puzzle.points * puzzle.pointMultiplierForHint; } break; } if (oneEvent.eventType == HOHEvent.HOHEventType.HintReplyEventType) hintHasBeenTaken = true; } if (hintHasBeenTaken && !answered) points -= puzzle.points * puzzle.pointMultiplierForHint; return points; }
internal void startTeam(HOHTeam selectedTeam, DateTime startTime) { if (selectedTeam == null) return; selectedTeam.startTime = startTime; selectedTeam.hasStarted = true; selectedTeam.hasGivenUp = false; selectedTeam.hasFinished = false; try { pointsForTeam.Remove(selectedTeam); } catch {} placeForTeam.Clear(); }
private int calculateHintsTakenForTeamAtPuzzle(HOHTeam team, HOHPuzzle puzzle) { foreach (HOHEvent oneEvent in team.events) { if (oneEvent.eventType == HOHEvent.HOHEventType.StandingsReplyEventType) return 1; } return 0; }
public int getPuzzlesTakenForTeam(HOHTeam team) { if (!puzzlesTakenForTeam.ContainsKey(team)){ int puzzleTakenCount = calculatePuzzlesTakenForTeam(team); puzzlesTakenForTeam.Add(team, puzzleTakenCount); return puzzleTakenCount; } else { return puzzlesTakenForTeam[team]; } }
public int getStandingsTakenForTeam(HOHTeam team) { if (!standingsTakenForTeam.ContainsKey(team)) { int standingTakenCount = calculateStandingsTakenForTeam(team); standingsTakenForTeam.Add(team, standingTakenCount); return standingTakenCount; } else { return standingsTakenForTeam[team]; } }
public int getHintsTakenForTeam(HOHTeam team) { if (!hintsTakenForTeam.ContainsKey(team)) { int hintTakenCount = calculateHintsTakenForTeam(team); hintsTakenForTeam.Add(team, hintTakenCount); return hintTakenCount; } else { return hintsTakenForTeam[team]; } }
public decimal getPointsForTeam(HOHTeam team) { if (!pointsForTeam.ContainsKey(team)) { decimal pointCount = calculatePointsForTeam(team); pointsForTeam.Add(team, pointCount); return pointCount; } else { return pointsForTeam[team]; } }
public static HOHTeam getTeamFromCSVLine(string csvLine) { if (csvLine.Trim().CompareTo("") == 0) return null; HOHTeam newTeam = null; ArrayList alResult = CSVParser.parseCSVLine(csvLine); if (string.Join("+", (string[])alResult.ToArray(typeof(string))).CompareTo(string.Join("+", (string[])CSVParser.parseCSVLine(getCSVHeaderLine().Trim()).ToArray(typeof(string)))) == 0) return null; if (alResult.Count >= (HOHTeam.csvLine.Length - HOHTeam.csvLine.Replace("{", "").Length)) { try { newTeam = new HOHTeam(); newTeam.name = alResult[0].ToString(); newTeam.id = alResult[1].ToString().ToUpper(); try { newTeam.startTime = DateTime.Parse(alResult[2].ToString()); } catch { newTeam.startTime = DateTime.Now; } } catch { return null; } } if (newTeam.id.CompareTo("") == 0) newTeam.id = newTeam.name; if (newTeam.startTime.CompareTo(DateTime.Now) <= 0) newTeam.hasStarted = true; return newTeam; }
private void addTeam(HOHTeam newTeam) { _gameModel.teams.Add(newTeam); // _smsManager.smsFetcher.addSmsInterceptorForPhoneNumber(newTeam.phoneNumber); }
internal void invalidatePointsForTeam(HOHTeam team) { this.gameModel.invalidatePointsForTeam(team); this.dataModelHasChanged(); }
internal bool isHintAvailableForTeam(HOHTeam team) { return getHintsTakenForTeam(team) < gameRules.maxHintsPerTeam; }
public TimeSpan getTimeToFinishForTeam(HOHTeam team) { return getTimeToFinishForTeam(team, this.gameRules); }
internal bool isStandingsAvailableForTeam(HOHTeam team) { return getStandingsTakenForTeam(team) < gameRules.maxStandingsPerTeam; }
public TimeSpan getTimeToFinishForTeam(HOHTeam team, HOHGameRules gameRules) { return gameRules.getTimeToFinishForDateTime(team.startTime); }
private int calculateHintsTakenForTeam(HOHTeam team, HOHGameRules gameRules) { int hintsTaken = 0; List<HOHPuzzle> puzzlesWithHint = new List<HOHPuzzle>(); foreach (HOHEvent oneEvent in team.events) { if (oneEvent.eventType == HOHEvent.HOHEventType.HintReplyEventType && !puzzlesWithHint.Contains(oneEvent.puzzle)) { puzzlesWithHint.Add(oneEvent.puzzle); hintsTaken++; } } return hintsTaken; }
internal int getHintsTakenForTeamAtPuzzle(HOHTeam team, HOHPuzzle puzzle) { if (!hintsTakenForTeamAtPuzzle.ContainsKey(team)) { hintsTakenForTeamAtPuzzle.Add(team, new Dictionary<HOHPuzzle, int>()); } if (!hintsTakenForTeamAtPuzzle[team].ContainsKey(puzzle)) { int hintCount = calculateHintsTakenForTeamAtPuzzle(team, puzzle); hintsTakenForTeamAtPuzzle[team].Add(puzzle, hintCount); return hintCount; } else { return hintsTakenForTeamAtPuzzle[team][puzzle]; } }
private int calculatePlaceForTeamAtPuzzle(HOHTeam team, HOHPuzzle puzzle, bool correctSolutionsOnly) { Dictionary<HOHTeam, int> arriveTimeAtPuzzle = new Dictionary<HOHTeam, int>(); foreach (HOHEvent oneEvent in puzzle.events) { if (oneEvent.eventType == HOHEvent.HOHEventType.SolutionEventType && (!correctSolutionsOnly || oneEvent.hasCorrectSolution()) && !arriveTimeAtPuzzle.ContainsKey(oneEvent.team)) { arriveTimeAtPuzzle.Add(oneEvent.team, (int)oneEvent.dateTime.Subtract(oneEvent.team.startTime).TotalSeconds); } } if (arriveTimeAtPuzzle.ContainsKey(team)) { List<KeyValuePair<HOHTeam, int>> sortedTimes = new List<KeyValuePair<HOHTeam, int>>(arriveTimeAtPuzzle); sortedTimes.Sort( delegate(KeyValuePair<HOHTeam, int> firstPair, KeyValuePair<HOHTeam, int> nextPair) { return firstPair.Value.CompareTo(nextPair.Value); } ); return sortedTimes.IndexOf(new KeyValuePair<HOHTeam, int>(team, arriveTimeAtPuzzle[team])) + 1; } else { return arriveTimeAtPuzzle.Count + 2; } }
internal decimal getPointsForTeamAtPuzzle(HOHTeam team, HOHPuzzle puzzle) { if (!pointsForTeamAtPuzzle.ContainsKey(team)) { pointsForTeamAtPuzzle.Add(team, new Dictionary<HOHPuzzle, decimal>()); } if (!pointsForTeamAtPuzzle[team].ContainsKey(puzzle)) { decimal points = calculatePointsForTeamAtPuzzle(team, puzzle); pointsForTeamAtPuzzle[team].Add(puzzle, points); return points; } else { return pointsForTeamAtPuzzle[team][puzzle]; } }
private decimal calculatePointsForTeam(HOHTeam team, HOHGameRules gameRules) { decimal points = 0; foreach (HOHPuzzle puzzle in this.puzzles) points += getPointsForTeamAtPuzzle(team, puzzle); points -= this.getTimePenaltyForTeam(team); return points; }
internal decimal getTimePenaltyForTeam(HOHTeam team) { return getTimePenaltyForTeam(team, this.gameRules); }
private int calculatePuzzlesTakenForTeam(HOHTeam team) { return calculatePuzzlesTakenForTeam(team, this.gameRules); }
internal decimal getTimePenaltyForTeam(HOHTeam team, HOHGameRules gameRules) { if (team.hasGivenUp) return gameRules.pointPenaltyForGivingUp; DateTime targetTime; if (team.hasFinished) targetTime = team.finishTime; else targetTime = DateTime.Now; return gameRules.getTimePenaltyForDateTime(team.startTime.AddMinutes(gameRules.gameDurationMinutes), targetTime); }
private int calculateStandingsTakenForTeam(HOHTeam team) { return calculateStandingsTakenForTeam(team, this.gameRules); }
internal void invalidatePointsForTeam(HOHTeam team) { //nyni toto pouziva jen timer co kontroluje zpozdeni try { pointsForTeam.Remove(team); } catch { } placeForTeam.Clear(); }
public int getCorrectPlaceForTeamAtPuzzle(HOHTeam team, HOHPuzzle puzzle) { if (!correctPlaceForTeamAtPuzzle.ContainsKey(team)) { correctPlaceForTeamAtPuzzle.Add(team, new Dictionary<HOHPuzzle, int>()); } if (!correctPlaceForTeamAtPuzzle[team].ContainsKey(puzzle)) { int place = calculatePlaceForTeamAtPuzzle(team, puzzle, true); correctPlaceForTeamAtPuzzle[team].Add(puzzle, place); return place; } else { return correctPlaceForTeamAtPuzzle[team][puzzle]; } }
public void startTeam(HOHTeam selectedTeam) { startTeam(selectedTeam, DateTime.Now); }