Search in sources :

Example 16 with InvalidPacketException

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);
}
Also used : PacketMobVitals(com.solinia.solinia.Models.PacketMobVitals) InvalidPacketException(com.solinia.solinia.Exceptions.InvalidPacketException) Test(org.junit.Test)

Example 17 with InvalidPacketException

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);
}
Also used : PacketOpenSpellbook(com.solinia.solinia.Models.PacketOpenSpellbook) InvalidPacketException(com.solinia.solinia.Exceptions.InvalidPacketException) Test(org.junit.Test)

Example 18 with InvalidPacketException

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];
}
Also used : InvalidPacketException(com.solinia.solinia.Exceptions.InvalidPacketException)

Example 19 with InvalidPacketException

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;
}
Also used : InvalidPacketException(com.solinia.solinia.Exceptions.InvalidPacketException)

Example 20 with InvalidPacketException

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));
    }
}
Also used : InvalidPacketException(com.solinia.solinia.Exceptions.InvalidPacketException)

Aggregations

InvalidPacketException (com.solinia.solinia.Exceptions.InvalidPacketException)31 Test (org.junit.Test)21 PacketMobVitals (com.solinia.solinia.Models.PacketMobVitals)4 PacketOpenSpellbook (com.solinia.solinia.Models.PacketOpenSpellbook)4 PacketCastingPercent (com.solinia.solinia.Models.PacketCastingPercent)3 PacketEffects (com.solinia.solinia.Models.PacketEffects)2 PacketEquipSlots (com.solinia.solinia.Models.PacketEquipSlots)2 PacketMemorisedSpells (com.solinia.solinia.Models.PacketMemorisedSpells)2 PacketOpenCharacterCreation (com.solinia.solinia.Models.PacketOpenCharacterCreation)2 PacketTrackingChoices (com.solinia.solinia.Models.PacketTrackingChoices)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 EffectSlot (com.solinia.solinia.Models.EffectSlot)1 EquipSlots (com.solinia.solinia.Models.EquipSlots)1 MemorisedSpells (com.solinia.solinia.Models.MemorisedSpells)1 RaceChoice (com.solinia.solinia.Models.RaceChoice)1 SpellbookPage (com.solinia.solinia.Models.SpellbookPage)1