WeaponProto.java
jmud-0.11/src/WeaponProto.java · 1.8 KB
From the archive jmud-0_11.tgz
Download the archive « Back to the archive contents
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import util.file.InvalidFileFormatException;
import string.InvalidFlagException;
import string.StrUtil;
import misc.Separators;
import util.log.Log;
class WeaponProto extends ItemProto {
int physical;
int mental;
int mystic;
int damageType;
WeaponProto(int zoneBase, int itemId, BufferedReader itemFile)
throws InvalidFileFormatException {
super(zoneBase, itemId, itemFile);
Log.log("Arma: " + getName());
StringTokenizer tok = null;
try {
String line = itemFile.readLine();
tok = new StringTokenizer(line);
}
catch(IOException e) {
throw new InvalidFileFormatException();
}
// physical
if (!tok.hasMoreTokens())
throw new InvalidFileFormatException();
physical = Integer.parseInt(tok.nextToken());
// mental
if (!tok.hasMoreTokens())
throw new InvalidFileFormatException();
mental = Integer.parseInt(tok.nextToken());
// mystic
if (!tok.hasMoreTokens())
throw new InvalidFileFormatException();
mystic = Integer.parseInt(tok.nextToken());
// damage type
if (!tok.hasMoreTokens())
throw new InvalidFileFormatException();
try {
damageType = StrUtil.parseFlags(tok.nextToken());
}
catch(InvalidFlagException e) {
throw new InvalidFileFormatException();
}
}
protected void finalize() {
super.finalize();
}
int getProtoType() {
return Item.T_WEAPON;
}
Item create() {
return new Weapon(this);
}
// Sheetable:
public String getSheet() {
return super.getSheet() + Separators.NL +
"Dano: Físico [" + physical + "] Mental [" + mental + "] Místico [" + mystic + "] Tipo: " + StrUtil.makeFlags(damageType);
}
}