Exemple #1
0
    def test_command_register(self):
        from shinymud.models.area import Area
        from shinymud.data import config
        from shinymud.models.player import Player
        from shinymud.commands import CommandRegister

        cmds = CommandRegister()
        self.assertEqual(cmds['supercalifragilisticexpieladocious'], None, 
                    "Command Register is returning things it doesn't have!")
        cmds.register((lambda : 3), ['bob', 'sam'])
        self.assertEqual(cmds['bob'](), 3, 
                         "Registered command 'bob' returned wrong value.")
        self.assertEqual(cmds['sam'](), 3,
                         "Registered command 'sam' returned wrong value.")
        self.assertEqual(cmds['bob'], cmds['sam'],
                         "Registered aliases 'bob' and 'sam' did not return same function.")
Exemple #2
0
    def test_command_register(self):
        from shinymud.models.area import Area
        from shinymud.data import config
        from shinymud.models.player import Player
        from shinymud.commands import CommandRegister

        cmds = CommandRegister()
        self.assertEqual(
            cmds['supercalifragilisticexpieladocious'], None,
            "Command Register is returning things it doesn't have!")
        cmds.register((lambda: 3), ['bob', 'sam'])
        self.assertEqual(cmds['bob'](), 3,
                         "Registered command 'bob' returned wrong value.")
        self.assertEqual(cmds['sam'](), 3,
                         "Registered command 'sam' returned wrong value.")
        self.assertEqual(
            cmds['bob'], cmds['sam'],
            "Registered aliases 'bob' and 'sam' did not return same function.")
Exemple #3
0
        elif roll > 10:
            self.log.debug("Hit!")
            self.hit()
        else:
            self.log.debug("Miss!")
            self.miss()
        if not self.target.battle:
            # If the target is killed, let everyone know
            self.attacker.update_output("You kill %s!" %
                                        self.target.fancy_name())
            self.attacker.location.tell_room(
                '%s killed %s.' % (self.attacker, self.target),
                [self.attacker.name, self.target.name])


Action_list = CommandRegister()


class Attack(BattleAction):
    def hit(self):
        """Calculates damage based on the player's damage object, (1-2 if none).
        """
        damage = self.attacker.damage.calculate()
        if not damage:
            damage = {'impact': randint(1, 2)}
        total = self.target.takes_damage(damage, self.attacker.fancy_name())
        self.attacker.update_output("You attack %s for %s damage!" %
                                    (self.target.fancy_name(), str(total)))

    def miss(self):
        self.attacker.update_output("You attack %s but miss!" %
Exemple #4
0
        if roll > 20:
            self.log.debug("CRITICAL HIT!")
            self.critical()
        elif roll > 10:
            self.log.debug("Hit!")
            self.hit()
        else:
            self.log.debug("Miss!")
            self.miss()
        if not self.target.battle:
            # If the target is killed, let everyone know
            self.attacker.update_output("You kill %s!" % self.target.fancy_name())
            self.attacker.location.tell_room('%s killed %s.' % (self.attacker, self.target),
                                            [self.attacker.name, self.target.name])
            
Action_list = CommandRegister()
class Attack(BattleAction):
    def hit(self):
        """Calculates damage based on the player's damage object, (1-2 if none).
        """
        damage = self.attacker.damage.calculate()
        if not damage:
            damage = {'impact': randint(1,2)}
        total = self.target.takes_damage(damage, self.attacker.fancy_name())
        self.attacker.update_output("You attack %s for %s damage!" % (self.target.fancy_name(), str(total)))
    
    def miss(self):
        self.attacker.update_output("You attack %s but miss!" % self.target.fancy_name())
        self.target.update_output("%s tried to attack you, but missed" % (self.attacker.fancy_name()))
    
    def critical(self):