mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
game(feat): add game mode
This commit is contained in:
parent
6b3f0ea619
commit
bb80400ad7
7
main.py
7
main.py
@ -2,7 +2,7 @@
|
||||
import argparse
|
||||
|
||||
from loguru import logger
|
||||
from utils import BASE_PATH, CONFIG
|
||||
from utils import BASE_PATH, CONFIG, GameMode
|
||||
|
||||
|
||||
def pos_int(string: str) -> int:
|
||||
@ -66,10 +66,11 @@ def main(args: argparse.ArgumentParser) -> None:
|
||||
|
||||
if args.train is not None:
|
||||
ai.log.debug("Training the AI")
|
||||
ai.train(*args.train)
|
||||
# ai.train(*args.train)
|
||||
game.Main(GameMode.AI_TRAINING).run()
|
||||
else:
|
||||
game.log.debug("Running the game")
|
||||
game.Main().run()
|
||||
game.Main(GameMode.PLAYER).run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import sys
|
||||
|
||||
import pygame
|
||||
from utils import CONFIG, Figure
|
||||
from utils import CONFIG, Figure, GameMode
|
||||
|
||||
from .game import Game
|
||||
from .log import log
|
||||
@ -25,8 +25,9 @@ class Main:
|
||||
music: Pygame music that plays in the background.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
def __init__(self, mode: GameMode) -> None:
|
||||
log.info("Initializing the game")
|
||||
self.game_mode = mode
|
||||
self._initialize_pygeme()
|
||||
self._initialize_game_components()
|
||||
self._start_background_music()
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from .config import CONFIG
|
||||
from .enum import Direction, Field, Rotation
|
||||
from .enum import Direction, Field, GameMode, Rotation
|
||||
from .figure import Figure, FigureConfig
|
||||
from .log import log
|
||||
from .path import BASE_PATH
|
||||
@ -15,4 +15,5 @@ __all__ = [
|
||||
"Direction",
|
||||
"Field",
|
||||
"Rotation",
|
||||
"GameMode",
|
||||
]
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from enum import Enum
|
||||
from enum import Enum, auto
|
||||
|
||||
|
||||
class Direction(Enum):
|
||||
@ -16,3 +16,9 @@ class Rotation(Enum):
|
||||
class Field(Enum):
|
||||
EMPTY = None
|
||||
FILLED = "Block"
|
||||
|
||||
|
||||
class GameMode(Enum):
|
||||
PLAYER = auto()
|
||||
AI_PLAYING = auto()
|
||||
AI_TRAINING = auto()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user