mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-28 05:45:10 -06:00
Adding more tests
This commit is contained in:
parent
8a17e9ba62
commit
14fd14659c
5 changed files with 36 additions and 11 deletions
|
|
@ -589,7 +589,7 @@ public final class BuildingUtils {
|
|||
if (HouseManager.isInDungeon(player)) {
|
||||
z = 3;
|
||||
}
|
||||
if (player.getHouseManager().hasRoom(z, location[0], location[1])) {
|
||||
if (player.getHouseManager().hasRoomAt(z, location[0], location[1])) {
|
||||
return location;
|
||||
}
|
||||
return null;
|
||||
|
|
@ -666,7 +666,7 @@ public final class BuildingUtils {
|
|||
else if (player.getHouseManager().hasExit(z, roomX - 1, roomY, Direction.EAST)) {
|
||||
exits[2] = 1;
|
||||
}
|
||||
else if (player.getHouseManager().hasRoom(z, roomX - 1, roomY)) {
|
||||
else if (player.getHouseManager().hasRoomAt(z, roomX - 1, roomY)) {
|
||||
exits[2] = -1;
|
||||
}
|
||||
if (roomY == 7) {
|
||||
|
|
@ -675,7 +675,7 @@ public final class BuildingUtils {
|
|||
else if (player.getHouseManager().hasExit(z, roomX, roomY + 1, Direction.SOUTH)) {
|
||||
exits[3] = 1;
|
||||
}
|
||||
else if (player.getHouseManager().hasRoom(z, roomX, roomY + 1)) {
|
||||
else if (player.getHouseManager().hasRoomAt(z, roomX, roomY + 1)) {
|
||||
exits[3] = -1;
|
||||
}
|
||||
if (roomX == 7) {
|
||||
|
|
@ -684,7 +684,7 @@ public final class BuildingUtils {
|
|||
else if (player.getHouseManager().hasExit(z, roomX + 1, roomY, Direction.WEST)) {
|
||||
exits[0] = 1;
|
||||
}
|
||||
else if (player.getHouseManager().hasRoom(z, roomX + 1, roomY)) {
|
||||
else if (player.getHouseManager().hasRoomAt(z, roomX + 1, roomY)) {
|
||||
exits[0] = -1;
|
||||
}
|
||||
if (roomY == 0) {
|
||||
|
|
@ -693,7 +693,7 @@ public final class BuildingUtils {
|
|||
else if (player.getHouseManager().hasExit(z, roomX, roomY - 1, Direction.NORTH)) {
|
||||
exits[1] = 1;
|
||||
}
|
||||
else if (player.getHouseManager().hasRoom(z, roomX, roomY - 1)) {
|
||||
else if (player.getHouseManager().hasRoomAt(z, roomX, roomY - 1)) {
|
||||
exits[1] = -1;
|
||||
}
|
||||
return exits;
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ public final class HouseManager {
|
|||
* Creates the default house.
|
||||
* @param location The house location.
|
||||
*/
|
||||
public void create(HouseLocation location) {
|
||||
public void createNewHouseAt(HouseLocation location) {
|
||||
clearRooms();
|
||||
Room room = rooms[0][4][3] = new Room(RoomProperties.GARDEN);
|
||||
room.configure(style);
|
||||
|
|
@ -427,7 +427,7 @@ public final class HouseManager {
|
|||
for (int x = 0; x < 8; x++) {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
Room room = rooms[3][x][y];
|
||||
if (hasRoom(3, x, y)) {
|
||||
if (hasRoomAt(3, x, y)) {
|
||||
BuildRegionChunk copy = room.getChunk().copy(dungeon.getPlanes()[0]);
|
||||
dungeon.replaceChunk(0, x, y, copy, from);
|
||||
room.loadDecorations(3, copy, this);
|
||||
|
|
@ -524,7 +524,7 @@ public final class HouseManager {
|
|||
* @param roomY The room y-coordinate.
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
public boolean hasRoom(int z, int roomX, int roomY) {
|
||||
public boolean hasRoomAt(int z, int roomX, int roomY) {
|
||||
Room room = rooms[z][roomX][roomY];
|
||||
return room != null && !room.getProperties().isRoof();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public final class RemovalDialogue extends DialoguePlugin {
|
|||
public boolean handle(int interfaceId, int buttonId) {
|
||||
if (stage == 0) {
|
||||
if (buttonId == 1) {
|
||||
if (plane == 0 && player.getHouseManager().hasRoom(1, pos[0], pos[1])) {
|
||||
if (plane == 0 && player.getHouseManager().hasRoomAt(1, pos[0], pos[1])) {
|
||||
interpreter.sendPlainMessage(false, "You can't remove a room supporting another room.");
|
||||
stage = 1;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class EstateAgentDialogue : DialoguePlugin {
|
|||
7 -> {
|
||||
if (player.inventory.contains(995, 1000)) {
|
||||
player.inventory.remove(Item(995, 1000))
|
||||
player.houseManager.create(HouseLocation.RIMMINGTON)
|
||||
player.houseManager.createNewHouseAt(HouseLocation.RIMMINGTON)
|
||||
npc(
|
||||
"Thank you. Go through the Rimmington house portal",
|
||||
"and you will find your house ready for you to start",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import api.forceWalk
|
||||
import core.game.node.entity.player.link.music.MusicEntry
|
||||
import core.game.node.entity.skill.construction.HouseLocation
|
||||
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.Assert
|
||||
import core.game.world.map.RegionManager
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
|
|
@ -15,6 +16,30 @@ class HouseManagerTests {
|
|||
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.region.planes[0].getRegionChunk(4, 3).objects.size)
|
||||
}
|
||||
|
||||
@Test fun constructShouldRegisterNewRegionToRegionManager() {
|
||||
val newManager = HouseManager()
|
||||
newManager.construct()
|
||||
Assertions.assertEquals(true, RegionManager.forId(newManager.region.id) == newManager.region)
|
||||
}
|
||||
|
||||
@Test fun constructShouldSetTheRegion() {
|
||||
val newManager = HouseManager()
|
||||
newManager.construct()
|
||||
Assertions.assertNotEquals(null, newManager.region)
|
||||
}
|
||||
|
||||
@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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue