mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Style fixes
A bunch of style fixes. Mostly white space and style import order tweaks, but a few other stylistic changes are present too.
This commit is contained in:
92
ItemList.py
92
ItemList.py
@@ -1,13 +1,14 @@
|
||||
from Items import ItemFactory
|
||||
from Fill import fill_restrictive
|
||||
from collections import namedtuple
|
||||
import random
|
||||
|
||||
from Items import ItemFactory
|
||||
from Fill import fill_restrictive
|
||||
|
||||
#This file sets the item pools for various modes. Timed modes and triforce hunt are enforced first, and then extra items are specified per mode to fill in the remaining space.
|
||||
#Some basic items that various modes require are placed here, including pendants and crystals. Medallion requirements for the two relevant entrances are also decided.
|
||||
|
||||
alwaysitems = ['Bombos', 'Book of Mudora', 'Bow', 'Cane of Somaria', 'Ether', 'Fire Rod', 'Flippers', 'Ocarina', 'Hammer', 'Hookshot', 'Ice Rod', 'Lamp',
|
||||
'Cape', 'Magic Powder', 'Mushroom', 'Pegasus Boots', 'Quake', 'Shovel', 'Bug Catching Net', 'Cane of Byrna']
|
||||
'Cape', 'Magic Powder', 'Mushroom', 'Pegasus Boots', 'Quake', 'Shovel', 'Bug Catching Net', 'Cane of Byrna']
|
||||
progressivegloves = ['Progressive Glove'] * 2
|
||||
basicgloves = ['Power Glove', 'Titans Mitts']
|
||||
|
||||
@@ -15,7 +16,7 @@ normalbottles = ['Bottle', 'Bottle (Red Potion)', 'Bottle (Green Potion)', 'Bott
|
||||
hardbottles = ['Bottle', 'Bottle (Red Potion)', 'Bottle (Green Potion)', 'Bottle (Blue Potion)', 'Bottle (Bee)', 'Bottle (Good Bee)']
|
||||
|
||||
normalbaseitems = (['Blue Boomerang', 'Red Boomerang', 'Silver Arrows', 'Magic Upgrade (1/2)'] + ['Rupees (300)'] * 4 +
|
||||
['Single Arrow', 'Sanctuary Heart Container', 'Arrow Upgrade (+10)', 'Bomb Upgrade (+10)'] + ['Boss Heart Container'] * 10 + ['Piece of Heart'] * 24)
|
||||
['Single Arrow', 'Sanctuary Heart Container', 'Arrow Upgrade (+10)', 'Bomb Upgrade (+10)'] + ['Boss Heart Container'] * 10 + ['Piece of Heart'] * 24)
|
||||
normalfirst15extra = ['Rupees (100)', 'Rupees (300)', 'Rupees (50)'] + ['Arrow Upgrade (+5)'] * 6 + ['Bomb Upgrade (+5)'] * 6
|
||||
normalsecond15extra = ['Bombs (3)'] * 10 + ['Rupees (50)'] * 2 + ['Arrows (10)'] * 2 + ['Rupee (1)']
|
||||
normalthird10extra = ['Rupees (50)'] * 4 + ['Rupees (20)'] * 3 + ['Arrows (10)', 'Rupee (1)', 'Rupees (5)']
|
||||
@@ -24,7 +25,7 @@ normalfinal25extra = ['Rupees (20)'] * 23 + ['Rupees (5)'] * 2
|
||||
|
||||
|
||||
easybaseitems = (['Blue Boomerang', 'Red Boomerang', 'Silver Arrows'] + ['Rupees (300)'] * 4 + ['Magic Upgrade (1/2)'] * 2 + ['Lamp'] * 2 +
|
||||
['Single Arrow', 'Sanctuary Heart Container'] + ['Boss Heart Container'] * 10 + ['Piece of Heart'] * 12)
|
||||
['Single Arrow', 'Sanctuary Heart Container'] + ['Boss Heart Container'] * 10 + ['Piece of Heart'] * 12)
|
||||
easyextra = ['Piece of Heart'] * 12 + ['Rupees (300)']
|
||||
easylimitedextra = ['Boss Heart Container'] * 3 # collapsing down the 12 pieces of heart
|
||||
easyfirst15extra = ['Rupees (100)', 'Arrow Upgrade (+10)', 'Bomb Upgrade (+10)'] + ['Arrow Upgrade (+5)'] * 6 + ['Bomb Upgrade (+5)'] * 6
|
||||
@@ -34,21 +35,21 @@ easyfinal25extra = ['Rupees (50)'] * 4 + ['Rupees (20)'] * 14 + ['Rupee (1)'] +
|
||||
easytimedotherextra = ['Red Clock'] * 5
|
||||
|
||||
hardbaseitems = (['Silver Arrows', 'Single Arrow'] + ['Rupees (300)'] + ['Rupees (100)'] * 2 + ['Rupees (50)'] + ['Bombs (3)'] +
|
||||
['Boss Heart Container'] * 5 + ['Piece of Heart'] * 24)
|
||||
['Boss Heart Container'] * 5 + ['Piece of Heart'] * 24)
|
||||
hardfirst20extra = ['Bombs (3)'] * 4 + ['Single Bomb'] * 4 + ['Rupees (5)'] * 5 + ['Rupee (1)'] * 2 + ['Rupees (100)'] + ['Rupees (50)'] * 4
|
||||
hardsecond20extra = ['Single Bomb'] * 4 + ['Rupees (5)'] * 10 + ['Rupees (20)'] * 2 + ['Rupee (1)'] * 3 + ['Arrows (10)']
|
||||
hardthird20extra = ['Arrows (10)'] * 4 + ['Rupees (20)'] * 3 + ['Rupees (5)'] * 3 + ['Single Bomb'] * 5 + ['Single Arrow'] * 5
|
||||
hardfinal20extra = ['Single Bomb'] * 4 + ['Rupees (5)'] * 2 + ['Single Arrow'] * 14
|
||||
|
||||
expertbaseitems = (['Single Arrow', 'Rupees (300)', 'Rupees (100)', 'Bombs (3)', 'Arrows (10)'] + ['Rupees (50)'] * 4 + ['Rupees (5)'] * 5 +
|
||||
['Rupees (20)'] + ['Single Bomb'] * 2 + ['Piece of Heart'] * 24)
|
||||
['Rupees (20)'] + ['Single Bomb'] * 2 + ['Piece of Heart'] * 24)
|
||||
expertfirst15extra = ['Single Bomb'] * 13 + ['Rupees (20)'] * 2
|
||||
expertsecond25extra = ['Single Bomb'] * 8 + ['Single Arrow'] * 9 + ['Rupees (20)'] * 3 + ['Rupee (1)'] * 5
|
||||
expertthird15extra = ['Rupees (5)'] * 5 + ['Single Bomb'] * 3 + ['Rupees (20)'] * 2 + ['Single Arrow'] * 5
|
||||
expertfinal25extra = ['Single Bomb'] * 4 + ['Rupees (20)'] * 3 + ['Single Arrow'] * 18
|
||||
|
||||
insanebaseitems = (['Single Arrow', 'Bombs (3)', 'Arrows (10)'] + ['Rupees (50)'] * 3 + ['Rupees (5)'] * 10 + ['Rupees (300)'] * 4 + ['Rupees (100)'] * 3 +
|
||||
['Rupee (1)'] * 4 + ['Single Bomb'] * 4)
|
||||
['Rupee (1)'] * 4 + ['Single Bomb'] * 4)
|
||||
insanefirst15extra = ['Single Bomb'] * 4 + ['Single Arrow'] * 4 + ['Rupee (1)'] * 4 + ['Rupees (300)'] + ['Rupees (100)'] + ['Rupees (50)']
|
||||
insanesecond25extra = ['Single Bomb'] * 7 + ['Single Arrow'] * 7 + ['Rupee (1)'] * 7 + ['Rupees (20)'] * 4
|
||||
insanethird10extra = ['Single Bomb'] * 3 + ['Single Arrow'] * 3 + ['Rupee (1)'] * 3 + ['Rupees (20)']
|
||||
@@ -56,29 +57,27 @@ insanefourth15extra = ['Single Bomb'] * 5 + ['Single Arrow'] * 5 + ['Rupee (1)']
|
||||
insanefinal25extra = ['Single Bomb'] * 2 + ['Single Arrow'] * 10 + ['Rupee (1)'] * 7 + ['Rupees (20)'] * 6
|
||||
|
||||
Difficulty = namedtuple('Difficulty',
|
||||
['baseitems', 'bottles', 'bottle_count','same_bottle', 'progressiveshield',
|
||||
'basicshield', 'progressivearmor', 'basicarmor', 'swordless',
|
||||
'progressivesword', 'basicsword', 'timedohko', 'timedother',
|
||||
'triforcehunt', 'triforce_pieces_required', 'conditional_extras',
|
||||
'extras'])
|
||||
['baseitems', 'bottles', 'bottle_count', 'same_bottle', 'progressiveshield',
|
||||
'basicshield', 'progressivearmor', 'basicarmor', 'swordless',
|
||||
'progressivesword', 'basicsword', 'timedohko', 'timedother',
|
||||
'triforcehunt', 'triforce_pieces_required', 'conditional_extras',
|
||||
'extras'])
|
||||
|
||||
TotalItemsToPlace = 153
|
||||
total_items_to_place = 153
|
||||
|
||||
def easy_conditional_extras(timer, goal, mode, pool, placed_items):
|
||||
extraitems = TotalItemsToPlace - len(pool) - len(placed_items)
|
||||
def easy_conditional_extras(timer, _goal, _mode, pool, placed_items):
|
||||
extraitems = total_items_to_place - len(pool) - len(placed_items)
|
||||
if extraitems < len(easyextra):
|
||||
return easylimitedextra
|
||||
if timer in ['timed', 'timed-countdown']:
|
||||
return easytimedotherextra
|
||||
return []
|
||||
|
||||
def no_conditonal_extras(*args):
|
||||
def no_conditonal_extras(*_args):
|
||||
return []
|
||||
|
||||
#def Difficulty(**kwargs):
|
||||
# protodifficulty._replace(**kwargs)
|
||||
|
||||
difficulties= {
|
||||
# pylint: disable=
|
||||
difficulties = {
|
||||
'normal': Difficulty(
|
||||
baseitems = normalbaseitems,
|
||||
bottles = normalbottles,
|
||||
@@ -96,7 +95,7 @@ difficulties= {
|
||||
triforcehunt = ['Triforce Piece'] * 30,
|
||||
triforce_pieces_required = 20,
|
||||
conditional_extras = no_conditonal_extras,
|
||||
extras = [normalfirst15extra,normalsecond15extra,normalthird10extra,normalfourth5extra,normalfinal25extra]
|
||||
extras = [normalfirst15extra, normalsecond15extra, normalthird10extra, normalfourth5extra, normalfinal25extra]
|
||||
),
|
||||
'easy': Difficulty(
|
||||
baseitems = easybaseitems,
|
||||
@@ -109,7 +108,7 @@ difficulties= {
|
||||
basicarmor = ['Blue Mail', 'Red Mail'] * 2,
|
||||
swordless = ['Rupees (20)'] * 8,
|
||||
progressivesword = ['Progressive Sword'] * 7,
|
||||
basicsword = ['Master Sword', 'Tempered Sword', 'Golden Sword'] *2 + ['Fighter Sword'],
|
||||
basicsword = ['Master Sword', 'Tempered Sword', 'Golden Sword'] *2 + ['Fighter Sword'],
|
||||
timedohko = ['Green Clock'] * 25,
|
||||
timedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 5, # +5 more Red Clocks if there is room
|
||||
triforcehunt = ['Triforce Piece'] * 30,
|
||||
@@ -178,7 +177,7 @@ difficulties= {
|
||||
|
||||
def generate_itempool(world):
|
||||
if (world.difficulty not in ['easy', 'normal', 'hard', 'expert', 'insane'] or world.goal not in ['ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals']
|
||||
or world.mode not in ['open', 'standard', 'swordless'] or world.timer not in ['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown'] or world.progressive not in ['on', 'off', 'random']):
|
||||
or world.mode not in ['open', 'standard', 'swordless'] or world.timer not in ['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown'] or world.progressive not in ['on', 'off', 'random']):
|
||||
raise NotImplementedError('Not supported yet')
|
||||
|
||||
world.push_item('Ganon', ItemFactory('Triforce'), False)
|
||||
@@ -217,19 +216,19 @@ 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=[]
|
||||
clock_mode=None
|
||||
treasure_hunt_count=None
|
||||
treasure_hunt_icon=None
|
||||
def get_pool_core(progressive, shuffle, difficulty, timer, goal, mode):
|
||||
pool = []
|
||||
placed_items = []
|
||||
clock_mode = None
|
||||
treasure_hunt_count = None
|
||||
treasure_hunt_icon = None
|
||||
|
||||
pool.extend(alwaysitems)
|
||||
|
||||
def wantProgressives():
|
||||
return random.choice([True, False]) if progressive == 'random' else progressive=='on'
|
||||
def want_progressives():
|
||||
return random.choice([True, False]) if progressive == 'random' else progressive == 'on'
|
||||
|
||||
if wantProgressives():
|
||||
if want_progressives():
|
||||
pool.extend(progressivegloves)
|
||||
else:
|
||||
pool.extend(basicgloves)
|
||||
@@ -253,17 +252,17 @@ def get_pool_core(progressive,shuffle,difficulty,timer, goal, mode):
|
||||
# all bottles, since only one bottle is available
|
||||
if diff.same_bottle:
|
||||
thisbottle = random.choice(diff.bottles)
|
||||
for i in range (diff.bottle_count):
|
||||
for _ in range(diff.bottle_count):
|
||||
if not diff.same_bottle:
|
||||
thisbottle = random.choice(diff.bottles)
|
||||
pool.append(thisbottle)
|
||||
|
||||
if wantProgressives():
|
||||
if want_progressives():
|
||||
pool.extend(diff.progressiveshield)
|
||||
else:
|
||||
pool.extend(diff.basicshield)
|
||||
|
||||
if wantProgressives():
|
||||
if want_progressives():
|
||||
pool.extend(diff.progressivearmor)
|
||||
else:
|
||||
pool.extend(diff.basicarmor)
|
||||
@@ -271,21 +270,21 @@ def get_pool_core(progressive,shuffle,difficulty,timer, goal, mode):
|
||||
if mode == 'swordless':
|
||||
pool.extend(diff.swordless)
|
||||
elif mode == 'standard':
|
||||
if wantProgressives():
|
||||
if want_progressives():
|
||||
placed_items.append(('Link\'s Uncle', 'Progressive Sword'))
|
||||
pool.extend(diff.progressivesword)
|
||||
else:
|
||||
placed_items.append(('Link\'s Uncle', 'Fighter Sword'))
|
||||
pool.extend(diff.basicsword)
|
||||
else:
|
||||
if wantProgressives():
|
||||
if want_progressives():
|
||||
pool.extend(diff.progressivesword)
|
||||
pool.extend(['Progressive Sword'])
|
||||
else:
|
||||
pool.extend(diff.basicsword)
|
||||
pool.extend(['Fighter Sword'])
|
||||
|
||||
extraitems = TotalItemsToPlace - len(pool) - len(placed_items)
|
||||
extraitems = total_items_to_place - len(pool) - len(placed_items)
|
||||
|
||||
if timer in ['timed', 'timed-countdown']:
|
||||
pool.extend(diff.timedother)
|
||||
@@ -306,8 +305,8 @@ def get_pool_core(progressive,shuffle,difficulty,timer, goal, mode):
|
||||
extraitems -= len(cond_extras)
|
||||
|
||||
for extra in diff.extras:
|
||||
if(extraitems > 0):
|
||||
pool.extend(extra )
|
||||
if extraitems > 0:
|
||||
pool.extend(extra)
|
||||
extraitems -= len(extra)
|
||||
|
||||
if goal == 'pedestal':
|
||||
@@ -315,19 +314,22 @@ def get_pool_core(progressive,shuffle,difficulty,timer, goal, mode):
|
||||
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.
|
||||
if __name__ == '__main__':
|
||||
def test():
|
||||
for difficulty in ['easy', 'normal', 'hard', 'expert', 'insane']:
|
||||
for goal in ['ganon', 'triforcehunt', 'pedestal']:
|
||||
for timer in ['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown']:
|
||||
for mode in ['open', 'standard', 'swordless']:
|
||||
for progressive in ['on','off']:
|
||||
for shuffle in ['full','insane']:
|
||||
for progressive in ['on', 'off']:
|
||||
for shuffle in ['full', 'insane']:
|
||||
out = get_pool_core(progressive, shuffle, difficulty, timer, goal, mode)
|
||||
count = len(out[0]) + len(out[1])
|
||||
|
||||
correct_count = TotalItemsToPlace
|
||||
correct_count = total_items_to_place
|
||||
if goal in ['pedestal']:
|
||||
# pedestal goals generate one extra item
|
||||
correct_count += 1
|
||||
|
||||
assert count == correct_count, "expected {0} items but found {1} items for {2}".format(correct_count, count, (progressive, shuffle, difficulty, timer, goal, mode))
|
||||
|
||||
if __name__ == '__main__':
|
||||
test()
|
||||
|
Reference in New Issue
Block a user