Example #1
0
        public void RoomCreate(Conn client)
        {
            var          userid   = client.ClientUseID;
            var          userinfo = LobbyServer.Ins.GetUserInfo(userid);
            NiuNiuPlayer player   = new NiuNiuPlayer(0, userinfo, client);

            dictNNPlayers.Add(0, player);

            simpledata.SimpleInt simpleInt = new simpledata.SimpleInt();
            simpleInt.simple = GameID;
            client.SendAsync((ushort)MainID.NiuNiu, (ushort)NiuNiuID.CreateSuccess, NetUtil.ProtobufSerialize(simpleInt));
        }
Example #2
0
        public void RoomJion(Conn client)
        {
            if (isPlaying)
            {
                simpledata.SimpleString simpleStr = new simpledata.SimpleString();
                simpleStr.simple = "加入房间失败:游戏已开始,请稍后。";
                byte[] data = NetUtil.ProtobufSerialize(simpleStr);
                client.SendAsync((ushort)MainID.NiuNiu, (ushort)NiuNiuID.JionFailure, data);
                //游戏开始 加入失败
                return;
            }

            if (dictNNPlayers.Count == GamePlayerNumber)
            {
                simpledata.SimpleString simpleStr = new simpledata.SimpleString();
                simpleStr.simple = "加入房间失败:游戏人数已满。";
                byte[] data = NetUtil.ProtobufSerialize(simpleStr);
                client.SendAsync((ushort)MainID.NiuNiu, (ushort)NiuNiuID.JionFailure, data);
                //游戏开始 加入失败
                return;
            }


            NiuNiuPlayer newNNPlayer = null;

            for (int i = 0; i < GamePlayerNumber; i++)
            {
                if (!dictNNPlayers.ContainsKey(i))
                {
                    var userid   = client.ClientUseID;
                    var userinfo = LobbyServer.Ins.GetUserInfo(userid);
                    newNNPlayer = new NiuNiuPlayer(i, userinfo, client);
                    dictNNPlayers.Add(i, newNNPlayer);
                    break;
                }
            }
            //所有玩家数据(包括新加入的玩家),发送给新加入的玩家
            GameSeatedUPlayers otherSeatedPlayers = new GameSeatedUPlayers();

            //刚加入玩家的数据,发给已经加入的玩家
            GamePlayer newGamePlayer = new GamePlayer();

            newGamePlayer.seatid = newNNPlayer.SeatID;
            newGamePlayer.user   = newNNPlayer.UserInfo;
            byte[] newPlayerData = NetUtil.ProtobufSerialize(newGamePlayer);

            foreach (var temp in dictNNPlayers.Values)
            {
                GamePlayer player = new GamePlayer();
                player.seatid = temp.SeatID;
                player.state  = temp.GState;
                player.user   = temp.UserInfo;
                otherSeatedPlayers.players.Add(player);
                otherSeatedPlayers.roomid = GameID;
                otherSeatedPlayers.hostid = hostid;

                if (temp.SeatID != newNNPlayer.SeatID)
                {
                    temp.conn.SendAsync((ushort)MainID.NiuNiu, (ushort)NiuNiuID.PlayerJion, newPlayerData);
                }
            }

            LogUtil.LogInfo(string.Format("****** 用户ID{0}    加入房间{1}     座位{2}", client.ClientUseID, GameID, newNNPlayer.SeatID));
            byte[] allPlayerData = NetUtil.ProtobufSerialize(otherSeatedPlayers);
            client.SendAsync((ushort)MainID.NiuNiu, (ushort)NiuNiuID.JionSuccess, allPlayerData);
        }
Example #3
0
        public static int CalcPower(NiuNiuPlayer p, NiuNiuPlayer phost)
        {
            int winType  = 0;
            int winPower = 0;

            if ((int)p.NNType == (int)phost.NNType)//比较牛几
            {
                winType = (int)p.NNType;
                if (p.MaxCard % 100 == phost.MaxCard % 100)    //比较点数
                {
                    if (p.MaxCard / 100 > phost.MaxCard / 100) //比较花色
                    {
                        winPower = 1;
                    }
                    else
                    {
                        winPower = -1;
                    }
                }
                else
                {
                    if (p.MaxCard % 100 > phost.MaxCard % 100) //比较点数
                    {
                        winPower = 1;
                    }
                    else
                    {
                        winPower = -1;
                    }
                }
            }
            else
            {
                if ((int)p.NNType > (int)phost.NNType)
                {
                    winType  = (int)p.NNType;
                    winPower = 1;
                }
                else
                {
                    winType  = (int)phost.NNType;
                    winPower = -1;
                }
            }


            switch ((int)winType)
            {
            case 7:
                winPower = winPower * 2;
                break;

            case 8:
                winPower = winPower * 2;
                break;

            case 9:
                winPower = winPower * 2;
                break;

            case 10:
                winPower = winPower * 3;
                break;

            case 11:
                winPower = winPower * 5;
                break;

            case 12:
                winPower = winPower * 8;
                break;
            }

            return(winPower);
        }