@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()); }
@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()); }