示例#1
0
文件: __init__.py 项目: fdChasm/spyd
def get_message_handlers():
    message_handlers = {}
    for registered_message_handler in RegistryManager.get_registrations('client_message_handler'):
        message_handler = registered_message_handler.registered_object
        message_type = message_handler.message_type
        message_handlers[message_type] = message_handler
    return message_handlers
示例#2
0
文件: __init__.py 项目: fdChasm/spyd
def get_client_event_handlers():
    client_event_handlers = {}
    for registered_event_handler in RegistryManager.get_registrations('room_client_event_handler'):
        event_handler = registered_event_handler.registered_object
        event_type = event_handler.event_type
        client_event_handlers[event_type] = event_handler
    return client_event_handlers
示例#3
0
文件: __init__.py 项目: fdChasm/spyd
def get_player_event_handlers():
    player_event_handlers = {}
    for registered_event_handler in RegistryManager.get_registrations('room_player_event_handler'):
        event_handler = registered_event_handler.registered_object
        event_type = event_handler.event_type
        player_event_handlers[event_type] = event_handler
    return player_event_handlers
示例#4
0
def get_player_event_handlers():
    player_event_handlers = {}
    for registered_event_handler in RegistryManager.get_registrations(
            'room_player_event_handler'):
        event_handler = registered_event_handler.registered_object
        event_type = event_handler.event_type
        player_event_handlers[event_type] = event_handler
    return player_event_handlers
示例#5
0
文件: __init__.py 项目: DanSeraf/spyd
def get_message_handlers():
    message_handlers = {}
    for registered_message_handler in RegistryManager.get_registrations(
            'client_message_handler'):
        message_handler = registered_message_handler.registered_object
        message_type = message_handler.message_type
        message_handlers[message_type] = message_handler
    return message_handlers
示例#6
0
文件: __init__.py 项目: DanSeraf/spyd
def get_client_event_handlers():
    client_event_handlers = {}
    for registered_event_handler in RegistryManager.get_registrations(
            'room_client_event_handler'):
        event_handler = registered_event_handler.registered_object
        event_type = event_handler.event_type
        client_event_handlers[event_type] = event_handler
    return client_event_handlers
    def __init__(self, punitive_model):
        self._punitive_model = punitive_model

        self._service_types = {}

        for service_type_registration in RegistryManager.get_registrations('master_client_service'):
            service_type = service_type_registration.args[0]

            self._service_types[service_type] = service_type_registration.registered_object
示例#8
0
    def __init__(self, punitive_model):
        self._punitive_model = punitive_model

        self._service_types = {}

        for service_type_registration in RegistryManager.get_registrations(
                'master_client_service'):
            service_type = service_type_registration.args[0]

            self._service_types[
                service_type] = service_type_registration.registered_object
示例#9
0
    def _initialize_gep_endpoints(self, config):
        message_handlers = {}
        for message_handler_registration in RegistryManager.get_registrations('gep_message_handler'):
            message_handler = message_handler_registration.registered_object
            if message_handler.msgtype in message_handlers:
                raise Exception("Duplicate message handler registered.")
            message_handlers[message_handler.msgtype] = message_handler

        gep_service_factory = txCascil.ServerServiceFactory()
        for gep_config in config['gep_endpoints'].itervalues():
            gep_service = gep_service_factory.build_service(self, gep_config, message_handlers, self.permission_resolver, self.event_subscription_fulfiller)
            gep_service.setServiceParent(self.root_service)
示例#10
0
    def _initialize_gep_endpoints(self, config):
        message_handlers = {}
        for message_handler_registration in RegistryManager.get_registrations(
                'gep_message_handler'):
            message_handler = message_handler_registration.registered_object
            if message_handler.msgtype in message_handlers:
                raise Exception("Duplicate message handler registered.")
            message_handlers[message_handler.msgtype] = message_handler

        gep_service_factory = txCascil.ServerServiceFactory()
        for gep_config in config['gep_endpoints'].values():
            gep_service = gep_service_factory.build_service(
                self, gep_config, message_handlers, self.permission_resolver,
                self.event_subscription_fulfiller)
            gep_service.setServiceParent(self.root_service)
示例#11
0
文件: __init__.py 项目: fdChasm/spyd
def display_awards(room):
    awards = map(lambda a: a.registered_object, RegistryManager.get_registrations('award'))

    mode_name = room.gamemode.clientmodename

    awards = filter(lambda a: a.is_valid_mode(mode_name), awards)

    awards = map(lambda a: AwardInstance(a, room._players.to_iterator), awards)

    awards = filter(lambda a: a.has_winner, awards)

    if awards:
        awards = sorted(awards, key=lambda a: a.left_weight, reverse=True)

        awards = map(lambda a: a.get_formatted(), awards)

        award_string = " | ".join(awards)
        room.server_message(awards_wrapper("{awards}", awards=award_string))
示例#12
0
文件: __init__.py 项目: DanSeraf/spyd
def display_awards(room):
    awards = [a.registered_object for a in RegistryManager.get_registrations('award')]

    mode_name = room.gamemode.clientmodename

    awards = [a for a in awards if a.is_valid_mode(mode_name)]

    awards = [AwardInstance(a, room._players.to_iterator) for a in awards]

    awards = [a for a in awards if a.has_winner]

    if awards:
        awards = sorted(awards, key=lambda a: a.left_weight, reverse=True)

        awards = [a.get_formatted() for a in awards]

        award_string = " | ".join(awards)
        room.server_message(awards_wrapper("{awards}", awards=award_string))
示例#13
0
文件: __init__.py 项目: fdChasm/spyd
from spyd.registry_manager import RegistryManager
from spyd.utils.import_all import import_all


import_all(__file__, 'spyd.game.gamemode', ['__init__'])


mode_nums = {}
gamemodes = {}

gamemode_objects = map(lambda a: a.registered_object, RegistryManager.get_registrations('gamemode'))

for gamemode_object in gamemode_objects:
    if gamemode_object.isbasemode:
        mode_nums[gamemode_object.clientmodenum] = gamemode_object.clientmodename

for gamemode_object in gamemode_objects:
    gamemodes[gamemode_object.clientmodename] = gamemode_object

def get_mode_name_from_num(mode_num):
    return mode_nums.get(mode_num, None)
示例#14
0
from spyd.registry_manager import RegistryManager
from spyd.utils.import_all import import_all

import_all(__file__, 'spyd.game.gamemode', ['__init__'])

mode_nums = {}
gamemodes = {}

gamemode_objects = [
    a.registered_object for a in RegistryManager.get_registrations('gamemode')
]

for gamemode_object in gamemode_objects:
    if gamemode_object.isbasemode:
        mode_nums[
            gamemode_object.clientmodenum] = gamemode_object.clientmodename

for gamemode_object in gamemode_objects:
    gamemodes[gamemode_object.clientmodename] = gamemode_object


def get_mode_name_from_num(mode_num):
    return mode_nums.get(mode_num, None)
示例#15
0
 def __init__(self):
     self.command_handlers = set()
     for registered_command in RegistryManager.get_registrations('command'):
         self.command_handlers.add(registered_command.registered_object)
示例#16
0
 def __init__(self):
     self.command_handlers = set()
     for registered_command in RegistryManager.get_registrations('command'):
         self.command_handlers.add(registered_command.registered_object)