Example #1
0
        public void DiscardByOther(Tile tile, bool chowable = false)
        {
            var winProcessorFactory = new WinProcessorFactory();
            var result = winProcessorFactory.Validate(Tiles, new List <Tile> {
                tile
            });

            if (result.Any() && PlayerWinable != null)
            {
                PlayerWinable(this, new PlayerWinEventArgs {
                    WinningTiles = result
                });
            }

            var kongableMelds = MaJiangAlgorithm.GetKongableMelds(Tiles, tile);

            if (kongableMelds.Any())
            {
                FireEvent(PlayerActions.Kong, kongableMelds, tile);
            }

            var pongableMelds = MaJiangAlgorithm.GetPongableMelds(Tiles, tile);

            if (pongableMelds.Any())
            {
                FireEvent(PlayerActions.Pong, pongableMelds, tile);
            }

            if (chowable)
            {
                var chowableMelds = MaJiangAlgorithm.GetChowableMelds(Tiles, tile);
                if (chowableMelds.Any())
                {
                    FireEvent(PlayerActions.Chow, chowableMelds, tile);
                }
            }
        }
Example #2
0
 public Player(string name, string id)
 {
     Id   = id;
     Name = name;
     WinProcessorFactory = new WinProcessorFactory();
 }