Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_misc_room_game.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 4b842c1fb686 |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
110 if player_init is None: | 110 if player_init is None: |
111 player_init = {} | 111 player_init = {} |
112 self.game_init = game_init | 112 self.game_init = game_init |
113 self.player_init = player_init | 113 self.player_init = player_init |
114 self.games = {} | 114 self.games = {} |
115 self.invitations = {} # values are a couple (x, y) with x the time and y a list of users | 115 self.invitations = ( |
116 {} | |
117 ) # values are a couple (x, y) with x the time and y a list of users | |
116 | 118 |
117 # These are the default settings, which can be overwritten by child class after initialization | 119 # These are the default settings, which can be overwritten by child class after initialization |
118 self.invite_mode = self.FROM_PLAYERS if self.player_init == {} else self.FROM_NONE | 120 self.invite_mode = self.FROM_PLAYERS if self.player_init == {} else self.FROM_NONE |
119 self.wait_mode = self.FOR_NONE if self.player_init == {} else self.FOR_ALL | 121 self.wait_mode = self.FOR_NONE if self.player_init == {} else self.FOR_ALL |
120 self.join_mode = self.INVITED | 122 self.join_mode = self.INVITED |
458 ): | 460 ): |
459 room_jid = jid.JID(room_jid_s) if room_jid_s else None | 461 room_jid = jid.JID(room_jid_s) if room_jid_s else None |
460 other_players = [jid.JID(player).userhostJID() for player in other_players] | 462 other_players = [jid.JID(player).userhostJID() for player in other_players] |
461 return self.prepare_room(other_players, room_jid, profile_key) | 463 return self.prepare_room(other_players, room_jid, profile_key) |
462 | 464 |
463 def prepare_room(self, other_players=None, room_jid=None, profile_key=C.PROF_KEY_NONE): | 465 def prepare_room( |
466 self, other_players=None, room_jid=None, profile_key=C.PROF_KEY_NONE | |
467 ): | |
464 """Prepare the room for a game: create it if it doesn't exist and invite players. | 468 """Prepare the room for a game: create it if it doesn't exist and invite players. |
465 | 469 |
466 @param other_players (list[JID]): list of other players JID (bare) | 470 @param other_players (list[JID]): list of other players JID (bare) |
467 @param room_jid (jid.JID): JID of the room, or None to generate a unique name | 471 @param room_jid (jid.JID): JID of the room, or None to generate a unique name |
468 @param profile_key (unicode): %(doc_profile_key)s | 472 @param profile_key (unicode): %(doc_profile_key)s |
714 idx += 1 | 718 idx += 1 |
715 started_elt.addChild(player_elt) | 719 started_elt.addChild(player_elt) |
716 return started_elt | 720 return started_elt |
717 | 721 |
718 def _send_elements(self, to_jid, data, profile=None): | 722 def _send_elements(self, to_jid, data, profile=None): |
719 """ TODO | 723 """TODO |
720 | 724 |
721 @param to_jid: recipient JID | 725 @param to_jid: recipient JID |
722 @param data: list of (elem, attr, content) with: | 726 @param data: list of (elem, attr, content) with: |
723 - elem: domish.Element, unicode or a couple: | 727 - elem: domish.Element, unicode or a couple: |
724 - domish.Element to be directly added as a child to the message | 728 - domish.Element to be directly added as a child to the message |
743 elem.addContent(content) | 747 elem.addContent(content) |
744 client.send(msg) | 748 client.send(msg) |
745 return defer.succeed(None) | 749 return defer.succeed(None) |
746 | 750 |
747 def send(self, to_jid, elem=None, attrs=None, content=None, profile=None): | 751 def send(self, to_jid, elem=None, attrs=None, content=None, profile=None): |
748 """ TODO | 752 """TODO |
749 | 753 |
750 @param to_jid: recipient JID | 754 @param to_jid: recipient JID |
751 @param elem: domish.Element, unicode or a couple: | 755 @param elem: domish.Element, unicode or a couple: |
752 - domish.Element to be directly added as a child to the message | 756 - domish.Element to be directly added as a child to the message |
753 - unicode name or couple (uri, name) to create a new domish.Element | 757 - unicode name or couple (uri, name) to create a new domish.Element |