Merge branch 'dev-1.1.0' of https://github.com/ainilili/ratel into dev-1.1.0

# Conflicts:
#	landlords-common/src/main/java/org/nico/ratel/landlords/helper/PokerHelper.java
This commit is contained in:
nico
2018-11-15 14:25:19 +08:00
11 changed files with 19 additions and 29 deletions
@@ -50,9 +50,11 @@ public class SimpleClient {
for(int i = 0; i < serverAddressList.size(); i++) {
SimplePrinter.printNotice((i+1) + ". " + serverAddressList.get(i));
}
int serverPick = Integer.parseInt(SimpleWriter.write("option"));
int serverPick = 0;
while(serverPick<1 || serverPick>serverAddressList.size()){
SimplePrinter.printNotice("Invalid Option");
try {
serverPick = Integer.parseInt(SimpleWriter.write("option"));
}catch(NumberFormatException e){}
}
serverAddress = serverAddressList.get(serverPick-1);
String[] elements = serverAddress.split(":");
@@ -5,7 +5,6 @@ import java.util.Map;
import org.nico.noson.Noson;
import org.nico.noson.entity.NoType;
import org.nico.ratel.landlords.client.SimpleClient;
import org.nico.ratel.landlords.entity.Poker;
import org.nico.ratel.landlords.enums.ServerEventCode;
import org.nico.ratel.landlords.helper.MapHelper;
@@ -13,20 +13,11 @@ public class ClientEventListener_CODE_SHOW_OPTIONS_SETTING extends ClientEventLi
@Override
public void call(Channel channel, String data) {
SimplePrinter.printNotice("Setting: ");
/*
case 0:
return buildHandStringSharp(pokers);
case 1:
return buildHandStringRounded(pokers);
case 2:
return textOnly(pokers);
case 3:
return textOnlyNoType(pokers);
*/
SimplePrinter.printNotice("1. Card with shape edges (Default)");
SimplePrinter.printNotice("2. Card with rounded edges");
SimplePrinter.printNotice("3. Text Only with types");
SimplePrinter.printNotice("4. Text Only without types");
SimplePrinter.printNotice("5. Unicode Cards");
SimplePrinter.printNotice("Please enter the number of setting (enter [BACK] return options list)");
String line = SimpleWriter.write("setting");
@@ -40,7 +31,7 @@ public class ClientEventListener_CODE_SHOW_OPTIONS_SETTING extends ClientEventLi
}
int choose = Integer.valueOf(line);
if(choose > 0 && choose <= 4){
if(choose >=1 && choose <= PokerHelper.totalPrinters){
PokerHelper.pokerPrinterType = choose - 1;
get(ClientEventCode.CODE_SHOW_OPTIONS).call(channel, data);
} else {
@@ -2,12 +2,9 @@ package org.nico.ratel.landlords.client.event;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListMap;
import org.nico.noson.Noson;
import org.nico.noson.entity.NoType;
import org.nico.ratel.landlords.entity.Room;
import org.nico.ratel.landlords.enums.ClientEventCode;
import org.nico.ratel.landlords.print.SimplePrinter;
@@ -1,7 +1,5 @@
package org.nico.ratel.landlords.enums;
import java.io.Serializable;
public enum SellType {
ILLEGAL("非合法"),
@@ -1,5 +1,6 @@
package org.nico.ratel.landlords.server.event;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
@@ -22,7 +23,11 @@ public interface ServerEventListener {
}else{
String eventListener = LISTENER_PREFIX + code.name();
Class<ServerEventListener> listenerClass = (Class<ServerEventListener>) Class.forName(eventListener);
listener = listenerClass.newInstance();
try {
listener = listenerClass.getDeclaredConstructor().newInstance();
} catch (InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
ServerEventListener.LISTENER_MAP.put(code, listener);
}
return listener;
@@ -1,8 +1,5 @@
package org.nico.ratel.landlords.server.event;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.nico.ratel.landlords.channel.ChannelUtils;
import org.nico.ratel.landlords.entity.ClientSide;
@@ -10,7 +7,6 @@ import org.nico.ratel.landlords.entity.Room;
import org.nico.ratel.landlords.enums.ClientEventCode;
import org.nico.ratel.landlords.enums.ClientRole;
import org.nico.ratel.landlords.enums.ClientType;
import org.nico.ratel.landlords.enums.RoomType;
import org.nico.ratel.landlords.enums.ServerEventCode;
import org.nico.ratel.landlords.helper.MapHelper;
import org.nico.ratel.landlords.helper.PokerHelper;
@@ -9,7 +9,6 @@ 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.helper.PokerHelper;
import org.nico.ratel.landlords.server.ServerContains;
public class ServerEventListener_CODE_GAME_POKER_PLAY_REDIRECT implements ServerEventListener{
@@ -11,7 +11,6 @@ import org.nico.ratel.landlords.enums.ClientEventCode;
import org.nico.ratel.landlords.enums.ClientRole;
import org.nico.ratel.landlords.enums.ClientType;
import org.nico.ratel.landlords.enums.RoomStatus;
import org.nico.ratel.landlords.enums.RoomType;
import org.nico.ratel.landlords.helper.MapHelper;
import org.nico.ratel.landlords.helper.PokerHelper;
import org.nico.ratel.landlords.server.ServerContains;
@@ -3,7 +3,6 @@ package org.nico.ratel.landlords.server.event;
import java.util.LinkedList;
import java.util.concurrent.ConcurrentSkipListMap;
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;
@@ -1,5 +1,6 @@
package org.nico.ratel.landlords.server.robot;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
@@ -13,7 +14,7 @@ public interface RobotEventListener {
public final static Map<ClientEventCode, RobotEventListener> LISTENER_MAP = new HashMap<>();
public void call(ClientSide robot, String data);
public static RobotEventListener get(ClientEventCode code) {
RobotEventListener listener = null;
try {
@@ -22,7 +23,11 @@ public interface RobotEventListener {
}else{
String eventListener = LISTENER_PREFIX + code.name();
Class<RobotEventListener> listenerClass = (Class<RobotEventListener>) Class.forName(eventListener);
listener = listenerClass.newInstance();
try {
listener = listenerClass.getDeclaredConstructor().newInstance();
} catch (NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
}
RobotEventListener.LISTENER_MAP.put(code, listener);
}
return listener;