Exemple #1
0
  public static Mob makeDefaultPlayerMob(String name) {
    Mob mob = new Mob();
    Player player = new Player();
    player.setMob(mob);
    mob.setNameAndId(name);
    mob.setAlias(name);
    mob.setPlayer(player);
    int[] defaultAttributes = {10, 10, 10, 10, 10};
    player.setAttributes(defaultAttributes);

    mob.setId(name);
    mob.setBrief(name);
    mob.setName(name);

    PlayerData data = player.getData();

    data.setLearns(100);
    data.setPracs(100);

    mob.setPlayer(player);

    player.setMob(mob);

    player.getData().setAlignment(new Attribute("Alignment", 1000));

    mob.setHeight(6);

    data.setTotalXp(0);
    data.setRemort(0);
    data.setPracs(0);

    mob.setLevel(1);

    data.setAge(16 + (int) (Math.random() * 5));

    mob.setHp("100");
    mob.setMv("100");
    mob.setMana(new MobMana(true));

    data.setThirst(500);
    data.setHunger(500);

    mob.setWimpy(10);

    return mob;
  }
Exemple #2
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());
  }