예제 #1
0
 public void startTeam(HOHTeam selectedTeam, DateTime startTime)
 {
     this.gameModel.startTeam(selectedTeam, startTime);
     this.dataModelHasChanged();
 }
예제 #2
0
        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;
        }
예제 #3
0
        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;
        }
예제 #4
0
 private decimal calculatePointsForTeam(HOHTeam team)
 {
     return calculatePointsForTeam(team, this.gameRules);
 }
예제 #5
0
        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;
        }
예제 #6
0
        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();
        }
예제 #7
0
 private int calculateHintsTakenForTeamAtPuzzle(HOHTeam team, HOHPuzzle puzzle)
 {
     foreach (HOHEvent oneEvent in team.events) {
     if (oneEvent.eventType == HOHEvent.HOHEventType.StandingsReplyEventType)
         return 1;
     }
     return 0;
 }
예제 #8
0
 public int getPuzzlesTakenForTeam(HOHTeam team)
 {
     if (!puzzlesTakenForTeam.ContainsKey(team)){
     int puzzleTakenCount = calculatePuzzlesTakenForTeam(team);
     puzzlesTakenForTeam.Add(team, puzzleTakenCount);
     return puzzleTakenCount;
     } else {
     return puzzlesTakenForTeam[team];
     }
 }
예제 #9
0
 public int getStandingsTakenForTeam(HOHTeam team)
 {
     if (!standingsTakenForTeam.ContainsKey(team))
     {
     int standingTakenCount = calculateStandingsTakenForTeam(team);
     standingsTakenForTeam.Add(team, standingTakenCount);
     return standingTakenCount;
     }
     else {
     return standingsTakenForTeam[team];
     }
 }
예제 #10
0
 public int getHintsTakenForTeam(HOHTeam team)
 {
     if (!hintsTakenForTeam.ContainsKey(team))
     {
     int hintTakenCount = calculateHintsTakenForTeam(team);
     hintsTakenForTeam.Add(team, hintTakenCount);
     return hintTakenCount;
     }
     else
     {
     return hintsTakenForTeam[team];
     }
 }
예제 #11
0
 public decimal getPointsForTeam(HOHTeam team)
 {
     if (!pointsForTeam.ContainsKey(team))
     {
     decimal pointCount = calculatePointsForTeam(team);
     pointsForTeam.Add(team, pointCount);
     return pointCount;
     }
     else
     {
     return pointsForTeam[team];
     }
 }
예제 #12
0
        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;
        }
예제 #13
0
 private void addTeam(HOHTeam newTeam)
 {
     _gameModel.teams.Add(newTeam);
        // _smsManager.smsFetcher.addSmsInterceptorForPhoneNumber(newTeam.phoneNumber);
 }
예제 #14
0
 internal void invalidatePointsForTeam(HOHTeam team)
 {
     this.gameModel.invalidatePointsForTeam(team);
     this.dataModelHasChanged();
 }
예제 #15
0
 internal bool isHintAvailableForTeam(HOHTeam team)
 {
     return getHintsTakenForTeam(team) < gameRules.maxHintsPerTeam;
 }
예제 #16
0
 public TimeSpan getTimeToFinishForTeam(HOHTeam team)
 {
     return getTimeToFinishForTeam(team, this.gameRules);
 }
예제 #17
0
 internal bool isStandingsAvailableForTeam(HOHTeam team)
 {
     return getStandingsTakenForTeam(team) < gameRules.maxStandingsPerTeam;
 }
예제 #18
0
 public TimeSpan getTimeToFinishForTeam(HOHTeam team, HOHGameRules gameRules)
 {
     return gameRules.getTimeToFinishForDateTime(team.startTime);
 }
예제 #19
0
        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;
        }
예제 #20
0
        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];
            }
        }
예제 #21
0
        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;
            }
        }
예제 #22
0
        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];
            }
        }
예제 #23
0
        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;
        }
예제 #24
0
 internal decimal getTimePenaltyForTeam(HOHTeam team)
 {
     return getTimePenaltyForTeam(team, this.gameRules);
 }
예제 #25
0
 private int calculatePuzzlesTakenForTeam(HOHTeam team)
 {
     return calculatePuzzlesTakenForTeam(team, this.gameRules);
 }
예제 #26
0
        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);
        }
예제 #27
0
 private int calculateStandingsTakenForTeam(HOHTeam team)
 {
     return calculateStandingsTakenForTeam(team, this.gameRules);
 }
예제 #28
0
 internal void invalidatePointsForTeam(HOHTeam team)
 {
     //nyni toto pouziva jen timer co kontroluje zpozdeni
     try { pointsForTeam.Remove(team); }
     catch { }
     placeForTeam.Clear();
 }
예제 #29
0
        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];
            }
        }
예제 #30
0
 public void startTeam(HOHTeam selectedTeam)
 {
     startTeam(selectedTeam, DateTime.Now);
 }