Files
Grinch-AP/worlds/v6/Rules.py

41 lines
2.2 KiB
Python
Raw Normal View History

2022-01-21 22:42:11 +01:00
import typing
from ..generic.Rules import add_rule
from .Regions import connect_regions, v6areas
2022-01-21 22:42:11 +01:00
2022-01-25 23:17:22 +01:00
def _has_trinket_range(state,player,start,end) -> bool:
for i in range(start,end):
if (not state.has("Trinket " + str(i+1).zfill(2), player)):
2022-01-21 22:42:11 +01:00
return False
return True
2022-02-04 21:34:39 +01:00
2022-02-05 16:53:43 +01:00
def set_rules(world, player, area_connections: typing.Dict[int, int], area_cost_map: typing.Dict[int, int]):
areashuffle = list(range(len(v6areas)))
2022-02-04 21:34:39 +01:00
if world.AreaRandomizer[player].value:
world.random.shuffle(areashuffle)
area_connections.update({(index+1): (value+1) for index, value in enumerate(areashuffle)})
area_connections.update({0:0})
2022-02-05 16:53:43 +01:00
if world.AreaCostRandomizer[player].value:
world.random.shuffle(areashuffle)
area_cost_map.update({(index+1): (value+1) for index, value in enumerate(areashuffle)})
area_cost_map.update({0:0})
2022-02-05 16:53:43 +01:00
for i in range(1,5):
connect_regions(world, player, "Menu", v6areas[area_connections[i]-1], lambda state: _has_trinket_range(state,player,world.DoorCost[player].value*(area_cost_map[i]-1),
world.DoorCost[player].value*area_cost_map[i]))
2022-01-21 22:42:11 +01:00
#Special Rule for V
add_rule(world.get_location("V",player), lambda state : state.can_reach("Laboratory",'Region',player) and
state.can_reach("The Tower",'Region',player) and
state.can_reach("Space Station 2",'Region',player) and
state.can_reach("Warp Zone",'Region',player))
2022-01-21 22:42:11 +01:00
2022-01-25 23:17:22 +01:00
#Special Rule for NPC Trinket
2022-02-18 19:29:59 +01:00
add_rule(world.get_location("V",player), lambda state : state.can_reach("Laboratory",'Region',player) or
( state.can_reach("The Tower",'Region',player) and
state.can_reach("Space Station 2",'Region',player) and
state.can_reach("Warp Zone",'Region',player) ))
2022-01-25 23:17:22 +01:00
world.completion_condition[player] = lambda state: state.can_reach("V",'Location',player)