Пример #1
0
        /// <summary>
        /// 公開情報を作成
        /// </summary>
        /// <returns></returns>
        private PublicStatus MakePublicStatus()
        {
            var publicStatus = new PublicStatus
            {
                field          = fieldStack.FirstOrDefault(),
                phase          = Phase.Trading,
                turn           = 0,
                hasFlowed      = false,
                isElevenBack   = false,
                isKakumei      = false,
                isShibari      = false,
                playerStatuses = new List <PublicPlayerStatus>()
            };

            foreach (var player in players)
            {
                var playerStatus = new PublicPlayerStatus
                {
                    id        = player.id,
                    seat      = player.seat,
                    roleRank  = player.roleRank,
                    cardCount = player.hand.Count,
                    hasPassed = player.hasPassed
                };
                publicStatus.playerStatuses.Add(playerStatus);
            }

            return(publicStatus);
        }
Пример #2
0
        public PublicStatus Clone()
        {
            var clone = new PublicStatus();

            foreach (var card in field)
            {
                field.Add(card);
            }
            clone.phase        = phase;
            clone.hasFlowed    = hasFlowed;
            clone.isElevenBack = isElevenBack;
            clone.isKakumei    = isKakumei;
            clone.isShibari    = isShibari;
            foreach (var playerStatus in playerStatuses)
            {
                playerStatuses.Add(playerStatus.Clone());
            }

            return(clone);
        }
Пример #3
0
        /// <summary>
        /// ゲーム情報通知
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="publicStatus"></param>
        /// <param name="privateStatus"></param>
        /// <returns></returns>
        public Task SendStatusAsync(
            string connectionId,
            PublicStatus publicStatus,
            PrivateStatus privateStatus)
        {
            var task = new Task(() =>
            {
                if (string.IsNullOrEmpty(connectionId))
                {
                    return;
                }
                SingleProcessMessageTransceiver client;
                if (_connectedClientTable.TryGetValue(connectionId, out client))
                {
                    client.ReceivedStatus?.Invoke(this, new ReceivedStatusArgs(publicStatus, privateStatus));
                }
            });

            task.RunSynchronously();
            return(task);
        }
Пример #4
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public Player(IClientMessageTransceiver messageTransceiver)
        {
            this.messageTransceiver = messageTransceiver;

            EventHandler <ReceivedPlayerIdArgs> receivedPlayerIdHandler = (sender, args) =>
            {
                id = args.PlayerId;
            };

            this.messageTransceiver.ReceivedPlayerId += receivedPlayerIdHandler;

            EventHandler <ReceivedStatusArgs> receivedStatusHandler = (sender, args) =>
            {
                publicStatus  = args.PublicStatus;
                privateStatus = args.PrivateStatus;
                UpdatedStatus?.Invoke(this, new UpdatedStatusArgs(publicStatus, privateStatus));
            };

            this.messageTransceiver.ReceivedStatus += receivedStatusHandler;

            EventHandler <ReceivedEndMessageArgs> receivedEndMessageHandler = (sender, args) =>
            {
                switch (args.EndMessage)
                {
                case EndMessage.NotEnd:
                    break;

                case EndMessage.EndRound:
                    EndedRound?.Invoke(this, new EndedRoundArgs());
                    break;

                case EndMessage.EndGame:
                    EndedGame?.Invoke(this, new EndedGameArgs());
                    break;
                }
            };

            this.messageTransceiver.ReceivedEndMessage += receivedEndMessageHandler;
        }
Пример #5
0
 public UpdatedStatusArgs(PublicStatus publicStatus, PrivateStatus privateStatus)
 {
     PublicStatus  = publicStatus;
     PrivateStatus = privateStatus;
 }
Пример #6
0
 public ReceivedStatusArgs(PublicStatus publicStatus, PrivateStatus privateStatus)
 {
     PublicStatus  = publicStatus;
     PrivateStatus = privateStatus;
 }