def init():
    """
    Game initialization function.
        1. Creates a L{Debugger} (debugger) and L{EventTimer} (eventTimer) and 
           stores references to them in an instance of L{EventManager}.
        2. Several listeners are started and registered with eventManager:
            - Instance of L{Universe} (universe)
            - Instance of L{UserInterface} (ui)
            - Instance of L{Window} (gameWindow)
        3. We send the eventManager a message to start the game
            - This message is interpreted by the gameWindow
    """
    
    debugger = Debugger()
    eventTimer = EventTimer()
    
    #Create the event manager for low-level events
    eventManager = Manager(eventTimer,debugger) #FIXME: more specific manager\
                                                #classes will be needed later?
    try:                                            
        client = GameClient(eventManager,host='10.41.24.79',port=1567)
    except:
        pass
    
    #Create the occurence manager for high-level events (same across client and server)
    #FIXME: NOT YET IMPLEMENTED
    #Note: Do we even need this anymore? - Julian
    #Response: I don't think so.  - Jared
    
    #===========================================
    #Create and register the standard listeners
    #With the event manager
    #===========================================
    #FIXME: Not yet fully implemented
    
    #THIS WILL BE CHANGED LATER TO ACCOUNT FOR LOADING, ETC.

    # World w is set to the activeWorld of the universe
    universe = Universe(eventManager)
    ui = UserInterface(eventManager,universe.activeWorld)
    
    gameWindow = Window(eventManager,width=1024,height=768)
    
    w = World()
    universe.changeWorld(w)
    
    #===========================================
    
    # Initialize 500 entities in World w
    for i in range(100):
        #w.addEntity(Entity('ball.png',i*50,i*50, w, (255,255,255)))
        #w.addEntity(TestEntity('testBuilding.png', i*50, i*50, w, 'alpha'))
        w.addEntity(TestEntity('testCraft.png',i*50,i*50,w,'alpha'))

    eventManager.post(Event.WorldManipulationEvent())
    
    #Notify the manager that the window should start to accept input:
    eventManager.post(Event.StartEvent())
    return eventManager.eventTypesToListeners
def init(host='localhost',server=None):
    """
    Most of this code is copied from init() function in client.py
    
    Game initialization function.
        1. Creates a L{Debugger} (debugger) and L{EventTimer} (eventTimer) and 
           stores references to them in an instance of L{EventManager}.
        2. Several listeners are started and registered with eventManager:
            - Instance of L{Universe} (universe)
            - Instance of L{UserInterface} (ui)
            - Instance of L{Window} (gameWindow)
        3. We send the eventManager a message to start the game
            - This message is interpreted by the gameWindow
    """
    
    #Creates a Debugger that posts events to the terminal for debugging purposes
    debugger = Debugger()
    eventTimer = EventTimer()
    
    #Create the event manager for low-level events
    eventManager = Manager(eventTimer,debugger) #FIXME: more specific manager\
    Entity.manager = eventManager    

    # World w is set to the activeWorld of the universe
    universe = Universe(eventManager)
    ui = UserInterface(eventManager,universe.activeWorld,'BROADCASTSERVER')

    gameWindow = Window(eventManager,width=1024,height=768)
    gameWindow.fullscreenMode = False
    gameWindow.updateScreenMode()

    w = World(universe)
    s.world=w

    networked = True
    client = GameClient(eventManager,host=s.host,port=1567)

	#wait until the client is assigned an ID before proceeding
    while client.ID == None:
        import time
        time.sleep(.02)
    print 'Got an ID',client.ID
    clientID = client.ID

    ui.setClientID(clientID)

    wManipulator = WorldManipulator(eventManager,w,networked,gameClientID = clientID)
    
    #generate the resources in the server, the existance of these
    #resources will propogate through to every client when they connect
    w._generateResources()
    
    #Notify the manager that the window should start to accept input:
    eventManager.post(Event.StartEvent())

    return eventManager.eventTypesToListeners
def init(host='localhost'):
    """
    Game initialization function.
        1. Creates a L{Debugger} (debugger) and L{EventTimer} (eventTimer) and
           stores references to them in an instance of L{EventManager}.
        2. Several listeners are started and registered with eventManager:
            - Instance of L{Universe} (universe)
            - Instance of L{UserInterface} (ui)
            - Instance of L{Window} (gameWindow)
        3. We send the eventManager a message to start the game
            - This message is interpreted by the gameWindow
    """

    debugger = Debugger()
    eventTimer = EventTimer()

    #Create the event manager for low-level events
    eventManager = Manager(eventTimer,debugger) #FIXME: more specific manager\
                                                #classes will be needed later?
    Entity.manager = eventManager

    #Create the occurence manager for high-level events (same across client and server)
    #FIXME: NOT YET IMPLEMENTED

    #THIS WILL BE CHANGED LATER TO ACCOUNT FOR LOADING, ETC.

    networked = True

    # World w is set to the activeWorld of the universe
    universe = Universe(eventManager)
    ui = UserInterface(eventManager,universe.activeWorld,None)

    gameWindow = Window(eventManager,width=1024,height=768)
    gameWindow.fullscreenMode = False
    gameWindow.updateScreenMode()

    w = World(universe)
    #universe.changeWorld(w)

    try:
        client = GameClient(eventManager,host=host,port=1567)
        while client.ID == None:
            import time
            time.sleep(.02)
        print 'Got an ID',client.ID
        clientID = client.ID
    #    client.sendRequest('GetWorld')

    except:
        networked = False

    if not networked:
        # Initialize 25 entities in World w
        # Initialize a TestTownCenter
        clientID = GameClient.ID = 0
        ui.setClientID(clientID)
        eventManager.post(Event.NewPlayerEvent(clientID))
        w._generateResources()
    else:
        clientID = client.ID
        ui.setClientID(clientID)

    wManipulator = WorldManipulator(eventManager,w,networked,gameClientID = clientID)

    #Notify the manager that the window should start to accept input:
    eventManager.post(Event.StartEvent())

    return eventManager.eventTypesToListeners