From 8025bc7ad09d971010dd7a60cdde96c841e99a25 Mon Sep 17 00:00:00 2001 From: Seefo Date: Wed, 9 Apr 2014 11:56:56 -0400 Subject: [PATCH] Changes to housing, added real player lot count to character sheet --- .../player_house_generic_small_style_01.py | 5 ++++ .../swg/CharacterSheetResponseMessage.java | 2 +- .../objects/creature/CreatureObject.java | 7 ++++- .../objects/player/PlayerObject.java | 30 ++++++++++++++++++- src/services/housing/HouseTemplate.java | 15 ++++++++++ src/services/housing/HousingService.java | 16 ++++++---- 6 files changed, 66 insertions(+), 9 deletions(-) diff --git a/scripts/houses/player_house_generic_small_style_01.py b/scripts/houses/player_house_generic_small_style_01.py index 95d9f2b4..3b1f0a4c 100644 --- a/scripts/houses/player_house_generic_small_style_01.py +++ b/scripts/houses/player_house_generic_small_style_01.py @@ -9,6 +9,11 @@ def setup(core): houseTemplate.addPlaceablePlanet("tatooine") houseTemplate.addPlaceablePlanet("corellia") houseTemplate.addPlaceablePlanet("naboo") + houseTemplate.addPlaceablePlanet("talus") + houseTemplate.addPlaceablePlanet("rori") + houseTemplate.addPlaceablePlanet("dantooine") + houseTemplate.addPlaceablePlanet("lok") + houseTemplate.setDefaultItemLimit(200) core.housingService.addHousingTemplate(houseTemplate) return \ No newline at end of file diff --git a/src/protocol/swg/CharacterSheetResponseMessage.java b/src/protocol/swg/CharacterSheetResponseMessage.java index 28de844d..70e14124 100644 --- a/src/protocol/swg/CharacterSheetResponseMessage.java +++ b/src/protocol/swg/CharacterSheetResponseMessage.java @@ -99,7 +99,7 @@ public class CharacterSheetResponseMessage extends SWGMessage { buffer.put(getUnicodeString(spouse)); - buffer.putInt(10); // lots remaining + buffer.putInt(creature.getPlayerObject().getLotsRemaining()); // lots remaining return buffer.flip(); } diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 74b2d7f3..da90caec 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -22,7 +22,6 @@ package resources.objects.creature; import java.lang.System; - import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -63,6 +62,7 @@ import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; +import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; @@ -1777,6 +1777,11 @@ public class CreatureObject extends TangibleObject implements IPersistent { return 0L; } + public PlayerObject getPlayerObject() + { + return (PlayerObject) this.getSlottedObject("ghost"); + } + //public float getCooldown(String cooldownGroup) { //return ((float) getCooldown(cooldownGroup) / (float) 1000); //} diff --git a/src/resources/objects/player/PlayerObject.java b/src/resources/objects/player/PlayerObject.java index 9448144d..1a50837d 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -45,7 +45,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=9) +@Persistent(version=10) public class PlayerObject extends IntangibleObject { // PLAY 3 @@ -127,6 +127,8 @@ public class PlayerObject extends IntangibleObject { private String holoEmote; private int holoEmoteUses; + private int lotsRemaining = 10; + @NotPersistent private PlayerMessageBuilder messageBuilder; @@ -822,4 +824,30 @@ public class PlayerObject extends IntangibleObject { public void setRecentContainer(ResourceContainerObject recentContainer) { this.recentContainer = recentContainer; } + + public void setLotsRemaining(int amount) + { + this.lotsRemaining = amount; + } + + public boolean addLots(int amount) + { + this.lotsRemaining += amount; + return true; + } + + public boolean deductLots(int amount) + { + if(this.lotsRemaining - amount > 0) + { + this.lotsRemaining -= amount; + return true; + } + return false; + } + + public int getLotsRemaining() + { + return this.lotsRemaining; + } } diff --git a/src/services/housing/HouseTemplate.java b/src/services/housing/HouseTemplate.java index aaba8d7e..fc2861df 100644 --- a/src/services/housing/HouseTemplate.java +++ b/src/services/housing/HouseTemplate.java @@ -11,6 +11,7 @@ public class HouseTemplate private String deedTemplate; private String buildingTemplate; private int lotCost; + private int defaultItemLimit; private Vector placeablePlanets; private Map buildingSigns; @@ -19,6 +20,7 @@ public class HouseTemplate this.deedTemplate = deedTemplate; this.buildingTemplate = buildingTemplate; this.lotCost = lotCost; + this.defaultItemLimit = 50; this.placeablePlanets = new Vector(); this.buildingSigns = new HashMap(); } @@ -31,6 +33,10 @@ public class HouseTemplate { this.placeablePlanets.add(planetName); } + public void setDefaultItemLimit(int itemLimit) + { + this.defaultItemLimit = itemLimit; + } public String getDeedTemplate() { @@ -48,8 +54,17 @@ public class HouseTemplate { return this.placeablePlanets; } + public boolean canBePlacedOn(String planetName) + { + if(placeablePlanets.contains(planetName)) return true; + else return false; + } public int getLotCost() { return this.lotCost; } + public int getDefaultItemLimit() + { + return this.defaultItemLimit; + } } diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index bbeab9f9..a8f2034b 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -78,16 +78,19 @@ public class HousingService implements INetworkDispatch { int structureLotCost = houseTemplate.getLotCost(); String structureTemplate = houseTemplate.getBuildingTemplate(); - // Lot stuff - if(actor.getAttachment("structureLots") == null) actor.setAttachment("structureLots", 10); // Temporary until better + if(!houseTemplate.canBePlacedOn(actor.getPlanet().getName())) + { + actor.sendSystemMessage("You may not place this structure on this planet.", (byte) 0); // should probably load this from an stf + return; + } - int playerLots = (int) actor.getAttachment("structureLots"); - if(playerLots - structureLotCost < 0) + // Lot stuff + if(actor.getPlayerObject().getLotsRemaining() - structureLotCost < 0) { actor.sendSystemMessage("You do not have enough available lots to place this structure.", (byte) 0); // should probably load this from an stf return; } - actor.setAttachment("structureLots", playerLots - structureLotCost); + actor.getPlayerObject().deductLots(structureLotCost); // Calculate our orientation and height Quaternion quaternion = new Quaternion(1, 0, 0, 0); @@ -101,7 +104,8 @@ public class HousingService implements INetworkDispatch { // Name the sign TangibleObject sign = (TangibleObject) building.getAttachment("structureSign"); - sign.setCustomName2(actor.getCustomName() + "'s House"); + String playerFirstName = actor.getCustomName().split(" ")[0]; + sign.setCustomName2(playerFirstName + "'s House"); //building.add(sign); core.objectService.destroyObject(deed);