mirror of
https://github.com/tiennm99/caro.git
synced 2026-09-03 00:17:42 +00:00
安全和界面显示优化
This commit is contained in:
+4
@@ -39,4 +39,8 @@ public abstract class ClientEventListener {
|
||||
protected ChannelFuture pushToServer(Channel channel, ServerEventCode code, String datas){
|
||||
return ChannelUtils.pushToServer(channel, code, datas);
|
||||
}
|
||||
|
||||
protected ChannelFuture pushToServer(Channel channel, ServerEventCode code){
|
||||
return pushToServer(channel, code, null);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ public class ClientEventListener_CODE_CLIENT_CONNECT extends ClientEventListener
|
||||
|
||||
@Override
|
||||
public void call(Channel channel, String data) {
|
||||
SimplePrinter.printNotice("Connection to server successful !!");
|
||||
SimplePrinter.printNotice("Connection to server successful, welcome to ratel !!");
|
||||
SimpleClient.id = Integer.parseInt(data);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ public class ClientEventListener_CODE_GAME_LANDLORD_ELECT extends ClientEventLis
|
||||
@Override
|
||||
public void call(Channel channel, String data) {
|
||||
Map<String, Object> map = MapHelper.parser(data);
|
||||
int turnClientId = (int) map.get("turnClientId");
|
||||
int turnClientId = (int) map.get("nextClientId");
|
||||
|
||||
if(turnClientId == SimpleClient.id) {
|
||||
SimplePrinter.printNotice("It's your turn to rob the landlord[Y/N]");
|
||||
@@ -29,7 +29,7 @@ public class ClientEventListener_CODE_GAME_LANDLORD_ELECT extends ClientEventLis
|
||||
call(channel, data);
|
||||
}
|
||||
}else {
|
||||
SimplePrinter.printNotice("It's turn " + map.get("turnClientNickname") + " to confirm, please wait patiently !");
|
||||
SimplePrinter.printNotice("It's turn " + map.get("nextClientNickname") + " to confirm, please wait patiently !");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-4
@@ -10,7 +10,6 @@ import org.nico.ratel.landlords.entity.Poker;
|
||||
import org.nico.ratel.landlords.enums.PokerLevel;
|
||||
import org.nico.ratel.landlords.enums.ServerEventCode;
|
||||
import org.nico.ratel.landlords.helper.MapHelper;
|
||||
import org.nico.ratel.landlords.helper.PokerHelper;
|
||||
import org.nico.ratel.landlords.print.SimplePrinter;
|
||||
import org.nico.ratel.landlords.print.SimpleWriter;
|
||||
|
||||
@@ -27,7 +26,7 @@ public class ClientEventListener_CODE_GAME_POKER_PLAY extends ClientEventListene
|
||||
SimplePrinter.printPokers(pokers);
|
||||
|
||||
|
||||
SimplePrinter.printNotice("Please enter the card you came up");
|
||||
SimplePrinter.printNotice("Please enter the card you came up (enter [exit] to exit current room, enter [pass] jump current round)");
|
||||
String line = SimpleWriter.write("card");
|
||||
|
||||
if(line == null){
|
||||
@@ -35,9 +34,9 @@ public class ClientEventListener_CODE_GAME_POKER_PLAY extends ClientEventListene
|
||||
call(channel, data);
|
||||
}else{
|
||||
if(line.equalsIgnoreCase("PASS")) {
|
||||
pushToServer(channel, ServerEventCode.CODE_GAME_POKER_PLAY, Noson.reversal(new Character[] {'p'}));
|
||||
pushToServer(channel, ServerEventCode.CODE_GAME_POKER_PLAY_PASS);
|
||||
}else if(line.equalsIgnoreCase("EXIT")){
|
||||
pushToServer(channel, ServerEventCode.CODE_CLIENT_EXIT, null);
|
||||
pushToServer(channel, ServerEventCode.CODE_CLIENT_EXIT);
|
||||
}else {
|
||||
String[] strs = line.split(" ");
|
||||
List<Character> options = new ArrayList<>();
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package org.nico.ratel.landlords.client.event;
|
||||
|
||||
import org.nico.ratel.landlords.enums.ClientEventCode;
|
||||
import org.nico.ratel.landlords.print.SimplePrinter;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
|
||||
public class ClientEventListener_CODE_GAME_POKER_PLAY_CANT_PASS extends ClientEventListener{
|
||||
|
||||
@Override
|
||||
public void call(Channel channel, String data) {
|
||||
SimplePrinter.printNotice("The last time you play the card, you can't pass");
|
||||
get(ClientEventCode.CODE_GAME_POKER_PLAY).call(channel, data);
|
||||
}
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package org.nico.ratel.landlords.client.event;
|
||||
|
||||
import org.nico.ratel.landlords.print.SimplePrinter;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
|
||||
public class ClientEventListener_CODE_GAME_POKER_PLAY_ORDER_ERROR extends ClientEventListener{
|
||||
|
||||
@Override
|
||||
public void call(Channel channel, String data) {
|
||||
|
||||
SimplePrinter.printNotice("Not turn you to operate, please wait other player !!");
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -9,15 +9,15 @@ import org.nico.ratel.landlords.print.SimplePrinter;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
|
||||
public class ClientEventListener_CODE_GAME_POKER_PLAY_DONT_SELL extends ClientEventListener{
|
||||
public class ClientEventListener_CODE_GAME_POKER_PLAY_PASS extends ClientEventListener{
|
||||
|
||||
@Override
|
||||
public void call(Channel channel, String data) {
|
||||
Map<String, Object> map = MapHelper.parser(data);
|
||||
|
||||
SimplePrinter.printNotice(map.get("currentClientNickname") + " dont out, turn next player " + map.get("turnClientNickname") + " out pokers");
|
||||
SimplePrinter.printNotice(map.get("clientNickname") + " dont out, turn next player " + map.get("nextClientNickname") + " out pokers");
|
||||
|
||||
int turnClientId = (int) map.get("turnClientId");
|
||||
int turnClientId = (int) map.get("nextClientId");
|
||||
if(SimpleClient.id == turnClientId) {
|
||||
get(ClientEventCode.CODE_GAME_POKER_PLAY).call(channel, data);
|
||||
}
|
||||
-1
@@ -15,7 +15,6 @@ public class ClientEventListener_CODE_ROOM_CREATE_SUCCESS extends ClientEventLis
|
||||
|
||||
SimplePrinter.printNotice("You has been create room with id " + room.getId());
|
||||
SimplePrinter.printNotice("Please wait for other players to join !");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ public class ClientEventListener_CODE_SHOW_POKERS extends ClientEventListener{
|
||||
|
||||
Map<String, Object> map = MapHelper.parser(data);
|
||||
|
||||
SimplePrinter.printNotice(map.get("currentClientNickname") + " out of the card");
|
||||
SimplePrinter.printNotice(map.get("clientNickname") + " out of the card");
|
||||
|
||||
List<Poker> pokers = Noson.convert(map.get("pokers"), new NoType<List<Poker>>() {});
|
||||
SimplePrinter.printPokers(pokers);
|
||||
|
||||
+1
@@ -29,6 +29,7 @@ public class ClientEventListener_CODE_SHOW_ROOMS extends ClientEventListener{
|
||||
SimplePrinter.printNotice("No available room, please create a room !");
|
||||
get(ClientEventCode.CODE_SHOW_OPTIONS).call(channel, data);
|
||||
}
|
||||
SimplePrinter.printNotice("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ public class Room implements Serializable{
|
||||
private PokerSell lastPokerShell;
|
||||
|
||||
private int lastSellClient = -1;
|
||||
|
||||
private int currentSellClient = -1;
|
||||
|
||||
public Room() {
|
||||
}
|
||||
@@ -49,6 +51,14 @@ public class Room implements Serializable{
|
||||
this.lastPokerShell = lastPokerShell;
|
||||
}
|
||||
|
||||
public final int getCurrentSellClient() {
|
||||
return currentSellClient;
|
||||
}
|
||||
|
||||
public final void setCurrentSellClient(int currentSellClient) {
|
||||
this.currentSellClient = currentSellClient;
|
||||
}
|
||||
|
||||
public int getLastSellClient() {
|
||||
return lastSellClient;
|
||||
}
|
||||
|
||||
@@ -38,10 +38,14 @@ public enum ClientEventCode implements Serializable{
|
||||
|
||||
CODE_GAME_POKER_PLAY_LESS("出牌太小"),
|
||||
|
||||
CODE_GAME_POKER_PLAY_DONT_SELL("不出"),
|
||||
CODE_GAME_POKER_PLAY_PASS("不出"),
|
||||
|
||||
CODE_GAME_POKER_PLAY_CANT_PASS("不允许不出"),
|
||||
|
||||
CODE_GAME_POKER_PLAY_INVALID("无效"),
|
||||
|
||||
CODE_GAME_POKER_PLAY_ORDER_ERROR("顺序错误"),
|
||||
|
||||
CODE_GAME_OVER("游戏结束"),
|
||||
;
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ public enum ServerEventCode implements Serializable{
|
||||
|
||||
CODE_GAME_LANDLORD_ELECT("抢地主"),
|
||||
|
||||
CODE_GAME_LANDLORD_GET("抢地主信息"),
|
||||
|
||||
CODE_GAME_POKER_PLAY("出牌环节"),
|
||||
|
||||
CODE_GAME_POKER_PLAY_PASS("不出"),
|
||||
|
||||
;
|
||||
|
||||
private String msg;
|
||||
|
||||
+7
-3
@@ -21,7 +21,11 @@ public class ServerEventListener_CODE_GAME_LANDLORD_ELECT implements ServerEvent
|
||||
clientSide.getPokers().addAll(room.getLandlordPokers());
|
||||
PokerHelper.sortPoker(clientSide.getPokers());
|
||||
|
||||
room.setLandlordId(clientSide.getId());
|
||||
int currentClientId = clientSide.getId();
|
||||
room.setLandlordId(currentClientId);
|
||||
room.setLastSellClient(currentClientId);
|
||||
room.setCurrentSellClient(currentClientId);
|
||||
|
||||
for(ClientSide client: room.getClientSideList()){
|
||||
String result = MapHelper.newInstance()
|
||||
.put("roomId", room.getId())
|
||||
@@ -46,8 +50,8 @@ public class ServerEventListener_CODE_GAME_LANDLORD_ELECT implements ServerEvent
|
||||
.put("roomId", room.getId())
|
||||
.put("roomOwner", room.getRoomOwner())
|
||||
.put("roomClientCount", room.getClientSideList().size())
|
||||
.put("turnClientNickname", turnClientSide.getNickname())
|
||||
.put("turnClientId", turnClientSide.getId())
|
||||
.put("nextClientNickname", turnClientSide.getNickname())
|
||||
.put("nextClientId", turnClientSide.getId())
|
||||
.json();
|
||||
ChannelUtils.pushToClient(turnClientSide.getChannel(), ClientEventCode.CODE_GAME_LANDLORD_ELECT, result);
|
||||
}
|
||||
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
package org.nico.ratel.landlords.server.event;
|
||||
|
||||
import org.nico.noson.Noson;
|
||||
import org.nico.ratel.landlords.channel.ChannelUtils;
|
||||
import org.nico.ratel.landlords.entity.ClientSide;
|
||||
import org.nico.ratel.landlords.entity.Room;
|
||||
import org.nico.ratel.landlords.enums.ClientEventCode;
|
||||
import org.nico.ratel.landlords.enums.ServerEventCode;
|
||||
import org.nico.ratel.landlords.helper.MapHelper;
|
||||
import org.nico.ratel.landlords.helper.PokerHelper;
|
||||
import org.nico.ratel.landlords.helper.TimeHelper;
|
||||
import org.nico.ratel.landlords.server.ServerContains;
|
||||
|
||||
public class ServerEventListener_CODE_GAME_LANDLORD_GET implements ServerEventListener{
|
||||
|
||||
@Override
|
||||
public void call(ClientSide clientSide, String data) {
|
||||
|
||||
Room room = ServerContains.ROOM_MAP.get(clientSide.getRoomId());
|
||||
ClientSide startGrabClient = ServerContains.CLIENT_SIDE_MAP.get(room.getLandlordId());
|
||||
|
||||
String result = MapHelper.newInstance()
|
||||
.put("roomId", room.getId())
|
||||
.put("roomOwner", room.getRoomOwner())
|
||||
.put("roomClientCount", room.getClientSideList().size())
|
||||
.put("turnClientNickname", startGrabClient.getNickname())
|
||||
.put("turnClientId", startGrabClient.getId())
|
||||
.json();
|
||||
for(ClientSide client: room.getClientSideList()){
|
||||
ChannelUtils.pushToClient(client.getChannel(), ClientEventCode.CODE_GAME_LANDLORD_ELECT, result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+66
-70
@@ -20,84 +20,80 @@ public class ServerEventListener_CODE_GAME_POKER_PLAY implements ServerEventList
|
||||
@Override
|
||||
public void call(ClientSide clientSide, String data) {
|
||||
Room room = ServerContains.ROOM_MAP.get(clientSide.getRoomId());
|
||||
Character[] options = Noson.convert(data, Character[].class);
|
||||
int[] indexes = PokerHelper.getIndexes(options, clientSide.getPokers());
|
||||
if(PokerHelper.checkPokerIndex(indexes, clientSide.getPokers())){
|
||||
boolean sellFlag = false;
|
||||
List<Poker> currentPokers = PokerHelper.getPoker(indexes, clientSide.getPokers());
|
||||
PokerSell currentPokerShell = PokerHelper.checkPokerType(currentPokers);
|
||||
if(room.getLastSellClient() != -1 && room.getLastSellClient() != clientSide.getId() && room.getLastPokerShell() != null){
|
||||
PokerSell lastPokerShell = room.getLastPokerShell();
|
||||
if(lastPokerShell.getSellType() != currentPokerShell.getSellType() && currentPokerShell.getSellType() != SellType.BOMB && currentPokerShell.getSellType() != SellType.KING_BOMB) {
|
||||
|
||||
if(room.getCurrentSellClient() == clientSide.getId()) {
|
||||
Character[] options = Noson.convert(data, Character[].class);
|
||||
int[] indexes = PokerHelper.getIndexes(options, clientSide.getPokers());
|
||||
if(PokerHelper.checkPokerIndex(indexes, clientSide.getPokers())){
|
||||
boolean sellFlag = true;
|
||||
|
||||
List<Poker> currentPokers = PokerHelper.getPoker(indexes, clientSide.getPokers());
|
||||
PokerSell currentPokerShell = PokerHelper.checkPokerType(currentPokers);
|
||||
if(room.getLastSellClient() != clientSide.getId() && room.getLastPokerShell() != null){
|
||||
PokerSell lastPokerShell = room.getLastPokerShell();
|
||||
|
||||
if(lastPokerShell.getSellType() != currentPokerShell.getSellType() && currentPokerShell.getSellType() != SellType.BOMB && currentPokerShell.getSellType() != SellType.KING_BOMB) {
|
||||
String result = MapHelper.newInstance()
|
||||
.put("playType", currentPokerShell.getSellType())
|
||||
.put("preType", lastPokerShell.getSellType())
|
||||
.put("pokers", clientSide.getPokers())
|
||||
.json();
|
||||
sellFlag = false;
|
||||
ChannelUtils.pushToClient(clientSide.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY_MISMATCH, result);
|
||||
}else if(lastPokerShell.getScore() >= currentPokerShell.getScore()) {
|
||||
String result = MapHelper.newInstance()
|
||||
.put("playScore", currentPokerShell.getScore())
|
||||
.put("preScore", lastPokerShell.getScore())
|
||||
.put("pokers", clientSide.getPokers())
|
||||
.json();
|
||||
sellFlag = false;
|
||||
ChannelUtils.pushToClient(clientSide.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY_LESS, result);
|
||||
}
|
||||
}
|
||||
if(sellFlag) {
|
||||
ClientSide next = clientSide.getNext();
|
||||
|
||||
room.setLastSellClient(clientSide.getId());
|
||||
room.setLastPokerShell(currentPokerShell);
|
||||
room.setCurrentSellClient(next.getId());
|
||||
|
||||
clientSide.getPokers().removeAll(currentPokers);
|
||||
String result = MapHelper.newInstance()
|
||||
.put("playType", currentPokerShell.getSellType())
|
||||
.put("preType", lastPokerShell.getSellType())
|
||||
.put("pokers", clientSide.getPokers())
|
||||
.json();
|
||||
ChannelUtils.pushToClient(clientSide.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY_MISMATCH, result);
|
||||
}else if(lastPokerShell.getScore() >= currentPokerShell.getScore()) {
|
||||
String result = MapHelper.newInstance()
|
||||
.put("playScore", currentPokerShell.getScore())
|
||||
.put("preScore", lastPokerShell.getScore())
|
||||
.put("pokers", clientSide.getPokers())
|
||||
.put("clientId", clientSide.getId())
|
||||
.put("clientNickname", clientSide.getNickname())
|
||||
.put("pokers", currentPokers)
|
||||
.json();
|
||||
ChannelUtils.pushToClient(clientSide.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY_LESS, result);
|
||||
}else {
|
||||
sellFlag = true;
|
||||
for(ClientSide client: room.getClientSideList()) {
|
||||
ChannelUtils.pushToClient(client.getChannel(), ClientEventCode.CODE_SHOW_POKERS, result);
|
||||
}
|
||||
|
||||
TimeHelper.sleep(500);
|
||||
|
||||
if(clientSide.getPokers().isEmpty()) {
|
||||
result = MapHelper.newInstance()
|
||||
.put("winnerNickname", clientSide.getNickname())
|
||||
.json();
|
||||
|
||||
for(ClientSide client: room.getClientSideList()) {
|
||||
ChannelUtils.pushToClient(client.getChannel(), ClientEventCode.CODE_GAME_OVER, result);
|
||||
}
|
||||
}else {
|
||||
result = MapHelper.newInstance()
|
||||
.put("pokers", next.getPokers())
|
||||
.json();
|
||||
|
||||
ChannelUtils.pushToClient(next.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY, result);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
sellFlag = true;
|
||||
}
|
||||
if(sellFlag) {
|
||||
room.setLastSellClient(clientSide.getId());
|
||||
room.setLastPokerShell(currentPokerShell);
|
||||
clientSide.getPokers().removeAll(currentPokers);
|
||||
String result = MapHelper.newInstance()
|
||||
.put("currentClientId", clientSide.getId())
|
||||
.put("currentClientNickname", clientSide.getNickname())
|
||||
.put("pokers", currentPokers)
|
||||
.json();
|
||||
for(ClientSide client: room.getClientSideList()) {
|
||||
ChannelUtils.pushToClient(client.getChannel(), ClientEventCode.CODE_SHOW_POKERS, result);
|
||||
}
|
||||
|
||||
TimeHelper.sleep(500);
|
||||
|
||||
if(clientSide.getPokers().isEmpty()) {
|
||||
result = MapHelper.newInstance()
|
||||
.put("winnerNickname", clientSide.getNickname())
|
||||
.json();
|
||||
for(ClientSide client: room.getClientSideList()) {
|
||||
ChannelUtils.pushToClient(client.getChannel(), ClientEventCode.CODE_GAME_OVER, result);
|
||||
}
|
||||
}else {
|
||||
ClientSide next = clientSide.getNext();
|
||||
result = MapHelper.newInstance()
|
||||
.put("pokers", next.getPokers())
|
||||
.json();
|
||||
|
||||
ChannelUtils.pushToClient(next.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY, result);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(options.length > 0 && options[0] == 'p') {
|
||||
ClientSide turnClient = clientSide.getNext();
|
||||
for(ClientSide client: room.getClientSideList()) {
|
||||
String result = MapHelper.newInstance()
|
||||
.put("currentClientId", clientSide.getId())
|
||||
.put("currentClientNickname", clientSide.getNickname())
|
||||
.put("turnClientId", turnClient.getId())
|
||||
.put("turnClientNickname", turnClient.getNickname())
|
||||
.put("pokers", client.getPokers())
|
||||
.json();
|
||||
ChannelUtils.pushToClient(client.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY_DONT_SELL, result);
|
||||
}
|
||||
}else {
|
||||
String result = MapHelper.newInstance()
|
||||
.put("pokers", clientSide.getPokers())
|
||||
.json();
|
||||
ChannelUtils.pushToClient(clientSide.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY, result);
|
||||
|
||||
ChannelUtils.pushToClient(clientSide.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY_INVALID, result);
|
||||
}
|
||||
}else {
|
||||
ChannelUtils.pushToClient(clientSide.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY_ORDER_ERROR, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package org.nico.ratel.landlords.server.event;
|
||||
|
||||
import org.nico.ratel.landlords.channel.ChannelUtils;
|
||||
import org.nico.ratel.landlords.entity.ClientSide;
|
||||
import org.nico.ratel.landlords.entity.Room;
|
||||
import org.nico.ratel.landlords.enums.ClientEventCode;
|
||||
import org.nico.ratel.landlords.helper.MapHelper;
|
||||
import org.nico.ratel.landlords.server.ServerContains;
|
||||
|
||||
public class ServerEventListener_CODE_GAME_POKER_PLAY_PASS implements ServerEventListener{
|
||||
|
||||
@Override
|
||||
public void call(ClientSide clientSide, String data) {
|
||||
Room room = ServerContains.ROOM_MAP.get(clientSide.getRoomId());
|
||||
|
||||
if(room.getCurrentSellClient() == clientSide.getId()) {
|
||||
if(clientSide.getId() != room.getLastSellClient()) {
|
||||
ClientSide turnClient = clientSide.getNext();
|
||||
|
||||
room.setCurrentSellClient(turnClient.getId());
|
||||
|
||||
for(ClientSide client: room.getClientSideList()) {
|
||||
String result = MapHelper.newInstance()
|
||||
.put("clientId", clientSide.getId())
|
||||
.put("clientNickname", clientSide.getNickname())
|
||||
.put("nextClientId", turnClient.getId())
|
||||
.put("nextClientNickname", turnClient.getNickname())
|
||||
.put("pokers", client.getPokers())
|
||||
.json();
|
||||
ChannelUtils.pushToClient(client.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY_PASS, result);
|
||||
}
|
||||
}else {
|
||||
String result = MapHelper.newInstance()
|
||||
.put("pokers", clientSide.getPokers())
|
||||
.json();
|
||||
ChannelUtils.pushToClient(clientSide.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY_CANT_PASS, result);
|
||||
}
|
||||
}else {
|
||||
ChannelUtils.pushToClient(clientSide.getChannel(), ClientEventCode.CODE_GAME_POKER_PLAY_ORDER_ERROR, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -48,8 +48,8 @@ public class ServerEventListener_CODE_GAME_STARTING implements ServerEventListen
|
||||
.put("roomId", room.getId())
|
||||
.put("roomOwner", room.getRoomOwner())
|
||||
.put("roomClientCount", room.getClientSideList().size())
|
||||
.put("turnClientNickname", startGrabClient.getNickname())
|
||||
.put("turnClientId", startGrabClient.getId())
|
||||
.put("nextClientNickname", startGrabClient.getNickname())
|
||||
.put("nextClientId", startGrabClient.getId())
|
||||
.put("pokers", client.getPokers())
|
||||
//.put("additionalPokers", room.getLandlordPokers())
|
||||
.json();
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package org.nico.ratel.landlords.server.event;
|
||||
|
||||
import org.nico.noson.Noson;
|
||||
import org.nico.ratel.landlords.channel.ChannelUtils;
|
||||
import org.nico.ratel.landlords.entity.ClientSide;
|
||||
import org.nico.ratel.landlords.enums.ClientEventCode;
|
||||
|
||||
public class ServerEventListener_CODE_GET_POKERS implements ServerEventListener{
|
||||
|
||||
@Override
|
||||
public void call(ClientSide clientSide, String data) {
|
||||
|
||||
ChannelUtils.pushToClient(clientSide.getChannel(), ClientEventCode.CODE_SHOW_POKERS, Noson.reversal(clientSide.getPokers()));
|
||||
}
|
||||
|
||||
}
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
package org.nico.ratel.landlords.server.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.nico.noson.Noson;
|
||||
import org.nico.ratel.landlords.channel.ChannelUtils;
|
||||
import org.nico.ratel.landlords.entity.ClientSide;
|
||||
import org.nico.ratel.landlords.entity.Room;
|
||||
import org.nico.ratel.landlords.enums.ClientEventCode;
|
||||
import org.nico.ratel.landlords.helper.MapHelper;
|
||||
import org.nico.ratel.landlords.server.ServerContains;
|
||||
|
||||
public class ServerEventListener_CODE_POKERS_GET implements ServerEventListener{
|
||||
|
||||
@Override
|
||||
public void call(ClientSide clientSide, String data) {
|
||||
List<Map<String, Object>> roomList = new ArrayList<>(ServerContains.ROOM_MAP.size());
|
||||
for(Entry<Integer, Room> entry: ServerContains.ROOM_MAP.entrySet()) {
|
||||
Room room = entry.getValue();
|
||||
roomList.add(MapHelper.newInstance()
|
||||
.put("roomId", room.getId())
|
||||
.put("roomOwner", room.getRoomOwner())
|
||||
.put("roomClientCount", room.getClientSideList().size())
|
||||
.map());
|
||||
}
|
||||
ChannelUtils.pushToClient(clientSide.getChannel(), ClientEventCode.CODE_SHOW_ROOMS, Noson.reversal(roomList));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user