Custom item pool feature
This is the starting point for the new custom item pool feature that will let users specify the item pool. It is functional, perhaps due for some minor tweaking and definitely needs more testing. The command line side is bad, just two parameters that hopefully don't do anything under any circumstance if the user tries to use them (don't really intend to support a command line version of this feature); maybe there's a better way to let the command line ER work in general without having any opportunity to activate this feature. The GUI should probably show the user the sum of the current item pool out of 153 so the user knows how to size the item pool more easily, but that's a todo.
This commit is contained in:
151
ItemList.py
151
ItemList.py
@@ -213,7 +213,11 @@ def generate_itempool(world):
|
||||
world.get_location('Agahnim 2').event = True
|
||||
|
||||
# set up item pool
|
||||
(pool, placed_items, clock_mode, treasure_hunt_count, treasure_hunt_icon) = get_pool_core(world.progressive, world.shuffle, world.difficulty, world.timer, world.goal, world.mode)
|
||||
if world.custom:
|
||||
(pool, placed_items, clock_mode, treasure_hunt_count, treasure_hunt_icon) = make_custom_item_pool(world.progressive, world.shuffle, world.difficulty, world.timer, world.goal, world.mode, world.customitemarray)
|
||||
world.rupoor_cost = min(world.customitemarray[67], 9999)
|
||||
else:
|
||||
(pool, placed_items, clock_mode, treasure_hunt_count, treasure_hunt_icon) = get_pool_core(world.progressive, world.shuffle, world.difficulty, world.timer, world.goal, world.mode)
|
||||
world.itempool = ItemFactory(pool)
|
||||
for (location, item) in placed_items:
|
||||
world.push_item(location, ItemFactory(item), False)
|
||||
@@ -230,10 +234,10 @@ def generate_itempool(world):
|
||||
|
||||
# logic has some branches where having 4 hearts is one possible requirement (of several alternatives)
|
||||
# rather than making all hearts/heart pieces progression items (which slows down generation considerably)
|
||||
# We mark one random heart container as an advancement item (or 4 heart peices in expert mode)
|
||||
if world.difficulty in ['easy', 'normal', 'hard']:
|
||||
# We mark one random heart container as an advancement item (or 4 heart pieces in expert mode)
|
||||
if world.difficulty in ['easy', 'normal', 'hard'] and not (world.custom and world.customitemarray[30] == 0):
|
||||
[item for item in world.itempool if item.name == 'Boss Heart Container'][0].advancement = True
|
||||
elif world.difficulty in ['expert']:
|
||||
elif world.difficulty in ['expert'] and not (world.custom and world.customitemarray[29] < 4):
|
||||
adv_heart_pieces = [item for item in world.itempool if item.name == 'Piece of Heart'][0:4]
|
||||
for hp in adv_heart_pieces:
|
||||
hp.advancement = True
|
||||
@@ -253,7 +257,6 @@ def generate_itempool(world):
|
||||
|
||||
fill_restrictive(world, world.get_all_state(keys=True), crystal_locations, crystals)
|
||||
|
||||
|
||||
def get_pool_core(progressive, shuffle, difficulty, timer, goal, mode):
|
||||
pool = []
|
||||
placed_items = []
|
||||
@@ -351,6 +354,144 @@ def get_pool_core(progressive, shuffle, difficulty, timer, goal, mode):
|
||||
placed_items.append(('Master Sword Pedestal', 'Triforce'))
|
||||
return (pool, placed_items, clock_mode, treasure_hunt_count, treasure_hunt_icon)
|
||||
|
||||
def make_custom_item_pool(progressive, shuffle, difficulty, timer, goal, mode, customitemarray):
|
||||
pool = []
|
||||
placed_items = []
|
||||
clock_mode = None
|
||||
treasure_hunt_count = None
|
||||
treasure_hunt_icon = None
|
||||
|
||||
# Correct for insanely oversized item counts and take initial steps to handle undersized pools.
|
||||
for x in range(0, 64):
|
||||
if customitemarray[x] > total_items_to_place:
|
||||
customitemarray[x] = total_items_to_place
|
||||
if customitemarray[66] > total_items_to_place:
|
||||
customitemarray[66] = total_items_to_place
|
||||
itemtotal = 0
|
||||
for x in range(0, 64):
|
||||
itemtotal = itemtotal + customitemarray[x]
|
||||
itemtotal = itemtotal + customitemarray[66]
|
||||
|
||||
pool.extend(['Bow'] * customitemarray[0])
|
||||
pool.extend(['Silver Arrows']* customitemarray[1])
|
||||
pool.extend(['Blue Boomerang'] * customitemarray[2])
|
||||
pool.extend(['Red Boomerang'] * customitemarray[3])
|
||||
pool.extend(['Hookshot'] * customitemarray[4])
|
||||
pool.extend(['Mushroom'] * customitemarray[5])
|
||||
pool.extend(['Magic Powder'] * customitemarray[6])
|
||||
pool.extend(['Fire Rod'] * customitemarray[7])
|
||||
pool.extend(['Ice Rod'] * customitemarray[8])
|
||||
pool.extend(['Bombos'] * customitemarray[9])
|
||||
pool.extend(['Ether'] * customitemarray[10])
|
||||
pool.extend(['Quake'] * customitemarray[11])
|
||||
pool.extend(['Lamp'] * customitemarray[12])
|
||||
pool.extend(['Hammer'] * customitemarray[13])
|
||||
pool.extend(['Shovel'] * customitemarray[14])
|
||||
pool.extend(['Ocarina'] * customitemarray[15])
|
||||
pool.extend(['Bug Catching Net'] * customitemarray[16])
|
||||
pool.extend(['Book of Mudora'] * customitemarray[17])
|
||||
pool.extend(['Cane of Somaria'] * customitemarray[19])
|
||||
pool.extend(['Cane of Byrna'] * customitemarray[20])
|
||||
pool.extend(['Cape'] * customitemarray[21])
|
||||
pool.extend(['Pegasus Boots'] * customitemarray[23])
|
||||
pool.extend(['Power Glove'] * customitemarray[24])
|
||||
pool.extend(['Titans Mitts'] * customitemarray[25])
|
||||
pool.extend(['Progressive Glove'] * customitemarray[26])
|
||||
pool.extend(['Flippers'] * customitemarray[27])
|
||||
pool.extend(['Piece of Heart'] * customitemarray[29])
|
||||
pool.extend(['Boss Heart Container'] * customitemarray[30])
|
||||
pool.extend(['Sanctuary Heart Container'] * customitemarray[31])
|
||||
pool.extend(['Master Sword'] * customitemarray[33])
|
||||
pool.extend(['Tempered Sword'] * customitemarray[34])
|
||||
pool.extend(['Golden Sword'] * customitemarray[35])
|
||||
pool.extend(['Blue Shield'] * customitemarray[37])
|
||||
pool.extend(['Red Shield'] * customitemarray[38])
|
||||
pool.extend(['Mirror Shield'] * customitemarray[39])
|
||||
pool.extend(['Progressive Shield'] * customitemarray[40])
|
||||
pool.extend(['Blue Mail'] * customitemarray[41])
|
||||
pool.extend(['Red Mail'] * customitemarray[42])
|
||||
pool.extend(['Progressive Armor'] * customitemarray[43])
|
||||
pool.extend(['Magic Upgrade (1/2)'] * customitemarray[44])
|
||||
pool.extend(['Magic Upgrade (1/4)'] * customitemarray[45])
|
||||
pool.extend(['Bomb Upgrade (+5)'] * customitemarray[46])
|
||||
pool.extend(['Bomb Upgrade (+10)'] * customitemarray[47])
|
||||
pool.extend(['Arrow Upgrade (+5)'] * customitemarray[48])
|
||||
pool.extend(['Arrow Upgrade (+10)'] * customitemarray[49])
|
||||
pool.extend(['Single Arrow'] * customitemarray[50])
|
||||
pool.extend(['Arrows (10)'] * customitemarray[51])
|
||||
pool.extend(['Single Bomb'] * customitemarray[52])
|
||||
pool.extend(['Bombs (3)'] * customitemarray[53])
|
||||
pool.extend(['Rupee (1)'] * customitemarray[54])
|
||||
pool.extend(['Rupees (5)'] * customitemarray[55])
|
||||
pool.extend(['Rupees (20)'] * customitemarray[56])
|
||||
pool.extend(['Rupees (50)'] * customitemarray[57])
|
||||
pool.extend(['Rupees (100)'] * customitemarray[58])
|
||||
pool.extend(['Rupees (300)'] * customitemarray[59])
|
||||
pool.extend(['Rupoor'] * customitemarray[60])
|
||||
pool.extend(['Blue Clock'] * customitemarray[61])
|
||||
pool.extend(['Green Clock'] * customitemarray[62])
|
||||
pool.extend(['Red Clock'] * customitemarray[63])
|
||||
pool.extend(['Triforce Piece'] * customitemarray[64])
|
||||
pool.extend(['Triforce'] * customitemarray[66])
|
||||
|
||||
diff = difficulties[difficulty]
|
||||
|
||||
# expert+ difficulties produce the same contents for
|
||||
# all bottles, since only one bottle is available
|
||||
if diff.same_bottle:
|
||||
thisbottle = random.choice(diff.bottles)
|
||||
for _ in range(customitemarray[18]):
|
||||
if not diff.same_bottle:
|
||||
thisbottle = random.choice(diff.bottles)
|
||||
pool.append(thisbottle)
|
||||
|
||||
if customitemarray[64] > 0 or customitemarray[65] > 0:
|
||||
treasure_hunt_count = max(min(customitemarray[65], 99), 1) #To display, count must be between 1 and 99.
|
||||
treasure_hunt_icon = 'Triforce Piece'
|
||||
# Ensure game is always possible to complete here, force sufficient pieces if the player is unwilling.
|
||||
if (customitemarray[64] < treasure_hunt_count) and (goal == 'triforcehunt') and (customitemarray[66] == 0):
|
||||
extrapieces = treasure_hunt_count - customitemarray[64]
|
||||
pool.extend(['Triforce Piece'] * extrapieces)
|
||||
itemtotal = itemtotal + extrapieces
|
||||
|
||||
if timer in ['display', 'timed', 'timed-countdown']:
|
||||
clock_mode = 'countdown' if timer == 'timed-countdown' else 'stopwatch'
|
||||
elif timer == 'timed-ohko':
|
||||
clock_mode = 'countdown-ohko'
|
||||
elif timer == 'ohko':
|
||||
clock_mode = 'ohko'
|
||||
|
||||
if goal == 'pedestal':
|
||||
placed_items.append(('Master Sword Pedestal', 'Triforce'))
|
||||
itemtotal = itemtotal + 1
|
||||
|
||||
if mode == 'standard':
|
||||
if progressive == 'off':
|
||||
placed_items.append(('Link\'s Uncle', 'Fighter Sword'))
|
||||
pool.extend(['Fighter Sword'] * max((customitemarray[32] - 1), 0))
|
||||
pool.extend(['Progressive Sword'] * customitemarray[36])
|
||||
else:
|
||||
placed_items.append(('Link\'s Uncle', 'Progressive Sword'))
|
||||
pool.extend(['Fighter Sword'] * customitemarray[32])
|
||||
pool.extend(['Progressive Sword'] * max((customitemarray[36] - 1), 0))
|
||||
else:
|
||||
pool.extend(['Fighter Sword'] * customitemarray[32])
|
||||
pool.extend(['Progressive Sword'] * customitemarray[36])
|
||||
|
||||
if shuffle == 'insanity':
|
||||
placed_items.append(('Link\'s House', 'Magic Mirror'))
|
||||
placed_items.append(('Sanctuary', 'Moon Pearl'))
|
||||
pool.extend(['Magic Mirror'] * max((customitemarray[22] -1 ), 0))
|
||||
pool.extend(['Moon Pearl'] * max((customitemarray[28] - 1), 0))
|
||||
else:
|
||||
pool.extend(['Magic Mirror'] * customitemarray[22])
|
||||
pool.extend(['Moon Pearl'] * customitemarray[28])
|
||||
|
||||
if itemtotal < total_items_to_place:
|
||||
pool.extend(['Nothing'] * (total_items_to_place - itemtotal))
|
||||
|
||||
return (pool, placed_items, clock_mode, treasure_hunt_count, treasure_hunt_icon)
|
||||
|
||||
# A quick test to ensure all combinations generate the correct amount of items.
|
||||
def test():
|
||||
for difficulty in ['easy', 'normal', 'hard', 'expert', 'insane']:
|
||||
|
||||
Reference in New Issue
Block a user