Merge branch 'main' into breaking_changes

# Conflicts:
#	BaseClasses.py
#	Mystery.py
#	WebHostLib/downloads.py
#	WebHostLib/models.py
#	WebHostLib/templates/macros.html
#	WebHostLib/upload.py
#	worlds/alttp/ItemPool.py
#	worlds/alttp/Main.py
This commit is contained in:
Fabian Dill
2021-01-17 06:50:25 +01:00
35 changed files with 965 additions and 187 deletions

View File

@@ -5,7 +5,7 @@ from enum import Enum, unique
import logging
import json
from collections import OrderedDict, Counter, deque
from typing import Union, Optional, List, Dict
from typing import *
import secrets
import random
@@ -345,6 +345,12 @@ class MultiWorld():
return [location for location in self.get_locations() if
(player is None or location.player == player) and location.item is None and location.can_reach(state)]
def get_unfilled_locations_for_players(self, location_name: str, players: Iterable[int]):
for player in players:
location = self.get_location(location_name, player)
if location.item is None:
yield location
def unlocks_new_location(self, item) -> bool:
temp_state = self.state.copy()
temp_state.collect(item, True)
@@ -1418,3 +1424,27 @@ class Spoiler(object):
outfile.write('\n'.join(path_listings))
class PlandoItem(NamedTuple):
item: str
location: str
world: Union[bool, str] = False # False -> own world, True -> not own world
from_pool: bool = True # if item should be removed from item pool
force: Union[bool, str] = 'silent' # False -> warns if item not successfully placed. True -> errors out on failure to place item.
def warn(self, warning: str):
if str(self.force).lower() in ['true', 'fail', 'failure', 'none', 'false', 'warn', 'warning']:
logging.warning(f'{warning}')
else:
logging.debug(f'{warning}')
def failed(self, warning: str, exception=Exception):
if str(self.force).lower() in ['true', 'fail', 'failure']:
raise exception(warning)
else:
self.warn(warning)
class PlandoConnection(NamedTuple):
entrance: str
exit: str
direction: str # entrance, exit or both