Fixed construction issue relating to incorrect isloaded checks causing null scenery

Fixed construction issue relating to houseregionid getting registered for dunegon id
Fixed construction issue relating to teleports in houses
This commit is contained in:
Skal Fate 2023-02-16 22:16:46 +00:00 committed by Ryan
parent 79696dfdde
commit f243293e8c
3 changed files with 7 additions and 130 deletions

View file

@ -225,7 +225,7 @@ public final class HouseManager {
public boolean pulse() {
spawnServant();
if (servant.isGreet()){
player.getDialogueInterpreter().sendDialogues(servant.getType().getId(), servant.getType().getId() == 4243 ? FacialExpression.HALF_GUILTY : null, "Welcome.");
player.getDialogueInterpreter().sendDialogues(servant.getType().getId(), servant.getType().getId() == 4243 ? FacialExpression.HAPPY : null, "Welcome.");
}
return true;
}
@ -252,7 +252,7 @@ public final class HouseManager {
}
if (house.isInHouse(player)) {
player.animate(Animation.RESET);
player.setLocation(house.location.getExitLocation());
player.getProperties().setTeleportLocation(house.location.getExitLocation());
}
}
@ -743,8 +743,11 @@ public final class HouseManager {
* Checks if the house region was constructed and active.
* @return {@code True} if an active region for the house exists.
*/
//public boolean isLoaded() {
// return (houseRegion != null) || (dungeonRegion != null);
//}
public boolean isLoaded() {
return (houseRegion != null) || (dungeonRegion != null);
return (houseRegion != null && houseRegion.isActive()) || (dungeonRegion != null && dungeonRegion.isActive());
}
/**

View file

@ -46,7 +46,7 @@ public final class HouseZone extends MapZone {
}
registerRegion(house.getHouseRegion().getId());
if (house.getDungeonRegion() != null) {
registerRegion(house.getHouseRegion().getId());
registerRegion(house.getDungeonRegion().getId());
}
}

View file

@ -1,126 +0,0 @@
import core.game.node.entity.player.link.music.MusicEntry
import content.global.skill.construction.HouseLocation
import content.global.skill.construction.HouseManager
import content.global.skill.construction.Servant
import content.global.skill.construction.ServantType
import core.game.world.map.RegionManager
import core.game.world.map.path.Pathfinder
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
class HouseManagerTests {
companion object {
init {TestUtils.preTestSetup()}
}
val manager = HouseManager()
val testPlayer = TestUtils.getMockPlayer("test")
@Test fun constructShouldLoadTheConstructedRegion() {
val newManager = HouseManager()
newManager.createNewHouseAt(HouseLocation.RIMMINGTON) //add a room to it, already tested below
newManager.construct()
Assertions.assertNotEquals(0, newManager.houseRegion.planes[0].getRegionChunk(4, 3).objects.size)
}
@Test fun constructShouldRegisterNewRegionToRegionManager() {
val newManager = HouseManager()
newManager.construct()
Assertions.assertEquals(true, RegionManager.forId(newManager.houseRegion.id) == newManager.houseRegion)
}
@Test fun constructShouldSetTheRegionInTheHouseManager() {
val newManager = HouseManager()
newManager.construct()
Assertions.assertNotEquals(null, newManager.houseRegion)
}
@Test fun constructShouldSetTheRegionBorders() {
val newManager = HouseManager()
newManager.construct()
Assertions.assertNotEquals(null, newManager.houseRegion.borders)
}
@Test fun constructShouldSetUpdateAllPlanes() {
val newManager = HouseManager()
newManager.construct()
Assertions.assertEquals(true, newManager.houseRegion.isUpdateAllPlanes)
}
@Test fun constructShouldReplacePlanes1And2UnusedChunksAndAllPlane3ChunksWithEmptyChunks() {
val newManager = HouseManager()
newManager.construct()
for(z in 1..3)
for (objs in newManager.houseRegion.planes[z].objects)
for (obj in objs) Assertions.assertEquals(null, obj)
}
@Test fun leaveShouldPlaceThePlayerAtTheHouseLocationExitLocation() {
val newManager = HouseManager()
val newPlayer = TestUtils.getMockPlayer("test3")
newManager.construct()
newManager.enter(newPlayer, false)
TestUtils.advanceTicks(5)
HouseManager.leave(newPlayer)
Assertions.assertEquals(newManager.location.exitLocation, newPlayer.location)
}
@Test fun toggleBuildingModeShouldChangeBuildingMode() {
val newManager = HouseManager()
val newPlayer = TestUtils.getMockPlayer("test4")
newManager.enter(newPlayer, false)
TestUtils.advanceTicks(5)
newManager.toggleBuildingMode(newPlayer, true)
Assertions.assertEquals(true, newManager.isBuildingMode)
}
@Test fun createShouldPlaceGardenInRooms() {
manager.createNewHouseAt(HouseLocation.RIMMINGTON)
Assertions.assertEquals(true, manager.hasRoomAt(0, 4, 3))
}
@Test fun enterShouldConstructDynamicRegionIfItHasNotBeenConstructed() {
manager.enter(testPlayer, false)
Assertions.assertEquals(true, manager.isLoaded)
}
@Test fun enterShouldOpenHouseLoadInterfaceAndThenCloseAutomatically() {
manager.enter(testPlayer, false)
Assertions.assertEquals(399, testPlayer.interfaceManager.opened.id)
TestUtils.advanceTicks(5)
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))
}
@Test fun reloadShouldPreserveLocalPlayerLocation() {
val separateManager = HouseManager()
val separatePlayer = TestUtils.getMockPlayer("test2")
separateManager.enter(separatePlayer, false)
TestUtils.advanceTicks(5)
Pathfinder.find(separatePlayer, separatePlayer.location.transform(10,10,0)).walk(separatePlayer)
TestUtils.advanceTicks(20)
val localX = separatePlayer.location.localX
val localY = separatePlayer.location.localY
separateManager.reload(separatePlayer, true)
TestUtils.advanceTicks(20)
Assertions.assertEquals(localX, separatePlayer.location.localX)
Assertions.assertEquals(localY, separatePlayer.location.localY)
}
}