Advertisement
SorrenNaas

Lilaya Cabin Room V3 AbstractPlaceType

Jan 13th, 2019
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.43 KB | None | 0 0
  1. /**Lilaya Cabin Room Mod V3 By SVNaas (Quality Control and Verification by Nuke Bait)
  2. *Replace contents of com.lilithsthrone.world.places.AbstractPlaceType with this
  3. */
  4.  
  5. package com.lilithsthrone.world.places;
  6.  
  7. import java.io.IOException;
  8. import java.io.InputStream;
  9. import java.util.ArrayList;
  10. import java.util.Arrays;
  11. import java.util.HashMap;
  12. import java.util.List;
  13. import java.util.Map;
  14. import java.util.Set;
  15.  
  16. import com.lilithsthrone.game.dialogue.DialogueNode;
  17. import com.lilithsthrone.game.dialogue.encounters.Encounter;
  18. import com.lilithsthrone.game.inventory.CharacterInventory;
  19. import com.lilithsthrone.utils.BaseColour;
  20. import com.lilithsthrone.utils.Colour;
  21. import com.lilithsthrone.utils.SvgUtil;
  22. import com.lilithsthrone.utils.Util;
  23. import com.lilithsthrone.world.Bearing;
  24. import com.lilithsthrone.world.EntranceType;
  25. import com.lilithsthrone.world.Weather;
  26. import com.lilithsthrone.world.WorldType;
  27.  
  28. /**
  29. * @since 0.3.1
  30. * @version 0.3.1
  31. * @author Innoxia
  32. */
  33. public class AbstractPlaceType {
  34.  
  35. protected String name;
  36. protected String tooltipDescription;
  37. protected String SVGString;
  38. protected String colourString;
  39. protected String backgroundColourString;
  40. protected BaseColour colour;
  41. protected Colour backgroundColour;
  42. protected DialogueNode dialogue;
  43. protected Encounter encounterType;
  44.  
  45. protected boolean globalMapTile;
  46. protected boolean dangerous;
  47. protected boolean itemsDisappear;
  48.  
  49. protected List<Weather> weatherImmunities;
  50. protected static List<Weather> allWeatherImmunities = new ArrayList<>(Arrays.asList(Weather.values()));
  51.  
  52. protected String virginityLossDescription;
  53.  
  54. protected static Map<String, String> SVGOverrides = new HashMap<>();
  55.  
  56. protected static int colourReplacementId = 0;
  57.  
  58. public AbstractPlaceType(String name,
  59. String tooltipDescription,
  60. String SVGPath,
  61. BaseColour colour,
  62. DialogueNode dialogue,
  63. Encounter encounterType,
  64. String virginityLossDescription) {
  65.  
  66. this.name = name;
  67. this.tooltipDescription = tooltipDescription;
  68. this.colour = colour;
  69. if(colour != null) {
  70. this.colourString = colour.toWebHexString();
  71. }
  72.  
  73. this.backgroundColour = Colour.MAP_BACKGROUND;
  74.  
  75. this.dialogue = dialogue;
  76. this.encounterType = encounterType;
  77. this.dangerous = false;
  78. this.weatherImmunities = new ArrayList<>();
  79. this.itemsDisappear = true;
  80. this.virginityLossDescription = virginityLossDescription;
  81.  
  82. this.globalMapTile = false;
  83.  
  84. if(SVGPath!=null) {
  85. try {
  86. InputStream is = this.getClass().getResourceAsStream("/com/lilithsthrone/res/map/" + SVGPath + ".svg");
  87. if(is==null) {
  88. System.err.println("Error! PlaceType icon file does not exist (Trying to read from '"+SVGPath+"')! (Code 1)");
  89. }
  90. String s = Util.inputStreamToString(is);
  91.  
  92. try {
  93. s = SvgUtil.colourReplacement("placeColour"+colourReplacementId, colour, s);
  94. colourReplacementId++;
  95. } catch(Exception ex) {
  96. System.err.println(SVGPath+" error!");
  97. }
  98.  
  99. SVGString = s;
  100.  
  101. is.close();
  102.  
  103. } catch (IOException e1) {
  104. e1.printStackTrace();
  105. }
  106. } else {
  107. SVGString = null;
  108. }
  109. }
  110.  
  111. public AbstractPlaceType initDangerous() {
  112. this.dangerous = true;
  113. if(backgroundColour==Colour.MAP_BACKGROUND) {
  114. backgroundColour = Colour.MAP_BACKGROUND_DANGEROUS;
  115. }
  116. return this;
  117. }
  118.  
  119. public AbstractPlaceType initItemsPersistInTile() {
  120. this.itemsDisappear = false;
  121. return this;
  122. }
  123.  
  124. public AbstractPlaceType initMapBackgroundColour(Colour backgroundColour) {
  125. this.backgroundColour = backgroundColour;
  126. return this;
  127. }
  128.  
  129. /**
  130. * Sets weather immunity to all Weather values.
  131. */
  132. public AbstractPlaceType initWeatherImmune() {
  133. this.weatherImmunities = allWeatherImmunities;
  134. return this;
  135. }
  136.  
  137. /**
  138. * Define weather immunity for this place.
  139. */
  140. public AbstractPlaceType initWeatherImmune(Weather... weatherImmunities) {
  141. this.weatherImmunities = new ArrayList<>(Arrays.asList(weatherImmunities));
  142. return this;
  143. }
  144.  
  145. public String getName() {
  146. return name;
  147. }
  148.  
  149. public String getTooltipDescription() {
  150. return tooltipDescription;
  151. }
  152.  
  153. public String getColourString() {
  154. if(colour!=null) {
  155. return colour.toWebHexString();
  156. } else if(colourString!=null) {
  157. return colourString;
  158. }
  159. return "";
  160. }
  161.  
  162.  
  163. public Colour getBackgroundColour() throws Exception {
  164. if(backgroundColourString!=null) { // background colour string is overriding any background set.
  165. throw new NullPointerException();
  166. }
  167. return backgroundColour;
  168. }
  169.  
  170. public String getBackgroundColourString() {
  171. if(backgroundColourString!=null) {
  172. return backgroundColourString;
  173. }
  174. return backgroundColour.toWebHexString();
  175. }
  176.  
  177. public Encounter getEncounterType() {
  178. return encounterType;
  179. }
  180.  
  181. public DialogueNode getDialogue(boolean withRandomEncounter) {
  182. return getDialogue(withRandomEncounter, false);
  183. }
  184.  
  185. public DialogueNode getDialogue(boolean withRandomEncounter, boolean forceEncounter) {
  186. if (getEncounterType() != null && withRandomEncounter) {
  187. DialogueNode dn = getEncounterType().getRandomEncounter(forceEncounter);
  188. if (dn != null) {
  189. return dn;
  190. }
  191. }
  192.  
  193. return dialogue;
  194. }
  195.  
  196. public Population getPopulation() {
  197. return null;
  198. }
  199.  
  200. public boolean isPopulated() {
  201. return getPopulation()!=null && !getPopulation().getSpecies().isEmpty();
  202. }
  203.  
  204. public boolean isLand() {
  205. return true;
  206. }
  207.  
  208. public boolean isDangerous() {
  209. return dangerous;
  210. }
  211.  
  212. public boolean isStormImmune() {
  213. return weatherImmunities.contains(Weather.MAGIC_STORM);
  214. }
  215.  
  216. public boolean isItemsDisappear() {
  217. return itemsDisappear;
  218. }
  219.  
  220. protected static String getSVGOverride(String pathName, Colour colour) {
  221. if(!SVGOverrides.keySet().contains(pathName+colour)) {
  222. try {
  223. InputStream is = colour.getClass().getResourceAsStream("/com/lilithsthrone/res/map/" + pathName + ".svg");
  224. if(is==null) {
  225. System.err.println("Error! PlaceType icon file does not exist (Trying to read from '"+pathName+"')! (Code 2)");
  226. }
  227. String s = Util.inputStreamToString(is);
  228.  
  229.  
  230. try {
  231. s = SvgUtil.colourReplacement("placeColour"+colourReplacementId, colour, s);
  232. colourReplacementId++;
  233. } catch(Exception ex) {
  234. System.err.println(pathName+" error!");
  235. }
  236.  
  237. SVGOverrides.put(pathName+colour, s);
  238.  
  239. is.close();
  240.  
  241. } catch (Exception e1) {
  242. System.err.println("Eeeeeek! PlaceType.getSVGOverride()");
  243. e1.printStackTrace();
  244. return "";
  245. }
  246. }
  247.  
  248. return SVGOverrides.get(pathName+colour);
  249. }
  250.  
  251. public String getSVGString(Set<PlaceUpgrade> upgrades) {
  252. return SVGString;
  253. }
  254.  
  255. public void applyInventoryInit(CharacterInventory inventory) {
  256.  
  257. }
  258.  
  259. // For determining where this place should be placed:
  260.  
  261. public Bearing getBearing() {
  262. return null;
  263. }
  264.  
  265. public WorldType getParentWorldType() {
  266. return null;
  267. }
  268.  
  269. public AbstractPlaceType getParentPlaceType() {
  270. return null;
  271. }
  272.  
  273. public EntranceType getParentAlignment() {
  274. return null;
  275. }
  276.  
  277. public String getPlaceNameAppendFormat(int count) {
  278. return "";
  279. }
  280.  
  281. public boolean isAbleToBeUpgraded() {
  282. return false;
  283. }
  284.  
  285. public ArrayList<PlaceUpgrade> getStartingPlaceUpgrades() {
  286. return new ArrayList<>();
  287. }
  288.  
  289. public ArrayList<PlaceUpgrade> getAvailablePlaceUpgrades(Set<PlaceUpgrade> upgrades) {
  290. return new ArrayList<>();
  291. }
  292.  
  293. public static ArrayList<PlaceUpgrade> getAvailableLilayaRoomPlaceUpgrades(Set<PlaceUpgrade> upgrades) {
  294. if(upgrades.contains(PlaceUpgrade.LILAYA_GUEST_ROOM)) {
  295. return PlaceUpgrade.getGuestRoomUpgrades();
  296.  
  297. } else if(upgrades.contains(PlaceUpgrade.LILAYA_SLAVE_ROOM)) {
  298. return PlaceUpgrade.getSlaveQuartersUpgradesSingle();
  299.  
  300. } else if(upgrades.contains(PlaceUpgrade.LILAYA_SLAVE_ROOM_DOUBLE)) {
  301. return PlaceUpgrade.getSlaveQuartersUpgradesDouble();
  302.  
  303. } else if(upgrades.contains(PlaceUpgrade.LILAYA_SLAVE_ROOM_CABIN)) {
  304. return PlaceUpgrade.getSlaveQuartersUpgradesCabin();
  305.  
  306. } else if(upgrades.contains(PlaceUpgrade.LILAYA_MILKING_ROOM)) {
  307. return PlaceUpgrade.getMilkingUpgrades();
  308. }
  309.  
  310. return PlaceUpgrade.getCoreRoomUpgrades();
  311. }
  312.  
  313. public String getLilayaRoomSVGString(Set<PlaceUpgrade> upgrades) {
  314. if(upgrades.contains(PlaceUpgrade.LILAYA_GUEST_ROOM)) {
  315. return getSVGOverride("dominion/lilayasHome/roomGuest", Colour.BASE_GREEN_LIGHT);
  316.  
  317. } else if(upgrades.contains(PlaceUpgrade.LILAYA_SLAVE_ROOM)) {
  318. return getSVGOverride("dominion/lilayasHome/roomSlave", Colour.BASE_CRIMSON);
  319.  
  320. } else if(upgrades.contains(PlaceUpgrade.LILAYA_MILKING_ROOM)) {
  321. return getSVGOverride("dominion/lilayasHome/roomMilking", Colour.BASE_ORANGE);
  322.  
  323. } else if(upgrades.contains(PlaceUpgrade.LILAYA_SLAVE_ROOM_DOUBLE)) {
  324. return getSVGOverride("dominion/lilayasHome/roomSlaveDouble", Colour.BASE_MAGENTA);
  325.  
  326. } else if(upgrades.contains(PlaceUpgrade.LILAYA_SLAVE_ROOM_CABIN)) {
  327. return getSVGOverride("dominion/lilayasHome/roomSlaveCabin", Colour.BASE_PURPLE_DARK);
  328.  
  329. } else {
  330. return SVGString;
  331. }
  332. }
  333.  
  334. public String getVirginityLossDescription() {
  335. return virginityLossDescription;
  336. }
  337.  
  338. public boolean isGlobalMapTile() {
  339. return globalMapTile;
  340. }
  341. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement