refactor(room): 重构房间底分逻辑
- 移除 EXRoomDealState 和 EXRoomStartGameState 中重复的底分计算逻辑- 在 EXRoom 中添加统一的底分计算方法 - 优化底分扣除和边池增加的逻辑 - 删除不必要的注释和未使用的代码master
parent
c22f15dbf4
commit
561d4f5d27
|
|
@ -84,10 +84,13 @@ public class EXRoom extends Room {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public EXPlayer win;
|
public EXPlayer win;
|
||||||
|
|
||||||
public EXRoom(String roomid, Map<String, String> redis_room_map) {
|
public EXRoom(String roomid, Map<String, String> redis_room_map) {
|
||||||
super(roomid, redis_room_map);
|
super(roomid, redis_room_map);
|
||||||
|
|
||||||
|
|
||||||
card = new RoomCard(this, 2, maxPlayers);
|
card = new RoomCard(this, 2, maxPlayers);
|
||||||
if (!this.config.containsKey(Config.ROOM_CONFIG_PRW_FORE)) {
|
if (!this.config.containsKey(Config.ROOM_CONFIG_PRW_FORE)) {
|
||||||
this.config.putInt(Config.ROOM_CONFIG_PRW_FORE, 2);
|
this.config.putInt(Config.ROOM_CONFIG_PRW_FORE, 2);
|
||||||
|
|
@ -119,6 +122,8 @@ public class EXRoom extends Room {
|
||||||
this.config.putInt(Config.ROOM_CONFIG_BASE_SCORE, 0);
|
this.config.putInt(Config.ROOM_CONFIG_BASE_SCORE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("底注"+this.config.getInt(Config.ROOM_CONFIG_BASE_SCORE));
|
// System.out.println("底注"+this.config.getInt(Config.ROOM_CONFIG_BASE_SCORE));
|
||||||
// int num = this.config.getInt(Config.ROOM_CONFIG_BASE_SCORE);
|
// int num = this.config.getInt(Config.ROOM_CONFIG_BASE_SCORE);
|
||||||
// System.out.println(num);
|
// System.out.println(num);
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,34 @@ public class EXRoomDealState extends StateBase<EXRoom> {
|
||||||
// 扣除底分
|
// 扣除底分
|
||||||
for (Entry<Integer, Player> entry : room.playerMapByPlaying.entrySet()) {
|
for (Entry<Integer, Player> entry : room.playerMapByPlaying.entrySet()) {
|
||||||
EXPlayer player = (EXPlayer) entry.getValue();
|
EXPlayer player = (EXPlayer) entry.getValue();
|
||||||
player.lostScore -= room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE);
|
// player.lostScore -= room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE);
|
||||||
room.sidePot += room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE);
|
// room.sidePot += room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE);
|
||||||
|
if (room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==0){
|
||||||
|
if (room.nextRound==1 && room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==0){
|
||||||
|
player.totalLostScore=1;
|
||||||
|
player.lostScore=-1;
|
||||||
|
}
|
||||||
|
room.sidePot = 2;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==1){
|
||||||
|
if (room.nextRound==1 && room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==1){
|
||||||
|
player.totalLostScore=2;
|
||||||
|
player.lostScore=-2;
|
||||||
|
|
||||||
|
}
|
||||||
|
room.sidePot = 4;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==2) {
|
||||||
|
if (room.nextRound==1 && room.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==2){
|
||||||
|
player.totalLostScore=5;
|
||||||
|
player.lostScore=-5;
|
||||||
|
|
||||||
|
}
|
||||||
|
room.sidePot = 10;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 广播协议
|
// 广播协议
|
||||||
TObject param = new TObject();
|
TObject param = new TObject();
|
||||||
|
|
|
||||||
|
|
@ -29,40 +29,15 @@ public void enter(EXRoom owner) {
|
||||||
for (Entry<Integer, Player> entry : owner.playerMapBySeat.entrySet()) {
|
for (Entry<Integer, Player> entry : owner.playerMapBySeat.entrySet()) {
|
||||||
EXPlayer player = (EXPlayer) entry.getValue();
|
EXPlayer player = (EXPlayer) entry.getValue();
|
||||||
|
|
||||||
if (owner.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==0){
|
|
||||||
if (owner.nextRound==1 && owner.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==0){
|
|
||||||
player.totalLostScore=1;
|
|
||||||
player.lostScore=-1;
|
|
||||||
|
|
||||||
}
|
|
||||||
owner.sidePot = 2;
|
|
||||||
|
|
||||||
}else if (owner.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==1){
|
|
||||||
if (owner.nextRound==1 && owner.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==1){
|
|
||||||
player.totalLostScore=2;
|
|
||||||
player.lostScore=-2;
|
|
||||||
|
|
||||||
}
|
|
||||||
owner.sidePot = 4;
|
|
||||||
|
|
||||||
}else if (owner.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==2) {
|
|
||||||
if (owner.nextRound==1 && owner.config.getInt(Config.ROOM_CONFIG_BASE_SCORE)==2){
|
|
||||||
player.totalLostScore=5;
|
|
||||||
player.lostScore=-5;
|
|
||||||
|
|
||||||
}
|
|
||||||
owner.sidePot = 10;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
player.clearEx();
|
player.clearEx();
|
||||||
}
|
}
|
||||||
// 清除房间的额外状态
|
// 清除房间的额外状态
|
||||||
owner.clearEx();
|
owner.clearEx();
|
||||||
|
|
||||||
System.out.println("底池分数:"+owner.sidePot);
|
System.out.println("底池分数:"+owner.sidePot);
|
||||||
|
//根据用户id拿用户信息
|
||||||
|
// EXPlayer player = (EXPlayer) owner.playerMapById.get(owner.owner_id);
|
||||||
|
|
||||||
|
|
||||||
// 开始游戏
|
// 开始游戏
|
||||||
owner.startGame();
|
owner.startGame();
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue