class getCritChance(unittest.TestCase):
    """ Test cases of getCritChance """
    
    def  setUp(self):
        """ Build the CritDelegate and Pkmn for the test """
        self.pkmn = BuildPokemonBattleWrapper()
        self.crit = CritDelegate(0)
        
    def checkMods(self):
        """ Test that mods affect the crit chance correctly """
        self.crit = CritDelegate(0)
        
        for mod in range(0, len(CritDelegate.critMods)):
            self.pkmn.statMods["CRT"] = mod
            chance = self.crit.getCritChance(self.pkmn)
            assert chance == CritDelegate.critMods[mod], "The Pkmn's crit mod should get the corresponding crit chance"
            
    def checkBase(self):
        """ Test that base affect the crit chance correctly """
        self.pkmn.statMods["CRT"] = 0
        
        for base in range(0, len(CritDelegate.critMods)):
            crit = CritDelegate(base)
            chance = crit.getCritChance(self.pkmn)
            assert chance == CritDelegate.critMods[base], "The Crit Delegate's base should get the corresponding crit chance"
            
    def checkBaseAndMod(self):
        """ Test that base and mod compound correctly """
        base = 2
        mod = 2
        
        self.crit = CritDelegate(base)
        self.pkmn.statMods["CRT"] = mod
        chance = self.crit.getCritChance(self.pkmn)
        assert chance == CritDelegate.critMods[base+mod], "The base and mod should compound to get the crit chance"
class checkForCrit(unittest.TestCase):
    """ Test cases of checkForCrit """
    
    def  setUp(self):
        """ Build the CritDelegate and Pkmn for the test """
        self.crit = CritDelegate(0)
        
    def didCrit(self):
        """ Test that checkForCrit returns correctly when it did crit """
        critChance = 1
        rand = 0
        
        crit, message = self.crit.checkForCrit(critChance, rand)
        assert crit, "Should crit if critChance is greater than random"
        assert message == CritDelegate.critMessage, "Should return the crit message" 
        
            
    def didntCrit(self):
        """ Test that checkForCrit returns correctly when it did not crit """
        critChance = 0
        rand = 1
        
        crit, message = self.crit.checkForCrit(critChance, rand)
        assert not crit, "Should not crit if critChance is less than random"
        assert message == CritDelegate.critMessage, "Should return the crit message" 
 def checkBase(self):
     """ Test that base affect the crit chance correctly """
     self.pkmn.statMods["CRT"] = 0
     
     for base in range(0, len(CritDelegate.critMods)):
         crit = CritDelegate(base)
         chance = crit.getCritChance(self.pkmn)
         assert chance == CritDelegate.critMods[base], "The Crit Delegate's base should get the corresponding crit chance"
Example #4
0
    def checkBase(self):
        """ Test that base affect the crit chance correctly """
        self.pkmn.statMods["CRT"] = 0

        for base in range(0, len(CritDelegate.critMods)):
            crit = CritDelegate(base)
            chance = crit.getCritChance(self.pkmn)
            assert chance == CritDelegate.critMods[
                base], "The Crit Delegate's base should get the corresponding crit chance"
Example #5
0
    def checkMods(self):
        """ Test that mods affect the crit chance correctly """
        self.crit = CritDelegate(0)

        for mod in range(0, len(CritDelegate.critMods)):
            self.pkmn.statMods["CRT"] = mod
            chance = self.crit.getCritChance(self.pkmn)
            assert chance == CritDelegate.critMods[
                mod], "The Pkmn's crit mod should get the corresponding crit chance"
Example #6
0
    def checkBaseAndMod(self):
        """ Test that base and mod compound correctly """
        base = 2
        mod = 2

        self.crit = CritDelegate(base)
        self.pkmn.statMods["CRT"] = mod
        chance = self.crit.getCritChance(self.pkmn)
        assert chance == CritDelegate.critMods[
            base +
            mod], "The base and mod should compound to get the crit chance"
 def checkMods(self):
     """ Test that mods affect the crit chance correctly """
     self.crit = CritDelegate(0)
     
     for mod in range(0, len(CritDelegate.critMods)):
         self.pkmn.statMods["CRT"] = mod
         chance = self.crit.getCritChance(self.pkmn)
         assert chance == CritDelegate.critMods[mod], "The Pkmn's crit mod should get the corresponding crit chance"
 def checkBaseAndMod(self):
     """ Test that base and mod compound correctly """
     base = 2
     mod = 2
     
     self.crit = CritDelegate(base)
     self.pkmn.statMods["CRT"] = mod
     chance = self.crit.getCritChance(self.pkmn)
     assert chance == CritDelegate.critMods[base+mod], "The base and mod should compound to get the crit chance"
Example #9
0
    def loadFromDB(cursor, parent):
        """ Loads an attack Crit Delegate from a Database """
        type, id = CritDelegateFactory.GetTypeAndID(cursor, parent.name)

        if type == "CORE":
            cursor.execute("SELECT base from CoreCritDelegate where id=?",
                           (id, ))
            base = cursor.fetchone()[0]
            return CritDelegate(base)

        cursor.close()
Example #10
0
class getCritChance(unittest.TestCase):
    """ Test cases of getCritChance """
    def setUp(self):
        """ Build the CritDelegate and Pkmn for the test """
        self.pkmn = BuildPokemonBattleWrapper()
        self.crit = CritDelegate(0)

    def checkMods(self):
        """ Test that mods affect the crit chance correctly """
        self.crit = CritDelegate(0)

        for mod in range(0, len(CritDelegate.critMods)):
            self.pkmn.statMods["CRT"] = mod
            chance = self.crit.getCritChance(self.pkmn)
            assert chance == CritDelegate.critMods[
                mod], "The Pkmn's crit mod should get the corresponding crit chance"

    def checkBase(self):
        """ Test that base affect the crit chance correctly """
        self.pkmn.statMods["CRT"] = 0

        for base in range(0, len(CritDelegate.critMods)):
            crit = CritDelegate(base)
            chance = crit.getCritChance(self.pkmn)
            assert chance == CritDelegate.critMods[
                base], "The Crit Delegate's base should get the corresponding crit chance"

    def checkBaseAndMod(self):
        """ Test that base and mod compound correctly """
        base = 2
        mod = 2

        self.crit = CritDelegate(base)
        self.pkmn.statMods["CRT"] = mod
        chance = self.crit.getCritChance(self.pkmn)
        assert chance == CritDelegate.critMods[
            base +
            mod], "The base and mod should compound to get the crit chance"
Example #11
0
class checkForCrit(unittest.TestCase):
    """ Test cases of checkForCrit """
    def setUp(self):
        """ Build the CritDelegate and Pkmn for the test """
        self.crit = CritDelegate(0)

    def didCrit(self):
        """ Test that checkForCrit returns correctly when it did crit """
        critChance = 1
        rand = 0

        crit, message = self.crit.checkForCrit(critChance, rand)
        assert crit, "Should crit if critChance is greater than random"
        assert message == CritDelegate.critMessage, "Should return the crit message"

    def didntCrit(self):
        """ Test that checkForCrit returns correctly when it did not crit """
        critChance = 0
        rand = 1

        crit, message = self.crit.checkForCrit(critChance, rand)
        assert not crit, "Should not crit if critChance is less than random"
        assert message == CritDelegate.critMessage, "Should return the crit message"
Example #12
0
 def setUp(self):
     """ Build the CritDelegate and Pkmn for the test """
     self.crit = CritDelegate(0)
Example #13
0
 def buildCritDelegate(element):
     """ Builds a critDelegate for the damageDelegate """
     delegate = element.find(Tags.critDelegateTag)
     base = int(delegate.find(Tags.baseTag).text)
     return CritDelegate(base)
 def  setUp(self):
     """ Build the CritDelegate and Pkmn for the test """
     self.pkmn = BuildPokemonBattleWrapper()
     self.crit = CritDelegate(0)
 def  setUp(self):
     """ Build the CritDelegate and Pkmn for the test """
     self.crit = CritDelegate(0)
Example #16
0
 def setUp(self):
     """ Build the CritDelegate and Pkmn for the test """
     self.pkmn = BuildPokemonBattleWrapper()
     self.crit = CritDelegate(0)
Example #17
0
 def buildNull():
     """ Returns a Null crit delegate """
     return CritDelegate(0)