Код IT
← Каталог

Python — диаблоид — `world/tile.py`

Фрагмент из «Python — диаблоид»: `world/tile.py`.

python spinoffencyclopedia9-04-razrabotka-igr-praktikum-razrabotki-igr-6 embed URL статья в энциклопедии
Python main.py
from dataclasses import dataclass

from core.config import TileType


@dataclass
class Tile:
    type: TileType = TileType.VOID
    walkable: bool = False

    @classmethod
    def floor(cls) -> "Tile":
        return cls(TileType.FLOOR, True)

    @classmethod
    def wall(cls) -> "Tile":
        return cls(TileType.WALL, False)

    @classmethod
    def start(cls) -> "Tile":
        return cls(TileType.START, True)

    @classmethod
    def exit(cls) -> "Tile":
        return cls(TileType.EXIT, True)
from dataclasses import dataclass

from core.config import TileType


@dataclass
class Tile:
    type: TileType = TileType.VOID
    walkable: bool = False

    @classmethod
    def floor(cls) -> "Tile":
        return cls(TileType.FLOOR, True)

    @classmethod
    def wall(cls) -> "Tile":
        return cls(TileType.WALL, False)

    @classmethod
    def start(cls) -> "Tile":
        return cls(TileType.START, True)

    @classmethod
    def exit(cls) -> "Tile":
        return cls(TileType.EXIT, True)