foundry.game package#
Subpackages#
- foundry.game.gfx package
- Subpackages
- foundry.game.gfx.objects package
- Submodules
- foundry.game.gfx.objects.Enemy module
- foundry.game.gfx.objects.EnemyItem module
- foundry.game.gfx.objects.EnemyItemFactory module
- foundry.game.gfx.objects.GeneratorObject module
- foundry.game.gfx.objects.Jump module
- foundry.game.gfx.objects.LevelObject module
- foundry.game.gfx.objects.LevelObjectFactory module
- foundry.game.gfx.objects.MapObject module
- foundry.game.gfx.objects.ObjectLike module
- foundry.game.gfx.objects.util module
- Module contents
- foundry.game.gfx.objects package
- Module contents
- Subpackages
- foundry.game.level package
- Submodules
- foundry.game.level.Level module
Level
Level.HEADER_LENGTH
Level.MIN_LENGTH
Level.WORLDS
Level.add_enemy()
Level.add_jump()
Level.add_object()
Level.attach_to_rom()
Level.attached_to_rom
Level.bring_to_background()
Level.bring_to_foreground()
Level.changed
Level.create_enemy_at()
Level.create_object_at()
Level.current_enemies_size()
Level.current_object_size()
Level.data_changed
Level.draw()
Level.enemies_end
Level.enemy_palette_index
Level.from_bytes()
Level.from_m3l()
Level.fully_loaded
Level.get_all_objects()
Level.get_intersecting_objects()
Level.get_object()
Level.get_object_names()
Level.get_rect()
Level.graphic_set
Level.has_next_area
Level.height
Level.index_of()
Level.is_too_big()
Level.is_vertical
Level.jumps_changed
Level.length
Level.music_index
Level.next_area_enemies
Level.next_area_objects
Level.next_area_tileset
Level.object_at()
Level.object_palette_index
Level.objects_end
Level.offsets
Level.paste_object_at()
Level.pipe_ends_level
Level.reload()
Level.remove_jump()
Level.remove_object()
Level.scroll_type
Level.size
Level.size_on_disk
Level.sorted_offsets
Level.start_action
Level.start_x_index
Level.start_y_index
Level.time_index
Level.to_bytes()
Level.to_m3l()
Level.too_many_enemies_or_items()
Level.too_many_level_objects()
Level.was_saved()
Level.width
LevelSignaller
get_level_name_suggestion()
- foundry.game.level.LevelControlled module
LevelControlled
LevelControlled.context_menu
LevelControlled.enemy_size_bar
LevelControlled.jump_destination_action
LevelControlled.jump_list
LevelControlled.level_size_bar
LevelControlled.level_view
LevelControlled.menu_toolbar_save_action
LevelControlled.object_dropdown
LevelControlled.object_list
LevelControlled.object_toolbar
LevelControlled.redo_action
LevelControlled.safe_to_change
LevelControlled.side_palette
LevelControlled.spinner_panel
LevelControlled.undo_action
LevelControlled.update_title()
LevelControlled.warning_list
- foundry.game.level.LevelController module
LevelController
LevelController.actions
LevelController.attach()
LevelController.changes
LevelController.copy()
LevelController.create_enemy_at()
LevelController.create_object_at()
LevelController.cut()
LevelController.delete()
LevelController.display_autoscroll_editor()
LevelController.display_block_viewer()
LevelController.display_header_editor()
LevelController.display_jump_editor()
LevelController.display_palette_viewer()
LevelController.display_warnings()
LevelController.focus_selected()
LevelController.is_attached
LevelController.last_position
LevelController.load_m3l()
LevelController.middle_mouse_release()
LevelController.on_jump_added()
LevelController.on_jump_edited()
LevelController.on_jump_removed()
LevelController.on_level_data_changed()
LevelController.on_reload()
LevelController.on_select()
LevelController.on_spin()
LevelController.paste()
LevelController.place_object_from_dropdown()
LevelController.refresh()
LevelController.safe_to_change
LevelController.screenshot
LevelController.select_all()
LevelController.stable_changes
LevelController.suggested_object
LevelController.title_suggestion
LevelController.to_background()
LevelController.to_data()
LevelController.to_foreground()
LevelController.to_m3l()
LevelController.update()
LevelController.update_gui_for_level()
LevelController.update_level()
LevelController.warp_to_alternative()
LevelController.zoom_in()
LevelController.zoom_out()
LevelSelectorController
require_safe_to_change()
- foundry.game.level.LevelLike module
- foundry.game.level.LevelManager module
LevelManager
LevelManager.actions
LevelManager.attach()
LevelManager.can_redo
LevelManager.can_undo
LevelManager.copy()
LevelManager.create_object_from_suggestion()
LevelManager.cut()
LevelManager.delete()
LevelManager.display_autoscroll_editor()
LevelManager.display_block_viewer()
LevelManager.display_header_editor()
LevelManager.display_jump_editor()
LevelManager.display_object_viewer()
LevelManager.display_palette_viewer()
LevelManager.display_player_viewer()
LevelManager.display_warnings()
LevelManager.do()
LevelManager.enabled
LevelManager.focus_selected()
LevelManager.force_select()
LevelManager.has_warnings
LevelManager.is_attached
LevelManager.last_position
LevelManager.load_m3l()
LevelManager.middle_mouse_release()
LevelManager.on_disable()
LevelManager.on_enable()
LevelManager.on_select()
LevelManager.paste()
LevelManager.redo()
LevelManager.refresh()
LevelManager.safe_to_change
LevelManager.screenshot
LevelManager.select_all()
LevelManager.stable_changes
LevelManager.state
LevelManager.title_suggestion
LevelManager.to_background()
LevelManager.to_data()
LevelManager.to_foreground()
LevelManager.to_m3l()
LevelManager.undo()
LevelManager.update()
LevelManager.warp_to_alternative()
LevelManager.zoom_in()
LevelManager.zoom_out()
Manager
require_enabled()
- foundry.game.level.LevelRef module
LevelRef
LevelRef.can_redo
LevelRef.can_undo
LevelRef.data_changed
LevelRef.do()
LevelRef.is_loaded
LevelRef.jumps_changed
LevelRef.level
LevelRef.load_level()
LevelRef.redo()
LevelRef.save_level_state()
LevelRef.selected_objects
LevelRef.set_level_state()
LevelRef.state
LevelRef.staticMetaObject
LevelRef.undo()
LevelRef.unload_level()
- foundry.game.level.WorldMap module
WorldMap
WorldMap.add_object()
WorldMap.draw()
WorldMap.from_bytes()
WorldMap.get_all_objects()
WorldMap.get_object()
WorldMap.get_object_names()
WorldMap.index_of()
WorldMap.level_at_position()
WorldMap.level_name_at_position()
WorldMap.object_at()
WorldMap.q_size
WorldMap.remove_object()
WorldMap.to_bytes()
- foundry.game.level.util module
DisplayInformation
Level
Location
PydanticDisplayInformation
PydanticLevel
PydanticLocation
find_level_by_pointers()
generate_default_level_information()
get_level_index()
get_world_levels()
get_worlds()
load_level_offsets()
to_pydantic_display_information()
to_pydantic_level()
to_pydantic_location()
- Module contents
Submodules#
foundry.game.Data module#
- class MapscreenPointerLocation(count, offset)#
Bases:
tuple
- count#
Alias for field number 0
- offset#
Alias for field number 1
- class Mario3Level(game_world, level_in_world, rom_level_offset, enemy_offset, real_obj_set, name)#
Bases:
NamedTuple
- class ObjectInfo(index, subindex, x, y, width, height, x2, y2, obj, objtype, rect, drag)#
Bases:
tuple
- drag#
Alias for field number 11
- height#
Alias for field number 5
- index#
Alias for field number 0
- obj#
Alias for field number 8
- objtype#
Alias for field number 9
- rect#
Alias for field number 10
- subindex#
Alias for field number 1
- width#
Alias for field number 4
- x#
Alias for field number 2
- x2#
Alias for field number 6
- y#
Alias for field number 3
- y2#
Alias for field number 7
- read_string_dict(path)#
foundry.game.Definitions module#
- pydantic model Definition#
Bases:
BaseModel
Show JSON schema
{ "title": "Definition", "type": "object", "properties": { "description": { "title": "Description", "default": "", "type": "string" }, "warnings": { "title": "Warnings", "default": [], "type": "array", "items": { "$ref": "#/definitions/WarningCreator" } }, "overlays": { "title": "Overlays" } }, "definitions": { "WarningCreator": { "title": "WarningCreator", "type": "object", "properties": {} } } }
- Config:
use_enum_values: bool = True
- Fields:
- field warnings: list[foundry.core.warnings.WarningCreator.WarningCreator] = []#
- get_warnings() list[foundry.core.warnings.Warning.Warning] #
foundry.game.EnemyDefinitions module#
- pydantic model EnemyDefinition#
Bases:
Definition
Show JSON schema
{ "title": "EnemyDefinition", "type": "object", "properties": { "description": { "title": "Description", "default": "", "type": "string" }, "warnings": { "title": "Warnings", "default": [], "type": "array", "items": { "$ref": "#/definitions/WarningCreator" } }, "overlays": { "title": "Overlays" }, "bmp_width": { "title": "Bmp Width", "default": 1, "type": "integer" }, "bmp_height": { "title": "Bmp Height", "default": 1, "type": "integer" }, "rect_width": { "title": "Rect Width", "default": 0, "type": "integer" }, "rect_height": { "title": "Rect Height", "default": 0, "type": "integer" }, "rect_x_offset": { "title": "Rect X Offset", "default": 0, "type": "integer" }, "rect_y_offset": { "title": "Rect Y Offset", "default": 0, "type": "integer" }, "icon_width": { "title": "Icon Width", "default": 0, "type": "integer" }, "icon_height": { "title": "Icon Height", "default": 0, "type": "integer" }, "icon_x_offset": { "title": "Icon X Offset", "type": "integer" }, "icon_y_offset": { "title": "Icon Y Offset", "type": "integer" }, "sprites": { "title": "Sprites", "type": "array", "items": { "$ref": "#/definitions/Sprite" } }, "blocks": { "title": "Blocks", "type": "array", "items": { "type": "integer" } }, "pages": { "title": "Pages", "type": "array", "items": { "type": "integer" } }, "orientation": { "default": 9, "allOf": [ { "$ref": "#/definitions/GeneratorType" } ] }, "check_level_bounds": { "title": "Check Level Bounds", "default": true, "type": "boolean" }, "check_compatibility": { "title": "Check Compatibility", "default": true, "type": "boolean" } }, "definitions": { "WarningCreator": { "title": "WarningCreator", "type": "object", "properties": {} }, "Sprite": { "title": "Sprite", "description": "Defines a given sprite and its properties", "type": "object", "properties": { "index": { "title": "Index", "type": "integer" }, "palette_index": { "title": "Palette Index", "default": 1, "type": "integer" }, "x_offset": { "title": "X Offset", "default": 0, "type": "integer" }, "y_offset": { "title": "Y Offset", "default": 0, "type": "integer" }, "horizontal_mirror": { "title": "Horizontal Mirror", "default": false, "type": "boolean" }, "vertical_mirror": { "title": "Vertical Mirror", "default": false, "type": "boolean" } }, "required": [ "index" ] }, "GeneratorType": { "title": "GeneratorType", "description": "\n The various different ways enemies can be represented inside the game.\n ", "enum": [ 0, 9, 10 ], "type": "integer" } } }
- Config:
use_enum_values: bool = True
- Fields:
- field orientation: GeneratorType = GeneratorType.SINGLE_BLOCK_OBJECT#
- field sprites: list[foundry.game.EnemyDefinitions.Sprite] [Optional]#
- get_warnings() list[foundry.core.warnings.Warning.Warning] #
- property suggested_icon_height: int#
Provides the suggested icon height, as the icon height my not be set.
- Returns:
- int
The suggested icon height.
- property suggested_icon_width: int#
Provides the suggested icon width, as the icon width my not be set.
- Returns:
- int
The suggested icon width.
- pydantic model EnemyDefinitions#
Bases:
BaseModel
Show JSON schema
{ "title": "EnemyDefinitions" }
- Fields:
__root__ (list[foundry.game.EnemyDefinitions.EnemyDefinition])
- class GeneratorType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
-
The various different ways enemies can be represented inside the game.
- CENTERED = 10#
- SINGLE_BLOCK_OBJECT = 9#
- SINGLE_SPRITE_OBJECT = 0#
- pydantic model Sprite#
Bases:
BaseModel
Defines a given sprite and its properties
Show JSON schema
{ "title": "Sprite", "description": "Defines a given sprite and its properties", "type": "object", "properties": { "index": { "title": "Index", "type": "integer" }, "palette_index": { "title": "Palette Index", "default": 1, "type": "integer" }, "x_offset": { "title": "X Offset", "default": 0, "type": "integer" }, "y_offset": { "title": "Y Offset", "default": 0, "type": "integer" }, "horizontal_mirror": { "title": "Horizontal Mirror", "default": false, "type": "boolean" }, "vertical_mirror": { "title": "Vertical Mirror", "default": false, "type": "boolean" } }, "required": [ "index" ] }
- Fields:
- get_enemy_metadata() EnemyDefinitions #
foundry.game.File module#
- class INESHeader(program_banks: int, character_banks: int, mapper: int, horizontal_mirroring: bool, battery_backed_ram: bool)#
Bases:
object
The representation of the header inside the ROM, following the INES format. Regarding the specifics of the INES format, more information can be found at INES.
- Attributes:
- INESHEADER_PREFIX: ClassVar[bytes]
The required prefix for any INES header.
- BASE_PROGRAM_SIZE: ClassVar[int]
The base program size for a standard copy of SMB3.
- PROGRAM_BANK_SIZE: ClassVar[int]
The size of any program bank.
- CHARACTER_BANK_SIZE: ClassVar[int]
The size of any character bank.
- INES_HEADER_SIZE
The size of the INES header.
- program_banks: int
The amount of 8kb banks of program data inside the file.
- character_banks: int
The amount of 4kb banks of graphical data inside the file.
- mapper: int
The memory mapper used by the file.
- horizontal_mirroring: bool
If the file uses horizontal mirroring, otherwise it is assumed it uses vertical mirroring. See Nametable_Mirroring for more information.
- battery_backed_ram: bool
If the file contains battery-backed RAM between 0x6000 and 0x7FFF or any other form of persistent memory.
- static address_is_global(address: int, program_banks: int) bool #
Determines if the address is inside the last two, global, banks of SMB3.
- Parameters:
- addressint
The address to check.
- program_banksint
The amount of program banks.
- Returns:
- bool
If the address is global.
- property character_size: int#
The amount of space dedicated to character data.
- Returns:
- int
The amount of bytes provided for character data.
- classmethod from_data(data: bytes, path: str | None = None) Self #
Generates an INES header from a file following the header.
- Parameters:
- databytes
The data to generate the header from.
- pathOptional[str], optional
The path used for better exception information, by default None
- Returns:
- INESHeader
The newly generated header.
- Raises:
- InvalidINESHeader
If the data does not follow an INES header.
- normalized_address(address: int, program_size: int = 262144) int #
Finds an address that would better account for ROM expansions.
- Parameters:
- addressint
The address to normalize.
- program_sizeint, optional
The program size of the original ROM, by default BASE_PROGRAM_SIZE
- Returns:
- int
The normalized address.
- static program_address(address: int) int #
Provides the address shifted to make the start of the program data start at the first index.
- Parameters:
- addressint
To shift to account for the size of the header.
- Returns:
- int
The absolute program address.
- property program_size: int#
The amount of space dedicated to program data.
- Returns:
- int
The amount of bytes provided for program banks.
- static relative_address(address: int) int #
Provides the relative address that would be references inside the ROM.
- Parameters:
- addressint
The absolute address.
- Returns:
- int
The relative address.
- property vertical_mirroring: bool#
Determines if the file uses vertical mirroring. See Nametable_Mirroring for more information.
- Returns:
- bool
If the file uses vertical mirroring.
- exception InvalidINESHeader(file_path: str | None = None)#
Bases:
TypeError
An exception that is raised if a file does not follow an INES header when it is meant to.
- class ROM(path: str | None = None)#
Bases:
Rom
- generate_tag() int | None #
Generates a identification tag for a file. This enables the file to be references later on.
This tag will include the ROM_MARKER value and eight random bytes that serve as the ID of the file.
- Returns:
- Optional[int]
The ID of the file, if the tag was successfully generated and applied.
- get_id() int | None #
Determines the ID of the file.
- Returns:
- Optional[int]
The ID of the file, if one can exist.
- header: INESHeader#
- property identifier: str#
Provides an identifier for the file.
- Returns:
- str
The identifier associated with this file.
- rom_data = bytearray(b'')#
- static set_additional_data(additional_data)#
- property settings: FileSettings#
Provides the settings for the file.
- Returns:
- FileSettings
The settings associated with this file.
- getrandbits(k, /)#
foundry.game.ObjectDefinitions module#
- class EndType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
-
Some level objects have blocks designated to be used at their ends. For example pipes, which can be extended, but always end at one side with the same couple of blocks. To keep track of where those special blocks are to be placed, this enum is used. When the value is TWO_ENDS they are always on opposite sides and whether they are left and right or top and bottom depends on the generator type of the object.
- END_ON_BOTTOM_OR_RIGHT = 2#
- END_ON_TOP_OR_LEFT = 1#
- TWO_ENDS = 3#
- UNIFORM = 0#
- class GeneratorType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
-
Level objects are generated using different methods, depending on their generator type. Some objects extend until they hit another object, some extend up to the sky. To identify in what way a specific type of level object is constructed, this enum lists the known generator types.
- CENTERED = 10#
- DESERT_PIPE_BOX = 3#
- DIAG_DOWN_LEFT = 2#
- DIAG_DOWN_RIGHT = 4#
- DIAG_UP_RIGHT = 5#
- DIAG_WEIRD = 8#
- ENDING = 14#
- HORIZONTAL = 0#
- HORIZONTAL_2 = 7#
- HORIZ_TO_GROUND = 6#
- PYRAMID_2 = 12#
- PYRAMID_TO_GROUND = 11#
- SINGLE_BLOCK_OBJECT = 9#
- TO_THE_SKY = 13#
- VERTICAL = 1#
- pydantic model Tileset#
Bases:
BaseModel
Show JSON schema
{ "title": "Tileset" }
- Fields:
__root__ (list[foundry.game.ObjectDefinitions.TilesetDefinition])
- pydantic model TilesetDefinition#
Bases:
Definition
Show JSON schema
{ "title": "TilesetDefinition", "type": "object", "properties": { "description": { "title": "Description", "default": "", "type": "string" }, "warnings": { "title": "Warnings", "default": [], "type": "array", "items": { "$ref": "#/definitions/WarningCreator" } }, "overlays": { "title": "Overlays" }, "domain": { "title": "Domain", "type": "integer" }, "min_value": { "title": "Min Value", "type": "integer" }, "max_value": { "title": "Max Value", "type": "integer" }, "bmp_width": { "title": "Bmp Width", "type": "integer" }, "bmp_height": { "title": "Bmp Height", "type": "integer" }, "blocks": { "title": "Blocks", "type": "array", "items": { "type": "integer" } }, "orientation": { "$ref": "#/definitions/GeneratorType" }, "ending": { "$ref": "#/definitions/EndType" }, "size": { "title": "Size", "default": 3, "type": "integer" }, "check_level_bounds": { "title": "Check Level Bounds", "default": true, "type": "boolean" } }, "required": [ "domain", "min_value", "max_value", "bmp_width", "bmp_height", "blocks", "orientation", "ending" ], "definitions": { "WarningCreator": { "title": "WarningCreator", "type": "object", "properties": {} }, "GeneratorType": { "title": "GeneratorType", "description": "\n Level objects are generated using different methods, depending on their generator type. Some objects extend until\n they hit another object, some extend up to the sky. To identify in what way a specific type of level object is\n constructed, this enum lists the known generator types.\n ", "enum": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ], "type": "integer" }, "EndType": { "title": "EndType", "description": "\n Some level objects have blocks designated to be used at their ends. For example pipes, which can be extended, but\n always end at one side with the same couple of blocks. To keep track of where those special blocks are to be placed,\n this enum is used. When the value is TWO_ENDS they are always on opposite sides and whether they are left and right\n or top and bottom depends on the generator type of the object.\n ", "enum": [ 0, 1, 2, 3 ], "type": "integer" } } }
- Config:
use_enum_values: bool = True
- Fields:
- field orientation: GeneratorType [Required]#
- get_warnings() list[foundry.core.warnings.Warning.Warning] #
- pydantic model Tilesets#
Bases:
BaseModel
Show JSON schema
{ "title": "Tilesets" }
- Fields:
__root__ (list[foundry.game.ObjectDefinitions.Tileset])