예제 #1
0
        /// <summary>
        /// 游戏结束
        /// </summary>
        private void GameOver(int userId, FightRoom room)
        {
            //确定身份 是农民还是地主
            int        identity = room.GetPlayerIdentity(userId);
            List <int> winUids  = room.GetSameIdentityUids(identity);
            int        winBeen  = room.Mutiple * 1000;

            //给胜利的玩家  胜场   豆子  经验  等级..之后玩家数据模型刷新
            for (int i = 0; i < winUids.Count; i++)
            {
                UserModel model = user.GetModelByUserId(winUids[i]);
                model.winCount++;
                model.been += winBeen;
                model.exp  += 100;
                int maxExp = model.lv * 100;
                while (maxExp <= model.exp)
                {
                    model.lv++;
                    model.exp -= maxExp;
                    maxExp     = model.lv * 100;
                }
                user.Update(model);
            }

            //给失败的玩家  败场   豆子  经验  等级..之后玩家数据模型刷新
            List <int> loseUids = room.GetDifIdentityUids(identity);

            for (int i = 0; i < winUids.Count; i++)
            {
                UserModel model = user.GetModelByUserId(loseUids[i]);
                model.loseCount++;
                model.been -= winBeen;
                model.exp  += 10;
                int maxExp = model.lv * 100;;
                while (maxExp <= model.exp)
                {
                    model.lv++;
                    model.exp -= maxExp;
                    maxExp     = model.lv * 100;
                }
                user.Update(model);
            }
            //给逃跑的玩家  逃跑   豆子  经验  等级..之后玩家数据模型刷新
            for (int i = 0; i < room.LeaveUidList.Count; i++)
            {
                UserModel model = user.GetModelByUserId(room.LeaveUidList[i]);
                model.runCount++;
                model.been -= (winBeen) * 3;
                model.exp  += 0;
                user.Update(model);
            }
            //给客户端发消息  谁赢了。身份,豆子多少
            OverDto dto = new OverDto();

            dto.winIdentity = identity; dto.winUidList = winUids; dto.beenCount = winBeen;

            Brocast(room, OpCode.FIGHT, FightCode.OVER_BRO, dto);

            fight.Destroy(room);
        }
예제 #2
0
        /// <summary>
        /// 游戏结束
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="room"></param>
        private void gameOver(int userId, FightRoom room)
        {
            //获取获胜身份 所有的玩家id
            int winIdentity = room.GetPlayerIdentity(userId);
            int winBeen     = room.Multiple * 1000;
            //给胜利的玩家添加胜场
            List <int> winUIds = room.GetSameIdentityUIds(winIdentity);

            for (int i = 0; i < winUIds.Count; i++)
            {
                UserModel um = userCache.GetModelById(winUIds[i]);
                um.WinCount++;
                um.Been += winBeen;
                um.Exp  += 100;
                userCache.Update(um);
            }
            //给失败的玩家添加负场
            List <int> loseUIds = room.GetDifferentIdentityUIds(winIdentity);

            for (int i = 0; i < loseUIds.Count; i++)
            {
                UserModel um = userCache.GetModelById(loseUIds[i]);
                um.LoseCount++;
                um.Been -= winBeen;
                um.Exp  += 10;
                userCache.Update(um);
            }
            //给逃跑玩家添加逃跑场次
            for (int i = 0; i < room.LeaveUIdList.Count; i++)
            {
                UserModel um = userCache.GetModelById(room.LeaveUIdList[i]);
                um.RunCount++;
                um.Been -= (winBeen) * 3;
                um.Been += 0;
                userCache.Update(um);
            }

            //给客户端发消息  赢的身份是什么? 谁赢了? 加多少豆子?
            OverDto dto = new OverDto();

            dto.WinIdentity = winIdentity;
            dto.WinUIdList  = winUIds;
            dto.BeenCount   = winBeen;
            brocast(room, OpCode.FIGHT, FightCode.OVER_BRO, dto);

            //在缓存层销毁房间数据
            fightCache.Destroy(room);
        }
예제 #3
0
        private void gameOver(int userId, FightRoom room)
        {
            int        winIdentity   = room.GetPlayerIdentity(userId);
            int        winBean       = room.Multiple * 1000;
            List <int> winUserIdList = room.GetSameIdentityUserId(winIdentity);

            //win player pluas win count
            for (int i = 0; i < winUserIdList.Count; i++)
            {
                UserModel um = userCache.GetModelByAccountId(winUserIdList[i]);
                um.WinCount++;
                um.Been = winBean;
                um.Exp  = um.LV * 100;
                int maxExp = um.LV * 100;
                while (maxExp <= um.Exp)
                {
                    um.LV++;
                    um.Exp -= maxExp;
                }
                userCache.Update(um);
            }
            //add lose count to loser
            List <int> loseUIds = room.GetDifferentIdentityUserId(winIdentity);

            for (int i = 0; i < loseUIds.Count; i++)
            {
                UserModel um = userCache.GetModelById(loseUIds[i]);
                um.LoseCount++;
                um.Been -= winBean;
                um.Exp  += 10;
                int maxExp = um.LV * 100;
                while (maxExp <= um.Exp)
                {
                    um.LV++;
                    um.Exp -= maxExp;
                }
                userCache.Update(um);
            }
            OverDto dto = new OverDto();

            dto.WinIdentity   = winIdentity;
            dto.WinUserIdList = winUserIdList;
            dto.BeanCount     = winBean;
            Broadcast(room, OpCode.FIGHT, FightCode.Over_BROADCAST, dto);

            fightCache.Destroy(room);
        }
예제 #4
0
        /// <summary>
        /// 游戏结束
        /// </summary>
        /// <param name="room"></param>
        /// <param name="userId"></param>
        private void GameOver(FightRoom room, int userId)
        {
            var winIdentity = room.GetPlayerIdentity(userId);
            var winUserIds  = room.GetSameIdentityUserIds(winIdentity);
            var beens       = room.multiple * 1000;

            //给胜利的玩家结算
            for (int i = 0; i < winUserIds.Count; i++)
            {
                var userModel = user.GetModelById(winUserIds[i]);
                userModel.winCount++;
                userModel.beens += winIdentity == Identity.Landlord ? beens : beens / 2;
                userModel.exp   += 100;
                user.Update(userModel);
            }
            var loseUserIds = room.GetDifferentIdentityUserIds(winIdentity);

            //给失败的玩家结算
            for (int i = 0; i < loseUserIds.Count; i++)
            {
                var userModel = user.GetModelById(loseUserIds[i]);
                userModel.loseCount++;
                userModel.beens -= winIdentity == Identity.Landlord ? beens / 2 : beens;
                userModel.exp   += 50;
                user.Update(userModel);
            }
            //给逃跑玩家结算  离开的时候已经结算了
            //for (int i = 0; i < room.leavePlayerIdList.Count; i++)
            //{
            //    var userModel = user.GetModelById(room.leavePlayerIdList[i]);
            //    userModel.runCount++;
            //    userModel.loseCount++;
            //    userModel.beens -= beens * 3;//逃跑的人减3倍
            //    user.Update(userModel);
            //}
            //给客户端发消息  游戏结束了
            var dto = new OverDto(winIdentity, winUserIds, beens);

            Brocast(room, OpCode.FIGHT, FightCode.OVER_BRO, dto);

            //游戏结束
            fight.Destroy(room);
        }
예제 #5
0
        /// <summary>
        /// 游戏结束
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="room"></param>
        private void gameOver(int userId, FightRoom room)
        {
            //获取获胜身份 所有玩家id
            int winIdentity = room.GetPlayerIdentity(userId);
            //给胜利玩家添加胜场
            List <int> winUIds = room.GetSameIdentityUIds(winIdentity);

            for (int i = 0; i < winUIds.Count; i++)
            {
                UserModel um = userCache.GetModelById(winUIds[i]);
                int       multiple;
                room.multiDict.TryGetValue(winUIds[i], out multiple);
                um.WinCount++;
                foreach (var player in room.PlayerList)
                {
                    if (player.UserId == winUIds[i])
                    {
                        if (player.Identity == Identity.FARMER)
                        {
                            um.winBeen += multiple * 100;
                            um.Been    += um.winBeen;
                        }
                        else if (player.Identity == Identity.LANDLORD)
                        {
                            um.winBeen += 400;
                            um.Been    += um.winBeen;
                        }
                    }
                }
                um.Exp += 100;
                int maxExp = um.Lv * 100;
                while (maxExp <= um.Exp)
                {
                    um.Lv++;
                    um.Exp -= maxExp;
                    maxExp  = um.Lv * 100;
                }
                userCache.Update(um);

                //给客户端发消息 赢得身份是什么?谁赢了?加多少豆子?
                OverDto dto = new OverDto();
                dto.WinIdentity = winIdentity;
                dto.WinUIdList  = winUIds;
                dto.tempUIdList = winUIds;
                dto.BeenCount   = um.winBeen;
                singleBrocast(room, OpCode.FIGHT, FightCode.OVER_BRO, dto, winUIds[i]);
                um.winBeen = 0;
            }
            //给失败的玩家添加负场
            List <int> loseUIds = room.GetDifferentIdentityUIds(winIdentity);

            for (int i = 0; i < loseUIds.Count; i++)
            {
                UserModel um = userCache.GetModelById(loseUIds[i]);
                int       multiple;
                room.multiDict.TryGetValue(loseUIds[i], out multiple);
                um.LoseCount++;
                foreach (var player in room.PlayerList)
                {
                    if (player.UserId == loseUIds[i])
                    {
                        if (player.Identity == Identity.FARMER)
                        {
                            um.winBeen -= multiple * 100;
                            if (um.winBeen >= 0)
                            {
                                um.Been -= um.winBeen;
                            }
                            else
                            {
                                um.Been += um.winBeen;
                            }
                        }
                        else if (player.Identity == Identity.LANDLORD)
                        {
                            um.winBeen -= 400;
                            if (um.winBeen >= 0)
                            {
                                um.Been -= um.winBeen;
                            }
                            else
                            {
                                um.Been += um.winBeen;
                            }
                        }
                    }
                }
                um.Exp += 10;
                int maxExp = um.Lv * 100;
                while (maxExp <= um.Exp)
                {
                    um.Lv++;
                    um.Exp -= maxExp;
                    maxExp  = um.Lv * 100;
                }
                userCache.Update(um);
                //给客户端发消息 赢得身份是什么?谁赢了?加多少豆子?
                OverDto dto = new OverDto();
                dto.WinIdentity = winIdentity;
                dto.WinUIdList  = winUIds;
                dto.tempUIdList = loseUIds;
                dto.BeenCount   = Math.Abs(um.winBeen);
                singleBrocast(room, OpCode.FIGHT, FightCode.OVER_BRO, dto, loseUIds[i]);
                um.winBeen = 0;
            }
            //给逃跑玩家添加逃跑场次
            for (int i = 0; i < room.LeaveUIdList.Count; i++)
            {
                UserModel um = userCache.GetModelById(room.LeaveUIdList[i]);
                int       multiple;
                room.multiDict.TryGetValue(loseUIds[i], out multiple);
                um.RunCount++;
                foreach (var player in room.PlayerList)
                {
                    if (player.UserId == winUIds[i])
                    {
                        if (player.Identity == Identity.FARMER)
                        {
                            um.winBeen -= multiple * 100;
                            if (um.winBeen >= 0)
                            {
                                um.Been -= um.winBeen;
                            }
                            else
                            {
                                um.Been += um.winBeen;
                            }
                        }
                        else if (player.Identity == Identity.LANDLORD)
                        {
                            um.winBeen -= 1200;
                            if (um.winBeen >= 0)
                            {
                                um.Been -= um.winBeen;
                            }
                            else
                            {
                                um.Been += um.winBeen;
                            }
                        }
                    }
                }
                um.Exp    += 0;
                um.winBeen = 0;
                userCache.Update(um);
            }

            //在缓存层销毁房间数值
            fightCache.Destroy(room);
        }