use of com.lilithsthrone.world.places.GenericPlace in project liliths-throne-public by Innoxia.
the class SlaveryManagementDialogue method getRoomEntry.
private static String getRoomEntry(boolean disabled, boolean currentLocation, Cell cell, List<NPC> occupants, float affectionChange, float obedienceChange) {
miscDialogueSB.setLength(0);
GenericPlace place = cell.getPlace();
miscDialogueSB.append("<div class='container-full-width inner' style='margin-bottom:4px; margin-top:4px; " + (!occupants.isEmpty() ? "background:#292929;'" : "'") + "'>" + "<div style='width:15%; float:left; margin:0; padding:0;'>" + "<span style='color:" + place.getColour().toWebHexString() + ";'>" + place.getName() + "</span></br>" + "</div>" + "<div style='width:20%; float:left; margin:0; padding:0;'>");
int i = 0;
for (NPC occupant : occupants) {
if (occupant.isSlave()) {
miscDialogueSB.append("<b style='color:" + occupant.getFemininity().getColour().toWebHexString() + ";'>" + occupant.getName() + "</b>" + (i + 1 == occupants.size() ? "" : "</br>"));
i++;
}
}
if (i == 0) {
miscDialogueSB.append("<b style='color:" + Colour.TEXT_GREY.toWebHexString() + ";'>Empty</b>");
}
miscDialogueSB.append("</div>" + "<div style='float:left; width:10%; margin:0; padding:0;'>" + i + "/" + place.getCapacity() + "</div>" + "<div style='float:left; width:15%; margin:0; padding:0;'>" + "<span style='color:" + (affectionChange == 0 ? Colour.BASE_GREY : (affectionChange > 0 ? Colour.GENERIC_GOOD : Colour.GENERIC_BAD)).toWebHexString() + ";'>" + (affectionChange > 0 ? "+" : "") + decimalFormat.format(affectionChange) + "</span>/hour" + "</div>" + "<div style='float:left; width:15%; margin:0; padding:0;'>" + "<span style='color:" + (obedienceChange == 0 ? Colour.BASE_GREY : (obedienceChange > 0 ? Colour.GENERIC_GOOD : Colour.GENERIC_BAD)).toWebHexString() + ";'>" + (obedienceChange > 0 ? "+" : "") + decimalFormat.format(obedienceChange) + "</span>/hour" + "</div>" + "<div style='float:left; width:15%; margin:0; padding:0;'>" + (disabled ? "[style.colourDisabled(N/A)]" : (place.getUpkeep() > 0 ? UtilText.formatAsMoney(-place.getUpkeep(), "span", Colour.GENERIC_BAD) : (place.getUpkeep() == 0 ? UtilText.formatAsMoney(-place.getUpkeep(), "span", Colour.TEXT_GREY) : UtilText.formatAsMoney(-place.getUpkeep(), "span", Colour.GENERIC_GOOD)))) + "/day" + "</div>" + "<div style='float:left; width:10%; margin:0 auto; padding:0; display:inline-block; text-align:center;'>" + (disabled ? "<div id='" + cell.getId() + (currentLocation ? "_PRESENT" : "") + "_DISABLED' class='square-button solo disabled'><div class='square-button-content'>" + SVGImages.SVG_IMAGE_PROVIDER.getSlaveInspectDisabled() + "</div></div>" : "<div id='" + cell.getId() + (currentLocation ? "_PRESENT" : "") + "' class='square-button solo'><div class='square-button-content'>" + SVGImages.SVG_IMAGE_PROVIDER.getSlaveInspect() + "</div></div>") + "</div>" + "</div>");
return miscDialogueSB.toString();
}
use of com.lilithsthrone.world.places.GenericPlace in project liliths-throne-public by Innoxia.
the class SlaveryManagementDialogue method getUpgradeEntry.
private static String getUpgradeEntry(Cell cell, PlaceUpgrade upgrade) {
miscDialogueSB.setLength(0);
GenericPlace place = cell.getPlace();
float affectionChange = upgrade.getHourlyAffectionGain();
float obedienceChange = upgrade.getHourlyObedienceGain();
boolean owned = place.getPlaceUpgrades().contains(upgrade);
boolean availableForPurchase = upgrade.isPrerequisitesMet(place) && upgrade.isAvailable(cell) && (owned ? Main.game.getPlayer().getMoney() >= upgrade.getRemovalCost() : Main.game.getPlayer().getMoney() >= upgrade.getInstallCost());
boolean canBuy = availableForPurchase;
miscDialogueSB.append("<div class='container-full-width inner' style='margin-bottom:4px; margin-top:4px;" + (owned ? "background:#292929;'" : "'") + "'>" + "<div style='width:30%; float:left; margin:0; padding:0;'>" + (owned ? "<b style='color:" + Colour.GENERIC_GOOD.toWebHexString() + ";'>" + Util.capitaliseSentence(upgrade.getName()) + "</b>" : (!availableForPurchase ? "<b style='color:" + Colour.GENERIC_BAD.toWebHexString() + ";'>" + Util.capitaliseSentence(upgrade.getName()) + "</b>" : "<b>" + Util.capitaliseSentence(upgrade.getName()) + "</b>")) + "</div>" + "<div style='width:10%; float:left; margin:0; padding:0;'>" + (upgrade.getCapacity() > 0 ? "<b style='color:" + Colour.GENERIC_EXCELLENT.toWebHexString() + ";'>+" + upgrade.getCapacity() + "</b>" : (upgrade.getCapacity() < 0 ? "<b style='color:" + Colour.GENERIC_TERRIBLE.toWebHexString() + ";'>" + upgrade.getCapacity() + "</b>" : "[style.colourDisabled(0)]")) + "</div>" + "<div style='float:left; width:15%; margin:0; padding:0;'>" + (affectionChange > 0 ? "<b style='color:" + Colour.AFFECTION.toWebHexString() + ";'>+" + decimalFormat.format(affectionChange) + "</b>/hour" : (affectionChange < 0 ? "<b style='color:" + Colour.GENERIC_BAD.toWebHexString() + ";'>" + decimalFormat.format(affectionChange) + "</b>/hour" : "[style.colourDisabled(0)]/hour")) + "</div>" + "<div style='float:left; width:15%; margin:0; padding:0;'>" + (obedienceChange > 0 ? "<b style='color:" + Colour.OBEDIENCE.toWebHexString() + ";'>+" + decimalFormat.format(obedienceChange) + "</b>/hour" : (obedienceChange < 0 ? "<b style='color:" + Colour.GENERIC_BAD.toWebHexString() + ";'>" + decimalFormat.format(obedienceChange) + "</b>/hour" : "[style.colourDisabled(0)]/hour")) + "</div>" + "<div style='float:left; width:10%; margin:0; padding:0;'>" + (upgrade.getUpkeep() > 0 ? UtilText.formatAsMoney(upgrade.getUpkeep(), "b", Colour.GENERIC_BAD) : UtilText.formatAsMoney(upgrade.getUpkeep(), "b", Colour.GENERIC_GOOD)) + "/day" + "</div>" + "<div style='float:left; width:10%; margin:0; padding:0;'>" + (owned ? (upgrade.getRemovalCost() < 0 ? UtilText.formatAsMoney(upgrade.getRemovalCost(), "b", Colour.GENERIC_GOOD) : (upgrade.getRemovalCost() < Main.game.getPlayer().getMoney() ? UtilText.formatAsMoney(upgrade.getRemovalCost(), "b") : UtilText.formatAsMoney(upgrade.getRemovalCost(), "b", Colour.GENERIC_BAD))) : (upgrade.getInstallCost() < 0 ? UtilText.formatAsMoney(upgrade.getInstallCost(), "b", Colour.GENERIC_GOOD) : (upgrade.getInstallCost() < Main.game.getPlayer().getMoney() ? UtilText.formatAsMoney(upgrade.getInstallCost(), "b") : UtilText.formatAsMoney(upgrade.getInstallCost(), "b", Colour.GENERIC_BAD)))) + "</div>" + "<div style='float:left; width:10%; margin:0 auto; padding:0; display:inline-block; text-align:center;'>");
if (owned) {
if (Main.game.getPlayer().getMoney() < upgrade.getRemovalCost() || upgrade.isCoreRoomUpgrade()) {
miscDialogueSB.append("<div id='" + upgrade + "_SELL_DISABLED' class='square-button solo disabled'><div class='square-button-content'>" + SVGImages.SVG_IMAGE_PROVIDER.getTransactionSellDisabled() + "</div></div>");
} else {
miscDialogueSB.append("<div id='" + upgrade + "_SELL' class='square-button solo'><div class='square-button-content'>" + SVGImages.SVG_IMAGE_PROVIDER.getTransactionSell() + "</div></div>");
}
} else {
if (Main.game.getPlayer().getMoney() < upgrade.getInstallCost() || Main.game.getSlaveryUtil().getGeneratedBalance() < 0) {
canBuy = false;
}
if (canBuy) {
if (!upgrade.getPrerequisites().isEmpty()) {
for (PlaceUpgrade prereq : upgrade.getPrerequisites()) {
if (!place.getPlaceUpgrades().contains(prereq)) {
canBuy = false;
break;
}
}
}
}
if (canBuy) {
miscDialogueSB.append("<div id='" + upgrade + "_BUY' class='square-button solo'><div class='square-button-content'>" + SVGImages.SVG_IMAGE_PROVIDER.getTransactionBuy() + "</div></div>");
} else {
miscDialogueSB.append("<div id='" + upgrade + "_BUY_DISABLED' class='square-button solo disabled'><div class='square-button-content'>" + SVGImages.SVG_IMAGE_PROVIDER.getTransactionBuyDisabled() + "</div></div>");
}
}
miscDialogueSB.append("</div>" + "<p>" + "<i>" + (!owned ? "[style.colourDisabled(" + upgrade.getDescriptionForPurchase() + ")]" : upgrade.getDescriptionAfterPurchase()) + "</i>" + "</p>" + (upgrade.isCoreRoomUpgrade() && !owned ? "<p>This is a [style.boldArcane(core modification)], and will [style.boldBad(remove all other modifications in this room when purchased)].</p>" : ""));
if (!canBuy) {
miscDialogueSB.append("<p>" + "<i>" + "[style.colourBad(" + getPurchaseAvailabilityTooltipText(SlaveryManagementDialogue.cellToInspect.getPlace(), upgrade) + ")]" + "</i>" + "</p>");
}
miscDialogueSB.append("</div>");
return miscDialogueSB.toString();
}
use of com.lilithsthrone.world.places.GenericPlace in project liliths-throne-public by Innoxia.
the class SlaveryManagementDialogue method getWorldRooms.
private static String getWorldRooms(WorldType worldType) {
StringBuilder worldRoomSB = new StringBuilder();
worldRoomSB.append("<div class='container-full-width' style='text-align:center;'>" + "<h6 style='color:" + worldType.getColour().toWebHexString() + "; text-align:center;'>" + worldType.getName() + "</h6>" + getRoomHeader());
Cell[][] cellGrid = Main.game.getWorlds().get(worldType).getCellGrid();
List<Cell> sortingCells = new ArrayList<>();
for (int i = 0; i < cellGrid.length; i++) {
for (int j = 0; j < cellGrid[0].length; j++) {
if (!cellGrid[i][j].getPlace().getPlaceUpgrades().isEmpty()) {
importantCells.add(cellGrid[i][j]);
sortingCells.add(cellGrid[i][j]);
}
}
}
sortingCells.sort(Comparator.comparing(Cell::getPlaceName));
for (Cell c : sortingCells) {
GenericPlace place = c.getPlace();
worldRoomSB.append(getRoomEntry(!place.isAbleToBeUpgraded(), false, c, Main.game.getCharactersTreatingCellAsHome(c), place.getHourlyAffectionChange(), place.getHourlyObedienceChange()));
}
worldRoomSB.append("</div>");
return worldRoomSB.toString();
}
use of com.lilithsthrone.world.places.GenericPlace in project liliths-throne-public by Innoxia.
the class Generation method generateTestMap.
/*
* Take in grid where important places need to go
* Take in important places list
* Randomly place places into grid
* Generate new grid with IMPASSABLE padding - place important places at regular intervals
* Start from middle and explore grid until visited all original places, changing IMPASSABLE to generic path or dangerous path as you go
* cannot explore into corners
*/
public static Cell[][] generateTestMap(WorldType worldType, int x, int y, Cell[][] grid, int padding) {
int paddedCellSize = 2 * padding + 1;
Cell[][] paddedGrid = new Cell[(grid.length * paddedCellSize) - (2 * padding)][(grid[0].length * paddedCellSize) - (2 * padding)];
for (int i = 0; i < paddedGrid.length; i++) {
for (int j = 0; j < paddedGrid[0].length; j++) {
if (i % paddedCellSize == 0 && j % paddedCellSize == 0) {
paddedGrid[i][j] = grid[i / paddedCellSize][j / paddedCellSize];
} else {
paddedGrid[i][j] = new Cell(worldType, new Vector2i(i, j));
paddedGrid[i][j].setPlace(new GenericPlace(PlaceType.GENERIC_IMPASSABLE));
}
}
}
int totalMajorPlaces = grid.length * grid[0].length;
List<Vector2i> discoveredMajorPlaces = new ArrayList<>();
return recursiveGenerateTestMap(worldType, (paddedGrid.length / 2) + 1, (paddedGrid[0].length / 2) + 1, paddedGrid, totalMajorPlaces, discoveredMajorPlaces);
}
use of com.lilithsthrone.world.places.GenericPlace in project liliths-throne-public by Innoxia.
the class Generation method recursiveGenerateTestMap.
private static Cell[][] recursiveGenerateTestMap(WorldType worldType, int x, int y, Cell[][] grid, int totalMajorPlaces, List<Vector2i> discoveredMajorPlaces) {
if (totalMajorPlaces == discoveredMajorPlaces.size()) {
return grid;
}
Random rnd = new Random();
int width = grid.length;
int height = grid[0].length;
// randomise this order:
int[] direction = { 1, 2, 3, 4 };
for (int i = direction.length - 1; i > 0; i--) {
int index = rnd.nextInt(i + 1);
// Simple swap
int a = direction[index];
direction[index] = direction[i];
direction[i] = a;
}
for (Integer index : direction) {
switch(index) {
case // West
1:
if (x - 1 >= 0 && y >= 0 && y <= height - 1) {
if (!isCorner(x - 1, y, grid) && grid[x - 1][y].getPlace().getPlaceType() == PlaceType.GENERIC_IMPASSABLE) {
grid[x - 1][y].setPlace(new GenericPlace(worldType.getStandardPlace()));
recursiveGenerateTestMap(worldType, x - 1, y, grid, totalMajorPlaces, discoveredMajorPlaces);
} else if (grid[x - 1][y].getPlace().getPlaceType() != worldType.getStandardPlace()) {
if (!discoveredMajorPlaces.contains(new Vector2i(x - 1, y))) {
discoveredMajorPlaces.add(new Vector2i(x - 1, y));
recursiveGenerateTestMap(worldType, x - 1, y, grid, totalMajorPlaces, discoveredMajorPlaces);
}
}
}
break;
case // East
2:
if (x + 1 <= width - 1 && y >= 0 && y <= height - 1) {
if (!isCorner(x + 1, y, grid) && grid[x + 1][y].getPlace().getPlaceType() == PlaceType.GENERIC_IMPASSABLE) {
grid[x + 1][y].setPlace(new GenericPlace(worldType.getStandardPlace()));
recursiveGenerateTestMap(worldType, x + 1, y, grid, totalMajorPlaces, discoveredMajorPlaces);
} else if (grid[x + 1][y].getPlace().getPlaceType() != worldType.getStandardPlace()) {
if (!discoveredMajorPlaces.contains(new Vector2i(x + 1, y))) {
discoveredMajorPlaces.add(new Vector2i(x + 1, y));
recursiveGenerateTestMap(worldType, x + 1, y, grid, totalMajorPlaces, discoveredMajorPlaces);
}
}
}
break;
case // South
3:
if (y - 1 >= 0 && x >= 0 && x <= width - 1) {
if (!isCorner(x, y - 1, grid) && grid[x][y - 1].getPlace().getPlaceType() == PlaceType.GENERIC_IMPASSABLE) {
grid[x][y - 1].setPlace(new GenericPlace(worldType.getStandardPlace()));
recursiveGenerateTestMap(worldType, x, y - 1, grid, totalMajorPlaces, discoveredMajorPlaces);
} else if (grid[x][y - 1].getPlace().getPlaceType() != worldType.getStandardPlace()) {
if (!discoveredMajorPlaces.contains(new Vector2i(x, y - 1))) {
discoveredMajorPlaces.add(new Vector2i(x, y - 1));
recursiveGenerateTestMap(worldType, x, y - 1, grid, totalMajorPlaces, discoveredMajorPlaces);
}
}
}
break;
case // North
4:
if (y + 1 <= height - 1 && x >= 0 && x <= width - 1) {
if (!isCorner(x, y + 1, grid) && grid[x][y + 1].getPlace().getPlaceType() == PlaceType.GENERIC_IMPASSABLE) {
grid[x][y + 1].setPlace(new GenericPlace(worldType.getStandardPlace()));
recursiveGenerateTestMap(worldType, x, y + 1, grid, totalMajorPlaces, discoveredMajorPlaces);
} else if (grid[x][y + 1].getPlace().getPlaceType() != worldType.getStandardPlace()) {
if (!discoveredMajorPlaces.contains(new Vector2i(x, y + 1))) {
discoveredMajorPlaces.add(new Vector2i(x, y + 1));
recursiveGenerateTestMap(worldType, x, y + 1, grid, totalMajorPlaces, discoveredMajorPlaces);
}
}
}
break;
}
}
System.out.println(discoveredMajorPlaces.size());
return grid;
}
Aggregations