def __init__(self, initSound=False, useMidi=False, debug=True):
        self.soundVolume = 1.0
        self.musicVolume = 1.0
        self.conf = lsconfig.readConfiguration()
        self.sounds = dict()
        self.useMidi = useMidi
        self.playlist = self.Playlist(self)

        self.musicIsPlaying = False

        self._init()
        if initSound:
            self.playSound('StartUp.wav')

        self.setSoundVolume(0.75)
        self.setMusicVolume(0.75)
    def _loadScoresFromDisk(self, fileName=None):

        if fileName is None:
            conf = lsconfig.readConfiguration()
            
            try:
                scoresFile = conf['SCORESFILE']
            except KeyError:
                scoresFile = os.path.join(conf['CONFIGDIR'], ".scores")
        else:
            scoresFile = fileName

        self.scoresFile = shelve.open(scoresFile)   # Shelve is faster than json
                                                    # Important since this single
                                                    # db stores all scores for
                                                    # all games


        try:
            return(defaultdict(list, self.scoresFile[self.gameName]))
        except KeyError:
            return defaultdict(list)
Beispiel #3
0
import imp
import multiprocessing
import os
import random
import time


from copy import copy

from lightsweeper.lsgame import LSGameEngine
from lightsweeper.lsconfig import userSelect
from lightsweeper import lscartridge
from lightsweeper import lsconfig

conf = lsconfig.readConfiguration()
try:
    GAMESDIRS = [conf["GAMESDIR"]]
except KeyError:
    print("WARNING: 'GAMESDIR' is not set.")
    GAMESDIRS = [os.path.abspath(os.getcwd())]

NUMPLAYS = 0 # The number of games the player can play (0 is infinite/free play)

try:
    rfidcart = lscartridge.LSRFID()
except lscartridge.NoCartReader:
    print("No cartridge reader found.")
    rfidcart = False
except lscartridge.ReaderNotSupported as e:
    print("Cartridge reader is not supported: {:s}".format(str(e)))
Beispiel #4
0
def main():

    print("\nLightsweeper Configuration utility")

    conf = lsconfig.readConfiguration()
    try:
        floorDir = conf["FLOORSDIR"]
    except KeyError:
        floorDir = conf["CONFIGDIR"]

    floorFiles = list(filter(lambda ls: ls.endswith(".floor"), os.listdir(floorDir)))

    if len(floorFiles) is 0:
        config = None
    else:
        choices = floorFiles
        NEW = "New Floor"
        choices.insert(0, NEW)
        selection = userSelect(choices, "\nWhich floor configuration would you like to edit?")
        if selection == NEW:
            config = None
        else:
            fileName = selection
            absFloorConfig = os.path.abspath(os.path.join(floorDir, fileName))
            try:
                config = LSFloorConfig(absFloorConfig)
            except lsconfig.CannotParseError as e:
                print("\nCould not parse the configuration at {:s}: {:s}".format(absFloorConfig, e))

    if config is None:                              # Start a new configuration
        config = interactiveConfig()

    elif config.cells is 0:     # Start a new configuration with a pre-existing filename
        config = interactiveConfig(config)

    else:                       # Load an existing configuration for editing
        print("\nThis is the configuration saved in " + config.fileName + ":\n")
        config.printConfig()

        print("\nBut the editing code is not here yet. Sorry.")
        exit()


    print("\nThis is the configuration: ")
    config.printConfig()

    if config.fileName is None:
        fileName = input("\nPlease enter a filename for this configuration (or blank to not save): ")
    else:
        fileName = config.fileName
    if fileName == "":
        print("OK, not saving this configuration.")
    else:
        try:
            config.writeConfig(fileName)
        except FileExistsError:
            if yesNO("{:s} already exists, would you like to overwrite it?".format(config.fileName)) is True:
                config.writeConfig(fileName, overwrite=True)
            else:
                print("OK, not saving any changes to this configuration.")
            

    input("\nDone - Press the Enter key to exit") # keeps double-click window open