def test_get_attribute_movementSpeed(self): """ Test that getting movementSpeed works as intended - min: 0 :return None: """ class_json = gameConstants.classesJson['dummy_one'] attributes = Attributes(class_json['Health'], class_json['Damage'], class_json['AttackRange'], class_json['AttackSpeed'], class_json['Armor'], class_json['MovementSpeed']) self.assertEqual(attributes.get_attribute("MovementSpeed"), 5) attributes.change_attribute("MovementSpeed", -15) self.assertEqual(attributes.get_attribute("MovementSpeed"), 0) attributes.change_attribute("MovementSpeed", 20) self.assertEqual(attributes.get_attribute("MovementSpeed"), 10)
def test_get_attribute_rooted(self): """ Test that getting if rooted works as intended - below 0: True - else: False :return None: """ class_json = gameConstants.classesJson['dummy_one'] attributes = Attributes(class_json['Health'], class_json['Damage'], class_json['AttackRange'], class_json['AttackSpeed'], class_json['Armor'], class_json['MovementSpeed']) self.assertEqual(attributes.get_attribute("Rooted"), False) attributes.change_attribute("Rooted", -1) self.assertEqual(attributes.get_attribute("Rooted"), True) attributes.change_attribute("Rooted", 2) self.assertEqual(attributes.get_attribute("Rooted"), False)
def test_change_attribute_health(self): """ Test that changing health works as intended - Can not be below 0 - Can not be above maxHealth :return None: """ class_json = gameConstants.classesJson['dummy_one'] attributes = Attributes(class_json['Health'], class_json['Damage'], class_json['AttackRange'], class_json['AttackSpeed'], class_json['Armor'], class_json['MovementSpeed']) self.assertEqual(attributes.health, 500) attributes.change_attribute("Health", -510) self.assertEqual(attributes.health, 0) attributes.change_attribute("Health", 600) self.assertEqual(attributes.health, 500) attributes.change_attribute("Health", -50) self.assertEqual(attributes.health, 450)
def test_constructor(self): """ Test default constructor :return None: """ class_json = gameConstants.classesJson['dummy_one'] attributes = Attributes(class_json['Health'], class_json['Damage'], class_json['AttackRange'], class_json['AttackSpeed'], class_json['Armor'], class_json['MovementSpeed']) self.assertEqual(attributes.maxHealth, 500) self.assertEqual(attributes.health, 500) self.assertEqual(attributes.attackRange, 0) self.assertEqual(attributes.attackSpeed, 5) self.assertEqual(attributes.armor, 50) self.assertEqual(attributes.movementSpeed, 5) self.assertEqual(attributes.stunned, 0) self.assertEqual(attributes.silenced, 0) self.assertEqual(attributes.rooted, 0)
def test_change_attribute_armor(self): """ Test that changing armor has no restrictions :return None: """ class_json = gameConstants.classesJson['dummy_one'] attributes = Attributes(class_json['Health'], class_json['Damage'], class_json['AttackRange'], class_json['AttackSpeed'], class_json['Armor'], class_json['MovementSpeed']) self.assertEqual(attributes.armor, 50) attributes.change_attribute("Armor", -60) self.assertEqual(attributes.armor, -10) attributes.change_attribute("Armor", 20) self.assertEqual(attributes.armor, 10)
def test_change_attribute_rooted(self): """ Test that changing rooted has no restrictions :return None: """ class_json = gameConstants.classesJson['dummy_one'] attributes = Attributes(class_json['Health'], class_json['Damage'], class_json['AttackRange'], class_json['AttackSpeed'], class_json['Armor'], class_json['MovementSpeed']) self.assertEqual(attributes.rooted, 0) attributes.change_attribute("Rooted", -1) self.assertEqual(attributes.rooted, -1) attributes.change_attribute("Rooted", 2) self.assertEqual(attributes.rooted, 1)
def test_get_attribute_health(self): """ Test that getting health works as intended - min: 0 - max: Maxhealth :return None: """ class_json = gameConstants.classesJson['dummy_one'] attributes = Attributes(class_json['Health'], class_json['Damage'], class_json['AttackRange'], class_json['AttackSpeed'], class_json['Armor'], class_json['MovementSpeed']) self.assertEqual(attributes.get_attribute("Health"), 500) attributes.change_attribute("Health", -510) self.assertEqual(attributes.get_attribute("Health"), 0) attributes.change_attribute("Health", 600) self.assertEqual(attributes.get_attribute("Health"), 500) attributes.change_attribute("Health", -50) self.assertEqual(attributes.get_attribute("Health"), 450)