Exemplo n.º 1
0
 public void startTeam(HOHTeam selectedTeam, DateTime startTime)
 {
     this.gameModel.startTeam(selectedTeam, startTime);
     this.dataModelHasChanged();
 }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 4
0
 private decimal calculatePointsForTeam(HOHTeam team)
 {
     return calculatePointsForTeam(team, this.gameRules);
 }
Exemplo n.º 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;
        }
Exemplo n.º 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();
        }
Exemplo n.º 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;
 }
Exemplo n.º 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];
     }
 }
Exemplo n.º 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];
     }
 }
Exemplo n.º 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];
     }
 }
Exemplo n.º 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];
     }
 }
Exemplo n.º 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;
        }
Exemplo n.º 13
0
 private void addTeam(HOHTeam newTeam)
 {
     _gameModel.teams.Add(newTeam);
        // _smsManager.smsFetcher.addSmsInterceptorForPhoneNumber(newTeam.phoneNumber);
 }
Exemplo n.º 14
0
 internal void invalidatePointsForTeam(HOHTeam team)
 {
     this.gameModel.invalidatePointsForTeam(team);
     this.dataModelHasChanged();
 }
Exemplo n.º 15
0
 internal bool isHintAvailableForTeam(HOHTeam team)
 {
     return getHintsTakenForTeam(team) < gameRules.maxHintsPerTeam;
 }
Exemplo n.º 16
0
 public TimeSpan getTimeToFinishForTeam(HOHTeam team)
 {
     return getTimeToFinishForTeam(team, this.gameRules);
 }
Exemplo n.º 17
0
 internal bool isStandingsAvailableForTeam(HOHTeam team)
 {
     return getStandingsTakenForTeam(team) < gameRules.maxStandingsPerTeam;
 }
Exemplo n.º 18
0
 public TimeSpan getTimeToFinishForTeam(HOHTeam team, HOHGameRules gameRules)
 {
     return gameRules.getTimeToFinishForDateTime(team.startTime);
 }
Exemplo n.º 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;
        }
Exemplo n.º 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];
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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];
            }
        }
Exemplo n.º 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;
        }
Exemplo n.º 24
0
 internal decimal getTimePenaltyForTeam(HOHTeam team)
 {
     return getTimePenaltyForTeam(team, this.gameRules);
 }
Exemplo n.º 25
0
 private int calculatePuzzlesTakenForTeam(HOHTeam team)
 {
     return calculatePuzzlesTakenForTeam(team, this.gameRules);
 }
Exemplo n.º 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);
        }
Exemplo n.º 27
0
 private int calculateStandingsTakenForTeam(HOHTeam team)
 {
     return calculateStandingsTakenForTeam(team, this.gameRules);
 }
Exemplo n.º 28
0
 internal void invalidatePointsForTeam(HOHTeam team)
 {
     //nyni toto pouziva jen timer co kontroluje zpozdeni
     try { pointsForTeam.Remove(team); }
     catch { }
     placeForTeam.Clear();
 }
Exemplo n.º 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];
            }
        }
Exemplo n.º 30
0
 public void startTeam(HOHTeam selectedTeam)
 {
     startTeam(selectedTeam, DateTime.Now);
 }