Exemplo n.º 1
0
  /** Test a source under another player. */
  @Test
  public void testIsValidNonContainedBelowPlayer() {
    MockStendlRPWorld.get();
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final Player alice = PlayerTestHelper.createPlayer("alice");
    alice.setPosition(0, 1);
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = ItemTestHelper.createItem();
    zone.add(dropitem);
    zone.add(bob);
    zone.add(alice);
    assertNotNull(dropitem.getID().getObjectID());
    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());
    MockStendlRPWorld.get().addRPZone(zone);
    assertNotNull(bob.getZone());

    SourceObject so = SourceObject.createSourceObject(action, alice);
    assertFalse("Picking an item below another player", so.isValid());

    // Bind it to alice. She should be able to pick it up
    dropitem.setBoundTo("alice");
    so = SourceObject.createSourceObject(action, alice);
    assertTrue("Picking an item belonging to player herself", so.isValid());

    // Sanity check. Should be still valid to bob
    so = SourceObject.createSourceObject(action, bob);
    assertTrue("Accessing bound object below oneself", so.isValid());
    // ... unless it's under alice
    dropitem.setPosition(0, 1);
    so = SourceObject.createSourceObject(action, bob);
    assertFalse("Picking an item below another player", so.isValid());
  }
Exemplo n.º 2
0
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    Log4J.init();

    MockStendhalRPRuleProcessor.get();

    MockStendlRPWorld.reset();
    MockStendlRPWorld.get();
  }
Exemplo n.º 3
0
  /** Tests for isValidNonContained. */
  @Test
  public void testIsValidNonContained() {
    MockStendlRPWorld.get();
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = ItemTestHelper.createItem();
    zone.add(dropitem);
    zone.add(bob);
    assertNotNull(dropitem.getID().getObjectID());
    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());
    MockStendlRPWorld.get().addRPZone(zone);
    assertNotNull(bob.getZone());

    final SourceObject so = SourceObject.createSourceObject(action, bob);
    assertTrue(so.isValid());
  }
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    new DatabaseFactory().initializeDatabase();
    MockStendlRPWorld.get();

    QuestHelper.setUpBeforeClass();

    setupZone(ZONE_NAME, new FlowerSellerNPC());
  }
Exemplo n.º 5
0
  /** Tests for isValidContained. */
  @Test
  public void testIsValidContained() {
    MockStendlRPWorld.get();
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = SingletonRepository.getEntityManager().getItem("money");
    assertNotNull(dropitem);
    zone.add(bob);
    assertTrue(bob.equipToInventoryOnly(dropitem));
    assertNotNull(dropitem.getID().getObjectID());
    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());

    action.put(EquipActionConsts.BASE_OBJECT, bob.getID().getObjectID());
    action.put(EquipActionConsts.BASE_SLOT, "bag");
    MockStendlRPWorld.get().addRPZone(zone);
    assertNotNull(bob.getZone());

    final SourceObject so = SourceObject.createSourceObject(action, bob);
    assertTrue("Unreachable slot", so.isValid());
  }
Exemplo n.º 6
0
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    final StendhalRPWorld world = MockStendlRPWorld.get();
    QuestHelper.setUpBeforeClass();

    final StendhalRPZone zone = new StendhalRPZone("int_semos_guard_house");
    new GroundskeeperNPC().configureZone(zone, null);

    world.addRPZone(zone);
    world.addRPZone(basement);
    quest.addToWorld();
  }
  /** Tests for adding from the producer adder method */
  @Test
  public final void testAddFromProducerAdder() {
    final ProducerRegister producerRegister = new ProducerRegister() {};
    assertTrue(producerRegister.getProducers().isEmpty());

    MockStendlRPWorld.get();

    final StendhalRPZone zone = new StendhalRPZone("admin_test");

    // call NPC code which will make ProducerAdder add to register
    new GoldsmithNPC().configureZone(zone, null);

    assertFalse(producerRegister.getProducers().isEmpty());
  }
Exemplo n.º 8
0
  /** Tests for isValidStackableDropTooMany. */
  @Test
  public void testIsValidStackableDropTooMany() {
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = ItemTestHelper.createItem("drops", 5);
    zone.add(dropitem);
    zone.add(bob);
    MockStendlRPWorld.get().addRPZone(zone);

    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());
    action.put(EquipActionConsts.QUANTITY, dropitem.getQuantity() + 3);
    final SourceObject so = SourceObject.createSourceObject(action, bob);
    assertTrue(so.isValid());
    assertEquals("too many are reduced to all", dropitem.getQuantity(), so.getQuantity());
  }
  /** Tests listing the food items */
  @Test
  public final void testGetProducedItems() {
    final ProducerRegister producerRegister = new ProducerRegister() {};

    MockStendlRPWorld.get();

    final StendhalRPZone zone = new StendhalRPZone("admin_test");

    // call NPC code which will make ProducerAdder add to register
    new BakerNPC().configureZone(zone, null);
    new BlacksheepBobNPC().configureZone(zone, null);

    assertFalse(producerRegister.getProducers().isEmpty());

    assertEquals(producerRegister.getProducedItemNames("food"), Arrays.asList("pie", "sausage"));
    assertEquals(producerRegister.getProducedItemNames("food").toString(), "[pie, sausage]");
  }
Exemplo n.º 10
0
  /** Tests for isValidStackable. */
  @Test
  public void testIsValidStackable() {
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = ItemTestHelper.createItem("drops", 5);
    zone.add(dropitem);
    zone.add(bob);
    assertNotNull(dropitem.getID().getObjectID());
    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());
    MockStendlRPWorld.get().addRPZone(zone);
    assertNotNull(bob.getZone());

    final SourceObject so = SourceObject.createSourceObject(action, bob);
    assertTrue(so.isValid());
    assertEquals("stackable returns full quantity", dropitem.getQuantity(), so.getQuantity());
  }
Exemplo n.º 11
0
  /** Tests for isValidStackableDropAFew. */
  @Test
  public void testIsValidStackableDropAFew() {
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = ItemTestHelper.createItem("drops", 5);
    zone.add(dropitem);
    zone.add(bob);
    MockStendlRPWorld.get().addRPZone(zone);

    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());
    final int amounttodrop = 3;
    action.put(EquipActionConsts.QUANTITY, amounttodrop);
    final SourceObject so = SourceObject.createSourceObject(action, bob);
    assertTrue(so.isValid());
    assertEquals("return the amount to be dropped", amounttodrop, so.getQuantity());
  }
Exemplo n.º 12
0
  /** Tests listing the working producers */
  @Test
  public final void testListWorkingProducers() {
    final ProducerRegister producerRegister = new ProducerRegister() {};
    Player player = PlayerTestHelper.createPlayer("player");

    MockStendlRPWorld.get();

    final StendhalRPZone zone = new StendhalRPZone("admin_test");

    // call NPC code which will make ProducerAdder add to register
    new BakerNPC().configureZone(zone, null);
    new BlacksheepBobNPC().configureZone(zone, null);

    assertFalse(producerRegister.getProducers().isEmpty());

    // no orders yet because the player didn't start any
    assertEquals(
        producerRegister.listWorkingProducers(player),
        "You have no ongoing or uncollected orders.");

    player.setQuest("arlindo_make_pie", "1;pie;1");
    player.setQuest("blacksheepbob_make_sausage", "210;sausage;" + System.currentTimeMillis());

    assertEquals(
        producerRegister.listWorkingProducers(player),
        "\r\nOrders: "
            + "\nArlindo has finished making your pie."
            + "\nBlacksheep Bob is making 210 sausages and will be ready in 7 hours.");

    // collect orders
    player.setQuest("arlindo_make_pie", "done");
    player.setQuest("blacksheepbob_make_sausage", "done");

    // no orders now because they are all collected
    assertEquals(
        producerRegister.listWorkingProducers(player),
        "You have no ongoing or uncollected orders.");
  }
  @AfterClass
  public static void teardownAfterClass() throws Exception {

    MockStendlRPWorld.reset();
  }
 @Before
 public void setUp() throws Exception {
   MockStendlRPWorld.get();
 }
 @After
 public void tearDown() throws Exception {
   MockStendlRPWorld.reset();
 }
Exemplo n.º 16
0
 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
   MockStendlRPWorld.get();
   GrowingPassiveEntityRespawnPointTestHelper.generateRPClasses();
 }
Exemplo n.º 17
0
 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
   new DatabaseFactory().initializeDatabase();
   MockStendlRPWorld.get();
 }
 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
   MockStendlRPWorld.get();
 }
 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
   Log4J.init();
   MockStendlRPWorld.get();
   ItemTestHelper.generateRPClasses();
 }