Example #1
0
 def add_players(self):
     self.loading_lock = 1
     self._p = players = []
     if not self._restored:
         if self.use_rpc:
             number = int(Compat3k.prompt_user("How many players (+ve number in figures): "))
             print ("Please start %d instance(s) " #pylint: disable = superfluous-parens
                    "of remote.py or remote.exe with unique ports."%number)
             print ("Once you have done this, " #pylint: disable = superfluous-parens
                    "enter the hosts and ports here.")
             for i in range(number):  #pylint: disable = unused-variable
                 players.append(self.PlayerClass(self, play=1))
             self.reserve=players[:]
         else:
             players.append(self.PlayerClass(self, play=1))
             self.reserve=[players[0]]
         for playerobj in players:
             self.level_initiate(playerobj)
     else:
         self.levels_reown()
         if self.use_rpc:
             number = int(Compat3k.prompt_user("How many players (+ve number in figures): "))
             print ("Please start %d instance(s) " #pylint: disable = superfluous-parens
                    "of remote.py or remote.exe with unique ports."%number)
             print ("Once you have done this, " #pylint: disable = superfluous-parens
                    "enter the hosts and ports here.")
             for i in range(number):  #pylint: disable = unused-variable
                 players.append(self.PlayerClass(self, play=1))
         else:
             players.append(self.reserve[0])
             self.reserve[0].play()
         for playerobj in players:
             self.level_restore(playerobj)
     self.loading_lock = 0
Example #2
0
    def __init__(self):
        try:
            import xmlrpclib  #pylint: disable = import-error
        except ImportError:
            #3k
            import xmlrpc.client as xmlrpclib  #pylint: disable = import-error

        class ClassicTransport(xmlrpclib.Transport):
            def make_connection(self, host):
                self._extra_headers = []
                self._connection = (None, None)
                r = xmlrpclib.Transport.make_connection(self, host)
                self._extra_headers = []
                self._connection = (None, None)
                return r

        host = Compat3k.prompt_user(
            "Host of next remote (blank for localhost): ").strip(
            ) or "localhost"
        port = int(Compat3k.prompt_user("Port used: "))
        self.backend = xmlrpclib.ServerProxy("http://%s:%d/" % (host, port),
                                             allow_none=True,
                                             transport=ClassicTransport())
        self._plot_cache = []
        self._already = {}
        self._dimensions = self.backend.get_dimensions()
        self._lock = allocate_lock()
        self.rpc_remote_address = (host, port)
Example #3
0
 def slow_ask_question(self, s, p=""):
     self._lock.acquire()
     r = Compat3k.unhexlify(
         self.display.hex_slow_ask_question(Compat3k.hexlify(s),
                                            Compat3k.hexlify(p)))
     self._lock.release()
     return r
Example #4
0
 def slow_push_message(self, s, p=""):
     self._lock.acquire()
     r = Compat3k.unhexlify(
         self.display.hex_slow_push_message(Compat3k.hexlify(s),
                                            Compat3k.hexlify(p)))
     self._lock.release()
     return r
    def _put_to_message_area(self, s, ask):
        """The backend behind all putting to the console message area,
        for ask or say.

        Not thread safe.

        Arguments:
        - s: The string to output.
        - ask: Boolean, should user input be waited for?
        - collect_input: Boolean, should the user input be collected?  Keep as 1
          unless the user is supposed to acknowledge receipt of the message with
          Return but not actually supposed to input stuff (e.g. More prompt).
        """
        _w = self.get_dimensions()[0]
        if _w < 0:
            _w = 80
        s_padded = s
        if len(s) < (_w-1):
            s_padded += (_w-len(s)-1)*" "
        self._engage_message_formatting()
        save_point = self.point[:]
        retu = None
        self.goto_point(0,21)
        self._output_text(s_padded)
        if ask:
            self._reset_terminal()
            retu = Compat3k.prompt_user("\r"+s)
        self._end_message_formatting()
        self.goto_point(*save_point)
        return retu
Example #6
0
 def add_players(self):
     self.loading_lock = 1
     self._p = players = []
     if not self._restored:
         if self.use_rpc:
             number = int(
                 Compat3k.prompt_user(
                     "How many players (+ve number in figures): "))
             print(
                 "Please start %d instance(s) "  #pylint: disable = superfluous-parens
                 "of remote.py or remote.exe with unique ports." % number)
             print(
                 "Once you have done this, "  #pylint: disable = superfluous-parens
                 "enter the hosts and ports here.")
             for i in range(number):  #pylint: disable = unused-variable
                 players.append(self.PlayerClass(self, play=1))
             self.reserve = players[:]
         else:
             players.append(self.PlayerClass(self, play=1))
             self.reserve = [players[0]]
         for playerobj in players:
             self.level_initiate(playerobj)
     else:
         self.levels_reown()
         if self.use_rpc:
             number = int(
                 Compat3k.prompt_user(
                     "How many players (+ve number in figures): "))
             print(
                 "Please start %d instance(s) "  #pylint: disable = superfluous-parens
                 "of remote.py or remote.exe with unique ports." % number)
             print(
                 "Once you have done this, "  #pylint: disable = superfluous-parens
                 "enter the hosts and ports here.")
             for i in range(number):  #pylint: disable = unused-variable
                 players.append(self.PlayerClass(self, play=1))
         else:
             players.append(self.reserve[0])
             self.reserve[0].play()
         for playerobj in players:
             self.level_restore(playerobj)
     self.loading_lock = 0
Example #7
0
 def hex_push_message(self, message):
     self.push_message(Compat3k.unhexlify(message))
 def _plot_character(self, y_coord, x_coord, character):
     self._conio_puttext(x_coord, y_coord, x_coord, y_coord, Compat3k.str_to_bytes(character))
 def set_window_title(self, title):
     self._conio_settitle(Compat3k.str_to_bytes(title))
Example #10
0
 def _plot_character(self, y_coord, x_coord, character):
     self._conio_puttext(x_coord, y_coord, x_coord, y_coord,
                         Compat3k.str_to_bytes(character))
Example #11
0
 def set_window_title(self, title):
     self._conio_settitle(Compat3k.str_to_bytes(title))
Example #12
0
 def hex_set_window_title(self, title):
     return self.set_window_title(Compat3k.unhexlify(title))
Example #13
0
 def hex_slow_ask_question(self, question, prefix=""):
     return Compat3k.hexlify(
         self.slow_ask_question(Compat3k.unhexlify(question),
                                Compat3k.unhexlify(prefix)))
Example #14
0
 def hex_set_window_title(self, title):
     return self.set_window_title(Compat3k.unhexlify(title))
Example #15
0
 def hex_slow_push_message(self, message, prefix=""):
     self.slow_push_message(Compat3k.unhexlify(message),
                            Compat3k.unhexlify(prefix))
Example #16
0
 def hex_ask_question(self, question):
     return Compat3k.hexlify(self.ask_question(Compat3k.unhexlify(question)))
Example #17
0
 def ask_question(self, s):
     self._lock.acquire()
     r = Compat3k.unhexlify(
         self.display.hex_ask_question(Compat3k.hexlify(s)))
     self._lock.release()
     return r
Example #18
0
 def push_message(self, s):
     self._lock.acquire()
     self.display.hex_push_message(Compat3k.hexlify(s))
     self._lock.release()
Example #19
0
 def hex_slow_ask_question(self, question, prefix=""):
     return Compat3k.hexlify(self.slow_ask_question(Compat3k.unhexlify(question), Compat3k.unhexlify(prefix)))
Example #20
0
 def hex_get_key_event(self):
     return Compat3k.hexlify(self.get_key_event())
Example #21
0
 def get_key_event(self):
     self._lock.acquire()
     r = Compat3k.unhexlify(self.display.hex_get_key_event())
     self._lock.release()
     return r
Example #22
0
 def hex_ask_question(self, question):
     return Compat3k.hexlify(self.ask_question(
         Compat3k.unhexlify(question)))
Example #23
0
 def hex_slow_push_message(self, message, prefix=""):
     self.slow_push_message(Compat3k.unhexlify(message), Compat3k.unhexlify(prefix))
Example #24
0
 def hex_push_message(self, message):
     self.push_message(Compat3k.unhexlify(message))
Example #25
0
 def hex_get_key_event(self):
     return Compat3k.hexlify(self.get_key_event())