def _loadSettings(self):
        """
        Load settings from settings file
        """
        # Make sure that the settings file exists
        # noinspection PyUnusedLocal
        try:
            f = open(SettingsCommon.getSettingsLocation(), "r")
            f.close()
        except (ValueError, Exception) as e:
            try:
                f = open(SettingsCommon.getSettingsLocation(), "w")
                f.write("")
                f.close()
                self.logger.warning(f'Game Settings File file re-created')
            except (ValueError, Exception) as e:
                self.logger.error(f"Error: {e}")
                return

        # Read data
        self._config.read(SettingsCommon.getSettingsLocation())

        self._limits.addMissingSettings()
        self._power.addMissingSettings()
        self._gameLevel.addMissingSettings()
        self._factors.addMissingSettings()
        self._debug.addMissingSettings()
        self._torpedoSpeeds.addMissingSettings()
        self._developer.addMissingSettings()
Beispiel #2
0
 def setUpClass(cls):
     TestBase.setUpLogging()
     TestFutureEventHandlers.clsLogger = getLogger(__name__)
     SettingsCommon.determineSettingsLocation()
     TestFutureEventHandlers._setupGame()
     TestFutureEventHandlers.clsLogger.debug(
         f'Running TestFutureEventHandlers')
def main():

    TestBase.setUpLogging()
    SettingsCommon.determineSettingsLocation()

    warpEffectRunner: WarpEffectRunner = WarpEffectRunner()

    warpEffectRunner.run()
def main():
    """
    Main method
    """
    LocateResources.setupSystemLogging()
    SettingsCommon.determineSettingsLocation()

    window: TestSpriteSheet = TestSpriteSheet(SCREEN_WIDTH, SCREEN_HEIGHT,
                                              SCREEN_TITLE)
    window.setup()
    arcadeRun()
Beispiel #5
0
    def setUpClass(cls):
        TestBase.setUpLogging()
        TestGalaxy.clsLogger = getLogger(__name__)
        SettingsCommon.determineSettingsLocation()

        TestBase.resetSingletons()

        TestGalaxy.clsGameSettings = GameSettings()
        TestGalaxy.clsGameSettings.debugCollectKlingonQuadrantCoordinates = True

        TestGalaxy.clsGameState = GameState()
        TestGalaxy.clsGalaxy = Galaxy()
Beispiel #6
0
def main():

    TestBase.setUpLogging()
    SettingsCommon.determineSettingsLocation()

    window: Window = Window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
    startView: TestEventScheduler = TestEventScheduler()

    window.show_view(startView)

    startView.setup()

    arcadeRun()
Beispiel #7
0
def main():
    """
    Main method
    """
    TestBase.setUpLogging()
    SettingsCommon.determineSettingsLocation()

    arcadeWindow: Window = Window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
    shootingView: TestShooting = TestShooting()

    arcadeWindow.set_exclusive_keyboard(exclusive=True)
    arcadeWindow.show_view(shootingView)

    shootingView.setup()

    arcadeRun()
Beispiel #8
0
    def init(self, *args, **kwds):

        self.logger: Logger = getLogger(__name__)

        BaseSubSetting.init(self, *args, **kwds)

        self._settingsCommon: SettingsCommon = SettingsCommon(self._config)
Beispiel #9
0
def main():

    TestBase.setUpLogging()
    SettingsCommon.determineSettingsLocation()

    arcadeWindow: Window = Window(title=SCREEN_TITLE,
                                  width=SCREEN_WIDTH,
                                  height=SCREEN_HEIGHT)
    arcadeWindow.background_color = color.BLACK
    arcadeWindow.clear()

    warpDialog: WarpDialog = WarpDialog(window=arcadeWindow,
                                        completeCallback=completeCallback)

    arcadeWindow.show_view(warpDialog)

    arcadeRun()
Beispiel #10
0
    def init(self, *args, **kwds):
        """
        This is a singleton based on the inheritance hierarchy
        """
        self.logger: Logger = getLogger(__name__)

        BaseSubSetting.init(self, *args, **kwds)

        self._settingsCommon: SettingsCommon = SettingsCommon(self._config)
Beispiel #11
0
def main():

    SettingsCommon.determineSettingsLocation()

    if ".." not in sysPath:
        sysPath.append("..")  # access to the classes to test

    testAll: TestAll = TestAll()
    status: int = 0
    if len(sysArgv) < 2:
        status: int = testAll.runTextTestRunner()
    else:
        for param in sysArgv[1:]:
            if param[:22] == "--produce-html-results":
                print(f'Running HTML Tests')
                status: int = testAll.runHtmlTestRunner()

    return status
    def setup(self):

        SettingsCommon.determineSettingsLocation()

        # self._backgroundSprite: QuadrantBackground = QuadrantBackground()

        fqFileName: str = LocateResources.getResourcesPath(resourcePackageName=LocateResources.IMAGE_RESOURCES_PACKAGE_NAME,
                                                           bareFileName='QuadrantBackground.png')
        self.background = load_texture(fqFileName)
        # Create the 'physics engine'
        # self.physicsEngine = PhysicsEngineSimple(self._enterprise, self._hardSpriteList)

        # These singletons are initialized for the first time
        self._gameSettings = GameSettings()     # Be able to read the preferences file
        self._gameState    = GameState()        # Set up the game parameters which uses the above
        self._gameEngine   = GameEngine()       # Then the engine needs to be initialized
        self._intelligence = Intelligence()
        self._computer     = Computer()
        self._galaxy       = Galaxy()           # This essentially finishes initializing most of the game

        self._messageConsole: MessageConsole = MessageConsole()
        self._eventEngine:    EventEngine    = EventEngine(self._messageConsole)

        self._statusConsole:  StatusConsole = StatusConsole(gameView=self)       # UI elements
        self._soundMachine:   SoundMachine = SoundMachine()

        self._enterprise: Enterprise = self._gameState.enterprise

        # Important mediators
        self._enterpriseMediator: EnterpriseMediator = EnterpriseMediator(view=self, warpTravelCallback=self._enterpriseHasWarped)
        self._quadrantMediator:   QuadrantMediator   = QuadrantMediator()
        self._galaxyMediator:     GalaxyMediator     = GalaxyMediator()

        self._quadrant: Quadrant = self._galaxy.currentQuadrant

        self._gameState.currentQuadrantCoordinates = self._galaxy.currentQuadrant.coordinates

        # And finally the rest of the UI elements
        self._quadrantMediator.enterQuadrant(quadrant=self._quadrant, enterprise=self._enterprise)

        self.logger.info(f'{self._enterprise=}')
        self.logger.info(f'{self._quadrant=}')
        self.logger.info(f'Setup Complete')
    def init(self):

        self.logger: Logger = getLogger(__name__)

        self._config: ConfigParser = cast(ConfigParser, None)    # initialized when empty preferences created

        self._settingsCommon: SettingsCommon       = SettingsCommon()
        self._limits:         LimitsSettings       = LimitsSettings()
        self._power:          PowerSettings        = PowerSettings()
        self._gameLevel:      GameLevelSettings    = GameLevelSettings()
        self._factors:        FactorsSettings      = FactorsSettings()
        self._debug:          DebugSettings        = DebugSettings()
        self._torpedoSpeeds:  TorpedoSpeedSettings = TorpedoSpeedSettings()
        self._developer:      DeveloperSettings    = DeveloperSettings()

        self._createEmptySettings()
        self._loadSettings()

        self.logger.info(f'Game Settings singleton initialized')
Beispiel #14
0
    def setUpClass(cls):
        """"""
        TestBase.setUpLogging()
        SettingsCommon.determineSettingsLocation()

        TestEventEngine._setupGame()
 def setUpClass(cls):
     TestBase.setUpLogging()
     TestTorpedoSpeeds.clsLogger = getLogger(__name__)
     SettingsCommon.determineSettingsLocation()
 def setUpClass(cls):
     TestBase.setUpLogging()
     TestCoordinates.clsLogger = getLogger(__name__)
     SettingsCommon.determineSettingsLocation()
 def setUpClass(cls):
     TestBase.setUpLogging()
     TestIntelligence.clsLogger = getLogger(__name__)
     SettingsCommon.determineSettingsLocation()
Beispiel #18
0
 def setUpClass(cls):
     TestBase.setUpLogging()
     TestMessageConsole.clsLogger = getLogger(__name__)
     SettingsCommon.determineSettingsLocation()