kxg.multiplayer.ServerActor

class kxg.multiplayer.ServerActor(pipe)[source]

Bases: kxg.actors.Actor

Event Handlers:

on_start_game(num_players)

on_update_game(dt)

on_finish_game()

Inherited from Actor

on_setup_gui(gui)

on_start_game(num_players)

on_update_game(dt)

on_finish_game()

Public Methods:

__init__(pipe)

Initialize self.

send_message(message)

Inherited from Actor

__init__(pipe)

Initialize self.

__rshift__(message)

send_message(message)

is_referee()

Inherited from ForumObserver

namedtuple(field_names, *[, rename, …])

Returns a new subclass of tuple with named fields.

__init__(pipe)

Initialize self.

__getstate__()

__setstate__(state)

subscribe_to_message(message_cls, callback)

subscribe_to_sync_response(message_cls, callback)

subscribe_to_undo_response(message_cls, callback)

unsubscribe_from_message(message_cls[, callback])

unsubscribe_from_sync_response(message_cls)

unsubscribe_from_undo_response(message_cls)

Private Methods:

_set_forum(forum, id)

_relay_message(message)

Relay messages from the forum on the server to the client represented by this actor.

_react_to_message(message)

Don’t ever change the world in response to a message.

Inherited from Actor

_set_world(world)

_set_forum(forum, id)

_get_nested_observers()

_relay_message(message)

Relay messages from the forum on the server to the client represented by this actor.

Inherited from ForumObserver

_react_to_message(message)

Don’t ever change the world in response to a message.

_react_to_sync_response(message)

_react_to_undo_response(message)

_enable_forum_observation()

_disable_forum_observation()

_check_if_forum_observation_enabled()

_add_callback(event, message_cls, callback)

_drop_callback(event, message_cls, callback)

_call_callbacks(event, message)

_get_nested_observers()

class CallbackInfo(message_cls, callback)

Bases: tuple

__add__(value, /)

Return self+value.

__contains__(key, /)

Return key in self.

__eq__(value, /)

Return self==value.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getitem__(key, /)

Return self[key].

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__iter__()

Implement iter(self).

__le__(value, /)

Return self<=value.

__len__()

Return len(self).

__lt__(value, /)

Return self<value.

__mul__(value, /)

Return self*value.

__ne__(value, /)

Return self!=value.

static __new__(_cls, message_cls, callback)

Create new instance of CallbackInfo(message_cls, callback)

__repr__()

Return a nicely formatted representation string

__rmul__(value, /)

Return value*self.

__slots__ = ()
_asdict()

Return a new OrderedDict which maps field names to their values.

_fields = ('message_cls', 'callback')
_fields_defaults = {}
classmethod _make(iterable)

Make a new CallbackInfo object from a sequence or iterable

_replace(**kwds)

Return a new CallbackInfo object replacing specified fields with new values

property callback

Alias for field number 1

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

property message_cls

Alias for field number 0

__getstate__()
__init__(pipe)[source]

Initialize self. See help(type(self)) for accurate signature.

__rshift__(message)
__setstate__(state)
_add_callback(event, message_cls, callback)
_call_callbacks(event, message)
_check_if_forum_observation_enabled()
_disable_forum_observation()
_drop_callback(event, message_cls, callback)
_enable_forum_observation()
_get_nested_observers()
_react_to_message(message)[source]

Don’t ever change the world in response to a message.

This method is defined is called by the game engine to trigger callbacks tied by this actor to particular messages. This is useful for ordinary actors, but remote actors are only meant to shuttle message between clients and should never react to individual messages.

_react_to_sync_response(message)
_react_to_undo_response(message)
_relay_message(message)[source]

Relay messages from the forum on the server to the client represented by this actor.

_set_forum(forum, id)[source]
_set_world(world)
property id
is_referee()
namedtuple(field_names, *, rename=False, defaults=None, module=None)

Returns a new subclass of tuple with named fields.

>>> Point = namedtuple('Point', ['x', 'y'])
>>> Point.__doc__                   # docstring for the new class
'Point(x, y)'
>>> p = Point(11, y=22)             # instantiate with positional args or keywords
>>> p[0] + p[1]                     # indexable like a plain tuple
33
>>> x, y = p                        # unpack like a regular tuple
>>> x, y
(11, 22)
>>> p.x + p.y                       # fields also accessible by name
33
>>> d = p._asdict()                 # convert to a dictionary
>>> d['x']
11
>>> Point(**d)                      # convert from a dictionary
Point(x=11, y=22)
>>> p._replace(x=100)               # _replace() is like str.replace() but targets named fields
Point(x=100, y=22)
on_finish_game()[source]
on_setup_gui(gui)
on_start_game(num_players)[source]
on_update_game(dt)[source]
send_message(message)[source]
subscribe_to_message(message_cls, callback)
subscribe_to_sync_response(message_cls, callback)
subscribe_to_undo_response(message_cls, callback)
unsubscribe_from_message(message_cls, callback=None)
unsubscribe_from_sync_response(message_cls, callback=None)
unsubscribe_from_undo_response(message_cls, callback=None)