Employ linters
This commit is contained in:
parent
d97e1a1294
commit
12b798ac00
10 changed files with 172 additions and 51 deletions
109
.gitignore
vendored
109
.gitignore
vendored
|
@ -1,5 +1,104 @@
|
|||
brutalmaze.egg-info
|
||||
build
|
||||
dist
|
||||
__pycache__
|
||||
*.pyc
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
|
|
|
@ -19,15 +19,15 @@
|
|||
__doc__ = 'Brutal Maze module for hero and enemy classes'
|
||||
|
||||
from collections import deque
|
||||
from math import atan2, gcd, sin, pi
|
||||
from math import atan2, gcd, pi, sin
|
||||
from random import choice, randrange, shuffle
|
||||
from sys import modules
|
||||
|
||||
from .constants import (
|
||||
TANGO, HERO_HP, SFX_HEART, HEAL_SPEED, MIN_BEAT, ATTACK_SPEED, ENEMY,
|
||||
ENEMY_SPEED, ENEMY_HP, SFX_SPAWN, SFX_SLASH_HERO, MIDDLE, WALL, FIRANGE,
|
||||
AROUND_HERO, ADJACENTS, EMPTY, SQRT2, ENEMIES)
|
||||
from .misc import sign, randsign, regpoly, fill_aapolygon, play
|
||||
from .constants import (ADJACENTS, AROUND_HERO, ATTACK_SPEED, EMPTY,
|
||||
ENEMIES, ENEMY, ENEMY_HP, ENEMY_SPEED, FIRANGE,
|
||||
HEAL_SPEED, HERO_HP, MIDDLE, MIN_BEAT, SFX_HEART,
|
||||
SFX_SLASH_HERO, SFX_SPAWN, SQRT2, TANGO, WALL)
|
||||
from .misc import fill_aapolygon, play, randsign, regpoly, sign
|
||||
from .weapons import Bullet
|
||||
|
||||
|
||||
|
@ -273,7 +273,7 @@ class Enemy:
|
|||
if self.spin_queue and wound: self.maze.hit_hero(wound, self.color)
|
||||
return wound
|
||||
|
||||
def get_angle(self, reversed=False):
|
||||
def get_angle(self):
|
||||
"""Return the angle of the vector whose initial point is
|
||||
the center of the screen and terminal point is the center of
|
||||
the enemy.
|
||||
|
@ -347,12 +347,12 @@ class Chameleon(Enemy):
|
|||
visible (float): time until the Chameleon is visible (in ms)
|
||||
"""
|
||||
def __init__(self, maze, x, y):
|
||||
Enemy.__init__(self, maze, x, y, 'Chameleon')
|
||||
super().__init__(maze, x, y, 'Chameleon')
|
||||
self.visible = 0.0
|
||||
|
||||
def wake(self):
|
||||
"""Wake the Chameleon up if it can see the hero."""
|
||||
if Enemy.wake(self) is True:
|
||||
if super().wake() is True:
|
||||
self.visible = 1000 / ENEMY_SPEED
|
||||
|
||||
def isunnoticeable(self, x=None, y=None):
|
||||
|
@ -361,25 +361,25 @@ class Chameleon(Enemy):
|
|||
Only search within column x and row y if these coordinates
|
||||
are provided.
|
||||
"""
|
||||
return (Enemy.isunnoticeable(self, x, y)
|
||||
return (super().isunnoticeable(x, y)
|
||||
or self.visible <= 0 and not self.spin_queue
|
||||
and self.maze.next_move <= 0)
|
||||
|
||||
def update(self):
|
||||
"""Update the Chameleon."""
|
||||
Enemy.update(self)
|
||||
super().update()
|
||||
if self.awake: self.visible -= 1000 / self.maze.fps
|
||||
|
||||
def hit(self, wound):
|
||||
"""Handle the Chameleon when it's attacked."""
|
||||
self.visible = 1000.0 / ENEMY_SPEED
|
||||
Enemy.hit(self, wound)
|
||||
super().hit(wound)
|
||||
|
||||
|
||||
class Plum(Enemy):
|
||||
"""Object representing an enemy of Plum."""
|
||||
def __init__(self, maze, x, y):
|
||||
Enemy.__init__(self, maze, x, y, 'Plum')
|
||||
super().__init__(maze, x, y, 'Plum')
|
||||
|
||||
def clone(self, other):
|
||||
"""Turn the other enemy into a clone of this Plum and return
|
||||
|
@ -396,18 +396,18 @@ class Plum(Enemy):
|
|||
class ScarletRed(Enemy):
|
||||
"""Object representing an enemy of Scarlet Red."""
|
||||
def __init__(self, maze, x, y):
|
||||
Enemy.__init__(self, maze, x, y, 'ScarletRed')
|
||||
super().__init__(maze, x, y, 'ScarletRed')
|
||||
|
||||
def fire(self):
|
||||
"""Scarlet Red doesn't shoot."""
|
||||
return False
|
||||
|
||||
def move(self):
|
||||
return Enemy.move(self, ENEMY_SPEED * SQRT2)
|
||||
return super().move(self, ENEMY_SPEED * SQRT2)
|
||||
|
||||
def slash(self):
|
||||
"""Handle the Scarlet Red's close-range attack."""
|
||||
self.wound -= Enemy.slash(self)
|
||||
self.wound -= super().slash()
|
||||
if self.wound < 0: self.wound = 0.0
|
||||
|
||||
|
||||
|
|
|
@ -16,28 +16,28 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with Brutal Maze. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
__version__ = '0.9.3'
|
||||
__version__ = '0.9.4'
|
||||
|
||||
import re
|
||||
from argparse import ArgumentParser, FileType, RawTextHelpFormatter
|
||||
from configparser import ConfigParser
|
||||
from contextlib import redirect_stdout
|
||||
from io import StringIO
|
||||
from math import atan2, radians, pi
|
||||
from math import atan2, pi, radians
|
||||
from os.path import join as pathjoin, pathsep
|
||||
from socket import socket, SOL_SOCKET, SO_REUSEADDR
|
||||
from socket import SO_REUSEADDR, SOL_SOCKET, socket
|
||||
from sys import stdout
|
||||
from threading import Thread
|
||||
|
||||
with redirect_stdout(StringIO()): import pygame
|
||||
from appdirs import AppDirs
|
||||
from palace import Context, Device, free, use_context
|
||||
from pygame import KEYDOWN, MOUSEBUTTONUP, QUIT, VIDEORESIZE
|
||||
from pygame.time import Clock, get_ticks
|
||||
from palace import free, use_context, Device, Context
|
||||
from appdirs import AppDirs
|
||||
|
||||
from .constants import SETTINGS, ICON, SFX, SFX_NOISE, HERO_SPEED, MIDDLE
|
||||
from .constants import HERO_SPEED, ICON, MIDDLE, SETTINGS, SFX, SFX_NOISE
|
||||
from .maze import Maze
|
||||
from .misc import sign, deg, join, play
|
||||
from .misc import deg, join, play, sign
|
||||
|
||||
|
||||
class ConfigReader:
|
||||
|
@ -277,8 +277,8 @@ class Game:
|
|||
connection.send(data)
|
||||
try:
|
||||
buf = connection.recv(7)
|
||||
except: # client is closed or timed out
|
||||
break
|
||||
except: # noqa
|
||||
break # client is closed or timed out
|
||||
if not buf: break
|
||||
try:
|
||||
move, angle, attack = map(int, buf.decode().split())
|
||||
|
|
|
@ -18,23 +18,23 @@
|
|||
|
||||
__doc__ = 'Brutal Maze module for the maze class'
|
||||
|
||||
from collections import defaultdict, deque
|
||||
import json
|
||||
from math import pi, log
|
||||
from collections import defaultdict, deque
|
||||
from math import log, pi
|
||||
from os import path
|
||||
from random import choice, sample
|
||||
|
||||
import pygame
|
||||
|
||||
from .characters import Hero, new_enemy
|
||||
from .constants import (
|
||||
EMPTY, WALL, HERO, ENEMY, ROAD_WIDTH, WALL_WIDTH, CELL_WIDTH, CELL_NODES,
|
||||
MAZE_SIZE, MIDDLE, INIT_SCORE, ENEMIES, SQRT2, SFX_SPAWN, SFX_MISSED,
|
||||
SFX_SLASH_ENEMY, SFX_LOSE, ADJACENTS, TANGO_VALUES, BG_COLOR, FG_COLOR,
|
||||
COLORS, HERO_HP, ENEMY_HP, ATTACK_SPEED, MAX_WOUND, HERO_SPEED,
|
||||
BULLET_LIFETIME, JSON_SEPARATORS)
|
||||
from .misc import (
|
||||
sign, deg, around, regpoly, fill_aapolygon, play, json_rec)
|
||||
from .constants import (ADJACENTS, ATTACK_SPEED, BG_COLOR,
|
||||
BULLET_LIFETIME, CELL_NODES, CELL_WIDTH, COLORS,
|
||||
EMPTY, ENEMIES, ENEMY, ENEMY_HP, FG_COLOR, HERO,
|
||||
HERO_HP, HERO_SPEED, INIT_SCORE, JSON_SEPARATORS,
|
||||
MAX_WOUND, MAZE_SIZE, MIDDLE, ROAD_WIDTH,
|
||||
SFX_LOSE, SFX_MISSED, SFX_SLASH_ENEMY, SFX_SPAWN,
|
||||
SQRT2, TANGO_VALUES, WALL, WALL_WIDTH)
|
||||
from .misc import around, deg, fill_aapolygon, json_rec, play, regpoly, sign
|
||||
from .weapons import LockOn
|
||||
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@ __doc__ = 'Brutal Maze module for miscellaneous functions'
|
|||
|
||||
from datetime import datetime
|
||||
from itertools import chain
|
||||
from math import degrees, cos, sin, pi
|
||||
from math import cos, degrees, pi, sin
|
||||
from os import path
|
||||
from random import shuffle
|
||||
|
||||
import pygame
|
||||
from pygame.gfxdraw import filled_polygon, aapolygon
|
||||
from palace import Buffer, Source
|
||||
from pygame.gfxdraw import aapolygon, filled_polygon
|
||||
|
||||
from .constants import ADJACENTS, CORNERS, MIDDLE
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ __doc__ = 'Brutal Maze module for weapon classes'
|
|||
|
||||
from math import cos, sin
|
||||
|
||||
from .constants import (BULLET_LIFETIME, SFX_SHOT_ENEMY, SFX_SHOT_HERO,
|
||||
BULLET_SPEED, ENEMY_HP, TANGO, BG_COLOR)
|
||||
from .misc import regpoly, fill_aapolygon
|
||||
from .constants import (BG_COLOR, BULLET_LIFETIME, BULLET_SPEED,
|
||||
ENEMY_HP, SFX_SHOT_ENEMY, SFX_SHOT_HERO, TANGO)
|
||||
from .misc import fill_aapolygon, regpoly
|
||||
|
||||
|
||||
class Bullet:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
from contextlib import closing, suppress
|
||||
from math import inf, atan2, degrees
|
||||
from math import atan2, degrees, inf
|
||||
from random import randrange, shuffle
|
||||
from socket import socket
|
||||
|
||||
|
@ -9,9 +9,9 @@ AROUND = [5, 2, 1, 0, 3, 6, 7, 8]
|
|||
|
||||
def get_moves(y, x):
|
||||
"""Return tuple of encoded moves."""
|
||||
return ((y - 1, x - 1), (y - 1, x), (y - 1, x + 1),
|
||||
(y, x - 1), (y, x), (y, x + 1),
|
||||
(y + 1, x - 1), (y + 1, x), (y + 1, x + 1))
|
||||
return ((y - 1, x - 1), (y - 1, x), (y - 1, x + 1), # noqa
|
||||
(y, x - 1), (y, x), (y, x + 1), # noqa
|
||||
(y + 1, x - 1), (y + 1, x), (y + 1, x + 1)) # noqa
|
||||
|
||||
|
||||
def is_wall(maze, y, x):
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<html>
|
||||
<meta charset='utf-8'>
|
||||
<title>Brutal Maze record player</title>
|
||||
<link rel='icon' type='image/png' href='_static/favicon.ico'>
|
||||
<link rel='stylesheet' type='text/css' href='_static/recplayer.css'>
|
||||
<script src='_static/brutalma.js'></script>
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'Brutal Maze'
|
||||
copyright = '2017-2020, Nguyễn Gia Phong'
|
||||
copyright = '2017-2020, Nguyễn Gia Phong' # noqa
|
||||
author = 'Nguyễn Gia Phong'
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '0.9.3'
|
||||
release = '0.9.4'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
|
21
tox.ini
Normal file
21
tox.ini
Normal file
|
@ -0,0 +1,21 @@
|
|||
[tox]
|
||||
envlist = py
|
||||
minversion = 3.3
|
||||
isolated_build = True
|
||||
|
||||
[testenv]
|
||||
deps =
|
||||
flake8-builtins
|
||||
isort
|
||||
commands =
|
||||
flake8
|
||||
isort . --check --diff
|
||||
|
||||
[flake8]
|
||||
hang-closing = True
|
||||
ignore = E129, E226, E228, E701, E704, W503
|
||||
exclude = .git,__pycache__,.tox,__init__.py
|
||||
|
||||
[isort]
|
||||
balanced_wrapping = True
|
||||
combine_as_imports = True
|
Loading…
Reference in a new issue