/// <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); }
/// <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; }
/// <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); }
/// <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); }
/// <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(); }
/// <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()); }
/// <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); }