Skip to content

Commit

Permalink
Backside door randomization
Browse files Browse the repository at this point in the history
  • Loading branch information
thezerothcat committed Nov 6, 2018
1 parent a1a0729 commit cf5c992
Show file tree
Hide file tree
Showing 27 changed files with 1,724 additions and 185 deletions.
4 changes: 4 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ https://github.com/thezerothcat/LaMulanaRandomizer/wiki

Note: The randomizer is not yet compatible with Java 9+, so you will need Java 8 in order to run it.

1.42:
-----------------------------
Randomized backside doors so that any front-side door can lead to any back-side door.

1.41:
-----------------------------
Minor logic updates and more inclusive subweapon pot randomization.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>lmr.randomizer</groupId>
<artifactId>randomizer</artifactId>
<version>1.41.0</version>
<version>1.42.0</version>
<name>La-Mulana Remake Randomizer</name>
<description>La-Mulana Remake Randomizer</description>
<packaging>jar</packaging>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/lmr/randomizer/DataFromFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public final class DataFromFile {
"Shop 9 (Sun) Item 1", "Shop 11 (Moonlight) Item 1", "Shop 12 Alt (Spring) Item 3", "Shop 13 (Goddess) Item 1",
"Shop 14 (Inferno) Item 1", "Shop 15 (Ruin) Item 1", "Shop 17 (Birth) Item 2", "Shop 18 (Lil Bro) Item 1",
"Shop 19 (Big Bro) Item 1", "Shop 20 (Twin Labs) Item 1", "Shop 21 (Unsolvable) Item 1");
public static final List<String> GUARDIAN_DEFEATED_EVENTS = Arrays.asList("Event: Amphisbaena Defeated",
"Event: Sakit Defeated", "Event: Ellmac Defeated", "Event: Bahamut Defeated", "Event: Viy Defeated",
"Event: Palenque Defeated", "Event: Baphomet Defeated", "Event: Tiamat Defeated");
public static List<Integer> RANDOM_ITEM_GRAPHICS = Arrays.asList(1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15,
18, 19, 20, 21, 24, 25, 26, 27, 28, 29, 32, 33, 38, 39, 41, 42, 43, 44, 45, 47, 48, 49, 51, 52, 53, 54,
55, 56, 5, 58, 59, 60, 61, 63, 64, 65, 66, 67, 68, 69, 73, 76, 91, 96, 97, 98, 99, 100, 102, 103, 104);
Expand Down Expand Up @@ -318,7 +321,7 @@ public static Map<String, NodeWithRequirements> getMapOfNodeNameToRequirementsOb
FileUtils.populateRequirements(mapOfNodeNameToRequirementsObject, "requirement/event_reqs.txt", true);
FileUtils.populateRequirements(mapOfNodeNameToRequirementsObject, "requirement/shop_reqs.txt", true);
FileUtils.populateRequirements(mapOfNodeNameToRequirementsObject, "requirement/attack_reqs.txt", true);
FileUtils.populateRequirements(mapOfNodeNameToRequirementsObject, "requirement/dead_ends.txt", true); // todo: remove this when dead ends are handled better
FileUtils.populateRequirements(mapOfNodeNameToRequirementsObject, "requirement/dead_ends.txt", true);
if(!Settings.getEnabledGlitches().isEmpty()) {
FileUtils.populateRequirements(mapOfNodeNameToRequirementsObject, "requirement/glitch/location_reqs.txt", true);
FileUtils.populateRequirements(mapOfNodeNameToRequirementsObject, "requirement/glitch/item_reqs.txt", true);
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/lmr/randomizer/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Created by thezerothcat on 7/10/2017.
*/
public class FileUtils {
public static final String VERSION = "1.41.0";
public static final String VERSION = "1.42.0";

private static BufferedWriter logWriter;
private static final List<String> KNOWN_RCD_FILE_HASHES = new ArrayList<>();
Expand Down Expand Up @@ -423,6 +423,9 @@ else if(line.startsWith("allowSubweaponStart")) {
else if(line.startsWith("randomizeCursedChests")) {
Settings.setRandomizeCursedChests(Boolean.valueOf(line.split("=")[1]), false);
}
else if(line.startsWith("randomizeBacksideDoors")) {
Settings.setRandomizeBacksideDoors(Boolean.valueOf(line.split("=")[1]), false);
}
else if(line.startsWith("replaceMapsWithWeights")) {
Settings.setReplaceMapsWithWeights(Boolean.valueOf(line.split("=")[1]), false);
}
Expand Down Expand Up @@ -521,6 +524,9 @@ public static void saveSettings() throws IOException {
writer.write(String.format("randomizeCursedChests=%s", Settings.isRandomizeCursedChests()));
writer.newLine();

writer.write(String.format("randomizeBacksideDoors=%s", Settings.isRandomizeBacksideDoors()));
writer.newLine();

writer.write(String.format("replaceMapsWithWeights=%s", Settings.isReplaceMapsWithWeights()));
writer.newLine();

Expand Down
21 changes: 17 additions & 4 deletions src/main/java/lmr/randomizer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -761,9 +761,11 @@ protected static void doTheThing(ProgressDialog dialog) throws Exception {

ItemRandomizer itemRandomizer = new ItemRandomizer();
ShopRandomizer shopRandomizer = buildShopRandomizer(itemRandomizer);
AccessChecker accessChecker = buildAccessChecker(itemRandomizer, shopRandomizer);
BacksideDoorRandomizer backsideDoorRandomizer = new BacksideDoorRandomizer();
AccessChecker accessChecker = buildAccessChecker(itemRandomizer, shopRandomizer, backsideDoorRandomizer);
accessChecker.initExitRequirements();

backsideDoorRandomizer.determineBacksideDoors(random);
List<String> startingNodes = getStartingNodes(Settings.isSubweaponOnly());

if(!initiallyAccessibleItems.isEmpty()) {
Expand Down Expand Up @@ -809,6 +811,11 @@ protected static void doTheThing(ProgressDialog dialog) throws Exception {
accessChecker.computeAccessibleNodes(startingNode);
}

// Add backside door nodes - we didn't need these for initially-accessible stuff since that can't require boss fights
for(String startingNode : backsideDoorRandomizer.getSettingNodes()) {
accessChecker.computeAccessibleNodes(startingNode);
}

boolean ankhJewelLock = false;
if(accessChecker.getQueuedUpdates().isEmpty()) {
if (!accessChecker.updateForBosses(attempt)) {
Expand Down Expand Up @@ -846,7 +853,7 @@ protected static void doTheThing(ProgressDialog dialog) throws Exception {
FileUtils.flush();

dialog.updateProgress(85, Translations.getText("progress.spoiler"));
outputLocations(itemRandomizer, shopRandomizer, attempt);
outputLocations(itemRandomizer, shopRandomizer, backsideDoorRandomizer, attempt);

dialog.updateProgress(90, Translations.getText("progress.read"));

Expand All @@ -864,6 +871,10 @@ protected static void doTheThing(ProgressDialog dialog) throws Exception {
GameDataTracker.updateSubweaponPot(availableSubweapons.get(random.nextInt(availableSubweapons.size())));
}

if(Settings.isRandomizeBacksideDoors()) {
backsideDoorRandomizer.updateBacksideDoors();
}

// if(Settings.isRandomizeMantras()) {
// GameDataTracker.randomizeMantras(random);
// }
Expand Down Expand Up @@ -1189,10 +1200,11 @@ private static ShopRandomizer buildShopRandomizer(ItemRandomizer itemRandomizer)
return shopRandomizer;
}

private static AccessChecker buildAccessChecker(ItemRandomizer itemRandomizer, ShopRandomizer shopRandomizer) {
private static AccessChecker buildAccessChecker(ItemRandomizer itemRandomizer, ShopRandomizer shopRandomizer, BacksideDoorRandomizer backsideDoorRandomizer) {
AccessChecker accessChecker = new AccessChecker();
accessChecker.setItemRandomizer(itemRandomizer);
accessChecker.setShopRandomizer(shopRandomizer);
accessChecker.setBacksideDoorRandomizer(backsideDoorRandomizer);
itemRandomizer.setAccessChecker(accessChecker);
shopRandomizer.setAccessChecker(accessChecker);
return accessChecker;
Expand Down Expand Up @@ -1397,9 +1409,10 @@ else if(removedItem.startsWith("Sacred Orb")) {
Settings.setSubweaponOnly(isSubweaponOnly());
}

private static void outputLocations(ItemRandomizer itemRandomizer, ShopRandomizer shopRandomizer, int attempt) throws IOException {
private static void outputLocations(ItemRandomizer itemRandomizer, ShopRandomizer shopRandomizer, BacksideDoorRandomizer backsideDoorRandomizer, int attempt) throws IOException {
itemRandomizer.outputLocations(attempt);
shopRandomizer.outputLocations(attempt);
backsideDoorRandomizer.outputLocations(attempt);
if (!Settings.getCurrentRemovedItems().isEmpty() || !Settings.getRemovedItems().isEmpty()) {
BufferedWriter writer = FileUtils.getFileWriter(String.format("%s/removed_items.txt", Settings.getStartingSeed()));
if (writer == null) {
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/lmr/randomizer/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public final class Settings {
private boolean allowSubweaponStart;
private boolean subweaponOnly;
private boolean randomizeCursedChests;
private boolean randomizeBacksideDoors;
private boolean replaceMapsWithWeights;
private boolean automaticGrailPoints;
private boolean automaticTranslations;
Expand Down Expand Up @@ -97,6 +98,7 @@ private Settings() {
allowSubweaponStart = false;
subweaponOnly = false;
randomizeCursedChests = false;
randomizeBacksideDoors = false;
removeSpaulder = false;
replaceMapsWithWeights = false;
automaticHardmode = false;
Expand Down Expand Up @@ -388,6 +390,17 @@ public static void setRandomizeCursedChests(boolean randomizeCursedChests, boole
singleton.randomizeCursedChests = randomizeCursedChests;
}

public static boolean isRandomizeBacksideDoors() {
return singleton.randomizeBacksideDoors;
}

public static void setRandomizeBacksideDoors(boolean randomizeBacksideDoors, boolean update) {
if(update && randomizeBacksideDoors != singleton.randomizeBacksideDoors) {
singleton.changed = true;
}
singleton.randomizeBacksideDoors = randomizeBacksideDoors;
}

public static boolean isReplaceMapsWithWeights() { return singleton.replaceMapsWithWeights; }

public static void setReplaceMapsWithWeights(boolean replaceMapsWithWeights, boolean update) {
Expand Down Expand Up @@ -716,6 +729,7 @@ public static String generateShortString() {
BiFunction<Boolean, Integer, Integer> processBooleanFlag = (Boolean b, Integer flagIndex) -> boolToInt(b) << flagIndex;

int booleanSettings = 0;
booleanSettings |= processBooleanFlag.apply(singleton.randomizeBacksideDoors, 20);
booleanSettings |= processBooleanFlag.apply(singleton.ushumgalluAssist, 19);
booleanSettings |= processBooleanFlag.apply(singleton.allowSubweaponStart, 18);
booleanSettings |= processBooleanFlag.apply(singleton.requireFullAccess, 17);
Expand Down Expand Up @@ -792,6 +806,7 @@ public static void importShortString(String text) {

BiFunction<Integer, Integer, Boolean> getBoolFlagFromInt = (startingVal, flagIdx) -> intToBool((startingVal >> flagIdx) & 0x1);

singleton.randomizeBacksideDoors = getBoolFlagFromInt.apply(booleanSettingsFlag, 20);
singleton.ushumgalluAssist = getBoolFlagFromInt.apply(booleanSettingsFlag, 19);
singleton.allowSubweaponStart = getBoolFlagFromInt.apply(booleanSettingsFlag, 18);
singleton.requireFullAccess = getBoolFlagFromInt.apply(booleanSettingsFlag, 17);
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/lmr/randomizer/Translations.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package lmr.randomizer;

import lmr.randomizer.FileUtils;
import lmr.randomizer.Settings;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -138,6 +135,10 @@ else if(itemName.startsWith("Map (")) {
translation);
}

public static String getDoorLocation(String doorName) {
return getText("doors." + doorName.replace("Location: ", "").replaceAll("[ \\[\\]]", ""));
}

private static String getMapLocationText(String locationKey) {
return getText("locations." + locationKey.replaceAll("[ ']", ""));
}
Expand Down
Loading

0 comments on commit cf5c992

Please sign in to comment.