Ejemplo n.º 1
0
        public TurnResult StartGame(int playernumber)
        {
            TurnResult result = new TurnResult();

            if (playernumber > 6)
            {
                return(result);
            }

            for (int i = 0; i < playernumber; i++)
            {
                _players.Add(new Player(i));
            }

            initGame();

            Random rng = new Random();

            currentPlayer = _players[rng.Next(_players.Count - 1)].id;

            phase = 0;

            result.accepted   = true;
            result.nextplayer = currentPlayer;
            result.nextphase  = phase;
            return(result);
        }
Ejemplo n.º 2
0
        public TurnResult Play(FirstAction act, String roomname)
        {
            TurnResult result = new TurnResult();

            result.nextphase  = phase;
            result.nextplayer = currentPlayer;


            if (_rooms.Any(x => x.name == roomname))
            {
                if (phase == 0)
                {
                    if (act == FirstAction.Move)
                    {
                        result.accepted = _players[currentPlayer].Move(_rooms.First(x => x.name == roomname));
                    }

                    if (result.accepted)
                    {
                        phase            = 1;
                        result.nextphase = 1;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        public TurnResult Play(SecondAction act, String personName, String itemName, String roomName)
        {
            TurnResult result = new TurnResult();

            if ((phase == 2 && act != SecondAction.Accuse) || act == SecondAction.Pass)
            {
                result.accepted   = false;
                result.nextphase  = 0;
                result.nextplayer = getNextPlayer();
            }
            else
            {
                if (act == SecondAction.Suggest && _persons.Any(x => x.name == personName) &&
                    _items.Any(x => x.name == itemName))
                {
                    result.accepted   = true;
                    result.suggestion = AskForResults(roomName, personName, itemName);
                    result.nextphase  = 2;
                    result.nextplayer = currentPlayer;
                }
                else if (act == SecondAction.Accuse && _persons.Any(x => x.name == personName) &&
                         _items.Any(x => x.name == itemName) && _rooms.Any(x => x.name == roomName))
                {
                    result.accepted             = true;
                    result.accusationSuccessful = Accusationsuccessfull(roomName, personName, itemName);
                    if (!result.accusationSuccessful)
                    {
                        result.nextplayer = getNextPlayer();
                        result.nextphase  = 0;
                    }
                }
            }

            return(result);
        }