📄 rank.java
字号:
package ergo.server;
// $Id: Rank.java,v 1.2 1999/08/13 01:18:10 sigue Exp $
/*
* Copyright (C) 1999 Carl L. Gay and Antranig M. Basman.
* See the file copyright.txt, distributed with this software,
* for further information.
*/
import ergo.*;
import ergo.util.*;
import ergo.logic.*;
import ergo.server.*;
public class Rank {
public static final int KYU = 0;
public static final int ADAN = 1;
public static final int PDAN = 2;
public static final int NR = -1;
public static final int QQ = -2;
private int numeric;
private int type;
private boolean star;
public int compareTo (Rank other) { // positive for ascending order...
if (numeric < other.numeric) return 1;
else if (numeric == other.numeric) return 0;
else return -1;
}
public Rank (String s) throws ParseException {
if (s.equals("??")) {
type = QQ;
numeric = 0;
}
else if (s.equals("NR")) {
type = NR;
numeric = 1;
}
else {
char finalc;
int number;
try {
finalc = s.charAt(s.length() - 1);
String left;
if (finalc == '*') {
star = true;
finalc = s.charAt(s.length() - 2);
left = s.substring(0, s.length() - 2);
}
else {
finalc = s.charAt(s.length() - 1);
left = s.substring(0, s.length() - 1);
}
// System.out.println("Left "+left);
number = Integer.parseInt(left);
}
catch (Exception e) {
Debug.backtrace(e);
throw new ParseException("Illegal rank format - last character not found " + s);
}
switch(finalc) {
case 'k':
type = KYU;
numeric = 32 - number;
break;
case 'd':
type = ADAN;
numeric = 31 + number;
break;
case 'p':
type = PDAN;
numeric = 40 + number;
break;
default:
throw new ParseException("Illegal rank format - illegal final character " + s);
} // end switch
} // end if numeric rank
} // end constructor
private String sstar () {
return star ? "*" : "";
}
public String render() {
switch(type) {
case QQ:
return "??";
case NR:
return "NR";
case KYU:
return Integer.toString(32 - numeric) + "k" + sstar();
case ADAN:
return Integer.toString(numeric - 31) + "d" + sstar();
case PDAN:
return Integer.toString(numeric - 40) + "p" + sstar();
default:
return null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -