Ejemplo n.º 1
0
 def execute(self, player, args):
     players = db.find_all(lambda x: isinstance(x, db.Player) and
                                     x.connected)
     player.send("{number} {playersare} connected: {players}.".format(
         number=len(players),
         playersare="player is" if len(players) == 1 else "players are",
         players=utils.comma_and(map(str, list(players)))))
Ejemplo n.º 2
0
 def execute(self, player, args):
     players = db.find_all(
         lambda x: isinstance(x, db.Player) and x.connected)
     player.send("{number} {playersare} connected: {players}.".format(
         number=len(players),
         playersare="player is" if len(players) == 1 else "players are",
         players=utils.comma_and(map(str, list(players)))))
Ejemplo n.º 3
0
Archivo: db.py Proyecto: rlazarus/MUSS
 def equipment_string(self):
     equipment = find_all(lambda x: x.location == self and hasattr(
         x, 'equipped') and x.equipped)
     text = utils.comma_and(map(str, list(equipment)))
     if equipment:
         return "{} is wearing {}.".format(self.name, text)
     else:
         return ""
Ejemplo n.º 4
0
Archivo: db.py Proyecto: rlazarus/MUSS
 def contents_string(self):
     contents = find_all(lambda x: x.location == self and not (hasattr(
         x, 'equipped') and x.equipped))
     text = utils.comma_and(map(str, list(contents)))
     if contents:
         return "{} is carrying {}.".format(self.name, text)
     else:
         return ""
Ejemplo n.º 5
0
 def equipment_string(self):
     equipment = find_all(lambda x: x.location == self
                                    and hasattr(x, 'equipped')
                                    and x.equipped)
     text = utils.comma_and(map(str, list(equipment)))
     if equipment:
         return "{} is wearing {}.".format(self.name, text)
     else:
         return ""
Ejemplo n.º 6
0
 def contents_string(self):
     contents = find_all(lambda x: x.location == self
                                   and not (hasattr(x, 'equipped')
                                            and x.equipped))
     text = utils.comma_and(map(str, list(contents)))
     if contents:
         return "{} is carrying {}.".format(self.name, text)
     else:
         return ""
Ejemplo n.º 7
0
Archivo: db.py Proyecto: rlazarus/MUSS
    def exits_string(self):
        """
        List the object's exits as a string formatted for display. If no exits,
        return an empty string.

        Exits from an object are pretty unlikely if the object isn't a room,
        but they're not illegal.
        """
        exits = find_all(lambda x: x.type == 'exit' and x.location is self)
        text = utils.comma_and(map(str, exits))
        if exits:
            return "Exits: {}".format(text)
        else:
            return ""
Ejemplo n.º 8
0
    def exits_string(self):
        """
        List the object's exits as a string formatted for display. If no exits,
        return an empty string.

        Exits from an object are pretty unlikely if the object isn't a room,
        but they're not illegal.
        """
        exits = find_all(lambda x: x.type == 'exit' and x.location is self)
        text = utils.comma_and(map(str, exits))
        if exits:
            return "Exits: {}".format(text)
        else:
            return ""
Ejemplo n.º 9
0
Archivo: db.py Proyecto: rlazarus/MUSS
    def equipment_string(self):
        """
        List the object's equipment as a string formatted for display. If no
        equipment, return an empty string.
        """
        objects = find_all(
            lambda x: x.type != 'player' and x.type != 'exit' and x.location is
            self and hasattr(x, 'equipped') and x.equipped)
        names = [o.position_string() for o in objects]
        text = utils.comma_and(names)

        if objects:
            return "Equipment: {}".format(text)
        else:
            return ""
Ejemplo n.º 10
0
    def equipment_string(self):
        """
        List the object's equipment as a string formatted for display. If no
        equipment, return an empty string.
        """
        objects = find_all(lambda x: x.type != 'player' and x.type != 'exit'
                                     and x.location is self
                                     and hasattr(x, 'equipped') and x.equipped)
        names = [o.position_string() for o in objects]
        text = utils.comma_and(names)

        if objects:
            return "Equipment: {}".format(text)
        else:
            return ""
Ejemplo n.º 11
0
Archivo: db.py Proyecto: rlazarus/MUSS
    def population_string(self):
        """
        List the players inside an object as a string formatted for display. If
        no one's inside the object, return an empty string.
        """

        population = find_all(
            lambda x: x.type == 'player' and x.location is self)
        if population:
            names = []
            for player in population:
                if player.connected:
                    names.append(player.position_string())
                else:
                    names.append(player.name + " (disconnected)")
            return "Players: {}".format(utils.comma_and(names))
        else:
            return ""
Ejemplo n.º 12
0
    def population_string(self):
        """
        List the players inside an object as a string formatted for display. If
        no one's inside the object, return an empty string.
        """

        population = find_all(lambda x: x.type == 'player' and
                                        x.location is self)
        if population:
            names = []
            for player in population:
                if player.connected:
                    names.append(player.position_string())
                else:
                    names.append(player.name + " (disconnected)")
            return "Players: {}".format(utils.comma_and(names))
        else:
            return ""
Ejemplo n.º 13
0
 def test_comma_and_three(self):
     self.assertEqual(utils.comma_and(["one", "two", "three"]),
                      "one, two, and three")
Ejemplo n.º 14
0
 def test_comma_and_one(self):
     self.assertEqual(utils.comma_and(["one"]), "one")
Ejemplo n.º 15
0
 def test_comma_and_zero(self):
     self.assertEqual(utils.comma_and([]), "")
Ejemplo n.º 16
0
 def test_comma_and_four(self):
     self.assertEqual(utils.comma_and(["one", "two", "three", "four"]),
                      "one, two, three, and four")
Ejemplo n.º 17
0
 def test_comma_and_two(self):
     self.assertEqual(utils.comma_and(["one", "two"]), "one and two")