Add "exclude" to item links (#497)

This commit is contained in:
CaitSith2
2022-05-11 16:37:18 -07:00
committed by GitHub
parent 977159e572
commit 3f691d6977
2 changed files with 11 additions and 2 deletions

View File

@@ -5,10 +5,9 @@ import numbers
import typing
import random
from schema import Schema, And, Or
from schema import Schema, And, Or, Optional
from Utils import get_fuzzy_results
class AssembleOptions(abc.ABCMeta):
def __new__(mcs, name, bases, attrs):
options = attrs["options"] = {}
@@ -642,6 +641,7 @@ class ItemLinks(OptionList):
{
"name": And(str, len),
"item_pool": [And(str, len)],
Optional("exclude"): [And(str, len)],
"replacement_item": Or(And(str, len), None)
}
])
@@ -657,6 +657,11 @@ class ItemLinks(OptionList):
if item_name not in world.item_names and item_name not in world.item_name_groups:
raise Exception(f"Item {item_name} from item link {link} "
f"is not a valid item name from {world.game}")
if "exclude" in link:
for item_name in link["exclude"]:
if item_name not in world.item_names and item_name not in world.item_name_groups:
raise Exception(f"Item {item_name} from item link {link} "
f"is not a valid item name from {world.game}")
if link["replacement_item"] and link["replacement_item"] not in world.item_names:
raise Exception(f"Item {link['replacement_item']} from item link {link} "
f"is not a valid item name from {world.game}")