示例#1
0
        public override void ButtonDealClicked(PlayerViewModel viewModel)
        {
            base.ButtonDealClicked(viewModel);
            if (viewModel.Status is MatchDeal)
            {
                List <CardInfo> cardInfoList = viewModel.CurrentSelectedCards;

                // 检查是否需要设置is_win 标志
                if (viewModel.HandCards.Count == cardInfoList.Count)
                {
                    int rank = CoreGameRoot.WinPlayersCount + 1;

                    Hashtable ht = new Hashtable();
                    ht.Add("is_win", true);
                    ht.Add("rank", rank);
                    if (rank == 1)
                    {
                        ht.Add("first_get", true);
                    }

                    Publish(new NetSetPlayerProperties()
                    {
                        ActorId         = viewModel.ActorId,
                        PropertiesToSet = ht
                    });
                }

                Hashtable ht2 = new Hashtable();
                ht2.Add("current_cards", JsonConvert.SerializeObject(cardInfoList));
                ht2.Add("current_cards_actor_id", viewModel.ActorId);

                Publish(new NetSetRoomProperties()
                {
                    PropertiesToSet = ht2
                });

                CoreGameRoot.ExecuteTurnNext();

                Publish(new NetRaiseEvent()
                {
                    EventCode = GameService.EventCode.ShowCardAndTurnNext
                });

                viewModel.ExecuteShowCardsToPile();
                CoreGameRoot.ExecuteRefreshCoreGame();
            }
        }
示例#2
0
        public override void OnCoreGameEventHandler(OnCoreGameEvent data)
        {
            base.OnCoreGameEventHandler(data);

            switch (data.EventCode)
            {
            case EventCode.MatchBegan:
            {
                CoreGameRoot.ExecuteRootMatchBegan();
                break;
            }

            case EventCode.ShowCardAndTurnNext:
            {
                int             current_cards_actor_id = Convert.ToInt32(Network.Client.CurrentRoom.CustomProperties ["current_cards_actor_id"]);
                PlayerViewModel currentCardsPlayer     = CoreGameRoot.PlayerCollection.SingleOrDefault(vm => vm.ActorId == current_cards_actor_id);
                currentCardsPlayer.ExecuteShowCardsToPile();
                CoreGameRoot.ExecuteRefreshCoreGame();
                break;
            }

            case EventCode.PassAndTurnNext:
            {
                CoreGameRoot.ExecuteRefreshCoreGame();
                break;
            }

            case EventCode.MatchOver:
            {
                CoreGameRoot.ExecuteRootMatchOver();
                break;
            }

            case EventCode.ClearCardsInPile:
            {
                CoreGameRoot.Pile.Cards.Clear();
                break;
            }

            default:
                break;
            }
        }