Ejemplo n.º 1
0
        public void WantLandlord(Player player)
        {
            player.Role = Role.Landlord;
            var hiddenCards = ((ChooseLandlordData)StateData).HiddenCards;

            player.SendCard(hiddenCards);
            GroupSender.Send($"底牌有{hiddenCards.ToCardString()}.");
            State = GameState.Gaming;
            Cycle.CurrentIndex = Cycle.List.FindIndex(p => p.PlayerID == player.PlayerID);
            Tick();
        }
Ejemplo n.º 2
0
        public void PlayerSendCard(Player player, ICollection <CardGroup> cardGroups)
        {
            if (Ruler.IsValidateForPlayer(player.Cards.ToCardGroups(), cardGroups) && Ruler.IsValidate(this, cardGroups))
            {
                var cards = cardGroups.ToCards();
                player.RemoveCard(cards);
                LastSendIndex = Cycle.List.FindIndex(p => p == player);

                GroupSender.Send($"{player.ToAtCode()} 出牌: {cards.ToCardString()}");
                Cycle.MoveNext();
                Tick();
            }
            else
            {
                GroupSender.Send("你出的牌无效");
            }
        }
Ejemplo n.º 3
0
        public void Tick()
        {
            var winner = Players.FirstOrDefault(player => player.Cards.Count == 0);

            if (winner != null)
            {
                GroupSender.Send($"{winner.ToAtCode()} 你赢了.");
                State = GameState.Finished;
                GamesManager.Games.Remove(this.GameID);
                return;
            }

            if (LastSendIndex == Cycle.List.FindIndex(p => p == CurrentPlayer))
            {
                LastRule = null;
            }

            GroupSender.Send($"{CurrentPlayer.ToAtCode()} 该你出牌了");
        }
Ejemplo n.º 4
0
        private void timer1_Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                lock (obj)
                {
                    TimerSender timerSender = new TimerSender();
                    timerSender.Send();

                    GroupSender groupSender = new GroupSender();
                    groupSender.Send();

                    GroupTimeSender groupTimeSender = new GroupTimeSender();
                    groupTimeSender.Send();
                }
            }
            catch (Exception ex)
            {
                Log.Info(" ========== 发生异常 ============ ");
                Log.Info(" ==========" + ex + " ============ ");
            }
        }
Ejemplo n.º 5
0
 public void SendChooseLandlordInfo()
 {
     GroupSender.Send($"{GetPlayerByIndex(((ChooseLandlordData)StateData).LandlordIndex).ToAtCode()} 你要抢地主吗?");
 }
Ejemplo n.º 6
0
        private void Button3_Click(object sender, EventArgs e)
        {
            GroupSender groupSender = new GroupSender();

            groupSender.Send();
        }