Beispiel #1
0
 def  setUp(self):
     """ Build the Step for the test """
     self.attack = Attack()
     self.originalPowerPointsValue = 10
     self.attack.currPowerPoints = self.originalPowerPointsValue
     self.step = RemovePPStep(self.attack)
     self.target = BuildPokemonBattleWrapper()
     self.target.getAbility().powerPointsPressure = self.powerPointsPressure
     
     self.pressure = 2
     self.usedAbility = False
Beispiel #2
0
    def __init__(self):
        self.hitDelegate = None
        self.damageDelegate = None
        self.speedDelegate = None

        self.effectDelegates = []
        self.makes_contact = False
        self.powerPoints = 0
        self.currPowerPoints = 0

        self.preconditionsStep = PreconditionStep(self)
        self.announcementStep = AnnouncementStep(self)
        self.removePPStep = RemovePPStep(self)
        self.hitStep = HitStep(self)
        self.damageStep = DamageStep(self)
        self.effectsStep = EffectsStep(self)
        self.handleContactStep = HandleContactStep(self)
        self.handleMissEffectsStep = HandleMissEffectsStep(self)
Beispiel #3
0
class Attack:
    """ Represents an Attack """
    def __init__(self):
        self.hitDelegate = None
        self.damageDelegate = None
        self.speedDelegate = None

        self.effectDelegates = []
        self.makes_contact = False
        self.powerPoints = 0
        self.currPowerPoints = 0

        self.preconditionsStep = PreconditionStep(self)
        self.announcementStep = AnnouncementStep(self)
        self.removePPStep = RemovePPStep(self)
        self.hitStep = HitStep(self)
        self.damageStep = DamageStep(self)
        self.effectsStep = EffectsStep(self)
        self.handleContactStep = HandleContactStep(self)
        self.handleMissEffectsStep = HandleMissEffectsStep(self)

    def use(self, user, target, environment):
        """ Uses the current attack Object in a Battle """
        messages = []
        messages += self.preconditionsStep.perform(user, target, environment)
        if self.preconditionsStep.passed:
            messages += self.announcementStep.perform(user, target,
                                                      environment)
            messages += self.removePPStep.perform(user, target, environment)
            messages += self.hitStep.perform(user, target, environment)
            if self.hitStep.hit:
                messages += self.damageStep.perform(user, target, environment)
                messages += self.effectsStep.perform(user, target, environment)
                messages += self.handleContactStep.perform(
                    user, target, environment)
            else:
                messages += self.handleMissEffectsStep.perform(
                    user, target, environment)

        return messages

    # Helper Methods
    def addDelegate(self, delegateCategory, delegate):
        """ Adds a delegate to an Attack Object """
        if delegateCategory == Tags.effectDelegateTag:
            self.effectDelegates.append(delegate)
            return
        setattr(self, delegateCategory, delegate)

    def isStatus(self):
        """ Returns if the Attack is a status attack """
        return isinstance(self.damageDelegate, NullDamageDelegate)
Beispiel #4
0
class Attack:
    """ Represents an Attack """
    
    def __init__(self):
        self.hitDelegate = None
        self.damageDelegate = None
        self.speedDelegate = None
        
        self.effectDelegates = []
        self.makes_contact = False
        self.powerPoints = 0
        self.currPowerPoints = 0
        
        self.preconditionsStep = PreconditionStep(self)
        self.announcementStep = AnnouncementStep(self)
        self.removePPStep = RemovePPStep(self)
        self.hitStep = HitStep(self)
        self.damageStep = DamageStep(self)
        self.effectsStep = EffectsStep(self)
        self.handleContactStep = HandleContactStep(self)
        self.handleMissEffectsStep = HandleMissEffectsStep(self)
        
    def use(self, user, target, environment):
        """ Uses the current attack Object in a Battle """
        messages = []
        messages += self.preconditionsStep.perform(user, target, environment)
        if self.preconditionsStep.passed:
            messages += self.announcementStep.perform(user, target, environment)
            messages += self.removePPStep.perform(user, target, environment)
            messages += self.hitStep.perform(user, target, environment)
            if self.hitStep.hit:
                messages += self.damageStep.perform(user, target, environment)
                messages += self.effectsStep.perform(user, target, environment)
                messages += self.handleContactStep.perform(user, target, environment)
            else:
                messages += self.handleMissEffectsStep.perform(user, target, environment)
        
        return messages
        
    # Helper Methods
    def addDelegate(self, delegateCategory, delegate):
        """ Adds a delegate to an Attack Object """
        if delegateCategory == Tags.effectDelegateTag:
            self.effectDelegates.append(delegate)
            return
        setattr(self, delegateCategory, delegate)
        
    def isStatus(self):
        """ Returns if the Attack is a status attack """
        return isinstance(self.damageDelegate, NullDamageDelegate)
Beispiel #5
0
 def __init__(self):
     self.hitDelegate = None
     self.damageDelegate = None
     self.speedDelegate = None
     
     self.effectDelegates = []
     self.makes_contact = False
     self.powerPoints = 0
     self.currPowerPoints = 0
     
     self.preconditionsStep = PreconditionStep(self)
     self.announcementStep = AnnouncementStep(self)
     self.removePPStep = RemovePPStep(self)
     self.hitStep = HitStep(self)
     self.damageStep = DamageStep(self)
     self.effectsStep = EffectsStep(self)
     self.handleContactStep = HandleContactStep(self)
     self.handleMissEffectsStep = HandleMissEffectsStep(self)
Beispiel #6
0
class perform(unittest.TestCase):
    """ Test cases of perform """
    
    def  setUp(self):
        """ Build the Step for the test """
        self.attack = Attack()
        self.originalPowerPointsValue = 10
        self.attack.currPowerPoints = self.originalPowerPointsValue
        self.step = RemovePPStep(self.attack)
        self.target = BuildPokemonBattleWrapper()
        self.target.getAbility().powerPointsPressure = self.powerPointsPressure
        
        self.pressure = 2
        self.usedAbility = False
        
    def standard(self):
        """ Test that the PP is decreased under normal circumstances """
        ppValue = 10
        self.attack.currPowerPoints = ppValue
        
        self.step.perform(None, self.target, None)
        
        self.assertTrue(self.usedAbility, "PP Pressure should have been determined by the Target's Pressure")
        self.assertEquals(ppValue-self.pressure, self.attack.currPowerPoints, "PP should have been reduced by the Target's Pressure")
        
    def hitSelf(self):
        """ Test that the PP is decreased under normal circumstances """
        self.attack.hitDelegate = HitSelfDelegate()
        ppValue = 10
        self.attack.currPowerPoints = ppValue
        
        self.step.perform(None, self.target, None)
        
        self.assertFalse(self.usedAbility, "PP Pressure should not have been determined by the Target's Pressure")
        self.assertEquals(ppValue-1, self.attack.currPowerPoints, 'PP should have been reduced by 1')
        
    def zero(self):
        """ Test that the PP is not decreased when already at zero """
        ppValue = 0
        self.attack.currPowerPoints = ppValue
        
        self.step.perform(None, self.target, None)
        
        self.assertEquals(0, self.attack.currPowerPoints, 'PP should stay at 0')
        
    def powerPointsPressure(self):
        """ Return the power Point Pressure """
        self.usedAbility = True
        return self.pressure