예제 #1
0
 /// <summary>
 /// 他のリクエストインスタンスから情報を取り込みます。<br>
 /// 元の参照情報を維持します。
 /// </summary>
 /// <param name="from">取り込み元リクエストインスタンス</param>
 public void ShallowImport(FieldAttachedRequest from)
 {
     this.RoomKey   = from.RoomKey;
     this.PlayerKey = from.PlayerKey;
     this.Context   = from.Context;
     this.Wind      = from.Wind;
 }
 /// <summary>
 /// 風牌の風と指定した風が同一かどうか
 /// </summary>
 /// <param name="kind">牌の種類</param>
 /// <param name="wind">風</param>
 /// <returns>風牌の風と指定した風が同一かどうか</returns>
 private bool EqualsWind(Tile.Kind kind, Wind.Index wind)
 {
     return(kind == Tile.Kind.East && wind == Wind.Index.East ||
            kind == Tile.Kind.South && wind == Wind.Index.South ||
            kind == Tile.Kind.West && wind == Wind.Index.West ||
            kind == Tile.Kind.North && wind == Wind.Index.North);
 }
예제 #3
0
        /// <summary>
        /// フィールド情報を紐付けます。
        /// </summary>
        public void Attach()
        {
            var room = RoomManager.Get(this.RoomKey);

            this.Context = room.Context;
            var player = room.GetPlayer(this.PlayerKey);

            this.Wind = player.Wind;
        }
예제 #4
0
        /// <summary>
        /// 場の終了かどうか
        /// </summary>
        /// <param name="room">部屋</param>
        /// <param name="winWind">アガったプレイヤの風</param>
        /// <returns>場の終了かどうか</returns>
        private bool HasFinishedHome(Room room, Wind.Index winWind)
        {
            // アガったプレイヤがいるかどうか
            if (winWind != Wind.Index.Undefined)
            {
                return(true);
            }
            // 流局かどうか
            var drawnGame = room.Context.Walls.All(wind => wind.All(rank => rank.All(tile => tile == Tile.Kind.Undefined.ToUint())));

            return(drawnGame);
        }
예제 #5
0
        /// <summary>
        /// プレイヤを追加します。
        /// </summary>
        /// <param name="wind">風</param>
        /// <param name="playerType">風</param>
        /// <param name="name">プレイヤ名</param>
        /// <param name="connectionId">コネクションID</param>
        public Guid AddPlayer(Wind.Index wind, PlayerType playerType, string name, string connectionId = null)
        {
            Debug.Assert(wind != Wind.Index.Undefined, "風が不正です。");
            var player = DiProvider.GetContainer().GetInstance <Player>();

            player.Key          = Guid.NewGuid();
            player.Wind         = wind;
            player.PlayerType   = playerType;
            player.Name         = name;
            player.ConnectionId = connectionId;
            this.Players[wind]  = player;
            return(player.Key);
        }
예제 #6
0
        /// <summary>
        /// 進行状況をアップデートします。
        /// </summary>
        /// <param name="roomKey">部屋キー</param>
        /// <param name="winIndex">あがったプレイヤの風</param>
        public static void Update(Guid roomKey, Wind.Index winIndex)
        {
            var room = RoomManager.Get(roomKey);
            var fieldAttachedRequest = DiProvider.GetContainer().GetInstance <FieldAttachedRequest>();

            fieldAttachedRequest.RoomKey   = roomKey;
            fieldAttachedRequest.PlayerKey = room.GetParentPlayer().Key;
            fieldAttachedRequest.Attach();
            var reachableInfo = DiProvider.GetContainer().GetInstance <ReachableAnalyzeReceiver>().Receive(fieldAttachedRequest);
            var updateReq     = DiProvider.GetContainer().GetInstance <UpdateGameProgressRequest>();

            updateReq.RoomKey           = roomKey;
            updateReq.ParentWaitingHand = reachableInfo.Reachable;
            updateReq.WinWind           = winIndex;
            updateReq.Attach();
            var updateRes = DiProvider.GetContainer().GetInstance <UpdateGameProgressReceiver>().Receive(updateReq);

            updateRes.Detach();
        }
예제 #7
0
 /// <summary>
 /// 捨牌を実行します。
 /// </summary>
 /// <returns>捨てた牌</returns>
 /// <param name="context">フィールド状態</param>
 /// <param name="wind">風</param>
 public uint Discard(FieldContext context, Wind.Index wind)
 {
     return(context.Hands[wind.ToInt()].Last());
 }
예제 #8
0
 /// <summary>
 /// 親継続かどうか
 /// </summary>
 /// <param name="room">部屋</param>
 /// <param name="parentWaitngHand">親のテンパイ有無</param>
 /// <param name="winWind">アガったプレイヤの風</param>
 /// <returns>親継続かどうか</returns>
 private bool RequiredKeepParent(Room room, bool parentWaitngHand, Wind.Index winWind)
 {
     return(parentWaitngHand || winWind == room.Parent);
 }