Adding more tests

This commit is contained in:
ceikry 2022-04-26 18:42:28 -05:00
parent 37ba4e1931
commit eabd15e2b1
3 changed files with 46 additions and 9 deletions

View file

@ -199,8 +199,8 @@ public final class HouseManager {
player.sendMessage("House location: " + region.getBaseLocation() + ", entry: " + getEnterLocation()); player.sendMessage("House location: " + region.getBaseLocation() + ", entry: " + getEnterLocation());
player.getProperties().setTeleportLocation(getEnterLocation()); player.getProperties().setTeleportLocation(getEnterLocation());
openLoadInterface(player); openLoadInterface(player);
player.getConfigManager().set(261, buildingMode); checkForAndSpawnServant(player);
player.getConfigManager().set(262, getRoomAmount()); updateVarbits(player, buildingMode);
player.getMusicPlayer().unlock(454, true); player.getMusicPlayer().unlock(454, true);
} }
@ -214,18 +214,32 @@ public final class HouseManager {
GameWorld.getPulser().submit(new Pulse(1, player) { GameWorld.getPulser().submit(new Pulse(1, player) {
@Override @Override
public boolean pulse() { public boolean pulse() {
if (hasServant()){
spawnServant();
if (servant.isGreet()){
player.getDialogueInterpreter().sendDialogues(servant.getType().getId(), servant.getType().getId() == 4243 ? FacialExpression.HALF_GUILTY : null, "Welcome.");
}
}
player.getInterfaceManager().close(); player.getInterfaceManager().close();
return true; return true;
} }
}); });
} }
public void checkForAndSpawnServant(Player player) {
if(!hasServant()) return;
GameWorld.getPulser().submit(new Pulse(1, player) {
@Override
public boolean pulse() {
spawnServant();
if (servant.isGreet()){
player.getDialogueInterpreter().sendDialogues(servant.getType().getId(), servant.getType().getId() == 4243 ? FacialExpression.HALF_GUILTY : null, "Welcome.");
}
return true;
}
});
}
public void updateVarbits(Player player, boolean build) {
player.varpManager.get(261).setVarbit(0, build ? 1 : 0);
player.varpManager.get(262).setVarbit(0, getRoomAmount());
}
/** /**
* Leaves this house. * Leaves this house.
* @param player The player leaving. * @param player The player leaving.

View file

@ -1,4 +1,7 @@
import core.game.node.entity.player.link.music.MusicEntry
import core.game.node.entity.skill.construction.HouseManager import core.game.node.entity.skill.construction.HouseManager
import core.game.node.entity.skill.construction.Servant
import core.game.node.entity.skill.construction.ServantType
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -21,4 +24,22 @@ class HouseManagerTests {
TestUtils.advanceTicks(5) TestUtils.advanceTicks(5)
Assertions.assertNotEquals(null, testPlayer.interfaceManager.opened) Assertions.assertNotEquals(null, testPlayer.interfaceManager.opened)
} }
@Test fun enterShouldSendServantIfHasOne() {
manager.servant = Servant(ServantType.BUTLER)
manager.enter(testPlayer, false)
TestUtils.advanceTicks(5)
Assertions.assertEquals(true, manager.servant.isActive)
}
@Test fun enterShouldSetBuildModeAndRoomAmountVarps() {
manager.enter(testPlayer, false)
Assertions.assertEquals(true, testPlayer.varpManager.get(261).varbits.isNotEmpty())
Assertions.assertEquals(true, testPlayer.varpManager.get(262).varbits.isNotEmpty())
}
@Test fun enterShouldUnlockPOHMusicTrack() {
manager.enter(testPlayer, false)
Assertions.assertEquals(true, testPlayer.musicPlayer.unlocked.contains(MusicEntry.forId(454).index))
}
} }

View file

@ -7,6 +7,7 @@ import rs09.ServerConstants
import rs09.game.ai.ArtificialSession import rs09.game.ai.ArtificialSession
import rs09.game.content.global.shops.Shop import rs09.game.content.global.shops.Shop
import rs09.game.content.global.shops.ShopItem import rs09.game.content.global.shops.ShopItem
import rs09.game.system.config.ConfigParser
import rs09.game.system.config.ServerConfigParser import rs09.game.system.config.ServerConfigParser
import rs09.game.system.config.XteaParser import rs09.game.system.config.XteaParser
import rs09.game.world.GameWorld import rs09.game.world.GameWorld
@ -28,8 +29,9 @@ object TestUtils {
fun preTestSetup() { fun preTestSetup() {
if(ServerConstants.DATA_PATH == null) { if(ServerConstants.DATA_PATH == null) {
ServerConfigParser.parse("worldprops/test.conf") ServerConfigParser.parse("worldprops/test.conf")
XteaParser().load()
Cache.init(this::class.java.getResource("cache").path.toString()) Cache.init(this::class.java.getResource("cache").path.toString())
ConfigParser().prePlugin()
ConfigParser().postPlugin()
} }
} }