System.exit(-1);
}
}
private int parsePlayerArguments(int index, String argv[]){
PlayerInfo player=null;
if(argv[index].equals("-remote")){
++index;
if(argv.length>=index+5){
int roleindex=getIntArg(argv[index], "roleindex"); ++index;
if(roleindex<1){
System.err.println("roleindex out of bounds");
printUsage();
System.exit(-1);
}
String name=argv[index]; ++index;
String host=argv[index]; ++index;
int port=getIntArg(argv[index], "port"); ++index;
int gdl=getIntArg(argv[index], "gdl"); ++index;
if (gdl == 1) {
if (getGdlVersion() != GDLVersion.v1) {
System.err.println("GDL-I players not allowed in GDL-II game");
printUsage();
System.exit(-1);
}
player=new RemotePlayerInfo(roleindex-1, name, host, port, GDLVersion.v1);
} else {
player=new RemotePlayerInfo(roleindex-1, name, host, port, GDLVersion.v2);
}
}else{
missingArgumentsExit(argv[index-1]);
}
}else if(argv[index].equals("-legal")){
++index;
if(argv.length>=index+1){
int roleindex=getIntArg(argv[index], "roleindex"); ++index;
if(roleindex<1){
System.err.println("roleindex out of bounds");
printUsage();
System.exit(-1);
}
player=new LegalPlayerInfo(roleindex-1, getGdlVersion()); // use GDL version of the game for the legal player too
}else{
missingArgumentsExit(argv[index-1]);
}
}else if(argv[index].equals("-random")){
++index;
if(argv.length>=index+1){
int roleindex=getIntArg(argv[index], "roleindex"); ++index;
if(roleindex<1){
System.err.println("roleindex out of bounds");
printUsage();
System.exit(-1);
}
player=new RandomPlayerInfo(roleindex-1, getGdlVersion()); // use GDL version of the game for the random player too
}else{
missingArgumentsExit(argv[index-1]);
}
}else{
System.err.println("invalid argument: "+argv[index]);
printUsage();
System.exit(-1);
}
for(PlayerInfo p:playerInfos){
if(p.getRoleindex()==player.getRoleindex()){
System.err.println("duplicate roleindex: "+player.getRoleindex());
printUsage();
System.exit(-1);
}
}
playerInfos.add(player);