当前位置: 首页>>代码示例>>Python>>正文


Python World.get_world方法代码示例

本文整理汇总了Python中World.get_world方法的典型用法代码示例。如果您正苦于以下问题:Python World.get_world方法的具体用法?Python World.get_world怎么用?Python World.get_world使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World的用法示例。


在下文中一共展示了World.get_world方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def __init__(self, name, port, approved, usingGlacier2, glacier2Host, glacier2Port,
              client_prx, ip_string, reporter = None, threshold = 300):
     """
     Initialize a main-to-game session.
     @param name Server's name.
     @param port Port that the server listens for clients on.
     @param approved True if the server is 'approved' by this server, otherwise False.
     @param usingGlacier2 [bool] True if clients must use Glacier2 to connect.
     @param glacier2Host Host name of the Glacier2 router.
     @param glacier2Port Port number that the Glacier2 router listens on.
     @param client_prx Proxy to the client's callback.
     @param ip_string IP obtained from the current.con.toString() method.
     @param reporter Debug reporter. Optional.
     """
     Base_Servant.__init__(self, ip_string, Client_Types.THEATRE_CLIENT_TYPE, 0, reporter);
     
     self.name = name;
     self.port = port;
     self.config = World.get_world().get_config();
     self.database = World.get_world().get_database();
     self.approved = approved;
     self.client_prx = MainToGameSession.ClientSessionPrx.uncheckedCast(client_prx.ice_timeout(8000));
     self.usingGlacier2 = usingGlacier2;
     self.glacier2Host = glacier2Host;
     self.glacier2Port = glacier2Port;
     
     self.player_limit = 100;
     self.forced_limit = False;
     self.player_list = {};
     self.threshold = threshold;
     self.current_map = "";
     self.current_mode = VTankObject.GameMode.DEATHMATCH;
开发者ID:summer-of-software,项目名称:vtank,代码行数:34,代码来源:MTGSession.py

示例2: RequestJoinGameServer

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def RequestJoinGameServer(self, server, current=None):
     self.refresh_action();
     
     if not self.active_tank:
         raise VTankException("You must select a tank first!");
     
     world = World.get_world();
     game = world.get_game_server_by_name(server.name);
     if not game:
         self.report("Tried to get a game server by the name of \"%s\", "\
             "but it didn't exist." % (server.name));
         raise PermissionDeniedException("That server is not available.");
     # Generate a key that would be unique.
     hash_value = "!!ASDFJKL:%s%s%s" % (str(random.randint(0, 10000)), server.name, self.name);
     
     key = sha1(hash_value).hexdigest();
     joined = True;
     try:
         if not game.add_player(key, self.name, self.userlevel, self.active_tank):
             self.report("%s tried to join %s, but was already in a game." % (
                 str(self), str(game)));
             joined = False;
     except Ice.Exception, e:
         self.report("Game server %s disconnected forcefully." % server.name);
         world.kick_user_by_name(server.name);
         
         raise PermissionDeniedException("That server is not available.");
开发者ID:summer-of-software,项目名称:vtank,代码行数:29,代码来源:MainSessionI.py

示例3: refresh_map_list

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def refresh_map_list(self):
     """
     This obtains a list of maps from the database. While it records all of the map
     names, it does not necessarily cache the maps. Map caching is dealt with by
     the rest of the class.
     """
     self.report("Refreshing maps...");
     
     self.size = 0;
     self.maps = {};
     results = self.database.do_query(Procedures.get_map_list());
     if results == None:
         error = str(self.database.get_last_error());
         self.report("Database error: %s." % error);
         raise RuntimeError, error; 
     if not len(results):
         # No maps.
         self.report("No maps to download.");
         self.maps = {};
         return;
     
     for set in results:
         # [0]filename, [1]filesize
         filename = set[0];
         filesize = set[1];
         if self.size + filesize > CACHE_LIMIT:
             # Do not download map: it breaks the cache limit.
             self.maps[filename] = None;
         else:
             # Download map.
             downloaded_map = self.download_map(filename);
             if not downloaded_map:
                 self.report("Didn't download map: %s." % filename);
                 continue;
             
             self.maps[filename] = downloaded_map;
             self.size += filesize;
         
         self.report("Added map: %s (size=%i, totalsize=%i)." % (
             filename, filesize, self.size));
             
     World.get_world().update_game_server_maps();
开发者ID:summer-of-software,项目名称:vtank,代码行数:44,代码来源:Map_Manager.py

示例4: __init__

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def __init__(self, username, userlevel, ip_string, reporter = None):
     """
     Start a Janitor session.
     @param username Username of the connected client.
     @param database_obj Access to the database.
     @param reporter Optional debug reporter.
     """
     Base_Servant.__init__(self, ip_string, JANITOR_CLIENT_TYPE, userlevel, reporter);
     
     self.name           = name;
     self.database       = World.get_world().get_database();
     self.callback       = None;
开发者ID:summer-of-software,项目名称:vtank,代码行数:14,代码来源:JanitorSessionI.py

示例5: __init__

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def __init__(self, name, ip_string, userlevel, reporter = None, threshold = 300):
     """
     Create a new map editor session.
     @param username The editor's username.
     @param database_obj SQL Database object.
     @param reporter Debug reporter. Default is None.
     @param threshold How long to wait (in seconds) before a client is kicked for inactivity.
     """
     Base_Servant.__init__(self, ip_string, Client_Types.MAPEDITOR_CLIENT_TYPE, userlevel, reporter);
     
     self.name       = name;
     self.database   = World.get_world().get_database();
     self.threshold  = threshold;
开发者ID:summer-of-software,项目名称:vtank,代码行数:15,代码来源:MapEditorSessionI.py

示例6: __init__

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def __init__(self, username, userlevel, ip_string, reporter = None, threshold = 30):
     Base_Servant.__init__(self, ip_string, Client_Types.VTANK_CLIENT_TYPE, userlevel, reporter);
     
     self.name = username;
     self.database = World.get_world().get_database();
     
     self.ranks = {};
     self.tank_list = {};
     self.active_tank = None;
     self.playing = False;
     
     self.threshold = threshold;
     
     self.refresh_tank_list();
开发者ID:summer-of-software,项目名称:vtank,代码行数:16,代码来源:MainSessionI.py

示例7: __init__

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def __init__(self, name, ip_string, reporter = None, threshold = 300):
     """
     Initialize an administrative session.
     @param name Administrator who opened the session.
     @param ip_string Obtained from current.con.toString().
     @param reporter Debug reporter. Null by default.
     @param threshold How long to wait before disconnecting an admin in seconds. Default is 300.
     """
     Base_Servant.__init__(self, ip_string, Client_Types.ADMIN_CLIENT_TYPE, 
                           UserLevel.ADMINISTRATOR, reporter);
     
     self.name = name;
     self.database = World.get_world().get_database();
     self.threshold = threshold;
     self.callback = None;
开发者ID:summer-of-software,项目名称:vtank,代码行数:17,代码来源:AdminSessionI.py

示例8: GetUserList

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def GetUserList(self, current=None):
     self.refresh_action();
     
     return World.get_world().get_full_userlist();
开发者ID:summer-of-software,项目名称:vtank,代码行数:6,代码来源:AdminSessionI.py

示例9: destroy

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def destroy(self, current=None):
     World.get_world().get_tracker().remove(self.get_id());
开发者ID:summer-of-software,项目名称:vtank,代码行数:4,代码来源:AdminSessionI.py

示例10: KickUserByAccountName

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def KickUserByAccountName(self, accountName, reason, current=None):
     self.refresh_action();
     if World.get_world().kick_user_by_name(accountName):
         self.report("%s was kicked for: %s" % (accountName, reason));
     else:
         raise BadInformationException, "User is not online.";
开发者ID:summer-of-software,项目名称:vtank,代码行数:8,代码来源:AdminSessionI.py

示例11: GetPlayersOnline

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def GetPlayersOnline(self, current=None):
     """
     Allow clients to see how many players are online.
     """
     world = World.get_world();
     return world.get_user_count();
开发者ID:summer-of-software,项目名称:vtank,代码行数:8,代码来源:AuthI.py

示例12: GetGameServerList

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def GetGameServerList(self, current=None):
     """
     Allow clients to see what game servers are available.
     """
     world = World.get_world();
     return world.get_game_server_list();
开发者ID:summer-of-software,项目名称:vtank,代码行数:8,代码来源:AuthI.py

示例13: GetGameServerList

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def GetGameServerList(self, current=None):
     self.refresh_action();
     
     world = World.get_world();
     return world.get_game_server_list();
开发者ID:summer-of-software,项目名称:vtank,代码行数:7,代码来源:MainSessionI.py

示例14: GetFullUserList

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
 def GetFullUserList(self, current=None):
     self.refresh_action();
     
     return World.get_world().get_complete_userlist();
开发者ID:summer-of-software,项目名称:vtank,代码行数:6,代码来源:AdminSessionI.py

示例15: main

# 需要导入模块: import World [as 别名]
# 或者: from World import get_world [as 别名]
def main(argv=[]):
    """
    This is the first function called when the program starts.  Do all initialization here.
    @param argv Optionally pass the command-line arguments.
    @return Exit code.  0 for success, non-zero for unnatural exit.
    """
    # Write pid to file.
    if not os.path.exists("./logs"):
        os.mkdir("logs");
    
    run_unit_tests  = False;
    config_file     = os.path.abspath("config.cfg");
    debug_mode      = False;
    
    # The first argument isn't important to us -- it's the program's name.
    del argv[0];
    
    for arg in argv:
        if arg == "--test" or arg == "-t":
            # Testing mode enabled.  The server will not run; it will perform unit tests.
            run_unit_tests = True;
            
        elif arg.startswith("-p") or arg.startswith("--port"):
            # Let user know how to set a port.
            print "Port cannot be set through command line, look in the config file.";
            return 1;
        
        elif arg == "-d" or arg == "--debug":
            # Enable debugging.
            debug_reporter("Debug mode enabled.");
            debug_mode = True;
        
        elif arg == "--generate-config" or arg == "-g":
            # Generate a configuration file.
            temp_config = Config.VTank_Config();
            result = temp_config.generate_config(os.path.abspath(".") + os.sep + "config.cfg");
            debug_reporter("Result: %s" % result);
            return int(result);
        
        elif arg == "--load-slice" or arg == "-s":
            # Load slice dynamically without generating files.
            load_slice_files();
        
        elif arg.startswith("--config-file="):
            # User is specifying the config file's name.
            config_file = arg[len("--config-file="):];
            if not config_file:
                print "--config-file usage:";
                print "--config-file=[FILENAME]";
                return 1;
            
            if not os.path.exists(os.path.abspath(config_file)):
                print "Config file does not exist:", config_file;
                return 1;
            
            debug_reporter("Using config file " + config_file + ".");
            
        else:
            # Unknown.
            print "Unknown option:", arg, " -- ignoring it.";
            
    # Run unit testing here.
    if run_unit_tests:
        import Unit_Test;
        return Unit_Test.run_all_tests();
    
    import Log;
    import World;
    import Config;
    import Map_Manager;
    
    if debug_mode:
        reporter_func = debug_reporter;
    else:
        reporter_func = Log.log_reporter;
    
    # Start handling the world.
    try:
        World.initialize_world(config_file, reporter_func);
        world = World.get_world();
        Map_Manager.initialize(world.get_config(), world.get_database(), reporter_func);
        
        # Write the process ID of this server to file.
        file = open('echelon.pid', 'w');
        with file:
            file.write(str(os.getpid()));
            
        stackless.tasklet(VersionChecker.get_mysql_version)();
        stackless.run();
        
        # Unless some design changes, it will likely never reach this point.
        # Instead, it will be running through the stackless scheduler.
        reporter_func("Waiting for Ice shutdown.");
        World.get_world().get_communicator().waitForShutdown();
    except Force_Exit_Exception, e:
        Log.log_print("CRITICAL_ERROR.log", "", "Startup failure: " + str(e));
        reporter_func("Critical error occurred: " + str(e));
        from sys import exit;
        return e.exit_code;
开发者ID:summer-of-software,项目名称:vtank,代码行数:101,代码来源:Echelon.py


注:本文中的World.get_world方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。