Core: convert mixture of Plando Options and Settings into just Options

This commit is contained in:
Fabian Dill
2023-01-17 17:25:59 +01:00
committed by Fabian Dill
parent c839a76fe7
commit 02d3eef565
9 changed files with 42 additions and 42 deletions

View File

@@ -113,8 +113,8 @@ class TestPlandoBosses(unittest.TestCase):
"""Test automatic singularity mode"""
self.assertIn(";singularity", MultiBosses.from_any("b2").value)
def testPlandoSettings(self):
"""Test that plando settings verification works"""
def testPlandoOptions(self):
"""Test that plando options verification works"""
plandoed_string = "l1-b2;l2-b1"
mixed_string = "l1-b2;shuffle"
regular_string = "shuffle"
@@ -123,14 +123,14 @@ class TestPlandoBosses(unittest.TestCase):
regular = MultiBosses.from_any(regular_string)
# plando should work with boss plando
plandoed.verify(None, "Player", Generate.PlandoSettings.bosses)
plandoed.verify(None, "Player", Generate.PlandoOptions.bosses)
self.assertTrue(plandoed.value.startswith(plandoed_string))
# plando should fall back to default without boss plando
plandoed.verify(None, "Player", Generate.PlandoSettings.items)
plandoed.verify(None, "Player", Generate.PlandoOptions.items)
self.assertEqual(plandoed, MultiBosses.option_vanilla)
# mixed should fall back to mode
mixed.verify(None, "Player", Generate.PlandoSettings.items) # should produce a warning and still work
mixed.verify(None, "Player", Generate.PlandoOptions.items) # should produce a warning and still work
self.assertEqual(mixed, MultiBosses.option_shuffle)
# mode stuff should just work
regular.verify(None, "Player", Generate.PlandoSettings.items)
regular.verify(None, "Player", Generate.PlandoOptions.items)
self.assertEqual(regular, MultiBosses.option_shuffle)

View File

@@ -10,7 +10,7 @@ from rando.ItemLocContainer import ItemLocation
# Holds settings not related to graph layout.
class RandoSettings(object):
def __init__(self, maxDiff, progSpeed, progDiff, qty, restrictions,
superFun, runtimeLimit_s, plandoSettings, minDiff):
superFun, runtimeLimit_s, PlandoOptions, minDiff):
self.progSpeed = progSpeed.lower()
self.progDiff = progDiff.lower()
self.maxDiff = maxDiff
@@ -20,7 +20,7 @@ class RandoSettings(object):
self.runtimeLimit_s = runtimeLimit_s
if self.runtimeLimit_s <= 0:
self.runtimeLimit_s = sys.maxsize
self.plandoSettings = plandoSettings
self.PlandoOptions = PlandoOptions
self.minDiff = minDiff
def getSuperFun(self):
@@ -30,7 +30,7 @@ class RandoSettings(object):
self.superFun = superFun[:]
def isPlandoRando(self):
return self.plandoSettings is not None
return self.PlandoOptions is not None
def getItemManager(self, smbm, nLocs):
if not self.isPlandoRando():
@@ -43,20 +43,20 @@ class RandoSettings(object):
return None
exclude = {'alreadyPlacedItems': defaultdict(int), 'forbiddenItems': []}
# locsItems is a dict {'loc name': 'item type'}
for locName,itemType in self.plandoSettings["locsItems"].items():
for locName,itemType in self.PlandoOptions["locsItems"].items():
if not any(loc.Name == locName for loc in locations):
continue
exclude['alreadyPlacedItems'][itemType] += 1
exclude['alreadyPlacedItems']['total'] += 1
exclude['forbiddenItems'] = self.plandoSettings['forbiddenItems']
exclude['forbiddenItems'] = self.PlandoOptions['forbiddenItems']
return exclude
def collectAlreadyPlacedItemLocations(self, container):
if not self.isPlandoRando():
return
for locName,itemType in self.plandoSettings["locsItems"].items():
for locName,itemType in self.PlandoOptions["locsItems"].items():
if not any(loc.Name == locName for loc in container.unusedLocations):
continue
item = container.getNextItemInPool(itemType)

View File

@@ -621,7 +621,7 @@ class VariaRandomizer:
self.ctrlDict = { getattr(ctrl, button) : button for button in ctrlButton }
args.moonWalk = ctrl.Moonwalk
plandoSettings = None
PlandoOptions = None
if args.plandoRando is not None:
forceArg('progressionSpeed', 'speedrun', "'Progression Speed' forced to speedrun")
progSpeed = 'speedrun'
@@ -632,10 +632,10 @@ class VariaRandomizer:
args.plandoRando = json.loads(args.plandoRando)
RomPatches.ActivePatches[self.player] = args.plandoRando["patches"]
DoorsManager.unserialize(args.plandoRando["doors"])
plandoSettings = {"locsItems": args.plandoRando['locsItems'], "forbiddenItems": args.plandoRando['forbiddenItems']}
PlandoOptions = {"locsItems": args.plandoRando['locsItems'], "forbiddenItems": args.plandoRando['forbiddenItems']}
randoSettings = RandoSettings(self.maxDifficulty, progSpeed, progDiff, qty,
restrictions, args.superFun, args.runtimeLimit_s,
plandoSettings, minDifficulty)
PlandoOptions, minDifficulty)
# print some parameters for jm's stats
if args.jm == True: