Beispiel #1
0
def startGame():
    try:
        testLobby = Lobby(generateRandomString(4))
        userID = generateRandomString(10)
        testLobby.startGame(userID)
        flag = True
    except:
        flag = False
    return flag
Beispiel #2
0
  def showTutorial(self):
    # evilynux - Make sure tutorial exists before launching
    #tutorialpath = self.engine.getPath(os.path.join("songs","tutorial"))
    tutorialpath = self.engine.tutorialFolder
    if not os.path.isdir(self.engine.resource.fileName(tutorialpath)):
      Log.debug("No folder found: %s" % tutorialpath)
      Dialogs.showMessage(self.engine, _("No tutorials found!"))
      return

    if self.engine.isServerRunning():
      return

    players = Dialogs.activateControllers(self.engine, 1) #akedrou
    if players == 0:
      return
    
    Config.set("game","game_mode", 0)    #MFH - ensure tutorial can work with new logic that depends on this mode variable
    Config.set("game","multiplayer_mode", 0)    #MFH - ensure tutorial can work with new logic that depends on this mode variable
    Config.set("game", "players", 1)
    Config.set("game", "tut", True)
    
    #Config.set("game","game_mode", 1) #MFH - don't force practice mode.... this is problematic.

    self.engine.startServer()
    self.engine.resource.load(self, "session", lambda: self.engine.connect("127.0.0.1"), synch = True)

    if Dialogs.showLoadingScreen(self.engine, lambda: self.session and self.session.isConnected):
      self.launchLayer(lambda: Lobby(self.engine, self.session, singlePlayer = True))
Beispiel #3
0
 def createLobby(self):
     self.checkForDeadLobbies()
     codeToCheck = self.generateRandomString(4)
     while (codeToCheck in self.lobbyList.keys()):
         codeToCheck = self.generateRandomString(4)
     self.lobbyList[codeToCheck] = Lobby(codeToCheck)
     return codeToCheck
Beispiel #4
0
  def newLocalGame(self, players=1, mode1p=0, mode2p=0): #mode1p=0(quickplay),1(practice),2(career) / mode2p=0(faceoff),1(profaceoff)
    self.engine.data.acceptSound.play()
    players = Dialogs.activateControllers(self.engine, players) #akedrou
    if players > 2: #hey look! Multiplayer support without the hassle!
      players = 2   #just comment these lines and everything will work! I promise!
    elif players == 0:
      return
    Config.set("game", "players", players)
    Config.set("game","game_mode", mode1p)
    Config.set("game","multiplayer_mode", mode2p)
    if Config.get("game", "tut") == True:
      Config.set("game", "tut", False)
      #Config.set("game", "selected_library", "")
      #Config.set("game", "selected_song", "")

    #MFH - testing new traceback logging:
    #raise TypeError


    if self.engine.isServerRunning():
      return
    self.engine.startServer()
    self.engine.resource.load(self, "session", lambda: self.engine.connect("127.0.0.1"), synch = True)
    
    if Dialogs.showLoadingScreen(self.engine, lambda: self.session and self.session.isConnected):
      self.launchLayer(lambda: Lobby(self.engine, self.session, singlePlayer = True))
Beispiel #5
0
    def showTutorial(self):
        # evilynux - Make sure tutorial exists before launching
        tutorialpath = self.engine.getPath(os.path.join("songs", "tutorial"))
        if not os.path.exists(tutorialpath):
            Dialogs.showMessage(self.engine,
                                _("No tutorial found in your song library!"))
            return

        if self.engine.isServerRunning():
            return

        Config.set(
            "player0", "mode_1p", 0
        )  #MFH - ensure tutorial can work with new logic that depends on this mode variable
        Config.set(
            "player0", "mode_2p", 0
        )  #MFH - ensure tutorial can work with new logic that depends on this mode variable
        Config.set("game", "players", 1)

        self.engine.startServer()
        self.engine.resource.load(self,
                                  "session",
                                  lambda: self.engine.connect("127.0.0.1"),
                                  synch=True)

        if Dialogs.showLoadingScreen(
                self.engine,
                lambda: self.session and self.session.isConnected):
            self.launchLayer(lambda: Lobby(
                self.engine, self.session, singlePlayer=True, tutorial=True))
Beispiel #6
0
    def newLocalGame(
        self,
        players=1,
        mode1p=0,
        mode2p=0
    ):  #mode1p=0(quickplay),1(practice),2(career) / mode2p=0(faceoff),1(profaceoff)
        Config.set("game", "players", players)
        Config.set("player0", "mode_1p", mode1p)
        Config.set("player1", "mode_2p", mode2p)
        if Config.get("game", "tut") == True:
            Config.set("game", "tut", False)
            #Config.set("game", "selected_library", "")
            #Config.set("game", "selected_song", "")

        #MFH - testing new traceback logging:
        #raise TypeError

        if self.engine.isServerRunning():
            return
        self.engine.startServer()
        self.engine.resource.load(self,
                                  "session",
                                  lambda: self.engine.connect("127.0.0.1"),
                                  synch=True)

        if Dialogs.showLoadingScreen(
                self.engine,
                lambda: self.session and self.session.isConnected):
            self.launchLayer(
                lambda: Lobby(self.engine, self.session, singlePlayer=True))
Beispiel #7
0
  def newSinglePlayerGame(self, songName = None):
    if self.engine.isServerRunning():
      return
    self.engine.startServer()
    self.engine.resource.load(self, "session", lambda: self.engine.connect("127.0.0.1"), synch = True)

    if Dialogs.showLoadingScreen(self.engine, lambda: self.session and self.session.isConnected):
      self.launchLayer(lambda: Lobby(self.engine, self.session, singlePlayer = True, songName = songName))
Beispiel #8
0
    def hostMultiplayerGame(self):
        self.engine.startServer()
        self.engine.resource.load(self, "session",
                                  lambda: self.engine.connect("127.0.0.1"))

        if Dialogs.showLoadingScreen(
                self.engine,
                lambda: self.session and self.session.isConnected):
            self.launchLayer(lambda: Lobby(self.engine, self.session))
Beispiel #9
0
  def joinMultiplayerGame(self, address = None):
    if not address:
      address = Dialogs.getText(self.engine, _("Enter the server address:"), "127.0.0.1")

    if not address:
      return
    
    self.engine.resource.load(self, "session", lambda: self.engine.connect(address))

    if Dialogs.showLoadingScreen(self.engine, lambda: self.session and self.session.isConnected, text = _("Connecting...")):
      self.launchLayer(lambda: Lobby(self.engine, self.session))
Beispiel #10
0
 def __init__(self):
     self.configs = {}
     self.configs["EmptyRoom"] = EmptyRoom()
     self.configs["FullRoom"] = FullRoom()
     self.configs["Corridor"] = Corridor()
     self.configs["Lobby"] = Lobby()
     self.configs["CrazyRoom"] = CrazyRoom()
     self.configs["SmallRoom"] = SmallRoom()
     self.configs["SwitchRoom"] = SwitchRoom()
     self.configs["HeapRoom"] = HeapRoom()
     self.configs["HeapLineRoom"] = HeapLineRoom()
Beispiel #11
0
    def showTutorial(self):
        # evilynux - Make sure tutorial exists before launching
        tutorialpath = self.engine.tutorialFolder
        if not os.path.isdir(self.engine.resource.fileName(tutorialpath)):
            Log.debug("No folder found: %s" % tutorialpath)
            Dialogs.showMessage(self.engine, _("No tutorials found!"))
            return

        self.engine.startWorld(1, None, 0, 0, tutorial = True)

        self.launchLayer(lambda: Lobby(self.engine))
Beispiel #12
0
 def newLocalGame(
     self,
     players=1,
     mode1p=0,
     mode2p=0,
     maxplayers=None,
     allowGuitar=True,
     allowDrum=True,
     allowMic=False
 ):  #mode1p=0(quickplay),1(practice),2(career) / mode2p=0(faceoff),1(profaceoff)
     self.engine.startWorld(players, maxplayers, mode1p, mode2p,
                            allowGuitar, allowDrum, allowMic)
     self.launchLayer(lambda: Lobby(self.engine))
Beispiel #13
0
    def showTutorial(self):
        # evilynux - Make sure tutorial exists before launching
        #tutorialpath = self.engine.getPath(os.path.join("songs","tutorial"))
        tutorialpath = self.engine.tutorialFolder
        if not os.path.isdir(self.engine.resource.fileName(tutorialpath)):
            Log.debug("No folder found: %s" % tutorialpath)
            Dialogs.showMessage(self.engine, _("No tutorials found!"))
            return

        # players = Dialogs.activateControllers(self.engine, 1) #akedrou
        # if players == 0:
        # return

        self.engine.startWorld(1, None, 0, 0, tutorial=True)

        self.launchLayer(lambda: Lobby(self.engine))
Beispiel #14
0
    def newLocalGame(
        self,
        players=1,
        mode1p=0,
        mode2p=0,
        maxplayers=None,
        allowGuitar=True,
        allowDrum=True,
        allowMic=False
    ):  #mode1p=0(quickplay),1(practice),2(career) / mode2p=0(faceoff),1(profaceoff)
        self.engine.data.acceptSound.play()
        players = Dialogs.activateControllers(self.engine, players, maxplayers,
                                              allowGuitar, allowDrum,
                                              allowMic)  #akedrou
        if players == 0:
            if self.engine.cmdPlay == 2:
                self.engine.cmdPlay = 0
            return
        Config.set("game", "players", players)
        Config.set("game", "game_mode", mode1p)
        Config.set("game", "multiplayer_mode", mode2p)
        if Config.get("game", "tut") == True:
            Config.set("game", "tut", False)
            #Config.set("game", "selected_library", "")
            #Config.set("game", "selected_song", "")

        #MFH - testing new traceback logging:
        #raise TypeError

        if self.engine.isServerRunning():
            return
        self.engine.startServer()
        self.engine.resource.load(self,
                                  "session",
                                  lambda: self.engine.connect("127.0.0.1"),
                                  synch=True)

        if Dialogs.showLoadingScreen(
                self.engine,
                lambda: self.session and self.session.isConnected):
            self.launchLayer(
                lambda: Lobby(self.engine, self.session, singlePlayer=True))
Beispiel #15
0
    def newLocalGame(
        self,
        players=1,
        mode1p=0,
        mode2p=0,
        maxplayers=None,
        allowGuitar=True,
        allowDrum=True,
        allowMic=False
    ):  #mode1p=0(quickplay),1(practice),2(career) / mode2p=0(faceoff),1(profaceoff)
        self.engine.data.acceptSound.play()
        # players = Dialogs.activateControllers(self.engine, players, maxplayers, allowGuitar, allowDrum, allowMic) #akedrou
        # if players == 0:
        # if self.engine.cmdPlay == 2:
        # self.engine.cmdPlay = 0
        # return

        self.engine.startWorld(players, maxplayers, mode1p, mode2p,
                               allowGuitar, allowDrum, allowMic)

        self.launchLayer(lambda: Lobby(self.engine))
Beispiel #16
0
    def newLocalGame(
        self,
        players=1,
        mode1p=0,
        mode2p=0
    ):  #mode1p=0(quickplay),1(practice),2(career) / mode2p=0(faceoff),1(profaceoff)
        Config.set("game", "players", players)
        Config.set("player0", "mode_1p", mode1p)
        Config.set("player1", "mode_2p", mode2p)

        if self.engine.isServerRunning():
            return
        self.engine.startServer()
        self.engine.resource.load(self,
                                  "session",
                                  lambda: self.engine.connect("127.0.0.1"),
                                  synch=True)

        if Dialogs.showLoadingScreen(
                self.engine,
                lambda: self.session and self.session.isConnected):
            self.launchLayer(
                lambda: Lobby(self.engine, self.session, singlePlayer=True))
def createLobby():
    client = MongoClient(DBURL + ":27017")
    db = client.Clubin_tv

    collection = db['Lobbies']

    createdLobby = False
    randomCode = ''

    while (not createdLobby
           ):  # Loop creates a new lobby code and checks if its being used
        randomCode = ''
        for i in range(4):
            randomCode += random.choice(string.ascii_uppercase)

        playlist = collection.find_one({'lobbyCode': randomCode})

        # if lobby code isn't being used, break out of loop
        # else keep going
        if (playlist == None):
            # Code IS NOT in use
            createdLobby = True

    global lobbies

    newLobby = Lobby(randomCode)
    lobbies.append(newLobby)
    for l in lobbies:
        print(l)

    res = collection.insert_one({
        'lobbyCode': randomCode,
        'connectedUsers': 0,
        'dateCreated': datetime.datetime.now()
    })
    # return JSONEncoder().encode(res.inserted_id)
    return randomCode
import argparse

"""
Makes a DeepQ Agent and runs it through one fight for each character in the roster so the user can view it
"""
if __name__ == "__main__":
    parser = argparse.ArgumentParser(description= 'Imports the specified class library and loads the specificed model.')
    parser.add_argument('-cn', '--className', type= str, default= "DeepQAgent", help= 'Name of the class library to import')
    parser.add_argument('-mn', '--modelName', type= str, default= None, help= 'Name of the specific model to be loaded and tested')
    parser.add_argument('-l', '--load', action= 'store_true', help= 'Boolean flag for if the user wants to load pre-existing weights')
    parser.add_argument('-c', '--character', type= str,  default= "ryu", help= 'The specific character this agent will play')

    args = parser.parse_args()
    if args.className is None:
        args.modelName = args.className

    agent = None
    exec("from {0} import {0}".format(args.className))
    exec("agent = {0}(load= {1}, name= \"{2}\", character= \"{3}\")".format(args.className, args.load, args.modelName, args.character))
    from Lobby import Lobby
    testLobby = Lobby()
    testLobby.addPlayer(agent)
    testLobby.executeTrainingRun(review= False, render= True)
Beispiel #19
0
# Validate user's command to run the client host
if len(sys.argv) < 2 :
    # Print invalid commend and standard error
    print("Invalid command! Write into cmd: Python3 chatServer.py [hostIP address]", file = sys.stderr)
    # Exit system because of improper command
    sys.exit(1)
# Set hostIP based on the user's command
else:
    hostIP = sys.argv[1]
    

# Create a listening socket using the address and port
listeningSocket = implementSocket((hostIP,PORT))

# Initilize the lobby object
lobby = Lobby()

# Create a list of connections and add listeningSocket to the list
connectionList = []
connectionList.append(listeningSocket)
userList = []

# Run server processes
while True:
    
    #Waiting until ready for reading, writing, wait for an "exceptional condition", talking turns on communication
    userRead, userWrite, socketErr = select.select(connectionList, [], [])

    # Iterate through the available users that needs to be read
    for user in userRead:
        # Test for new user
Beispiel #20
0
            The training data for the model
        
        model
            The model for the function to train

        Returns
        -------
        model
            The now trained and hopefully improved model
        """
        raise NotImplementedError("Implement this is in the inherited agent")

    ### End of Abstract methods


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Processes agent parameters.')
    parser.add_argument(
        '-r',
        '--render',
        action='store_true',
        help=
        'Boolean flag for if the user wants the game environment to render during play'
    )
    args = parser.parse_args()
    from Lobby import Lobby
    testLobby = Lobby(render=args.render)
    agent = Agent()
    testLobby.addPlayer(agent)
    testLobby.executeTrainingRun()
Beispiel #21
0
		event_queue.append(('join', self))

	def on_close(self):
		print str(self) + "disconnected from server"
		event_queue.append(('quit', self))

	def on_msg(self, msg):
		event_queue.append((msg['input'], self))

server = Listener(8888, TempServer)

#global board
#board = Board(900, 600, 6, 6, 5)

global lobby 
lobby = Lobby(GAMESCREENSIZE[0], GAMESCREENSIZE[1])

while 1:
	
	# enqueue the player events received by the client handlers
	poll()
	
	# apply events onto game state
	for event, handler in event_queue: 
		if event == 'quit':
			if handler in gameclients.keys():
				gamename = gameclients[handler]
				
				#if a player remove returns true, game is empty, end it
				if games[gamename].remove_player(clients[handler]):
					#remove button from game
Beispiel #22
0
    def on_close(self):
        print "close"
        event_queue.append(('quit', self))

    def on_msg(self, msg):
        event_queue.append((msg['input'], self))


server = Listener(8888, TempServer)

global board
board = Board(900, 600, 6, 6, 5)

global lobby
lobby = Lobby(900, 600)

while 1:

    # enqueue the player events received by the client handlers
    poll()

    # apply events onto game state
    for event, handler in event_queue:
        if event == 'quit':
            #name = clients[handler]._name
            board.remove_player(clients[handler])
            del clients[handler]
            #broadcast(str(name) + " quit the game")
        elif event == 'join':
            #generate Name and Color
Beispiel #23
0
# This file tests the Game

from Lobby import Lobby
from Game import Game
from Player import Player
from Table import Table
from TexasHoldemGameDefinition import TexasHoldemGameDefinition

# Create your lobby. In this lobby we will limit the number of players to 10
lobby = Lobby("RubesAndDonks", 20)

# Create a bunch of players and add them to the lobby
# In real life this would be done asynchronously
stackSize = 1000
try:
    lobby.addPlayerToWaitingList(Player(1, stackSize, "Joe Blow"))
    lobby.addPlayerToWaitingList(Player(2, stackSize, "Freddy Mercury"))
    lobby.addPlayerToWaitingList(Player(3, stackSize, "Harry Legg"))
except:
    print("Could not add a player to the lobby")

# Create the table and add the players to the table
tableNumber = 1
numSeats = 10
table = Table(tableNumber, numSeats)

numberOfEmptySeatsAtTable = table.getNumSeats() - table.getNumPlayers()

while (numberOfEmptySeatsAtTable > 0):
    # See if anyone is waiting in the lobby to fill the empty
    # seats
        'Boolean flag for if the user wants the game environment to render during play'
    )
    parser.add_argument(
        '-l',
        '--load',
        action='store_true',
        help='Boolean flag for if the user wants to load pre-existing weights')
    parser.add_argument(
        '-e',
        '--episodes',
        type=int,
        default=10,
        help=
        'Intger representing the number of training rounds to go through, checkpoints are made at the end of each episode'
    )
    parser.add_argument(
        '-n',
        '--name',
        type=str,
        default=None,
        help=
        'Name of the instance that will be used when saving the model or it\'s training logs'
    )
    args = parser.parse_args()
    qAgent = DeepQAgent(load=args.load, name=args.name)

    from Lobby import Lobby
    testLobby = Lobby()
    testLobby.addPlayer(qAgent)
    testLobby.executeTrainingRun(episodes=args.episodes, render=args.render)
Beispiel #25
0
    if bot.get_cog("Twitch"):
        #await bot.get_cog("Twitch").t_bot.start()
        pass

if __name__ == "__main__":
    #Start DataBase engine
    engine = create_engine('sqlite:///db/app.db')
    Session = sessionmaker(bind=engine)
    Base.metadata.create_all(engine) #Create tables if empty
    db = Session()
    bot.db = db

    #Load all Cogs for this bot
    bot.add_cog(Admin(bot))
    bot.add_cog(LobbyAdmin(bot))
    bot.add_cog(Lobby(bot))
    #Crashes program:
    bot.add_cog(Twitch(bot))
    try:
        from RoleSync import RoleSync
        bot.add_cog(RoleSync(bot))
    except:
        pass
    try:
        from VoiceRole import VoiceRole
        bot.add_cog(VoiceRole(bot))
    except:
        pass

    try:
        bot.run(getToken())
Beispiel #26
0
def gameInit():
    pygame.init()
    global TURN 
    TURN = 0
    global GAMECLOCK
    GAMECLOCK = pygame.time.Clock()
    global FRAMERATE
    FRAMERATE = 40
    
    """
        Program State overview:
            0 = loading
            1 = main screen
            2 = game
            3 = game lobby
            4 = online game
    """
    global PROG_STATE
    PROG_STATE = 0
    
    global VIEWPORT
    VIEWPORT = FixedViewport(900, 600)

    global LOBBY 
    LOBBY = Lobby(900,600)

    
    global GAMEBOARD
    GAMEBOARD = Board(VIEWPORT.width, VIEWPORT.height, 4, 4, 5)


    value1 = LOBBY.add_game()
    value2 = LOBBY.add_game()
    value3 = LOBBY.add_game()
    value4 = LOBBY.add_game()
    value5 = LOBBY.add_game()
    value6 = LOBBY.add_game()
    value7 = LOBBY.add_game()
    value8 = LOBBY.add_game()
    value9 = LOBBY.add_game()
    value10 = LOBBY.add_game()

    LOBBY.remove_game(value1)

    value11 = LOBBY.add_game()
    # value12 = LOBBY.add_game()

    # player_one = Player("Katie", (255,0,0))
    # GAMEBOARD.add_player(player_one)

    # player_two = Player("Justin", (0,255,0))
    # GAMEBOARD.add_player(player_two)
    
    # player_three = Player("Chris", (0,0,255))
    # GAMEBOARD.add_player(player_three)
    
    #player_four = Player("Sufana", (100,100,100))
    #GAMEBOARD.add_player(player_four)
    
    #player_five = Player("Shibani", (200,200,200))
    #GAMEBOARD.add_player(player_five)
    
    global GAME_STATE
    GAME_STATE = 1;
Beispiel #27
0
from Lobby import Lobby

Lobby.presentation()
Lobby.login()
Beispiel #28
0
 def restartGame(self):
     splash = Dialogs.showLoadingSplashScreen(self.engine, "")
     self.engine.view.pushLayer(Lobby(self.engine))
     Dialogs.hideLoadingSplashScreen(self.engine, splash)