use of com.solinia.solinia.Exceptions.InvalidPacketException in project solinia3-core by mixxit.
the class PacketMobVitalsTest method IfMissingSeperatorsThrowInvalidPacket.
@Test
public void IfMissingSeperatorsThrowInvalidPacket() {
String expectedException = "Packet data is wrong format";
String actualException = "";
try {
new PacketMobVitals().fromPacketData("moo");
} catch (InvalidPacketException e) {
actualException = e.getMessage();
}
assertEquals(expectedException, actualException);
}
use of com.solinia.solinia.Exceptions.InvalidPacketException in project solinia3-core by mixxit.
the class PacketOpenSpellbookTest method WhenGivenPacketDataReturnExpectedFormat.
@Test
public void WhenGivenPacketDataReturnExpectedFormat() {
String testForPacketData = "1^1|1|1|1|1|Name";
String foundPacketData = "";
try {
PacketOpenSpellbook vitals = new PacketOpenSpellbook();
vitals.fromPacketData(testForPacketData);
foundPacketData = vitals.toPacketData();
} catch (InvalidPacketException e) {
e.printStackTrace();
}
assertEquals(testForPacketData, foundPacketData);
}
use of com.solinia.solinia.Exceptions.InvalidPacketException in project solinia3-core by mixxit.
the class PacketInZone method fromPacketData.
public void fromPacketData(String data) throws InvalidPacketException {
if (data == null)
throw new InvalidPacketException("Packet data is empty");
if (!data.contains("^"))
throw new InvalidPacketException("Packet data is wrong format");
String[] dataArray = data.split("\\^", -1);
if (dataArray.length < 2)
throw new InvalidPacketException("Packet data missing elements");
this.zoneId = Integer.parseInt(dataArray[0]);
this.zoneMusic = dataArray[1];
}
use of com.solinia.solinia.Exceptions.InvalidPacketException in project solinia3-core by mixxit.
the class PacketCastingPercent method fromPacketData.
public void fromPacketData(String data) throws InvalidPacketException {
if (data == null)
throw new InvalidPacketException("Packet data is empty");
if (!data.contains("^"))
throw new InvalidPacketException("Packet data is wrong format");
String[] dataArray = data.split("\\^", -1);
float castingPercent = Float.parseFloat(dataArray[0]);
this.castingPercent = castingPercent;
}
use of com.solinia.solinia.Exceptions.InvalidPacketException in project solinia3-core by mixxit.
the class PacketOpenCharacterCreation method fromPacketData.
public void fromPacketData(String data) throws InvalidPacketException {
if (data == null)
throw new InvalidPacketException("Packet data is empty");
// now pages
this.characterCreation = new CharacterCreation();
if (data.equals(""))
return;
String[] dataArray = data.split("\\^", -1);
for (int i = 0; i < dataArray.length; i++) {
String[] effectArray = dataArray[i].split("\\|", -1);
int RaceId = Integer.parseInt(effectArray[0]);
int ClassId = Integer.parseInt(effectArray[1]);
String RaceName = effectArray[2];
String ClassName = effectArray[3];
String RaceShort = effectArray[4];
String ClassShort = effectArray[5];
String RaceDescription = effectArray[6];
String ClassDescription = effectArray[7];
int STR = Integer.parseInt(effectArray[8]);
int STA = Integer.parseInt(effectArray[9]);
int AGI = Integer.parseInt(effectArray[10]);
int DEX = Integer.parseInt(effectArray[11]);
int INT = Integer.parseInt(effectArray[12]);
int WIS = Integer.parseInt(effectArray[13]);
int CHA = Integer.parseInt(effectArray[14]);
String Alignment = effectArray[15];
this.characterCreation.raceChoices.put(RaceName + "_" + ClassName, new RaceChoice(RaceId, ClassId, RaceName, ClassName, RaceShort, ClassShort, RaceDescription, ClassDescription, STR, STA, AGI, DEX, INT, WIS, CHA, Alignment));
}
}
Aggregations