Ejemplo n.º 1
0
 def __init__(self):
     # INITIALIZE
     if self.fullscreen:
         self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
     else:
         self.screen = pygame.display.set_mode(self.resolution)
     pygame.font.init()
     # RUN LEVEL VARIABLES
     self.my_ship = ship.Ship()
     self.crew = [crew.Crew()]
     self.mood = mood.Mood()
     self.states = [Encounter()]
     # LOAD GRAPHICS
     self.myfont = pygame.font.SysFont('Courier New', self.font_scale)
     self.bar_gui = pygame.image.load("bitmaps/bar_gui.bmp")
     self.cursor = pygame.image.load("bitmaps/cursor.bmp").convert()
     self.cursor.set_colorkey(self.black)
     paths_red_img = pygame.image.load("bitmaps/pathsRed.bmp").convert()
     self.pathsRed = [''] * 6
     for i in range(6):
         rect = pygame.Rect((12 * i, 0, 12, 12))
         self.pathsRed[i] = pygame.Surface(rect.size).convert()
         self.pathsRed[i].blit(paths_red_img, (0, 0), rect)
         self.pathsRed[i].set_colorkey((0, 0, 0))
     # UPDATE
     self.update()
Ejemplo n.º 2
0
def test_bulk_start_10_msgs(sqs_session=None,
                            sqs_queue_name=None,
                            mock_=None,
                            *args,
                            **kwargs):
    logger = logging.getLogger('default')
    required_only = {
        'sqs_session': sqs_session,
        'queue_name': sqs_queue_name,
        'MessageProcessor': BulkMsgProcessor,
        'logger': logger,
        'statsd': statsd,
        'worker_limit': 1,
        'wait_time': 20,
        'max_number_of_messages': 10,
        'bulk_mode': True
    }

    c = crew.Crew(**required_only)
    # When you really want to be sure about what code you are hitting
    # assert sqs_session.using_real_aws == False
    c.start()
    time.sleep(30)
    try:
        assert sqs_session.delete_count == sqs_session.receive_count
        assert sqs_session.delete_count == 10
    except:
        logging.exception('Exception from test_bulk_start_10_msgs')
        c.stop()
        raise
    else:
        c.stop()
Ejemplo n.º 3
0
def test_crew_without_sqs():
    no_sqs = {
        'MessageProcessor': MsgProcessor,
        'logger': logging.getLogger('default'),
        'statsd': statsd
    }

    with pytest.raises(TypeError):
        crew.Crew(**no_sqs)
Ejemplo n.º 4
0
def test_crew_with_resource():
    with_resource = {
        'sqs_resource': 'resource',
        'MessageProcessor': MsgProcessor,
        'logger': logging.getLogger('default'),
        'statsd': statsd
    }

    assert crew.Crew(**with_resource).sqs_resource == 'resource'
Ejemplo n.º 5
0
def test_crew_with_no_optionals():
    required_only = {
        'sqs_session': 'fake session',
        'queue_name': 'something',
        'MessageProcessor': MsgProcessor,
        'logger': logging.getLogger('default'),
        'statsd': statsd
    }

    assert crew.Crew(**required_only).worker_limit == 10
Ejemplo n.º 6
0
def test_crew_with_bulk_msg_processor():
    required_only = {
        'sqs_session': 'fake session',
        'queue_name': 'something',
        'MessageProcessor': BulkMsgProcessor,
        'logger': logging.getLogger('default'),
        'statsd': statsd,
        'bulk_mode': True
    }

    assert crew.Crew(**required_only).MessageProcessor == BulkMsgProcessor
Ejemplo n.º 7
0
def test_crew_with_all_args():
    optionals = {
        'sqs_session': 'fake session',
        'queue_name': 'something',
        'MessageProcessor': MsgProcessor,
        'logger': logging.getLogger('default'),
        'statsd': statsd,
        'sentry': None,
        'worker_limit': 9
    }

    assert crew.Crew(**optionals).worker_limit == 9
Ejemplo n.º 8
0
    def test_crew_with_bulk_msg_processor(self):
        """
        Assert that MessageProcessor param equals to BulkMsgProcessor class defined
        """
        required_only = {
            'sqs_session': 'fake session',
            'queue_name': 'something',
            'MessageProcessor': BulkMsgProcessor,
            'logger': logging.getLogger('default'),
            'bulk_mode': True
        }

        assert crew.Crew(**required_only).MessageProcessor == BulkMsgProcessor
Ejemplo n.º 9
0
    def test_poll_queue_invoked(self):
        """
        Assert that bulk_mode param is set to False
        """
        required_only = {
            'sqs_session': 'fake session',
            'queue_name': 'something',
            'sqs_resource': 'resource',
            'MessageProcessor': BulkMsgProcessor,
            'logger': logging.getLogger('default'),
            'bulk_mode': False
        }

        c = crew.Crew(**required_only)
        assert c.bulk_mode == False
Ejemplo n.º 10
0
def test_crew_without_sqs():
    no_sqs = {
        'MessageProcessor': MsgProcessor,
        'logger': logging.getLogger('default'),
        'statsd': statsd
    }

    with pytest.raises(TypeError):
        crew.Crew(**no_sqs)

# TODO: this test needs an sqs queue to work
# def test_start():
#     required_only = {
#         'sqs_session': None,
#         'queue_name': 'something',
#         'MessageProcessor': MsgProcessor,
#         'logger': logging.getLogger('default'),
#         'statsd': statsd
#     }

#     c = crew.Crew(**required_only)
#     c.start()
Ejemplo n.º 11
0
    def __init__(self):
        
        self.state = 3  # Initilise with intro set, normally 3.

        self.creditText = ["1994 Channel 7, Destiny: Virtual",
                          "Released Under GPL V3.0 in 2013 by Jeremy D Stanton of IronSeed.net",
                          "2013 y-salnikov - Converted IronSeed to FreePascal and GNU/Linux",
                          "2016 Nuke Bloodaxe - Pascal Code Tidying/Prep",
                          "2020 Nuke Bloodaxe - Complete Python Refactor/Rewrite",
                          "All rights reserved."]
        self.versionText = ["Ironseed", g.version]
        
        # Set Window version and Display surface
        print("Initialise Screen.")
        self.displaySurface = pygame.display.set_mode(g.size)
        pygame.display.set_caption(self.versionText[0]+' '+self.versionText[1])
        
        # Initialise game objects
        print("Initilising IronSeed Game Time")
        g.starDate = [2, 3, 3784, 8, 75] # M,D,Y,H,M.
        g.gameDate = h.IronSeedTime()
        
        # Populate Item dictionaries
        print("Loading Items")
        items.loadItemData()
        print("Loading Scan Data")
        planets.loadScanData()
        print("Initialising Planets")
        planets.initialisePlanets()
        print("Loading Planetary Systems")
        planets.loadPlanetarySystems()
        print("Populating Planetary Systems")
        planets.populatePlanetarySystems()
        print("Loading Crew Data")
        crew.loadCrewData()
        print("Initialising Internal Objects:")
        weaponsAndShields.loadWeaponsAndShields()
        print("Crew Objects")
        self.crew = crew.Crew()
        print("Ship Objects")
        self.ship = ship.Ship()
        print("Intro Objects")
        self.intro = intro_main.IronseedIntro()
        print("Game Generator Objects")
        self.generator = gen.Generator(self.ship, self.crew)  # Settings at new-game state.
        print("Commnications System Objects")
        self.crewCom = crewC.crewComm(self.crew)  # Needs to have crew data set.
        print("Planet Scanner Objects")
        self.planetScanner = PlanetScanner.PlanetScanner(self.ship, self.crew)
        print("EGO Synth Manipulation System")
        self.EGOManipulation = EGOSynthManipulator.EGOManipulator(self.crew)
        print("Command Deck System")
        self.commandDeck = commandDeck.CommandDeck(self.ship, self.crew)
        print("Creating Main Menu")
        self.mainMenu = mainMenu.MainMenu()
        
        self.states = {1:self.generator.update,  # The crew + ship selection system.
                       2:self.mainMenu.update,  # Main menu.
                       3:self.intro.update,  # Game Intro - quite useful for testing.
                       4:"cargo",  # Ship cargo system, includes item assembly.
                       5:self.planetScanner.update,  # Planet surveys and drone ops.
                       6:"Communications",  # Comms between ships/planets
                       7:"Combat",  # Normal and simulated combat.
                       8:self.crewCom.update,  # "talk" with crew members.
                       9:self.EGOManipulation.update,  # Ego-synth manipulation.
                       10:self.commandDeck.update,  # Main game command deck.
                       11: "Load Game",
                       12: "Save Game" }
        
        self.interactive = {1:self.generator.interact,
                            2:self.mainMenu.interact,
                            3:self.intro.interact,
                            4:"cargo",
                            5:self.planetScanner.interact,
                            6:"Communications",
                            7:"Combat",
                            8:self.crewCom.interact,
                            9:self.EGOManipulation.interact,
                            10:self.commandDeck.interact,
                            11:"Load Game",
                            12:"Save Game"}
        print("We Are GO!")
Ejemplo n.º 12
0
    def __init__(self):
        
        self.state = 3  # Initilise with intro set, normally 3.

        self.creditText = ["1994 Channel 7, Destiny: Virtual",
                          "Released Under GPL V3.0 in 2013 by Jeremy D Stanton of IronSeed.net",
                          "2013 y-salnikov - Converted IronSeed to FreePascal and GNU/Linux",
                          "2016 Nuke Bloodaxe - Pascal Code Tidying/Prep",
                          "2020 Nuke Bloodaxe - Complete Python Refactor/Rewrite",
                          "All rights reserved."]
        self.versionText = ["Ironseed", g.version]
        
        # Set Window version and Display surface
        print("Initialise Screen.")
        self.displaySurface = pygame.display.set_mode(g.size)
        pygame.display.set_caption(self.versionText[0]+' '+self.versionText[1])
        
        # Initialise game objects
        print("Initilising IronSeed Game Time")
        g.starDate = [2, 3, 3784, 8, 75] # M,D,Y,H,M.
        g.gameDate = h.IronSeedTime()
        
        # Populate Item dictionaries
        print("Loading Items: ", end='')
        items.loadItemData()
        print("complete.")
        print("Loading Scan Data: ", end='')
        planets.loadScanData()
        print("complete.")
        print("Initialising Planets: ", end='')
        planets.initialisePlanets()
        print("complete.")
        print("Loading Planetary Systems: ", end='')
        planets.loadPlanetarySystems()
        print("complete.")
        print("Populating Planetary Systems: ", end='')
        planets.populatePlanetarySystems()
        print("complete.")
        print("Loading Crew Data: ", end='')
        crew.loadCrewData()
        print("complete.")
        print("Initialising Internal Objects.")
        print("Weapon and Shield Objects: ", end='')
        weaponsAndShields.loadWeaponsAndShields()
        print("complete.")
        print("Crew Objects: ", end='')
        self.crew = crew.Crew()
        print("complete.")
        print("Ship Objects: ", end='')
        self.ship = ship.Ship()
        print("complete.")
        print("Intro Objects: ", end='')
        self.intro = intro_main.IronseedIntro()
        print("complete.")
        print("Game Generator Objects: ", end='')
        self.generator = gen.Generator(self.ship, self.crew)  # Settings at new-game state.
        print("complete.")
        print("Commnications System Objects: ", end='')
        self.crewCom = crewC.crewComm(self.crew)  # Needs to have crew data set.
        print("complete.")
        print("Planet Scanner Objects: ", end='')
        self.planetScanner = PlanetScanner.PlanetScanner(self.ship, self.crew)
        print("complete.")
        print("EGO Synth Manipulation System: ", end='')
        self.EGOManipulation = EGOSynthManipulator.EGOManipulator(self.crew)
        print("complete.")
        print("Cargo Deck Objects: ", end='')
        self.cargoDeck = cargoDeck.CargoDeck(self.ship)
        print("complete.")
        print("Crew Status Objects: ", end='')
        self.crewStatus = crewStatus.CrewStatus(self.crew)
        print("complete.")
        print("Plant Comms Objects: ", end='')
        self.planetComms = planetComms.PlanetComm(self.ship)
        print("complete.")
        print("Command Deck System: ", end='')
        self.commandDeck = commandDeck.CommandDeck(self.ship, self.crew)
        print("complete.")
        print("Creating Main Menu: ", end='')
        self.mainMenu = mainMenu.MainMenu()
        print("complete.")
        
        # Note:  While in Alpha, the below state list is not exhaustive.
        
        self.states = {1:self.generator.update,  # The crew + ship selection system.
                       2:self.mainMenu.update,  # Main menu.
                       3:self.intro.update,  # Game Intro - quite useful for testing.
                       4:self.cargoDeck.update,  # Ship cargo system - make mistakes fast.
                       5:self.planetScanner.update,  # Planet surveys and drone ops.
                       6:"Ship Hail",  # Comms between ships, with alien character portrait.
                       7:"Combat",  # Normal and simulated combat.
                       8:self.crewCom.update,  # "talk" with crew members.
                       9:self.EGOManipulation.update,  # Ego-synth manipulation.
                       10:self.commandDeck.update,  # Main game command deck.
                       11: "Load Game", # Load Game Screen
                       12: "Save Game", # Save Game Screen (exists?)
                       13: self.crewStatus.update, # Crew character status screen.
                       14: self.planetComms.update, # Ship to planet comms.
                       15: "Ship Logs", # Listing of all log files.
                       16: "Creation",  # really item assembly/disassembly.
                       17: "Sector Map" # Inter-Sector travel.
                       }
        
        self.interactive = {1:self.generator.interact,
                            2:self.mainMenu.interact,
                            3:self.intro.interact,
                            4:self.cargoDeck.interact,
                            5:self.planetScanner.interact,
                            6:"Communications",
                            7:"Combat",
                            8:self.crewCom.interact,
                            9:self.EGOManipulation.interact,
                            10:self.commandDeck.interact,
                            11:"Load Game",
                            12:"Save Game",
                            13: self.crewStatus.interact,
                            14: self.planetComms.interact,
                            15: "Ship Logs",
                            16: "Creation",
                            17: "Sector Map"
                            }
        print("We Are GO!")