Esempio n. 1
0
        public void SetData(GameModel gameData)
        {
            _iteration++;
            _model = gameData;

            OnGameChanged?.Invoke(this, new GameChanged());
        }
Esempio n. 2
0
        public void AddParticipant(Participant participant)
        {
            if (FinishedVoting)
            {
                throw new SCRUMPokerException("Game is finished, no new participants are allowed");
            }
            if (Participants.Count == 0)
            {
                Participants.Add(participant);
                Facilitator = participant;
                return;
            }
            Participant gameParticipant;

            for (int i = 0; i < Participants.Count; i++)
            {
                gameParticipant = Participants[i];
                if (gameParticipant.Name.Equals(participant.Name))
                {
                    Participants[i] = participant;
                    return;
                }
            }
            Participants.Add(participant);
            OnGameChanged?.Invoke();
        }
Esempio n. 3
0
 public void CreateNewGame()
 {
     _model = new GameModel();
     SetName();
     _iteration++;
     OnGameCreated?.Invoke(this, new GameCreated());
     OnGameChanged?.Invoke(this, new GameChanged());
 }
Esempio n. 4
0
 /// <summary>
 /// Resets Game data and loop
 /// </summary>
 public void RestartGame()
 {
     for (int i = 0; i < GameArray.Length; i++)
     {
         GameArray[i] = EmptyChar;
     }
     turnCount = 0;
     OnGameChanged?.Invoke(this, GameArray);
     GameLoop();
 }
Esempio n. 5
0
        public void AddGame(string gameName, Participant creator)
        {
            var game = new Game();

            game.OnGameStatusChanged += () => OnGameChanged?.Invoke();
            game.Subject              = gameName;
            game.Facilitator          = creator;
            games.Add(game.Subject, game);
            OnGameChanged?.Invoke();
        }
Esempio n. 6
0
 public void SendVote(PokerVote vote)
 {
     if (!HasVoted(vote.VoteParticipant))
     {
         Votes.Add(vote);
         OnGameChanged?.Invoke();
     }
     else
     {
         throw new SCRUMPokerException("Participant already voted");
     }
 }
Esempio n. 7
0
 public bool RemoveGame(int gameID)
 {
     if (gameDictionary.ContainsKey(gameID))
     {
         Game game = gameDictionary[gameID];
         OnGameChanged?.Invoke(game, DataChangeCode.Remove);
         return(gameDictionary.Remove(gameID));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 8
0
 public bool AddGame(Game game)
 {
     if (!gameDictionary.ContainsKey(game.GameID))
     {
         gameDictionary.Add(game.GameID, game);
         OnGameChanged?.Invoke(game, DataChangeCode.Add);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 9
0
    public void UpdateGameInfo(GameObject updatedGame)
    {
        if (updatedGame.ToString().Equals(game.ToString()))
        {
            return;
        }
        var currentState = GameState;

        game = updatedGame;
        if (!game.State.Equals(currentState))
        {
            // change state
            CheckState();
        }
        OnGameChanged.Invoke(this);
    }
Esempio n. 10
0
 //loops every turn
 void GameLoop()
 {
     while (turnCount <= 9)
     {
         Player currentPlayer;
         if (IsPlayer1Turn)
         {
             currentPlayer = Player1;
         }
         else
         {
             currentPlayer = Player2;
         }
         int turnInt = currentPlayer.Turn(this);
         GameArray[turnInt - 1] = currentPlayer.PlayerChar;
         IsPlayer1Turn          = !IsPlayer1Turn;
         turnCount++;
         OnGameChanged?.Invoke(this, GameArray);
         if (CheckForWinner(currentPlayer.PlayerChar))
         {
             OnGameFinished?.Invoke(this, currentPlayer);
         }
     }
 }
Esempio n. 11
0
 public void Init()
 {
     OnGameChanged?.Invoke(this, new GameChanged());
 }
Esempio n. 12
0
 public void DeleteGame(Game game)
 {
     games.Remove(game.Subject);
     OnGameChanged?.Invoke();
 }
Esempio n. 13
0
 public void ToggleRoom()
 {
     FinishedVoting = !FinishedVoting;
     OnGameChanged?.Invoke();
     OnGameStatusChanged?.Invoke();
 }
 private void StateChanged() => OnGameChanged?.Invoke();