diff options
author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2020-09-19 11:12:54 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2020-09-19 11:12:54 +0700 |
commit | 12b798ac0058fefeb315f98f5385d96ccb322faa (patch) | |
tree | a83509c7c257aed00e8c8ef5c760037e4d4d9273 /brutalmaze | |
parent | d97e1a1294ba3bc542b0611b39f86b218de935b0 (diff) | |
download | brutalmaze-12b798ac0058fefeb315f98f5385d96ccb322faa.tar.gz |
Employ linters
Diffstat (limited to 'brutalmaze')
-rw-r--r-- | brutalmaze/characters.py | 32 | ||||
-rw-r--r-- | brutalmaze/game.py | 18 | ||||
-rw-r--r-- | brutalmaze/maze.py | 20 | ||||
-rw-r--r-- | brutalmaze/misc.py | 4 | ||||
-rw-r--r-- | brutalmaze/weapons.py | 6 |
5 files changed, 40 insertions, 40 deletions
diff --git a/brutalmaze/characters.py b/brutalmaze/characters.py index 7e9312e..7fa8c93 100644 --- a/brutalmaze/characters.py +++ b/brutalmaze/characters.py @@ -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 diff --git a/brutalmaze/game.py b/brutalmaze/game.py index ecf23d6..8b11228 100644 --- a/brutalmaze/game.py +++ b/brutalmaze/game.py @@ -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()) diff --git a/brutalmaze/maze.py b/brutalmaze/maze.py index 8be20fe..73bccf5 100644 --- a/brutalmaze/maze.py +++ b/brutalmaze/maze.py @@ -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 diff --git a/brutalmaze/misc.py b/brutalmaze/misc.py index 60d89c9..db1be00 100644 --- a/brutalmaze/misc.py +++ b/brutalmaze/misc.py @@ -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 diff --git a/brutalmaze/weapons.py b/brutalmaze/weapons.py index b66ad80..e42f127 100644 --- a/brutalmaze/weapons.py +++ b/brutalmaze/weapons.py @@ -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: |