public static void setPVPReward(PVPRoomPlayerList curPVPRoomPlayerList) { string gameRoomType = curPVPRoomPlayerList.m_gameRoomType; List <string> list = new List <string>(); CommonUtil.splitStr(gameRoomType, list, '_'); if (list.Count == 3) { if (list[0].CompareTo("PVP") == 0) { PVPGameRoomData pvpGameRoomData = PVPGameRoomDataScript.getInstance().getDataByRoomType(gameRoomType); // PVP-金币场 if (list[1].CompareTo("JinBi") == 0) { // 2000金币场 if (pvpGameRoomData.reward_num == 2000) { // 第一名 { int getHuiZhangNum = 1; UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(curPVPRoomPlayerList.m_playerList[0].m_uid); if (userInfo_Game != null) { int vipLevel = userInfo_Game.vipLevel; if ((vipLevel >= 2) && (vipLevel <= 4)) { getHuiZhangNum += 1; } else if ((vipLevel >= 5) && (vipLevel <= 7)) { getHuiZhangNum += 2; } else if ((vipLevel >= 8) && (vipLevel <= 10)) { getHuiZhangNum += 3; } } else { TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPVPReward出错:UserInfo_Game_Manager.getDataByUid()为空"); } curPVPRoomPlayerList.m_playerList[0].m_pvpReward = "1:2000;110:" + getHuiZhangNum; } // 第二名 { curPVPRoomPlayerList.m_playerList[1].m_pvpReward = "1:1000"; } } // 10000金币场 else if (pvpGameRoomData.reward_num == 10000) { // 第一名 { int getHuiZhangNum = 1; UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(curPVPRoomPlayerList.m_playerList[0].m_uid); if (userInfo_Game != null) { int vipLevel = userInfo_Game.vipLevel; if ((vipLevel >= 2) && (vipLevel <= 4)) { getHuiZhangNum += 1; } else if ((vipLevel >= 5) && (vipLevel <= 7)) { getHuiZhangNum += 2; } else if ((vipLevel >= 8) && (vipLevel <= 10)) { getHuiZhangNum += 3; } } else { TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPVPReward出错:UserInfo_Game_Manager.getDataByUid()为空"); } curPVPRoomPlayerList.m_playerList[0].m_pvpReward = "1:10000;110:" + getHuiZhangNum; } // 第二名 { curPVPRoomPlayerList.m_playerList[1].m_pvpReward = "1:1000"; } } // 5000金币场(用于ios审核) else if (pvpGameRoomData.reward_num == 5000) { // 第一名 { int getHuiZhangNum = 1; UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(curPVPRoomPlayerList.m_playerList[0].m_uid); if (userInfo_Game != null) { int vipLevel = userInfo_Game.vipLevel; if ((vipLevel >= 2) && (vipLevel <= 4)) { getHuiZhangNum += 1; } else if ((vipLevel >= 5) && (vipLevel <= 7)) { getHuiZhangNum += 2; } else if ((vipLevel >= 8) && (vipLevel <= 10)) { getHuiZhangNum += 3; } } else { TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPVPReward出错:UserInfo_Game_Manager.getDataByUid()为空"); } curPVPRoomPlayerList.m_playerList[0].m_pvpReward = "1:5000;110:" + getHuiZhangNum; } // 第二名 { curPVPRoomPlayerList.m_playerList[1].m_pvpReward = "1:1000"; } } } // PVP-话费场 else if (list[1].CompareTo("HuaFei") == 0) { // 1元话费场 if (list[2].CompareTo("1") == 0) { // 第一名 { int getHuiZhangNum = 1; UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(curPVPRoomPlayerList.m_playerList[0].m_uid); if (userInfo_Game != null) { int vipLevel = userInfo_Game.vipLevel; if ((vipLevel >= 2) && (vipLevel <= 4)) { getHuiZhangNum += 1; } else if ((vipLevel >= 5) && (vipLevel <= 7)) { getHuiZhangNum += 2; } else if ((vipLevel >= 8) && (vipLevel <= 10)) { getHuiZhangNum += 3; } } else { TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPVPReward出错:UserInfo_Game_Manager.getDataByUid()为空"); } curPVPRoomPlayerList.m_playerList[0].m_pvpReward = "111:1;110:" + getHuiZhangNum; } // 第二名 { curPVPRoomPlayerList.m_playerList[1].m_pvpReward = "1:500"; } } // 5元话费场 else if (list[2].CompareTo("5") == 0) { // 第一名 { int getHuiZhangNum = 2; UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(curPVPRoomPlayerList.m_playerList[0].m_uid); if (userInfo_Game != null) { int vipLevel = userInfo_Game.vipLevel; if ((vipLevel >= 2) && (vipLevel <= 4)) { getHuiZhangNum += 1; } else if ((vipLevel >= 5) && (vipLevel <= 7)) { getHuiZhangNum += 2; } else if ((vipLevel >= 8) && (vipLevel <= 10)) { getHuiZhangNum += 3; } } else { TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPVPReward出错:UserInfo_Game_Manager.getDataByUid()为空"); } curPVPRoomPlayerList.m_playerList[0].m_pvpReward = "112:1;110:" + getHuiZhangNum; } // 第二名 { curPVPRoomPlayerList.m_playerList[1].m_pvpReward = "1:5000;110:1"; } } } } } }
// 游戏结束 public override void gameOver(RoomData room) { try { room.setRoomState(RoomState.RoomState_end); room.m_masterPokerType = -1; LogUtil.getInstance().writeRoomLog(room, m_logFlag + "----" + ":比赛结束,roomid = :" + room.getRoomId()); // 游戏在线统计 for (int i = 0; i < room.getPlayerDataList().Count; i++) { Request_OnlineStatistics.doRequest(room.getPlayerDataList()[i].m_uid, room.getRoomId(), room.m_gameRoomType, room.getPlayerDataList()[i].m_isAI, (int)Request_OnlineStatistics.OnlineStatisticsType.OnlineStatisticsType_exit); } // 计算每个玩家的金币(积分) GameUtil.setPlayerScore(room, false); // 加减金币 { for (int i = 0; i < room.getPlayerDataList().Count; i++) { // 如果玩家这一局赢了,则检测是否有金币加倍buff? if (room.getPlayerDataList()[i].m_score > 0) { bool canUse = false; UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(room.getPlayerDataList()[i].m_uid); if (userInfo_Game != null) { for (int j = 0; j < userInfo_Game.BuffData.Count; j++) { if ((userInfo_Game.BuffData[j].prop_id == (int)TLJCommon.Consts.Prop.Prop_jiabeika) && (userInfo_Game.BuffData[j].buff_num > 0)) { userInfo_Game.BuffData[j].buff_num -= 1; canUse = true; LogUtil.getInstance().writeRoomLog(room, m_logFlag + "----" + ":此玩家有双倍金币buff,金币奖励加倍 :" + room.getPlayerDataList()[i].m_uid); break; } } } if (canUse) { room.getPlayerDataList()[i].m_score *= 2; // 扣除玩家buff:加倍卡 Request_UseBuff.doRequest(room.getPlayerDataList()[i].m_uid, (int)TLJCommon.Consts.Prop.Prop_jiabeika); } } // 加、减玩家金币值 Request_ChangeUserWealth.doRequest(room.getPlayerDataList()[i].m_uid, 1, room.getPlayerDataList()[i].m_score, "休闲场结算"); } } // 逻辑处理 { List <string> winnerList = new List <string>(); // 闲家赢 if (room.m_getAllScore >= 80) { for (int i = 0; i < room.getPlayerDataList().Count; i++) { if (room.getPlayerDataList()[i].m_isBanker == 0) { winnerList.Add(room.getPlayerDataList()[i].m_uid); ++room.getPlayerDataList()[i].m_myLevelPoker; if (room.getPlayerDataList()[i].m_myLevelPoker == 15) { room.getPlayerDataList()[i].m_myLevelPoker = 2; } room.m_levelPokerNum = room.getPlayerDataList()[i].m_myLevelPoker; // 提交任务 if (!room.getPlayerDataList()[i].m_isAI) { Request_ProgressTask.doRequest(room.getPlayerDataList()[i].m_uid, 203); Request_ProgressTask.doRequest(room.getPlayerDataList()[i].m_uid, 212); } // 记录胜利次数数据 { Request_RecordUserGameData.doRequest(room.getPlayerDataList()[i].m_uid, room.m_gameRoomType, (int)TLJCommon.Consts.GameAction.GameAction_Win); } } } } // 庄家赢 else { for (int i = 0; i < room.getPlayerDataList().Count; i++) { if (room.getPlayerDataList()[i].m_isBanker == 1) { winnerList.Add(room.getPlayerDataList()[i].m_uid); ++room.getPlayerDataList()[i].m_myLevelPoker; if (room.getPlayerDataList()[i].m_myLevelPoker == 15) { room.getPlayerDataList()[i].m_myLevelPoker = 2; } room.m_levelPokerNum = room.getPlayerDataList()[i].m_myLevelPoker; // 提交任务 if (!room.getPlayerDataList()[i].m_isAI) { Request_ProgressTask.doRequest(room.getPlayerDataList()[i].m_uid, 203); Request_ProgressTask.doRequest(room.getPlayerDataList()[i].m_uid, 212); } // 记录胜利次数数据 { Request_RecordUserGameData.doRequest(room.getPlayerDataList()[i].m_uid, room.m_gameRoomType, (int)TLJCommon.Consts.GameAction.GameAction_Win); } } } } // 游戏数据统计 Request_GameStatistics.doRequest(room, winnerList); } // 通知 { JObject respondJO; { respondJO = new JObject(); respondJO.Add("tag", m_tag); respondJO.Add("playAction", (int)TLJCommon.Consts.PlayAction.PlayAction_GameOver); respondJO.Add("getAllScore", room.m_getAllScore); respondJO.Add("isBankerWin", room.m_getAllScore >= 80 ? 0 : 1); respondJO.Add("isContiune", false); } // 给在线的人推送 for (int i = 0; i < room.getPlayerDataList().Count; i++) { // 推送给客户端 if (!room.getPlayerDataList()[i].isOffLine()) { if (!(room.getPlayerDataList()[i].m_isAI)) { if (respondJO.GetValue("score") != null) { respondJO.Remove("score"); } respondJO.Add("score", room.getPlayerDataList()[i].m_score); PlayService.m_serverUtil.sendMessage(room.getPlayerDataList()[i].m_connId, respondJO.ToString()); } } else { if (!(room.getPlayerDataList()[i].m_isAI)) { // 记录逃跑数据 Request_RecordUserGameData.doRequest(room.getPlayerDataList()[i].m_uid, room.m_gameRoomType, (int)TLJCommon.Consts.GameAction.GameAction_Run); } } // 告诉数据库服务器该玩家打完一局 { Request_GameOver.doRequest(room.getPlayerDataList()[i].m_uid, room.m_gameRoomType); } } } // 检查是否删除该房间 { if (GameUtil.checkRoomNonePlayer(room)) { LogUtil.getInstance().writeRoomLog(room, m_logFlag + "----" + ":所有人都离线,解散该房间:" + room.getRoomId()); GameLogic.removeRoom(this, room, true); } } } catch (Exception ex) { TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":gameOver异常:" + ex); } }
/* * canFuShu:是否可以为负数? * 休闲场score代表金币,是要扣除的,所以可以为负数 * PVP场score代表积分,扣到0就不扣了,不能为负数 */ public static void setPlayerScore(RoomData room, bool canFuShu) { try { float jichufenshu = 985; float changcixishu = 1; float defenxishu = 1; float xianjiadefen; // 计算场次系数 { List <string> tempList = new List <string>(); CommonUtil.splitStr(room.m_gameRoomType, tempList, '_'); switch (tempList[0]) { case "XiuXian": { if (tempList[2].CompareTo("Common") == 0) { changcixishu = 2; } else if (tempList[2].CompareTo("ChuJi") == 0) { changcixishu = 1; } else if (tempList[2].CompareTo("ZhongJi") == 0) { changcixishu = 2; } else if (tempList[2].CompareTo("GaoJi") == 0) { changcixishu = 3; } } break; case "PVP": { changcixishu = 1; } break; } } // 计算得分系数 { if (room.m_getAllScore == 0) { defenxishu = -3.6f; } else if ((room.m_getAllScore >= 5) && (room.m_getAllScore <= 40)) { defenxishu = -2.6f; } else if ((room.m_getAllScore >= 45) && (room.m_getAllScore <= 75)) { defenxishu = -1.6f; } else if (room.m_getAllScore == 80) { defenxishu = 1.0f; } else if ((room.m_getAllScore >= 85) && (room.m_getAllScore <= 120)) { defenxishu = 1.6f; } else if ((room.m_getAllScore >= 125) && (room.m_getAllScore <= 195)) { defenxishu = 2.6f; } else if (room.m_getAllScore >= 200) { defenxishu = 3.6f; } } xianjiadefen = jichufenshu * changcixishu * defenxishu; if (!canFuShu) { // 闲家赢 if (xianjiadefen > 0) { float winerCanGetScote = 0; for (int i = 0; i < room.getPlayerDataList().Count; i++) { if (room.getPlayerDataList()[i].m_isBanker == 1) { UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(room.getPlayerDataList()[i].m_uid); if (userInfo_Game != null) { if (userInfo_Game.gold >= xianjiadefen) { winerCanGetScote += xianjiadefen; room.getPlayerDataList()[i].m_score = (int)(-xianjiadefen); } else { winerCanGetScote += userInfo_Game.gold; room.getPlayerDataList()[i].m_score = (-userInfo_Game.gold); } } else { TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPlayerScore出错:UserInfo_Game_Manager.getDataByUid()为空"); } } } for (int i = 0; i < room.getPlayerDataList().Count; i++) { if (room.getPlayerDataList()[i].m_isBanker != 1) { room.getPlayerDataList()[i].m_score = (int)winerCanGetScote / 2; } } } // 庄家赢 else { float winerCanGetScote = 0; for (int i = 0; i < room.getPlayerDataList().Count; i++) { UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(room.getPlayerDataList()[i].m_uid); if (userInfo_Game != null) { if (room.getPlayerDataList()[i].m_isBanker != 1) { if (userInfo_Game.gold >= (-xianjiadefen)) { winerCanGetScote += (-xianjiadefen); room.getPlayerDataList()[i].m_score = (int)xianjiadefen; } else { winerCanGetScote += userInfo_Game.gold; room.getPlayerDataList()[i].m_score = (-userInfo_Game.gold); } } } else { TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":setPlayerScore出错:UserInfo_Game_Manager.getDataByUid()为空"); } } for (int i = 0; i < room.getPlayerDataList().Count; i++) { if (room.getPlayerDataList()[i].m_isBanker == 1) { room.getPlayerDataList()[i].m_score = (int)winerCanGetScote / 2; } } } } else { for (int i = 0; i < room.getPlayerDataList().Count; i++) { if (room.getPlayerDataList()[i].m_isBanker == 1) { room.getPlayerDataList()[i].m_score += (-(int)xianjiadefen); } else { room.getPlayerDataList()[i].m_score += (int)xianjiadefen; } } } } catch (Exception ex) { TLJ_PlayService.PlayService.log.Error("GameUtil.setPlayerScore()----" + ex.Message + "gameRoomType:" + room.m_gameRoomType); } }
public static void setPlayerScore(DDZ_RoomData room, bool canFuShu) { try { float jichufenshu = 100; float changcixishu = 1; float beishu = 1; for (int i = 0; i < room.getPlayerDataList().Count; i++) { float score = 0; // 叫分 * 春天倍数 * 炸弹倍数 beishu = room.m_maxJiaoFenPlayerData.m_jiaofen * room.m_beishu_chuntian * room.m_beishu_bomb; if (room.getPlayerDataList()[i].m_isJiaBang == 1) { beishu *= 2; } score = jichufenshu * changcixishu * beishu; room.getPlayerDataList()[i].m_score = (int)score; } // 地主赢 if (room.m_winPlayerData.m_isDiZhu == 1) { int winerCanGetScote = 0; for (int i = 0; i < room.getPlayerDataList().Count; i++) { DDZ_PlayerData playerData = room.getPlayerDataList()[i]; if (playerData.m_isDiZhu != 1) { UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(playerData.m_uid); if (userInfo_Game != null) { if (userInfo_Game.gold < playerData.m_score) { winerCanGetScote += userInfo_Game.gold; playerData.m_score = -userInfo_Game.gold; } else { winerCanGetScote += playerData.m_score; playerData.m_score = -playerData.m_score; } } } } room.m_diZhuPlayer.m_score = winerCanGetScote; } // 农民赢 else { int winerCanGetScote = 0; for (int i = 0; i < room.getPlayerDataList().Count; i++) { DDZ_PlayerData playerData = room.getPlayerDataList()[i]; if (playerData.m_isDiZhu != 1) { UserInfo_Game userInfo_Game = UserInfo_Game_Manager.getDataByUid(playerData.m_uid); if (userInfo_Game != null) { winerCanGetScote += playerData.m_score; } } } room.m_diZhuPlayer.m_score = -winerCanGetScote; } } catch (Exception ex) { TLJ_PlayService.PlayService.log.Error("DDZ_GameUtil.setPlayerScore()----" + ex + "gameRoomType:" + room.m_gameRoomType); } }