feat:update
parent
9f1b4722b0
commit
ea2e98eb41
Binary file not shown.
|
|
@ -215,11 +215,21 @@ public class GameController implements IController{
|
|||
|
||||
|
||||
/**
|
||||
* 房间解散投票请求
|
||||
* 处理房间解散投票请求
|
||||
* 当玩家对房间解散投票做出响应时,该方法会被调用
|
||||
* 它的主要作用是根据玩家的投票结果来处理房间的解散流程
|
||||
*
|
||||
* @param sender 发起投票请求的会话
|
||||
* @param params 投票结果参数,包含玩家的投票结果(同意或不同意)
|
||||
* @param gid 游戏ID,用于标识特定的游戏
|
||||
* @param owner 投票的房间所有者,即做出投票响应的玩家
|
||||
*/
|
||||
@ActionKey(Router.GAME_DISMISS_ROOM_VOTE)
|
||||
public void routerDismissRoomVote(Session sender,ITObject params,int gid,Player owner) {
|
||||
public void routerDismissRoomVote(Session sender, ITObject params, int gid, Player owner) {
|
||||
// 获取玩家的投票结果,true表示同意解散,false表示不同意解散
|
||||
boolean agree = params.getBoolean("result");
|
||||
|
||||
// 调用房间解散流程中的响应方法,根据玩家的投票结果来执行相应的逻辑
|
||||
owner.room.dismissRunable.responseDismiss(owner, agree);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import com.taurus.permanent.data.Session;
|
|||
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
|
||||
/**
|
||||
* 基本房间对象
|
||||
*
|
||||
|
|
@ -263,8 +264,14 @@ public class Room implements Runnable {
|
|||
this.win = new ArrayList<>();
|
||||
this.loss = new ArrayList<>();
|
||||
this.config = TObject.newFromJsonData(redis_room_map.get("options"));
|
||||
hpData = this.config.getTObject("hpData");
|
||||
System.out.println("数据1"+hpData);
|
||||
System.out.println("数据:"+redis_room_map.get("hpData"));
|
||||
System.out.println("数据3"+hpData.getInt("maxRound"));
|
||||
Integer num = hpData.getInt("maxRound");
|
||||
this.maxPlayers = Integer.parseInt(redis_room_map.get("maxPlayers"));
|
||||
this.maxRound = Integer.parseInt(redis_room_map.get("times"));
|
||||
// this.maxRound = Integer.parseInt(redis_room_map.get("times"));
|
||||
this.maxRound = hpData.getInt("maxRound");
|
||||
this.config.putInt("maxPlayers", this.maxPlayers);
|
||||
this.config.putInt("times", this.maxRound);
|
||||
this.pay = Integer.parseInt(redis_room_map.get("pay"));
|
||||
|
|
@ -594,6 +601,9 @@ public class Room implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 游戏结束
|
||||
*/
|
||||
|
|
@ -610,8 +620,7 @@ public class Room implements Runnable {
|
|||
this.saveRecRound();
|
||||
|
||||
if (total) {
|
||||
|
||||
this.saveMilitaryTotal(false);
|
||||
this.saveMilitaryTotal(true);
|
||||
} else {
|
||||
roomResult();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@ import java.util.List;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import com.data.util.ErrorCode;
|
||||
import com.game.Constant;
|
||||
import com.game.Global;
|
||||
import com.game.data.Timer.ITaskHandler;
|
||||
import com.game.room.state.RoomDestoryGameState;
|
||||
import com.taurus.core.entity.ITObject;
|
||||
|
||||
/**
|
||||
* 房间解散处理
|
||||
|
|
@ -53,21 +55,40 @@ public class RoomDismiss {
|
|||
this.dismissCallback(player);
|
||||
}
|
||||
|
||||
public void responseDismiss(Player player, boolean agree) {
|
||||
/**
|
||||
* 处理玩家的解散请求响应
|
||||
* 此方法主要用于处理玩家对解散邀请的回应只有当游戏尚未开始且玩家的解散状态为待定(0)时,才允许更新玩家的解散状态
|
||||
*
|
||||
* @param player 玩家对象,表示作出回应的玩家
|
||||
* @param agree 布尔值,表示玩家是否同意解散true表示同意,false表示不同意
|
||||
*/
|
||||
public void responseDismiss(Player player, boolean agree) {
|
||||
// 检查游戏是否尚未开始且玩家的解散状态为待定如果条件不满足,则直接返回,不进行后续操作
|
||||
if (start == false || player.dismissState != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据玩家的回应更新玩家的解散状态
|
||||
if (agree) {
|
||||
player.dismissState = 1;
|
||||
player.dismissState = 1; // 玩家同意解散,设置状态为1
|
||||
} else {
|
||||
player.dismissState = 2;
|
||||
}
|
||||
dismissCallback(player);
|
||||
player.dismissState = 2; // 玩家不同意解散,设置状态为2
|
||||
}
|
||||
|
||||
// 调用回调方法,通知玩家解散状态已更新
|
||||
dismissCallback(player);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理玩家解散房间的回调方法
|
||||
*
|
||||
* @param player 发起解散请求的玩家
|
||||
*/
|
||||
private void dismissCallback(Player player) {
|
||||
int agreeCount = 0;
|
||||
int notAgreeCount = 0;
|
||||
// 遍历玩家列表,统计同意和不同意解散房间的玩家数量
|
||||
for (Player p : playerList) {
|
||||
if (p.dismissState == 1) {
|
||||
agreeCount += 1;
|
||||
|
|
@ -76,25 +97,40 @@ public class RoomDismiss {
|
|||
}
|
||||
}
|
||||
|
||||
// 判断所有玩家是否都同意解散房间
|
||||
agree = notAgreeCount == 0 && agreeCount == playerList.size();
|
||||
|
||||
// 如果所有玩家都同意,解散房间
|
||||
if (agree) {
|
||||
// // 结束房间内的游戏
|
||||
// player.room.saveMilitaryTotal(true);
|
||||
interruptTimer();
|
||||
} else {
|
||||
// 如果有玩家不同意,通知游戏控制器解散房间失败
|
||||
if (notAgreeCount > 0) {
|
||||
Global.gameCtr.dismisRoomFail(owner);
|
||||
interruptTimer();
|
||||
} else {
|
||||
// 如果没有玩家明确表示不同意,继续等待并通知游戏控制器
|
||||
Global.gameCtr.dismissRoom(askPlayer, null, playerList, getLeftTime());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 中断定时器
|
||||
*
|
||||
* 此方法用于中断并释放当前对象初始化的定时器如果定时器不为空,则停止定时器的操作,
|
||||
* 并将定时器引用置为null,以准备将其销毁最后,调用checkDestroy方法来检查对象是否可以被销毁
|
||||
*/
|
||||
private void interruptTimer() {
|
||||
// 检查定时器是否已被初始化且不为null
|
||||
if (timer != null)
|
||||
// 停止定时器的操作
|
||||
timer.stop();
|
||||
// 将定时器引用置为null,表示不再使用定时器
|
||||
timer = null;
|
||||
// 调用方法检查对象是否可以被销毁
|
||||
checkDestroy();
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +173,7 @@ public class RoomDismiss {
|
|||
private void checkDestroy() {
|
||||
start = false;
|
||||
if (agree) {
|
||||
// owner.saveMilitaryTotal(true);
|
||||
owner.saveMilitaryTotal(true);
|
||||
owner.stateMachine.changeState(Global.getState(RoomDestoryGameState.class));
|
||||
}
|
||||
agree = true;
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -111,7 +111,7 @@ public void RouterAction(Session sender, ITObject params, int gid, Player owner)
|
|||
|
||||
// 获取房间的胜利者
|
||||
EXPlayer win = owner.win;
|
||||
if (win != null) {
|
||||
if (win != null ) {
|
||||
// 创建一个数组,用于存储房间内所有玩家的信息
|
||||
ITArray info = new TArray();
|
||||
// 遍历房间内的所有玩家
|
||||
|
|
@ -172,6 +172,7 @@ public void RouterAction(Session sender, ITObject params, int gid, Player owner)
|
|||
public void roomResult(EXRoom owner) {
|
||||
ITObject result = getRoomResultData(owner, false);
|
||||
result.putInt("type", 0);
|
||||
owner.nextRound++;
|
||||
owner.broadCastToClient(0, Config.GAME_EVT_RESULT1, result);
|
||||
}
|
||||
|
||||
|
|
@ -281,7 +282,8 @@ public void dealCard(EXRoom room) {
|
|||
}
|
||||
|
||||
param.putInt("bank_seat", exPlayer.room.bankerSeat);
|
||||
param.putInt("round", room.round);
|
||||
param.putInt("round", room.nextRound);
|
||||
|
||||
if (Global.loggerDebug) {
|
||||
Global.logger.info(room + " deal card:" + exPlayer.cardInhand);
|
||||
}
|
||||
|
|
@ -301,6 +303,10 @@ public void dealCard(EXRoom room) {
|
|||
room.counts=2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
param.putInt("raiseRound", room.raiseRound);
|
||||
exPlayer.sendEvent(Config.GAME_EVT_PLAYER_DEAL, param);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class EXRoom extends Room {
|
|||
|
||||
|
||||
//存储下局次数
|
||||
public int nextRound = 0;
|
||||
public int nextRound = 1;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -77,6 +77,13 @@ public class EXRoom extends Room {
|
|||
*/
|
||||
public int callCount = 0;
|
||||
|
||||
/**
|
||||
* 是否所有玩家都allin
|
||||
*/
|
||||
public int isAllIn = 0;
|
||||
|
||||
|
||||
|
||||
public EXPlayer win;
|
||||
|
||||
public EXRoom(String roomid, Map<String, String> redis_room_map) {
|
||||
|
|
@ -108,7 +115,23 @@ public class EXRoom extends Room {
|
|||
if (!this.config.containsKey(Config.ROOM_CONFIG_ROUND)){
|
||||
this.config.putInt(Config.ROOM_CONFIG_ROUND, 1);
|
||||
}
|
||||
if (!this.config.containsKey(Config.ROOM_CONFIG_BASE_SCORE)){
|
||||
this.config.putInt(Config.ROOM_CONFIG_BASE_SCORE, 0);
|
||||
}
|
||||
|
||||
if (this.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==0){
|
||||
this.sidePot = 1;
|
||||
}
|
||||
if (this.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==1){
|
||||
this.sidePot = 2;
|
||||
}
|
||||
if (this.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==2) {
|
||||
this.sidePot = 5;
|
||||
}
|
||||
|
||||
// System.out.println("底注"+this.config.getInt(Config.ROOM_CONFIG_BASE_SCORE));
|
||||
// int num = this.config.getInt(Config.ROOM_CONFIG_BASE_SCORE);
|
||||
// System.out.println(num);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
|
|
|
|||
|
|
@ -29,10 +29,16 @@ public class EXPlayerAllInState extends StateBase<EXPlayer> {
|
|||
@Override
|
||||
public void enter(EXPlayer owner) {
|
||||
|
||||
|
||||
|
||||
if (owner.betScore == 0) {
|
||||
return;
|
||||
}
|
||||
EXRoom room = owner.getRoom();
|
||||
room.isAllIn++;
|
||||
|
||||
System.out.println("底池分数:"+room.sidePot);
|
||||
|
||||
if (owner.fold) {
|
||||
// 已经弃牌则转入下一位玩家
|
||||
TObject param = new TObject();
|
||||
|
|
@ -62,9 +68,15 @@ public class EXPlayerAllInState extends StateBase<EXPlayer> {
|
|||
room.callCount = 1;
|
||||
List<Integer> actions = new ArrayList<Integer>();
|
||||
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1){
|
||||
if (room.isAllIn== room.playerMapById.size()){
|
||||
over(owner);
|
||||
return;
|
||||
}
|
||||
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1 && room.counts==2){
|
||||
actions.add(Integer.parseInt(Config.GAME_ALL_IN));
|
||||
}
|
||||
actions.add(Integer.parseInt(Config.GAME_FOLD));
|
||||
|
||||
ITArray actionArray = Util.toTArray(actions);
|
||||
param.putTArray("actions", actionArray);
|
||||
|
|
@ -81,6 +93,9 @@ public class EXPlayerAllInState extends StateBase<EXPlayer> {
|
|||
// 记录房间当前操作
|
||||
room.actionType = Integer.parseInt(Config.GAME_BET);
|
||||
toNextState(owner);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -94,7 +109,8 @@ public class EXPlayerAllInState extends StateBase<EXPlayer> {
|
|||
EXRoom room = owner.getRoom();
|
||||
room.bankerSeat = owner.seat;
|
||||
room.win = owner;
|
||||
room.roomResult();
|
||||
// room.roomResult();
|
||||
room.endGame();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -122,9 +138,24 @@ public class EXPlayerAllInState extends StateBase<EXPlayer> {
|
|||
+ "--lostScore:" + player.lostScore);
|
||||
}
|
||||
|
||||
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==0){
|
||||
owner.betScore=20;
|
||||
}
|
||||
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==1){
|
||||
owner.betScore=50;
|
||||
}
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==2) {
|
||||
owner.betScore=100;
|
||||
}
|
||||
|
||||
System.out.println("all in 下注分数1:"+owner.betScore);
|
||||
|
||||
// 扣除下注分数
|
||||
owner.lostScore = 0 - owner.betScore;
|
||||
// room.callScore = 0;
|
||||
System.out.println("底池分数:"+room.sidePot);
|
||||
room.sidePot += owner.betScore;
|
||||
room.raiseRound = 0;
|
||||
// 广播协议
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class EXPlayerBetState extends StateBase<EXPlayer> {
|
|||
actions.add(Integer.parseInt(Config.GAME_CALL));
|
||||
actions.add(Integer.parseInt(Config.GAME_FOLD));
|
||||
actions.add(Integer.parseInt(Config.GAME_RAISE));
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1){
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1 && room.counts==2){
|
||||
actions.add(Integer.parseInt(Config.GAME_ALL_IN));
|
||||
}
|
||||
// actions.add(Integer.parseInt(Config.GAME_ALL_IN));
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class EXPlayerCallState extends StateBase<EXPlayer> {
|
|||
actions.add(Integer.parseInt(Config.GAME_CHECK));
|
||||
}
|
||||
// actions.add(Integer.parseInt(Config.GAME_ALL_IN));
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1){
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1 && room.counts==2){
|
||||
actions.add(Integer.parseInt(Config.GAME_ALL_IN));
|
||||
}
|
||||
ITArray actionArray = Util.toTArray(actions);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class EXPlayerCheckState extends StateBase<EXPlayer> {
|
|||
actions.add(Integer.parseInt(Config.GAME_FOLD));
|
||||
// actions.add(Integer.parseInt(Config.GAME_ALL_IN));
|
||||
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1){
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1 && room.counts==2){
|
||||
actions.add(Integer.parseInt(Config.GAME_ALL_IN));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,8 +73,13 @@ public class EXPlayerFoldState extends StateBase<EXPlayer> {
|
|||
public void over(EXRoom room) {
|
||||
EXPlayer player = CardCheck.CheckCall(room);
|
||||
room.win = player;
|
||||
room.roomResult();
|
||||
if (room.nextRound==room.maxRound){
|
||||
room.endGame();
|
||||
}else {
|
||||
room.roomResult();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class EXPlayerRaiseState extends StateBase<EXPlayer> {
|
|||
actions.add(Integer.parseInt(Config.GAME_FOLD));
|
||||
// actions.add(Integer.parseInt(Config.GAME_ALL_IN));
|
||||
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1){
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1 && room.counts==2){
|
||||
actions.add(Integer.parseInt(Config.GAME_ALL_IN));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class EXRoomDealState extends StateBase<EXRoom> {
|
|||
actions.add(Integer.parseInt(Config.GAME_FOLD));
|
||||
// actions.add(Integer.parseInt(Config.GAME_CHECK));
|
||||
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1){
|
||||
if (room.config.getInt(Config.ROOM_CONFIG_ALLIN)==1 && room.counts==2){
|
||||
actions.add(Integer.parseInt(Config.GAME_ALL_IN));
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue