Mercurial > libervia-backend
comparison sat/plugins/plugin_misc_tarot.py @ 4037:524856bd7b19
massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a
pre-PEP8 code, to use the same coding style as in Twisted.
However, snake_case is more readable and it's better to follow PEP8 best practices, so it
has been decided to move on full snake_case. Because Libervia has a huge codebase, this
ended with a ugly mix of camelCase and snake_case.
To fix that, this patch does a big refactoring by renaming every function and method
(including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case.
This is a massive change, and may result in some bugs.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:54:42 +0200 |
parents | be6d91572633 |
children |
comparison
equal
deleted
inserted
replaced
4036:c4464d7ae97b | 4037:524856bd7b19 |
---|---|
47 C.PI_DESCRIPTION: _("""Implementation of Tarot card game"""), | 47 C.PI_DESCRIPTION: _("""Implementation of Tarot card game"""), |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 class Tarot(object): | 51 class Tarot(object): |
52 def inheritFromRoomGame(self, host): | 52 def inherit_from_room_game(self, host): |
53 global RoomGame | 53 global RoomGame |
54 RoomGame = host.plugins["ROOM-GAME"].__class__ | 54 RoomGame = host.plugins["ROOM-GAME"].__class__ |
55 self.__class__ = type( | 55 self.__class__ = type( |
56 self.__class__.__name__, (self.__class__, RoomGame, object), {} | 56 self.__class__.__name__, (self.__class__, RoomGame, object), {} |
57 ) | 57 ) |
58 | 58 |
59 def __init__(self, host): | 59 def __init__(self, host): |
60 log.info(_("Plugin Tarot initialization")) | 60 log.info(_("Plugin Tarot initialization")) |
61 self._sessions = memory.Sessions() | 61 self._sessions = memory.Sessions() |
62 self.inheritFromRoomGame(host) | 62 self.inherit_from_room_game(host) |
63 RoomGame._init_( | 63 RoomGame._init_( |
64 self, | 64 self, |
65 host, | 65 host, |
66 PLUGIN_INFO, | 66 PLUGIN_INFO, |
67 (NS_CG, CG_TAG), | 67 (NS_CG, CG_TAG), |
79 _("Petite"), | 79 _("Petite"), |
80 _("Garde"), | 80 _("Garde"), |
81 _("Garde Sans"), | 81 _("Garde Sans"), |
82 _("Garde Contre"), | 82 _("Garde Contre"), |
83 ] | 83 ] |
84 host.bridge.addMethod( | 84 host.bridge.add_method( |
85 "tarotGameLaunch", | 85 "tarot_game_launch", |
86 ".plugin", | 86 ".plugin", |
87 in_sign="asss", | 87 in_sign="asss", |
88 out_sign="", | 88 out_sign="", |
89 method=self._prepareRoom, | 89 method=self._prepare_room, |
90 async_=True, | 90 async_=True, |
91 ) # args: players, room_jid, profile | 91 ) # args: players, room_jid, profile |
92 host.bridge.addMethod( | 92 host.bridge.add_method( |
93 "tarotGameCreate", | 93 "tarot_game_create", |
94 ".plugin", | 94 ".plugin", |
95 in_sign="sass", | 95 in_sign="sass", |
96 out_sign="", | 96 out_sign="", |
97 method=self._createGame, | 97 method=self._create_game, |
98 ) # args: room_jid, players, profile | 98 ) # args: room_jid, players, profile |
99 host.bridge.addMethod( | 99 host.bridge.add_method( |
100 "tarotGameReady", | 100 "tarot_game_ready", |
101 ".plugin", | 101 ".plugin", |
102 in_sign="sss", | 102 in_sign="sss", |
103 out_sign="", | 103 out_sign="", |
104 method=self._playerReady, | 104 method=self._player_ready, |
105 ) # args: player, referee, profile | 105 ) # args: player, referee, profile |
106 host.bridge.addMethod( | 106 host.bridge.add_method( |
107 "tarotGamePlayCards", | 107 "tarot_game_play_cards", |
108 ".plugin", | 108 ".plugin", |
109 in_sign="ssa(ss)s", | 109 in_sign="ssa(ss)s", |
110 out_sign="", | 110 out_sign="", |
111 method=self.play_cards, | 111 method=self.play_cards, |
112 ) # args: player, referee, cards, profile | 112 ) # args: player, referee, cards, profile |
113 host.bridge.addSignal( | 113 host.bridge.add_signal( |
114 "tarotGamePlayers", ".plugin", signature="ssass" | 114 "tarot_game_players", ".plugin", signature="ssass" |
115 ) # args: room_jid, referee, players, profile | 115 ) # args: room_jid, referee, players, profile |
116 host.bridge.addSignal( | 116 host.bridge.add_signal( |
117 "tarotGameStarted", ".plugin", signature="ssass" | 117 "tarot_game_started", ".plugin", signature="ssass" |
118 ) # args: room_jid, referee, players, profile | 118 ) # args: room_jid, referee, players, profile |
119 host.bridge.addSignal( | 119 host.bridge.add_signal( |
120 "tarotGameNew", ".plugin", signature="sa(ss)s" | 120 "tarot_game_new", ".plugin", signature="sa(ss)s" |
121 ) # args: room_jid, hand, profile | 121 ) # args: room_jid, hand, profile |
122 host.bridge.addSignal( | 122 host.bridge.add_signal( |
123 "tarotGameChooseContrat", ".plugin", signature="sss" | 123 "tarot_game_choose_contrat", ".plugin", signature="sss" |
124 ) # args: room_jid, xml_data, profile | 124 ) # args: room_jid, xml_data, profile |
125 host.bridge.addSignal( | 125 host.bridge.add_signal( |
126 "tarotGameShowCards", ".plugin", signature="ssa(ss)a{ss}s" | 126 "tarot_game_show_cards", ".plugin", signature="ssa(ss)a{ss}s" |
127 ) # args: room_jid, type ["chien", "poignée",...], cards, data[dict], profile | 127 ) # args: room_jid, type ["chien", "poignée",...], cards, data[dict], profile |
128 host.bridge.addSignal( | 128 host.bridge.add_signal( |
129 "tarotGameCardsPlayed", ".plugin", signature="ssa(ss)s" | 129 "tarot_game_cards_played", ".plugin", signature="ssa(ss)s" |
130 ) # args: room_jid, player, type ["chien", "poignée",...], cards, data[dict], profile | 130 ) # args: room_jid, player, type ["chien", "poignée",...], cards, data[dict], profile |
131 host.bridge.addSignal( | 131 host.bridge.add_signal( |
132 "tarotGameYourTurn", ".plugin", signature="ss" | 132 "tarot_game_your_turn", ".plugin", signature="ss" |
133 ) # args: room_jid, profile | 133 ) # args: room_jid, profile |
134 host.bridge.addSignal( | 134 host.bridge.add_signal( |
135 "tarotGameScore", ".plugin", signature="ssasass" | 135 "tarot_game_score", ".plugin", signature="ssasass" |
136 ) # args: room_jid, xml_data, winners (list of nicks), loosers (list of nicks), profile | 136 ) # args: room_jid, xml_data, winners (list of nicks), loosers (list of nicks), profile |
137 host.bridge.addSignal( | 137 host.bridge.add_signal( |
138 "tarotGameInvalidCards", ".plugin", signature="ssa(ss)a(ss)s" | 138 "tarot_game_invalid_cards", ".plugin", signature="ssa(ss)a(ss)s" |
139 ) # args: room_jid, game phase, played_cards, invalid_cards, profile | 139 ) # args: room_jid, game phase, played_cards, invalid_cards, profile |
140 self.deck_ordered = [] | 140 self.deck_ordered = [] |
141 for value in ["excuse"] + list(map(str, list(range(1, 22)))): | 141 for value in ["excuse"] + list(map(str, list(range(1, 22)))): |
142 self.deck_ordered.append(TarotCard(("atout", value))) | 142 self.deck_ordered.append(TarotCard(("atout", value))) |
143 for suit in ["pique", "coeur", "carreau", "trefle"]: | 143 for suit in ["pique", "coeur", "carreau", "trefle"]: |
144 for value in list(map(str, list(range(1, 11)))) + ["valet", "cavalier", "dame", "roi"]: | 144 for value in list(map(str, list(range(1, 11)))) + ["valet", "cavalier", "dame", "roi"]: |
145 self.deck_ordered.append(TarotCard((suit, value))) | 145 self.deck_ordered.append(TarotCard((suit, value))) |
146 self.__choose_contrat_id = host.registerCallback( | 146 self.__choose_contrat_id = host.register_callback( |
147 self._contratChoosed, with_data=True | 147 self._contrat_choosed, with_data=True |
148 ) | 148 ) |
149 self.__score_id = host.registerCallback(self._scoreShowed, with_data=True) | 149 self.__score_id = host.register_callback(self._score_showed, with_data=True) |
150 | 150 |
151 def __card_list_to_xml(self, cards_list, elt_name): | 151 def __card_list_to_xml(self, cards_list, elt_name): |
152 """Convert a card list to domish element""" | 152 """Convert a card list to domish element""" |
153 cards_list_elt = domish.Element((None, elt_name)) | 153 cards_list_elt = domish.Element((None, elt_name)) |
154 for card in cards_list: | 154 for card in cards_list: |
517 ) # the player after the dealer start | 517 ) # the player after the dealer start |
518 game_data["first_player"] = next_player = game_data["players"][next_player_idx] | 518 game_data["first_player"] = next_player = game_data["players"][next_player_idx] |
519 to_jid = jid.JID(room_jid.userhost() + "/" + next_player) # FIXME: gof: | 519 to_jid = jid.JID(room_jid.userhost() + "/" + next_player) # FIXME: gof: |
520 self.send(to_jid, "your_turn", profile=profile) | 520 self.send(to_jid, "your_turn", profile=profile) |
521 | 521 |
522 def _contratChoosed(self, raw_data, profile): | 522 def _contrat_choosed(self, raw_data, profile): |
523 """Will be called when the contrat is selected | 523 """Will be called when the contrat is selected |
524 @param raw_data: contains the choosed session id and the chosen contrat | 524 @param raw_data: contains the choosed session id and the chosen contrat |
525 @param profile_key: profile | 525 @param profile_key: profile |
526 """ | 526 """ |
527 try: | 527 try: |
528 session_data = self._sessions.profileGet(raw_data["session_id"], profile) | 528 session_data = self._sessions.profile_get(raw_data["session_id"], profile) |
529 except KeyError: | 529 except KeyError: |
530 log.warning(_("session id doesn't exist, session has probably expired")) | 530 log.warning(_("session id doesn't exist, session has probably expired")) |
531 # TODO: send error dialog | 531 # TODO: send error dialog |
532 return defer.succeed({}) | 532 return defer.succeed({}) |
533 | 533 |
534 room_jid = session_data["room_jid"] | 534 room_jid = session_data["room_jid"] |
535 referee_jid = self.games[room_jid]["referee"] | 535 referee_jid = self.games[room_jid]["referee"] |
536 player = self.host.plugins["XEP-0045"].getRoomNick(room_jid, profile) | 536 player = self.host.plugins["XEP-0045"].get_room_nick(room_jid, profile) |
537 data = xml_tools.XMLUIResult2DataFormResult(raw_data) | 537 data = xml_tools.xmlui_result_2_data_form_result(raw_data) |
538 contrat = data["contrat"] | 538 contrat = data["contrat"] |
539 log.debug( | 539 log.debug( |
540 _("contrat [%(contrat)s] choosed by %(profile)s") | 540 _("contrat [%(contrat)s] choosed by %(profile)s") |
541 % {"contrat": contrat, "profile": profile} | 541 % {"contrat": contrat, "profile": profile} |
542 ) | 542 ) |
549 ) | 549 ) |
550 d.addCallback(lambda ignore: {}) | 550 d.addCallback(lambda ignore: {}) |
551 del self._sessions[raw_data["session_id"]] | 551 del self._sessions[raw_data["session_id"]] |
552 return d | 552 return d |
553 | 553 |
554 def _scoreShowed(self, raw_data, profile): | 554 def _score_showed(self, raw_data, profile): |
555 """Will be called when the player closes the score dialog | 555 """Will be called when the player closes the score dialog |
556 @param raw_data: nothing to retrieve from here but the session id | 556 @param raw_data: nothing to retrieve from here but the session id |
557 @param profile_key: profile | 557 @param profile_key: profile |
558 """ | 558 """ |
559 try: | 559 try: |
560 session_data = self._sessions.profileGet(raw_data["session_id"], profile) | 560 session_data = self._sessions.profile_get(raw_data["session_id"], profile) |
561 except KeyError: | 561 except KeyError: |
562 log.warning(_("session id doesn't exist, session has probably expired")) | 562 log.warning(_("session id doesn't exist, session has probably expired")) |
563 # TODO: send error dialog | 563 # TODO: send error dialog |
564 return defer.succeed({}) | 564 return defer.succeed({}) |
565 | 565 |
566 room_jid_s = session_data["room_jid"].userhost() | 566 room_jid_s = session_data["room_jid"].userhost() |
567 # XXX: empty hand means to the frontend "reset the display"... | 567 # XXX: empty hand means to the frontend "reset the display"... |
568 self.host.bridge.tarotGameNew(room_jid_s, [], profile) | 568 self.host.bridge.tarot_game_new(room_jid_s, [], profile) |
569 del self._sessions[raw_data["session_id"]] | 569 del self._sessions[raw_data["session_id"]] |
570 return defer.succeed({}) | 570 return defer.succeed({}) |
571 | 571 |
572 def play_cards(self, player, referee, cards, profile_key=C.PROF_KEY_NONE): | 572 def play_cards(self, player, referee, cards, profile_key=C.PROF_KEY_NONE): |
573 """Must be call by player when the contrat is selected | 573 """Must be call by player when the contrat is selected |
574 @param player: player's name | 574 @param player: player's name |
575 @param referee: arbiter jid | 575 @param referee: arbiter jid |
576 @cards: cards played (list of tuples) | 576 @cards: cards played (list of tuples) |
577 @profile_key: profile | 577 @profile_key: profile |
578 """ | 578 """ |
579 profile = self.host.memory.getProfileName(profile_key) | 579 profile = self.host.memory.get_profile_name(profile_key) |
580 if not profile: | 580 if not profile: |
581 log.error(_("profile %s is unknown") % profile_key) | 581 log.error(_("profile %s is unknown") % profile_key) |
582 return | 582 return |
583 log.debug( | 583 log.debug( |
584 _("Cards played by %(profile)s: [%(cards)s]") | 584 _("Cards played by %(profile)s: [%(cards)s]") |
585 % {"profile": profile, "cards": cards} | 585 % {"profile": profile, "cards": cards} |
586 ) | 586 ) |
587 elem = self.__card_list_to_xml(TarotCard.from_tuples(cards), "cards_played") | 587 elem = self.__card_list_to_xml(TarotCard.from_tuples(cards), "cards_played") |
588 self.send(jid.JID(referee), elem, {"player": player}, profile=profile) | 588 self.send(jid.JID(referee), elem, {"player": player}, profile=profile) |
589 | 589 |
590 def newRound(self, room_jid, profile): | 590 def new_round(self, room_jid, profile): |
591 game_data = self.games[room_jid] | 591 game_data = self.games[room_jid] |
592 players = game_data["players"] | 592 players = game_data["players"] |
593 game_data["first_player"] = None # first player for the current trick | 593 game_data["first_player"] = None # first player for the current trick |
594 game_data["contrat"] = None | 594 game_data["contrat"] = None |
595 common_data = { | 595 common_data = { |
611 del (deck[:]) | 611 del (deck[:]) |
612 msg_elts = {} | 612 msg_elts = {} |
613 for player in players: | 613 for player in players: |
614 msg_elts[player] = self.__card_list_to_xml(hand[player], "hand") | 614 msg_elts[player] = self.__card_list_to_xml(hand[player], "hand") |
615 | 615 |
616 RoomGame.newRound(self, room_jid, (common_data, msg_elts), profile) | 616 RoomGame.new_round(self, room_jid, (common_data, msg_elts), profile) |
617 | 617 |
618 pl_idx = game_data["current_player"] = (game_data["init_player"] + 1) % len( | 618 pl_idx = game_data["current_player"] = (game_data["init_player"] + 1) % len( |
619 players | 619 players |
620 ) # the player after the dealer start | 620 ) # the player after the dealer start |
621 player = players[pl_idx] | 621 player = players[pl_idx] |
624 | 624 |
625 def room_game_cmd(self, mess_elt, profile): | 625 def room_game_cmd(self, mess_elt, profile): |
626 """ | 626 """ |
627 @param mess_elt: instance of twisted.words.xish.domish.Element | 627 @param mess_elt: instance of twisted.words.xish.domish.Element |
628 """ | 628 """ |
629 client = self.host.getClient(profile) | 629 client = self.host.get_client(profile) |
630 from_jid = jid.JID(mess_elt["from"]) | 630 from_jid = jid.JID(mess_elt["from"]) |
631 room_jid = jid.JID(from_jid.userhost()) | 631 room_jid = jid.JID(from_jid.userhost()) |
632 nick = self.host.plugins["XEP-0045"].getRoomNick(client, room_jid) | 632 nick = self.host.plugins["XEP-0045"].get_room_nick(client, room_jid) |
633 | 633 |
634 game_elt = mess_elt.firstChildElement() | 634 game_elt = mess_elt.firstChildElement() |
635 game_data = self.games[room_jid] | 635 game_data = self.games[room_jid] |
636 is_player = self.isPlayer(room_jid, nick) | 636 is_player = self.is_player(room_jid, nick) |
637 if "players_data" in game_data: | 637 if "players_data" in game_data: |
638 players_data = game_data["players_data"] | 638 players_data = game_data["players_data"] |
639 | 639 |
640 for elt in game_elt.elements(): | 640 for elt in game_elt.elements(): |
641 if not is_player and (elt.name not in ("started", "players")): | 641 if not is_player and (elt.name not in ("started", "players")): |
647 ): # new game created and/or players list updated | 647 ): # new game created and/or players list updated |
648 players = [] | 648 players = [] |
649 for player in elt.elements(): | 649 for player in elt.elements(): |
650 players.append(str(player)) | 650 players.append(str(player)) |
651 signal = ( | 651 signal = ( |
652 self.host.bridge.tarotGameStarted | 652 self.host.bridge.tarot_game_started |
653 if elt.name == "started" | 653 if elt.name == "started" |
654 else self.host.bridge.tarotGamePlayers | 654 else self.host.bridge.tarot_game_players |
655 ) | 655 ) |
656 signal(room_jid.userhost(), from_jid.full(), players, profile) | 656 signal(room_jid.userhost(), from_jid.full(), players, profile) |
657 | 657 |
658 elif elt.name == "player_ready": # ready to play | 658 elif elt.name == "player_ready": # ready to play |
659 player = elt["player"] | 659 player = elt["player"] |
665 % {"player": player, "status": status} | 665 % {"player": player, "status": status} |
666 ) | 666 ) |
667 if ( | 667 if ( |
668 list(status.values()).count("ready") == nb_players | 668 list(status.values()).count("ready") == nb_players |
669 ): # everybody is ready, we can start the game | 669 ): # everybody is ready, we can start the game |
670 self.newRound(room_jid, profile) | 670 self.new_round(room_jid, profile) |
671 | 671 |
672 elif elt.name == "hand": # a new hand has been received | 672 elif elt.name == "hand": # a new hand has been received |
673 self.host.bridge.tarotGameNew( | 673 self.host.bridge.tarot_game_new( |
674 room_jid.userhost(), self.__xml_to_list(elt), profile | 674 room_jid.userhost(), self.__xml_to_list(elt), profile |
675 ) | 675 ) |
676 | 676 |
677 elif elt.name == "contrat": # it's time to choose contrat | 677 elif elt.name == "contrat": # it's time to choose contrat |
678 form = data_form.Form.fromElement(elt.firstChildElement()) | 678 form = data_form.Form.fromElement(elt.firstChildElement()) |
679 session_id, session_data = self._sessions.newSession(profile=profile) | 679 session_id, session_data = self._sessions.new_session(profile=profile) |
680 session_data["room_jid"] = room_jid | 680 session_data["room_jid"] = room_jid |
681 xml_data = xml_tools.dataForm2XMLUI( | 681 xml_data = xml_tools.data_form_2_xmlui( |
682 form, self.__choose_contrat_id, session_id | 682 form, self.__choose_contrat_id, session_id |
683 ).toXml() | 683 ).toXml() |
684 self.host.bridge.tarotGameChooseContrat( | 684 self.host.bridge.tarot_game_choose_contrat( |
685 room_jid.userhost(), xml_data, profile | 685 room_jid.userhost(), xml_data, profile |
686 ) | 686 ) |
687 | 687 |
688 elif elt.name == "contrat_choosed": | 688 elif elt.name == "contrat_choosed": |
689 # TODO: check we receive the contrat from the right person | 689 # TODO: check we receive the contrat from the right person |
750 elif elt.name == "chien": # we have received the chien | 750 elif elt.name == "chien": # we have received the chien |
751 log.debug(_("tarot: chien received")) | 751 log.debug(_("tarot: chien received")) |
752 data = {"attaquant": elt["attaquant"]} | 752 data = {"attaquant": elt["attaquant"]} |
753 game_data["stage"] = "ecart" | 753 game_data["stage"] = "ecart" |
754 game_data["attaquant"] = elt["attaquant"] | 754 game_data["attaquant"] = elt["attaquant"] |
755 self.host.bridge.tarotGameShowCards( | 755 self.host.bridge.tarot_game_show_cards( |
756 room_jid.userhost(), "chien", self.__xml_to_list(elt), data, profile | 756 room_jid.userhost(), "chien", self.__xml_to_list(elt), data, profile |
757 ) | 757 ) |
758 | 758 |
759 elif elt.name == "cards_played": | 759 elif elt.name == "cards_played": |
760 if game_data["stage"] == "ecart": | 760 if game_data["stage"] == "ecart": |
788 elif game_data["stage"] == "play": | 788 elif game_data["stage"] == "play": |
789 current_player = game_data["players"][game_data["current_player"]] | 789 current_player = game_data["players"][game_data["current_player"]] |
790 cards = TarotCard.from_tuples(self.__xml_to_list(elt)) | 790 cards = TarotCard.from_tuples(self.__xml_to_list(elt)) |
791 | 791 |
792 if mess_elt["type"] == "groupchat": | 792 if mess_elt["type"] == "groupchat": |
793 self.host.bridge.tarotGameCardsPlayed( | 793 self.host.bridge.tarot_game_cards_played( |
794 room_jid.userhost(), | 794 room_jid.userhost(), |
795 elt["player"], | 795 elt["player"], |
796 self.__xml_to_list(elt), | 796 self.__xml_to_list(elt), |
797 profile, | 797 profile, |
798 ) | 798 ) |
856 # finally, we tell to the next player to play | 856 # finally, we tell to the next player to play |
857 to_jid = jid.JID(room_jid.userhost() + "/" + next_player) | 857 to_jid = jid.JID(room_jid.userhost() + "/" + next_player) |
858 self.send(to_jid, "your_turn", profile=profile) | 858 self.send(to_jid, "your_turn", profile=profile) |
859 | 859 |
860 elif elt.name == "your_turn": | 860 elif elt.name == "your_turn": |
861 self.host.bridge.tarotGameYourTurn(room_jid.userhost(), profile) | 861 self.host.bridge.tarot_game_your_turn(room_jid.userhost(), profile) |
862 | 862 |
863 elif elt.name == "score": | 863 elif elt.name == "score": |
864 form_elt = next(elt.elements(name="x", uri="jabber:x:data")) | 864 form_elt = next(elt.elements(name="x", uri="jabber:x:data")) |
865 winners = [] | 865 winners = [] |
866 loosers = [] | 866 loosers = [] |
867 for winner in elt.elements(name="winner", uri=NS_CG): | 867 for winner in elt.elements(name="winner", uri=NS_CG): |
868 winners.append(str(winner)) | 868 winners.append(str(winner)) |
869 for looser in elt.elements(name="looser", uri=NS_CG): | 869 for looser in elt.elements(name="looser", uri=NS_CG): |
870 loosers.append(str(looser)) | 870 loosers.append(str(looser)) |
871 form = data_form.Form.fromElement(form_elt) | 871 form = data_form.Form.fromElement(form_elt) |
872 session_id, session_data = self._sessions.newSession(profile=profile) | 872 session_id, session_data = self._sessions.new_session(profile=profile) |
873 session_data["room_jid"] = room_jid | 873 session_data["room_jid"] = room_jid |
874 xml_data = xml_tools.dataForm2XMLUI( | 874 xml_data = xml_tools.data_form_2_xmlui( |
875 form, self.__score_id, session_id | 875 form, self.__score_id, session_id |
876 ).toXml() | 876 ).toXml() |
877 self.host.bridge.tarotGameScore( | 877 self.host.bridge.tarot_game_score( |
878 room_jid.userhost(), xml_data, winners, loosers, profile | 878 room_jid.userhost(), xml_data, winners, loosers, profile |
879 ) | 879 ) |
880 elif elt.name == "error": | 880 elif elt.name == "error": |
881 if elt["type"] == "invalid_cards": | 881 if elt["type"] == "invalid_cards": |
882 played_cards = self.__xml_to_list( | 882 played_cards = self.__xml_to_list( |
883 next(elt.elements(name="played", uri=NS_CG)) | 883 next(elt.elements(name="played", uri=NS_CG)) |
884 ) | 884 ) |
885 invalid_cards = self.__xml_to_list( | 885 invalid_cards = self.__xml_to_list( |
886 next(elt.elements(name="invalid", uri=NS_CG)) | 886 next(elt.elements(name="invalid", uri=NS_CG)) |
887 ) | 887 ) |
888 self.host.bridge.tarotGameInvalidCards( | 888 self.host.bridge.tarot_game_invalid_cards( |
889 room_jid.userhost(), | 889 room_jid.userhost(), |
890 elt["phase"], | 890 elt["phase"], |
891 played_cards, | 891 played_cards, |
892 invalid_cards, | 892 invalid_cards, |
893 profile, | 893 profile, |
895 else: | 895 else: |
896 log.error(_("Unmanaged error type: %s") % elt["type"]) | 896 log.error(_("Unmanaged error type: %s") % elt["type"]) |
897 else: | 897 else: |
898 log.error(_("Unmanaged card game element: %s") % elt.name) | 898 log.error(_("Unmanaged card game element: %s") % elt.name) |
899 | 899 |
900 def getSyncDataForPlayer(self, room_jid, nick): | 900 def get_sync_data_for_player(self, room_jid, nick): |
901 return [] | 901 return [] |