mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Start implementing object oriented scaffold for world types
(There's still a lot of work ahead, such as: registering locations and items to the World, as well as methods to create_item_from_name() many more method names for various stages embedding Options into the world type and many more...)
This commit is contained in:
37
worlds/AutoWorld.py
Normal file
37
worlds/AutoWorld.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from BaseClasses import MultiWorld
|
||||
|
||||
class AutoWorldRegister(type):
|
||||
world_types = {}
|
||||
|
||||
def __new__(cls, name, bases, dct):
|
||||
new_class = super().__new__(cls, name, bases, dct)
|
||||
if "game" in dct:
|
||||
AutoWorldRegister.world_types[dct["game"]] = new_class
|
||||
return new_class
|
||||
|
||||
|
||||
def call_single(world: MultiWorld, method_name: str, player: int):
|
||||
method = getattr(world.worlds[player], method_name)
|
||||
return method(world, player)
|
||||
|
||||
|
||||
def call_all(world: MultiWorld, method_name: str):
|
||||
for player in world.player_ids:
|
||||
call_single(world, method_name, player)
|
||||
|
||||
|
||||
class World(metaclass=AutoWorldRegister):
|
||||
"""A World object encompasses a game's Items, Locations, Rules and additional data or functionality required.
|
||||
A Game should have its own subclass of World in which it defines the required data structures."""
|
||||
|
||||
def __init__(self, player: int):
|
||||
self.player = int
|
||||
|
||||
def generate_basic(self, world: MultiWorld, player: int):
|
||||
pass
|
||||
|
||||
def generate_output(self, world: MultiWorld, player: int):
|
||||
pass
|
||||
|
||||
def create_regions(self, world: MultiWorld, player: int):
|
||||
pass
|
||||
Reference in New Issue
Block a user