Search in sources :

Example 1 with ItemOnItemMessage

use of org.apollo.game.message.impl.ItemOnItemMessage in project apollo by apollo-rsps.

the class ItemOnItemMessageDecoder method decode.

@Override
public ItemOnItemMessage decode(GamePacket packet) {
    GamePacketReader reader = new GamePacketReader(packet);
    int targetSlot = (int) reader.getUnsigned(DataType.SHORT);
    int usedSlot = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
    int targetId = (int) reader.getSigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
    int targetInterface = (int) reader.getUnsigned(DataType.SHORT);
    int usedId = (int) reader.getSigned(DataType.SHORT, DataOrder.LITTLE);
    int usedInterface = (int) reader.getUnsigned(DataType.SHORT);
    return new ItemOnItemMessage(usedInterface, usedId, usedSlot, targetInterface, targetId, targetSlot);
}
Also used : GamePacketReader(org.apollo.net.codec.game.GamePacketReader) ItemOnItemMessage(org.apollo.game.message.impl.ItemOnItemMessage)

Example 2 with ItemOnItemMessage

use of org.apollo.game.message.impl.ItemOnItemMessage in project apollo by apollo-rsps.

the class ItemOnItemVerificationHandlerTests method terminateWithNoTargetItem.

@Test
public void terminateWithNoTargetItem() throws Exception {
    Player player = mock(Player.class);
    Inventory inventory = new Inventory(28);
    inventory.set(1, new Item(4151, 1));
    when(player.getInventory()).thenReturn(inventory);
    ItemOnItemMessage itemOnItemMessage = new ItemOnItemMessage(BankConstants.SIDEBAR_INVENTORY_ID, 4151, 1, BankConstants.SIDEBAR_INVENTORY_ID, 4152, 2);
    itemOnItemVerificationHandler.handle(player, itemOnItemMessage);
    assertTrue("ItemOnItemVerificationHandler: failed terminating message with invalid target item", itemOnItemMessage.terminated());
}
Also used : Item(org.apollo.game.model.Item) Player(org.apollo.game.model.entity.Player) ItemOnItemMessage(org.apollo.game.message.impl.ItemOnItemMessage) Inventory(org.apollo.game.model.inv.Inventory) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with ItemOnItemMessage

use of org.apollo.game.message.impl.ItemOnItemMessage in project apollo by apollo-rsps.

the class ItemOnItemMessageDecoder method decode.

@Override
public ItemOnItemMessage decode(GamePacket packet) {
    GamePacketReader reader = new GamePacketReader(packet);
    int targetId = (int) reader.getUnsigned(DataType.SHORT);
    int usedSlot = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
    int usedId = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE);
    int targetInterface = (int) reader.getUnsigned(DataType.SHORT, DataOrder.LITTLE, DataTransformation.ADD);
    int targetSlot = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
    int usedInterface = (int) reader.getUnsigned(DataType.SHORT, DataTransformation.ADD);
    return new ItemOnItemMessage(usedInterface, usedId, usedSlot, targetInterface, targetId, targetSlot);
}
Also used : GamePacketReader(org.apollo.net.codec.game.GamePacketReader) ItemOnItemMessage(org.apollo.game.message.impl.ItemOnItemMessage)

Aggregations

ItemOnItemMessage (org.apollo.game.message.impl.ItemOnItemMessage)3 GamePacketReader (org.apollo.net.codec.game.GamePacketReader)2 Item (org.apollo.game.model.Item)1 Player (org.apollo.game.model.entity.Player)1 Inventory (org.apollo.game.model.inv.Inventory)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1