예제 #1
0
  @Test
  public void testUnhide() {

    Mob player1Mob = TestHelper.makeDefaultPlayerMob("player1");

    // Teach rescue to player
    Ability ability = new Ability("hide", 100);
    player1Mob.getLearned().add(ability);
    World.add(new BaseSkill("hide"));

    Race human = new Race();
    World.getInstance().addToWorld(human);

    // have test resource file to load in a mob sheep and mob player
    // test files.
    Mob sheepMob = new Mob();
    sheepMob.setNameAndId("sheep");
    sheepMob.setAlias("sheep");
    sheepMob.setHp("2d10+50");

    Room whiteRoom = new Room();

    whiteRoom.add(sheepMob);
    whiteRoom.add(player1Mob);

    Command hide = new Hide();
    hide.execute(player1Mob, player1Mob.getAlias());

    assertEquals("player should be hidden", true, player1Mob.isHidden());

    Command unhide = new Unhide();
    unhide.execute(player1Mob, player1Mob.getAlias());

    assertEquals("player should be unhidden", false, player1Mob.isHidden());

    Command kill = new Kill();

    assertEquals("Check sheep name", "sheep", sheepMob.getName());
    assertNotNull("Check sheep exists in the room", whiteRoom.getMob(sheepMob.getName()));
    assertEquals("Check sheep is in the room", sheepMob, whiteRoom.getMob(sheepMob.getName()));

    World.getInstance(); // Starts time.

    // kill.execute(player1Mob, sheepMob.getName());
    kill.execute(sheepMob, player1Mob.getName());

    // Check they are targeting each other.
    assertEquals("sheep should not target player1", player1Mob, sheepMob.getFight().getTarget());
  }
예제 #2
0
파일: Zone.java 프로젝트: ivstuart/tea-mud
  public void setGiveItem(String give_) {
    String elements[] = give_.split(" ");

    if (elements.length < 3) {
      LOGGER.error("Give needs to be [mob] [room] [item] <load percentage>");
      return;
    }

    Mob mob = World.getRoom(elements[1]).getMob(elements[0]);

    if (mob == null) {
      LOGGER.error("Mob was null for id: " + elements[0]);
      return;
    }

    Item item = EntityProvider.createItem(elements[2]);

    if (item == null) {
      LOGGER.error("Item was null for id: " + elements[2]);
      return;
    }

    if (elements.length == 4) {
      item.setLoadPercentage(Integer.parseInt(elements[3]));
    }

    if (item.isLoaded()) {
      mob.getInventory().add(item); // Gives to room mob only.
    }
  }
예제 #3
0
파일: Zone.java 프로젝트: ivstuart/tea-mud
  public void setPropInRoom(String propInRoom) {
    String elements[] = propInRoom.split(" ");

    // LOGGER.debug("Elements :"+elements[0]+" "+elements[1]);

    Prop prop = EntityProvider.createProp(elements[0]);

    Room room = World.getRoom(elements[1]);

    // LOGGER.debug("Adding mob "+mob.getName()+" to room "+room.getId());

    room.add(prop);
  }
예제 #4
0
  public static Room makeRoomGrid() {
    Room root = new Room();
    root.setId("Z0-:0:0:0");

    World.add(root);

    RoomBuilder roomBuilder = new RoomBuilder();
    roomBuilder.setId("Z0-:0:0:0");
    roomBuilder.setRoomPrefix("Z0-");
    roomBuilder.setPath("3x3");
    roomBuilder.setExecute(null);

    return root;
  }
예제 #5
0
파일: Zone.java 프로젝트: ivstuart/tea-mud
  /**
   * Mob then item space seperated then load percentage for item
   *
   * @param give_
   */
  public void setGive(String give_) {
    String elements[] = give_.split(" ");

    if (elements.length < 2) {
      LOGGER.error("Give needs to be [mob] [item] <load percentage>");
      return;
    }
    Mob mob = World.getMob(elements[0]);
    Item item = EntityProvider.createItem(elements[1]);
    mob.getInventory().add(item); // Gives to template mob only

    if (elements.length == 3) {
      item.setLoadPercentage(Integer.parseInt(elements[2]));
    }
  }
예제 #6
0
  @Test
  public void testStander() {
    Race human = new Race();
    World.getInstance().addToWorld(human);

    // have test resource file to load in a mob sheep and mob player
    // test files.
    Mob sheepMob = new Mob();
    sheepMob.setNameAndId("sheep");
    sheepMob.setAlias("sheep");
    sheepMob.setHp("500");
    sheepMob.setMv("500");
    sheepMob.setBehaviour("Stander");

    BaseBehaviour baseBehaviour = BehaviourFactory.create("Stander");
    baseBehaviour.setMob(sheepMob);
    baseBehaviour.setParameter(100);

    sheepMob.addTickable(baseBehaviour);
    WorldTime.addTickable(sheepMob);

    Room whiteRoom = new Room();
    whiteRoom.add(sheepMob);
    sheepMob.setRoom(whiteRoom);

    Mob player1Mob = TestHelper.makeDefaultPlayerMob("player1");
    whiteRoom.add(player1Mob);
    player1Mob.setRoom(whiteRoom);

    Tackle.setTackled(player1Mob, sheepMob);

    sheepMob.getMobStatus().clear();

    baseBehaviour.tick();
    baseBehaviour.tick();
    baseBehaviour.tick();

    assertEquals("sheep should be standing", MobState.STAND, sheepMob.getState());

    assertEquals("sheep should be standing", false, sheepMob.getFight().isGroundFighting());
  }
예제 #7
0
파일: Zone.java 프로젝트: ivstuart/tea-mud
  public void setMobInRoom(String mobAndRoom_) {
    String elements[] = mobAndRoom_.split(" ");

    // LOGGER.debug("Elements :"+elements[0]+" "+elements[1]);

    Mob mob = EntityProvider.createMob(elements[0], elements[1]);

    if (mob == null) {
      LOGGER.error("Room id:" + elements[1] + " mob null for:" + elements[0]);
      return;
    }

    Room room = World.getRoom(elements[1]);

    if (room == null) {
      LOGGER.error("Room id:" + elements[1] + " null for mob:" + elements[0]);
    }
    // LOGGER.debug("Adding mob "+mob.getName()+" to room "+room.getId());

    room.add(mob);
  }
예제 #8
0
파일: Zone.java 프로젝트: ivstuart/tea-mud
 public void setItemInRoom(String itemAndRoom_) {
   String elements[] = itemAndRoom_.split(" ");
   Item item = EntityProvider.createItem(elements[0]);
   Room room = World.getRoom(elements[1]);
   room.add(item);
 }