def test_print_out(self): expected_output = "Prueba de salida\n" console = Console() capturedOutput = io.StringIO() sys.stdout = capturedOutput console.print_out("Prueba de salida") sys.stdout = sys.__stdout__ self.assertEqual(expected_output, capturedOutput.getvalue())
def __init__(self, width, height, title, game_xml_file): super().__init__(width, height, title) file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) print('working dir: ' + str(os.getcwd())) self.z_level_renderer: ZlvlRenderer = ZlvlRenderer(NUM_Z_LEVELS) self.game_logic: GameLogic = GameLogic(game_xml_file, self.z_level_renderer.z_levels) self.hi = HumanInteraction(self.game_logic, self.z_level_renderer.z_levels[2], self.z_level_renderer.z_levels[4]) self.console: Console = Console() self.ui = UI(self.game_logic, self.hi, SCREEN_WIDTH, SCREEN_HEIGHT) self.z_level_renderer.ui = self.ui self.z_level_renderer.gl = self.game_logic self.z_level_renderer.camera_event_listener.append(self.hi) self.camera: Optional[Camera] = None self.commands: [(str, str)] = [] # for performance measurement self.draw_time: float = .0 self.max_update_time: float = .0 self.frame_count = 0 self.fps_start_timer = None self.fps = None self.num_of_sprites: int = 0 self.fps_colour = arcade.color.WHITE self.draw_time_colour = arcade.color.WHITE self.wall_clock_time = .0 if Definitions.SHOW_AI_CTRL: self.ai_ctrl: Optional[AIControl] = None
class Game(object): """docstring for Game""" def __init__(self): super(Game, self).__init__() self.console_manager = Console() self.factory = None self.thinker = None self.guesser = None def mainloop(self): game_end = False self.thinker.think() while not game_end: number_guessed = self.guesser.think() thinker_response = self.thinker.analize(number_guessed) game_end = self.guesser.analize(thinker_response) self.console_manager.print_out("El número correcto es {}".format(number_guessed)) def game_initialize(self): game_initializated = False while not game_initializated: self.console_manager.print_menu() game_type = int(self.console_manager.handle_input("Elija el modo de juego: ")) if game_type == 1: self.factory = PcVsHumanFactory() game_initializated = True elif game_type == 2: self.factory = HumanVsPcFactory() game_initializated = True else: self.console_manager.print_out("Opción no válida // ") self.thinker = self.factory.give_thinker_player() self.guesser = self.factory.give_guesser_player()
#! /usr/bin/env python3 """ File: main.py Author: Dibyaranjan Sathua Created on: 07/09/20, 2:05 PM This is the main function to use the repricer tool using console input. """ from src.console import Console from src.amazon import Amazon if __name__ == "__main__": Console.read() amazon = Amazon(seller_name=Console.SellerName, target_rating=Console.TargetRating, min_profit=Console.MinProfit, input_file=Console.FileName) amazon.run()
''' Created on Feb 22, 2017 @author: Razvan ''' from src.repo import FileRepository from src.Sentence import SentenceValidator from src.controller import Controller from src.console import Console if __name__ == '__main__': sentenceRepo = FileRepository(SentenceValidator, "input.txt") scrambleController = Controller(sentenceRepo) console = Console(scrambleController) try: console.run() except Exception as ex: print(ex) print("Bye")
''' Created on Feb 23, 2017 @author: Razvan ''' from src.console import Console from src.controllers import Controller from src.repo import Repository from src.validators import BattleshipValidator if __name__ == '__main__': playerBattleshipsRepo = Repository(BattleshipValidator) computerBattleshipsRepo = Repository(BattleshipValidator) gameController = Controller(playerBattleshipsRepo, computerBattleshipsRepo) console = Console(gameController) try: console.run() except Exception as ex: print(ex) print("Bye")
''' Created on Feb 22, 2017 @author: Razvan ''' from src.domain import Taximestrist from src.validators import TaximetristValidator, OrderValidator from src.repository import FileRepository from src.controllers import OrderController from src.console import Console if __name__ == '__main__': taxiRepo = FileRepository(TaximetristValidator, "taxi") orderRepo = FileRepository(OrderValidator, "order") orderController = OrderController(taxiRepo, orderRepo) console = Console(orderController) try: console.run() except Exception as ex: print(ex) print("Exit!")
def init_console(parser): """Initialises the console""" font = pygame.font.SysFont("Courier", 12) text = Text(font, size=(200, 40), position=(0, 0)) error_text = init_error_message(parser) return Console(parser, text, error_text)
def test_console_is_single_instance(self): console_one = Console() console_two = Console() self.assertEqual(console_one, console_two, "No son misma instancia")
def test_console_instanciate(self): instance = Console() self.assertIsInstance(instance, Console, 'No se pudo instanciar la consola')
def __init__(self): super(Game, self).__init__() self.console_manager = Console() self.factory = None self.thinker = None self.guesser = None
def __init__(self): self.console_manager = Console()