use of org.apollo.game.model.entity.Entity in project apollo by apollo-rsps.
the class ItemOnObjectVerificationHandlerTests method terminateIfInvalidSlot.
@Test
public void terminateIfInvalidSlot() throws Exception {
Position playerPosition = new Position(3200, 3200);
Position objectPosition = new Position(3200, 3200);
World world = mock(World.class);
Region region = mock(Region.class);
RegionRepository regionRepository = mock(RegionRepository.class);
Player player = mock(Player.class);
Set<Entity> entitySet = new HashSet<>();
entitySet.add(new StaticGameObject(world, 4151, objectPosition, 0, 0));
Inventory inventory = new Inventory(28);
when(player.getInventory()).thenReturn(inventory);
when(world.getRegionRepository()).thenReturn(regionRepository);
when(regionRepository.fromPosition(objectPosition)).thenReturn(region);
when(player.getPosition()).thenReturn(playerPosition);
when(region.getEntities(objectPosition, EntityType.STATIC_OBJECT, EntityType.DYNAMIC_OBJECT)).thenReturn(entitySet);
ItemOnObjectMessage itemOnObjectMessage = new ItemOnObjectMessage(SynchronizationInventoryListener.INVENTORY_ID, 4151, 30, 1, objectPosition.getX(), objectPosition.getY());
ItemOnObjectVerificationHandler itemOnObjectVerificationHandler = new ItemOnObjectVerificationHandler(world);
itemOnObjectVerificationHandler.handle(player, itemOnObjectMessage);
assertTrue("ObjectVerificationHandler: message not terminated when no valid slot given!", itemOnObjectMessage.terminated());
}
use of org.apollo.game.model.entity.Entity in project apollo by apollo-rsps.
the class Region method contains.
/**
* Checks if this Region contains the specified Entity.
*
* This method operates in constant time.
*
* @param entity The Entity.
* @return {@code true} if this Region contains the Entity, otherwise {@code false}.
*/
public boolean contains(Entity entity) {
Position position = entity.getPosition();
Set<Entity> local = entities.get(position);
return local != null && local.contains(entity);
}
use of org.apollo.game.model.entity.Entity in project apollo by apollo-rsps.
the class ObjectActionVerificationHandlerTests method terminateIfOutOfRange.
@Test
public void terminateIfOutOfRange() throws Exception {
Position playerPosition = new Position(3200, 3200);
Position objectPosition = new Position(3200, 3216);
World world = mock(World.class);
Region region = mock(Region.class);
RegionRepository regionRepository = mock(RegionRepository.class);
Player player = mock(Player.class);
Set<Entity> entitySet = new HashSet<>();
entitySet.add(new StaticGameObject(world, 4151, objectPosition, 0, 0));
when(world.getRegionRepository()).thenReturn(regionRepository);
when(regionRepository.fromPosition(objectPosition)).thenReturn(region);
when(player.getPosition()).thenReturn(playerPosition);
when(region.getEntities(objectPosition, EntityType.STATIC_OBJECT, EntityType.DYNAMIC_OBJECT)).thenReturn(entitySet);
ObjectActionMessage objectActionMessage = new ObjectActionMessage(1, 4151, objectPosition);
ObjectActionVerificationHandler objectActionVerificationHandler = new ObjectActionVerificationHandler(world);
objectActionVerificationHandler.handle(player, objectActionMessage);
assertTrue("ObjectVerificationHandler: message not terminated when out of range!", objectActionMessage.terminated());
}
Aggregations