PEP8 formatter changes
This commit is contained in:
		
							parent
							
								
									727a0737c6
								
							
						
					
					
						commit
						f05dfdef55
					
				
					 5 changed files with 20 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -13,17 +13,20 @@ MAP_WIDTH, MAP_HEIGHT = 80, 45
 | 
			
		|||
FONT_CP437 = 'terminal16x16_gs_ro.png'
 | 
			
		||||
FONT_BDF = 'ter-u32n.bdf'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def parse_args(argv, *a, **kw):
 | 
			
		||||
    parser = argparse.ArgumentParser(*a, **kw)
 | 
			
		||||
    parser.add_argument('--debug', action='store_true', default=True)
 | 
			
		||||
    args = parser.parse_args(argv)
 | 
			
		||||
    return args
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def walk_up_directories_of_path(path):
 | 
			
		||||
    while path and path != '/':
 | 
			
		||||
        path = os.path.dirname(path)
 | 
			
		||||
        yield path
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def find_fonts_directory():
 | 
			
		||||
    '''Walk up the filesystem tree from this script to find a fonts/ directory.'''
 | 
			
		||||
    for parent_dir in walk_up_directories_of_path(__file__):
 | 
			
		||||
| 
						 | 
				
			
			@ -36,6 +39,7 @@ def find_fonts_directory():
 | 
			
		|||
 | 
			
		||||
    return possible_fonts_dir
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main(argv):
 | 
			
		||||
    '''
 | 
			
		||||
    Beginning of the game
 | 
			
		||||
| 
						 | 
				
			
			@ -68,6 +72,7 @@ def main(argv):
 | 
			
		|||
    with tcod.context.new(columns=console.width, rows=console.height, tileset=tileset) as context:
 | 
			
		||||
        engine.run_event_loop(context, console)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def run_until_exit():
 | 
			
		||||
    '''
 | 
			
		||||
    Run main() and call sys.exit when it finishes. In practice, this function will never return. The game engine has
 | 
			
		||||
| 
						 | 
				
			
			@ -76,4 +81,5 @@ def run_until_exit():
 | 
			
		|||
    result = main(sys.argv)
 | 
			
		||||
    sys.exit(0 if not result else result)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
run_until_exit()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,6 +17,8 @@ if TYPE_CHECKING:
 | 
			
		|||
    from .engine import Engine
 | 
			
		||||
 | 
			
		||||
# pylint: disable=too-few-public-methods
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class AI(Component):
 | 
			
		||||
    '''An abstract class providing AI for an entity.'''
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -28,6 +30,7 @@ class AI(Component):
 | 
			
		|||
        '''Produce an action to perform'''
 | 
			
		||||
        raise NotImplementedError()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class HostileEnemy(AI):
 | 
			
		||||
    '''Entity AI for a hostile enemy.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +63,8 @@ class HostileEnemy(AI):
 | 
			
		|||
            direction_to_next_position = entity_position.direction_to_adjacent_point(next_position)
 | 
			
		||||
 | 
			
		||||
            if engine.map.visible[tuple(self.entity.position)]:
 | 
			
		||||
                log.AI.info('`-> Hero is visible to %s, bumping %s (%s)', self.entity, direction_to_next_position, next_position)
 | 
			
		||||
                log.AI.info('`-> Hero is visible to %s, bumping %s (%s)',
 | 
			
		||||
                            self.entity, direction_to_next_position, next_position)
 | 
			
		||||
 | 
			
		||||
            return BumpAction(self.entity, direction_to_next_position)
 | 
			
		||||
        else:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,6 +7,7 @@ from typing import Optional
 | 
			
		|||
class Component:
 | 
			
		||||
    '''A base, abstract Component that implement some aspect of an Entity's behavior.'''
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Fighter(Component):
 | 
			
		||||
    '''A Fighter is an Entity that can fight. That is, it has hit points (health), attack, and defense.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,6 +14,7 @@ from .geometry import Direction, Point
 | 
			
		|||
if TYPE_CHECKING:
 | 
			
		||||
    from .engine import Engine
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class EventHandler(tcod.event.EventDispatch[Action]):
 | 
			
		||||
    '''Abstract event handler class'''
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -49,6 +50,7 @@ class EventHandler(tcod.event.EventDispatch[Action]):
 | 
			
		|||
    def ev_quit(self, event: tcod.event.Quit) -> Optional[Action]:
 | 
			
		||||
        return ExitAction()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class MainGameEventHandler(EventHandler):
 | 
			
		||||
    '''
 | 
			
		||||
    Handler of `tcod` events for the main game.
 | 
			
		||||
| 
						 | 
				
			
			@ -95,6 +97,7 @@ class MainGameEventHandler(EventHandler):
 | 
			
		|||
            mouse_point = None
 | 
			
		||||
        self.engine.current_mouse_point = mouse_point
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GameOverEventHandler(EventHandler):
 | 
			
		||||
    '''When the game is over (the hero dies, the player quits, etc), this event handler takes over.'''
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,10 @@
 | 
			
		|||
# Eryn Wells <eryn@erynwells.me>
 | 
			
		||||
 | 
			
		||||
'''
 | 
			
		||||
This module defines the level map, a number of basic building blocks (Rooms, etc), and objects that generate various
 | 
			
		||||
parts of a map.
 | 
			
		||||
'''
 | 
			
		||||
 | 
			
		||||
import random
 | 
			
		||||
 | 
			
		||||
import numpy as np
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue