Skip to content
Merged

Work #29

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Flake8 Linting

on:
push:
branches:
- main
- work
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint flake8
pip install -r requirements.txt

- name: Run Flake8
run: |
flake8 tetr_cli --max-line-length=100
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "tetr_cli"
version = "1.0.2"
version = "1.0.3"
description = "Setup script for the tetr_cli package."
authors = [
{ name = "Airun_Iru", email = "hugo_s_tanaka@yahoo.com" }
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="tetr_cli",
version="1.0.2",
version="1.0.3",
packages=find_packages(),
entry_points={
"console_scripts": [
Expand Down
21 changes: 12 additions & 9 deletions tetr_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@
"Score_Screen": "score_screen",
# Solo Modes
"Solo_Menu": "solo.solo_menu",
"Level_Select": "solo.level_select",
"Marathon": "solo.marathon",
"Sprint": "solo.sprint",
"Ultra": "solo.ultra",
# Multiplayer Modes
"Multi_Menu": "multi.multi_menu",
"Host_Room": "multi.host_room",
"Join_Room": "multi.join_room",
# "Multi_Menu": "multi.multi_menu",
# "Host_Room": "multi.host_room",
# "Join_Room": "multi.join_room",
}


Expand Down Expand Up @@ -132,15 +133,17 @@ async def main(
init_pair(6, 46, -1) # S
init_pair(7, 196, -1) # Z
init_pair(8, 244, -1) # Garbage
init_pair(9, 15, -1) # White
else:
init_pair(1, COLOR_YELLOW, -1) # O
init_pair(2, COLOR_CYAN, -1) # I
init_pair(3, COLOR_MAGENTA, -1) # T
init_pair(1, COLOR_YELLOW, COLOR_BLACK) # O
init_pair(2, COLOR_CYAN, COLOR_BLACK) # I
init_pair(3, COLOR_MAGENTA, COLOR_BLACK) # T
init_pair(4, COLOR_YELLOW, COLOR_BLACK) # L
init_pair(5, COLOR_BLUE, -1) # J
init_pair(6, COLOR_GREEN, -1) # S
init_pair(7, COLOR_RED, -1) # Z
init_pair(5, COLOR_BLUE, COLOR_BLACK) # J
init_pair(6, COLOR_GREEN, COLOR_BLACK) # S
init_pair(7, COLOR_RED, COLOR_BLACK) # Z
init_pair(8, COLOR_WHITE, COLOR_BLACK) # Light gray on black
init_pair(9, COLOR_WHITE, COLOR_BLACK) # White

start_time: float = 0.0
elapsed_time: float = 0.0
Expand Down
5 changes: 5 additions & 0 deletions tetr_cli/tetr_modules/menu_core/menu_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ def current_value(self) -> int:
"""This will return the current value."""
return self.__current_value

@current_value.setter
def current_value(self, value: int) -> None:
"""This will set the current value."""
self.__current_value = value

@property
def old_value(self) -> int:
"""This will return the old value."""
Expand Down
7 changes: 4 additions & 3 deletions tetr_cli/tetr_modules/modes/multi/join_wait_room.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""This will display the wait room menu."""

# coding: utf-8

from typing import Dict
# from typing import Dict

from curses import window
# from curses import window

from tetr_cli.tetr_modules.menu_core.base_mode import BaseModeClass

Expand All @@ -16,4 +17,4 @@ def __init__(self) -> None:


if __name__ == "__main__":
print("This is a module file and cannot be run directly.")
print("This is a module file and cannot be run directly.")
42 changes: 42 additions & 0 deletions tetr_cli/tetr_modules/modes/solo/level_select_mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""This will handle the level select screen."""

from typing import Dict, Set
from curses import window

from tetr_cli.tetr_modules.menu_core.menu_mode import SideMenuToggleClass
from tetr_cli.tetr_modules.modules.database import set_temp

TOGGLE_TO_ACTION: Dict[str, Dict[str, str]] = {
"Confirm": {"action": "Marathon", "sound": "select_confirm"},
"Go_Back": {"action": "Solo_Menu", "sound": "select_back"},
}


class ModeClass(SideMenuToggleClass):
"""This will handle the option mode menu."""

def __init__(self) -> None:
"""This will initialize this class."""
super().__init__(
toggle_name="level",
toggle_to_action=TOGGLE_TO_ACTION,
lower=0,
upper=25,
step=5,
)
self.current_value = 1

def increment_frame(self, stdscr: window, pressed_keys: Set[str]) -> None:
"""This will progress the menu based on the inputs."""
self.menu_control(pressed_keys)
self.display_toggle(stdscr, "Marathon Level")
if self.current_value == 0:
self.current_value = 1
elif self.current_value == 6:
self.current_value = 5
if "enter" in pressed_keys:
set_temp("level", str(self.current_value))


if __name__ == "__main__":
print("This is a bgm_option module, please run starter.py.")
18 changes: 16 additions & 2 deletions tetr_cli/tetr_modules/modes/solo/marathon_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
DRAW_BOARD_HEIGHT,
DRAW_BOARD_WIDTH,
)
from tetr_cli.tetr_modules.modules.database import set_temp, get_setting
from tetr_cli.tetr_modules.modules.database import set_temp, get_temp, get_setting
from tetr_cli.tetr_modules.modules.safe_curses import safe_addstr


Expand All @@ -30,6 +30,7 @@ def __init__(self) -> None:
self.mode: str = "countdown"
self.__das: int = int((int(get_setting("das", "10")) * self.fps_limit) / 60)
self.__arr: int = int((int(get_setting("arr", "2")) * self.fps_limit) / 60)
self.level: int = int(get_temp("level"))

def show_stats(self, stdscr: window) -> None:
"""This will show the stats on bottom right."""
Expand Down Expand Up @@ -160,6 +161,18 @@ def play_mode(self, stdscr: window, pressed_keys: Set[str]) -> None:
self.sound_action["BGM"] = ["stop"]
return

if self.board.animation_mode:
self.board.animate_clear_lines(self.level)
self.board.draw_minos_on_board(
stdscr=stdscr,
offset=self.offset,
max_yx=self.max_yx,
current_mino=self.current_mino,
ghost_position=self.ghost_mino_position(self.current_mino),
)
self.display_action_text(stdscr)
return

# Level up for every 10 lines cleared
self.level = max(self.level, (self.lines_cleared // 10) + 1)

Expand Down Expand Up @@ -198,6 +211,7 @@ def play_mode(self, stdscr: window, pressed_keys: Set[str]) -> None:
self.current_mino.orientation,
self.current_mino.position,
)
self.sound_action["SFX"].append("place_mino")
self.calculate_score()
self.reset_mino()

Expand Down Expand Up @@ -241,7 +255,7 @@ def countdown_mode(self, stdscr: window) -> None:
self.mode = "play_music_wait"
self.sound_action["SFX"].append("go")
safe_addstr(stdscr, self.max_yx[0] // 2, self.max_yx[1] // 2, "Go", A_BOLD)
self.counter = self.fps_limit // 2
self.counter = (3 * self.fps_limit) // 2

def increment_frame(self, stdscr: window, pressed_keys: Set[str]) -> None:
"""This will increment the frame."""
Expand Down
2 changes: 1 addition & 1 deletion tetr_cli/tetr_modules/modes/solo/solo_menu_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


OPTION_TO_ACTION: Dict[str, Dict[str, str]] = {
"Marathon": {"action": "Marathon", "sound": "select_confirm"},
"Marathon": {"action": "Level_Select", "sound": "select_confirm"},
"Sprint": {"action": "Sprint", "sound": "select_confirm"},
"Ultra": {"action": "Ultra", "sound": "select_confirm"},
"Go_Back": {"action": "Main_Menu", "sound": "select_back"},
Expand Down
13 changes: 13 additions & 0 deletions tetr_cli/tetr_modules/modes/solo/sprint_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ def play_mode(self, stdscr: window, pressed_keys: Set[str]) -> None:
arr=self.__arr,
)

if self.board.animation_mode:
self.board.animate_clear_lines(self.level)
self.board.draw_minos_on_board(
stdscr=stdscr,
offset=self.offset,
max_yx=self.max_yx,
current_mino=self.current_mino,
ghost_position=self.ghost_mino_position(self.current_mino),
)
self.display_action_text(stdscr)
return

self.check_keyinput_pressed(pressed_keys=pressed_keys)
if not self.current_mino:
self.board.draw_minos_on_board(
Expand Down Expand Up @@ -228,6 +240,7 @@ def play_mode(self, stdscr: window, pressed_keys: Set[str]) -> None:
self.current_mino.orientation,
self.current_mino.position,
)
self.sound_action["SFX"].append("place_mino")
self.calculate_score()
self.reset_mino()

Expand Down
13 changes: 13 additions & 0 deletions tetr_cli/tetr_modules/modes/solo/ultra_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ def play_mode(self, stdscr: window, pressed_keys: Set[str]) -> None:
arr=self.__arr,
)

if self.board.animation_mode:
self.board.animate_clear_lines(self.level)
self.board.draw_minos_on_board(
stdscr=stdscr,
offset=self.offset,
max_yx=self.max_yx,
current_mino=self.current_mino,
ghost_position=self.ghost_mino_position(self.current_mino),
)
self.display_action_text(stdscr)
return

self.check_keyinput_pressed(pressed_keys=pressed_keys)
if not self.current_mino:
self.board.draw_minos_on_board(
Expand Down Expand Up @@ -236,6 +248,7 @@ def play_mode(self, stdscr: window, pressed_keys: Set[str]) -> None:
self.current_mino.orientation,
self.current_mino.position,
)
self.sound_action["SFX"].append("place_mino")
self.calculate_score()
self.reset_mino()

Expand Down
12 changes: 9 additions & 3 deletions tetr_cli/tetr_modules/modules/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async def load_sfx() -> Dict[str, Sound]:
"""Load all sound effects."""

mixer.init()
mixer.set_num_channels(32)
mixer.music.set_volume(float(get_setting("music_volume", "25")) / 100)

sound_effects = {
Expand All @@ -25,10 +26,14 @@ async def load_sfx() -> Dict[str, Sound]:
"select_back": mixer.Sound(str(sound_path / "sfx/select_back.wav")),
"single": mixer.Sound(str(sound_path / "sfx/single.wav")),
"double": mixer.Sound(str(sound_path / "sfx/double.wav")),
"triple": mixer.Sound(str(sound_path / "sfx/triple.wav")),
"quad": mixer.Sound(str(sound_path / "sfx/quad.wav")),
"t_spin_single": mixer.Sound(str(sound_path / "sfx/t_spin_single.wav")),
"t_spin_double": mixer.Sound(str(sound_path / "sfx/t_spin_double.wav")),
"t_spin_triple": mixer.Sound(str(sound_path / "sfx/t_spin_triple.wav")),
"t_spin": mixer.Sound(str(sound_path / "sfx/t_spin.wav")),
"all_clear": mixer.Sound(str(sound_path / "sfx/all_clear.wav")),
"hold": mixer.Sound(str(sound_path / "sfx/hold.wav")),
"place_mino": mixer.Sound(str(sound_path / "sfx/place_mino.wav")),
"rotate": mixer.Sound(str(sound_path / "sfx/rotate.wav")),
"move": mixer.Sound(str(sound_path / "sfx/move.wav")),
"countdown": mixer.Sound(str(sound_path / "sfx/countdown.wav")),
"go": mixer.Sound(str(sound_path / "sfx/go.wav")),
}
Expand Down Expand Up @@ -63,6 +68,7 @@ async def play_sounds(
if sound_action and "SFX" in sound_action:
for sfx in sound_action["SFX"]:
try:
sound_effect_dict[sfx].stop()
sound_effect_dict[sfx].play()
except Exception as err:
print(f"Failed to play SFX: {err}")
Expand Down
Loading