mirror of
https://github.com/tiennm99/caro.git
synced 2026-05-24 04:24:23 +00:00
add poker type
This commit is contained in:
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
import org.nico.noson.Noson;
|
||||
import org.nico.noson.entity.NoType;
|
||||
import org.nico.ratel.landlords.client.handler.DefaultChannelInitializer;
|
||||
import org.nico.ratel.landlords.helper.PokerHelper;
|
||||
import org.nico.ratel.landlords.print.SimplePrinter;
|
||||
import org.nico.ratel.landlords.print.SimpleWriter;
|
||||
|
||||
@@ -37,6 +38,14 @@ public class SimpleClient {
|
||||
if(args[index].equalsIgnoreCase("-h") || args[index].equalsIgnoreCase("-host")) {
|
||||
serverAddress = args[index + 1];
|
||||
}
|
||||
if(args[index].equalsIgnoreCase("-pt") || args[index].equalsIgnoreCase("-pt")) {
|
||||
int selection = Integer.parseInt(args[index + 1]);
|
||||
|
||||
if( selection > 0 && selection < 4 ){
|
||||
PokerHelper.pokerPrinterType = selection;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.nico.ratel.landlords.enums.SellType;
|
||||
|
||||
public class PokerHelper {
|
||||
|
||||
public static int pokerPrinterType = 0;
|
||||
private static List<Poker> basePokers = new ArrayList<Poker>(54);
|
||||
|
||||
private static Comparator<Poker> pokerComparator = new Comparator<Poker>() {
|
||||
@@ -256,6 +257,59 @@ public class PokerHelper {
|
||||
|
||||
public static String printPoker(List<Poker> pokers) {
|
||||
sortPoker(pokers);
|
||||
switch(pokerPrinterType){
|
||||
case 0:
|
||||
return buildHandStringSharp(pokers);
|
||||
case 1:
|
||||
return buildHandStringRounded(pokers);
|
||||
case 2:
|
||||
return textOnly(pokers);
|
||||
case 3:
|
||||
return textOnlyNoType(pokers);
|
||||
default:
|
||||
return buildHandStringSharp(pokers);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private static String buildHandStringSharp(List<Poker> pokers){
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if(pokers != null && pokers.size() > 0) {
|
||||
|
||||
for(int index = 0; index < pokers.size(); index ++) {
|
||||
if(index == 0) {
|
||||
builder.append("┌──┐");
|
||||
}else {
|
||||
builder.append("──┐");
|
||||
}
|
||||
}
|
||||
builder.append(System.lineSeparator());
|
||||
for(int index = 0; index < pokers.size(); index ++) {
|
||||
if(index == 0) {
|
||||
builder.append("│");
|
||||
}
|
||||
String name = pokers.get(index).getLevel().getName();
|
||||
builder.append(name + (name.length() == 1 ? " " : "" ) + "|");
|
||||
}
|
||||
builder.append(System.lineSeparator());
|
||||
for(int index = 0; index < pokers.size(); index ++) {
|
||||
if(index == 0) {
|
||||
builder.append("│");
|
||||
}
|
||||
builder.append(pokers.get(index).getType().getName() + " |");
|
||||
}
|
||||
builder.append(System.lineSeparator());
|
||||
for(int index = 0; index < pokers.size(); index ++) {
|
||||
if(index == 0) {
|
||||
builder.append("└──┘");
|
||||
} else {
|
||||
builder.append("──┘");
|
||||
}
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
private static String buildHandStringRounded(List<Poker> pokers){
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if(pokers != null && pokers.size() > 0) {
|
||||
|
||||
@@ -292,5 +346,27 @@ public class PokerHelper {
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
private static String textOnly(List<Poker> pokers){
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if(pokers != null && pokers.size() > 0) {
|
||||
for(int index = 0; index < pokers.size(); index ++) {
|
||||
String name = pokers.get(index).getLevel().getName();
|
||||
String type = pokers.get(index).getType().getName();
|
||||
|
||||
builder.append(name + type);
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
private static String textOnlyNoType(List<Poker> pokers){
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if(pokers != null && pokers.size() > 0) {
|
||||
for(int index = 0; index < pokers.size(); index ++) {
|
||||
String name = pokers.get(index).getLevel().getName();
|
||||
builder.append(name);
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.nico.ratel.landlords.helper.PokerHelper;
|
||||
public class SimplePrinter {
|
||||
|
||||
private final static SimpleDateFormat FORMAT = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
|
||||
public static int pokerDisplayFormat = 0;
|
||||
|
||||
public static void printPokers(List<Poker> pokers) {
|
||||
System.out.println(PokerHelper.printPoker(pokers));
|
||||
|
||||
Reference in New Issue
Block a user