internal override Selection Transition(object input)
        {
            Exception ex = TryValidateInput(input);
            if (ex != null)
                throw ex;

            switch (_state)
            {
                case 0:
                    return States[_state++];
                case 1:
                    _tile = input as Tile;
                    return States[_state++];
                case 2:
                    var space = input as Space;
                    Controller.Instance.PlaceTile(_tile, space, Authority);
                    return Controller.Instance.Activate(_tile);
            }
            throw new UnknownTransitionException();
        }
        /// <summary>
        ///   Removes a tile from a space on the board.
        /// </summary>
        public void RemoveTile(Tile tile, double authority = 0)
        {
            Exception ex = CanRemoveTile(tile, authority);
            if (ex != null)
                throw ex;

            tile.IsFlipped = false;
            tile.Space = null;
            tile.Owner = null;
            tile.RemoveAllTokens();
            tile.Reset();
        }
        internal override Selection Transition(object input)
        {
            if (input == null && _activeStateIndex == -1)
                return _stateSequence[++_activeStateIndex];

            if (input != null)
                switch (_activeStateIndex)
                {
                    case 0:
                    {
                        var tile = input as Tile;
                        if (tile == null)
                            throw new ArgumentException();

                        _tile = tile;
                        return _stateSequence[++_activeStateIndex];
                    }
                    case 1:
                    {
                        var space = input as Space;
                        if (space == null)
                            throw new ArgumentException();

                        _tile.Space.Tile = null;
                        _tile.Space = space;
                        space.Tile = _tile;

                        if (space.AdjacentTiles.Any(t => t.Building == "Sanctum"))
                            _tile.Flags = Flags.Holy;

                        return _stateSequence[++_activeStateIndex];
                    }
                }
            throw new UnknownTransitionException("Reflecting Pond");
        }
 /// <summary>
 ///   Enumerates a list of possible spaces where the specific tile can be placed.
 /// </summary>
 public IEnumerable<Space> GetPlacableSpaces(Tile tile = null)
 {
     return Board.Edges.Where(space => (CanPlaceTile(tile, space) == null));
 }
        /// <summary>
        ///   Places a tile on a space but does not activates it.
        /// </summary>
        public void PlaceTile(Tile tile, Space space, double authority = 0)
        {
            Exception ex = CanPlaceTile(tile, space, authority);
            if (ex != null)
                throw ex;

            Debug.Assert(tile.Space == null && space.Tile == null);
            tile.Space = space;
            tile.Owner = ActivePlayer;
            tile.IsFlipped = true;
            tile.AddToken(tile.Owner);
            if (tile.Space.AdjacentTiles.Any(tile2 => (tile2.Building == "Sanctum" && tile2.IsFlipped)))
                tile.Flags = Flags.Holy;
            ActivePlayer.RemoveFromHand(tile);
        }
        internal override Selection Transition(object input)
        {
            Controller control = Controller.DefaultInstance;

            if (input == null && _state == -1)
                return States[++_state];

            Exception ex = TryValidateInput(input);
            if (ex != null)
                throw ex;

            switch (_state)
            {
                case 0:
                    _player = (Player)input;
                    if (_player != null)
                        control.TileSet = _player.Hand.ToList();
                    return States[++_state];
                case 1:
                    _tile = input as Tile;
                    _player.RemoveFromHand(_tile);
                    _player.AddToHand(control.Deck.Pop());

                    return States[++_state];
                case 2:
                    var space = input as Space;
                    control.PlaceTile(_tile, space, Authority);
                    ++_state;
                    return Controller.DefaultInstance.Activate(_tile);
            }
            throw new UnknownTransitionException("Thieves Guild");
        }
 /// <summary>
 ///   Activates a tile placed on the board.
 /// </summary>
 /// <exception cref = "ArgumentException">Thrown if the tile is not on the board.</exception>
 public Selection Activate(Tile tile)
 {
     ActiveTile = tile;
     return ActiveTile.Transition(null);
 }
        internal override Selection Transition(object input)
        {
            if (input == null && _activeStateIndex == -1)
                return _stateSequence[++_activeStateIndex];

            Exception e = TryValidateInput(input);
            if (e != null)
                throw e;

            if (input != null)
                switch (_activeStateIndex)
                {
                    case 0:
                    {
                        var tile = input as Tile;
                        if (tile == null)
                            throw new ArgumentException();

                        _tile1 = tile;
                        return _stateSequence[++_activeStateIndex];
                    }
                    case 1:
                    {
                        var tile = input as Tile;
                        if (tile == null)
                            throw new ArgumentException();

                        _tile2 = tile;

                        Space temp1 = _tile1.Space;
                        Space temp2 = _tile2.Space;
                        _tile1.Space = temp2;
                        _tile2.Space = temp1;
                        temp2.Tile = _tile1;
                        temp1.Tile = _tile2;
                        return _stateSequence[++_activeStateIndex];
                    }
                }
            throw new UnknownTransitionException("Abandoned Mine");
        }
        internal override Selection Transition(object input)
        {
            Controller control = Controller.DefaultInstance;

            Exception ex = TryValidateInput(input);
            if (ex != null)
                throw ex;

            switch (_state)
            {
                case 0:
                    //draw 5 cards from the deck and set as activehand to wait for user input
                    for (int i = 0; i<Drawsize; i++)
                        _drawnCards.AddLast(control.Deck.Pop());
                    control.TileSet = _drawnCards.ToList();
                    return States[_state++];
                case 1:
                    _tile = (Tile)input;
                    if (_tile.Building == "Cathedral")
                        throw new InvalidOperationException("Cannot place Sanctum from within a Sanctum");
                    _drawnCards.Remove(_tile);
                    foreach (Tile tileInHand in _drawnCards)
                        control.Deck.Enqueue(tileInHand);

                    return States[_state++];
                case 2:
                    var space = input as Space;
                    control.PlaceTile(_tile, space, Authority);
                    return Controller.DefaultInstance.Activate(_tile);
            }
            throw new UnknownTransitionException();
        }
예제 #10
0
 /// <summary>
 ///   Places a tile on the top of the deck.
 /// </summary>
 public abstract void Push(Tile tile);
예제 #11
0
 /// <summary>
 ///   Places a tile on the bottom of the deck.
 /// </summary>
 public abstract void Enqueue(Tile tile);
예제 #12
0
        internal override Selection Transition(object input)
        {
            if (input == null && _activeStateIndex == -1)
                if (Space.AdjacentTiles.Where(t => t.TokenCount() != 0 && t.Flags != Flags.Holy).Count() == 0)
                    return Selection.None;
                else
                    return _stateSequence[++_activeStateIndex];

            if (input != null && _activeStateIndex == 0)
            {
                var tile = input as Tile;

                if (tile == null || tile.TokenCount() == 0)
                    throw new ArgumentException("Choose a tile that has tokens on it");

                // Multiple players have tokens on this tile, ask which one
                if (tile.TokenCount()>1 && tile.Tokens.Count()>1)
                {
                    _currentTile = tile;
                    Controller.DefaultInstance.PlayerSet =
                        Controller.DefaultInstance.Players.Where(p => tile.Tokens.ContainsKey(p)).ToList();
                    return _stateSequence[++_activeStateIndex];
                }
                var tempPlayer = (Player)tile.Tokens.First().Key;
                tile.RemoveToken(tempPlayer);
                AddToken(tempPlayer);
                if (Space.AdjacentTiles.Where(t => t.TokenCount() != 0 && t.Flags != Flags.Holy).Count() == 0)
                    return Selection.None;
                return _stateSequence[_activeStateIndex];
            }
            if (input != null && _activeStateIndex == 1)
            {
                var player = input as Player;
                _currentTile.RemoveToken(player);
                AddToken(player);
                Controller.DefaultInstance.PlayerSet = null;
                if (Space.AdjacentTiles.Where(t => t.TokenCount() != 0 && t.Flags != Flags.Holy).Count() == 0)
                    return Selection.None;
                return _stateSequence[--_activeStateIndex];
            }
            throw new UnknownTransitionException("Grove");
        }
예제 #13
0
 /// <summary>
 ///   Removes a tile from a players hand.
 /// </summary>
 public void RemoveFromHand(Tile tile)
 {
     _hand.Remove(tile);
 }
예제 #14
0
 /// <summary>
 ///   Adds a tile to a players hand.
 /// </summary>
 public void AddToHand(Tile tile)
 {
     _hand.AddLast(tile);
 }