This repository has been archived on 2022-12-29. You can view files and clone it, but cannot push or open issues or pull requests.
zeropod/plugin/chess/__init__.py

36 lines
930 B
Python

from cinput import ControlInput, Button
from enum import Enum, auto
from graphics import Graphics
from .draw import Draw
from .sunfish import initial
class GameState(Enum):
MAIN_MENU = auto()
THINKING = auto()
CHOOSE_ROW = auto()
CHOOSE_COL = auto()
GAME_OVER = auto()
def execute(cinput: ControlInput, graphics: Graphics, _):
graphics.clear()
draw = Draw(graphics)
draw.draw_board(initial)
state = GameState.MAIN_MENU
menu_index = 0
while True:
if state == GameState.MAIN_MENU:
draw.draw_menu(menu_index)
key = cinput.get_one_shot()
if state == GameState.MAIN_MENU:
if key == Button.DIR_U:
menu_index -= 1
if menu_index < 0:
menu_index = 0
elif key == Button.DIR_D:
menu_index += 1
if menu_index > 2:
menu_index = 2