def test_decrement_stamina_when_attacking(self): player = Character(1) enemy = Character(2) original_stamina = player.stamina player.deal_damage(enemy) assert original_stamina - 10 == player.stamina
def test_equip_weapon(self): player = Character(1) weapon = Weapon(0, 0) player.equip(weapon) assert player.weapon == weapon assert weapon.equipped == True
def test_equip_too_high_level_weapon(self): player = Character(1) weapon = Weapon(0, 20) player.equip(weapon) assert player.weapon == None assert weapon.equipped == False
def test_deal_damage(self): player = Character(1) enemy = Character(2) original_health = enemy.health player.deal_damage(enemy) assert original_health - 50 == enemy.health assert enemy.health > 0
def char_setup(): from main import Character bob = Character() bob.char_name = "Bob" bob.money = { "GP": 100, "SP": 100, "EP": 100, "CP": 100, "PP": 100 } return bob
def create_enemy(event): """ Creates either an easy or hard enemy for the user to face. """ x = random.randint(0, 1) if x == 0: enemy = Character(random.randint(2, 8), random.randint(5, 10)) else: enemy = Character(random.randint(6, 12), random.randint(10, 20)) return enemy
def test_heal(self): char1 = Character(1) char2 = Character(2) factions = ['f1', 'f2', 'f3', 'f4', 'f5'] for x in factions[0:3]: char1.join_faction(x) for x in factions[2:5]: char2.join_faction(x) char1.health = 300 assert char1.heal(char2)
def create_characters(pictures): return [ # bigwhite Character((-800, -600), pictures['character'], ["Hover near the water to refuel!"]), Character((-1200, -500), pictures['character'], ["Go to the green planet!", 'It\'s position is -110/-30']), # smallgreen Character((-11207, -2900), pictures['character_small'], [ "I know where Elysium is.", "Elysium is east of the sun in 150/170" ]), Character((-11100, -2900), pictures['character_small'], ["There is a small golden planet.", "It's in -50/-110"]), Character((-11000, -2900), pictures['character_small'], ["There is a big blue planet.", "It's in -150/-50"]), ]
def get_character_from_json(json): character = Character() character.name = json['name'] character.health = json['health'] character.damage = json['damage'] character.description = json['description'] character.is_friendly = json['friendly'] return character
def test_dead_enemy_damage(self): player = Character(1) enemy = Character(2) enemy.alive = False original_health = enemy.health player.deal_damage(enemy) assert original_health == enemy.health
def test_deal_too_much_damage(self): player = Character(1) enemy = Character(2) enemy.health = 20 player.deal_damage(enemy) assert enemy.health == 0 assert enemy.alive == False
def test_deal_damage_with_weapon(self): player = Character(1) player.equip(Weapon(20, 0)) enemy = Character(2) original_health = enemy.health player.deal_damage(enemy) assert original_health - 70 == enemy.health assert enemy.health > 0
def test_low_stamina_damage(self): player = Character(1) enemy = Character(2) player.stamina = 2 original_health = enemy.health player.deal_damage(enemy) assert original_health == enemy.health
def set_up(event): """ Beginnning of the game, asks the user if they want to begin. """ global room global character if room is not None or character is not None: return fallback_call(event) input = event['request']['intent']['slots']['input']['value'] character = Character(100, 5) set_scene(event, [create_enemy(event)]) if input == 'no': speech = "Despite not wanting to go on an adventure the ground breaks " \ "out from underneath you and you find yourself in a {} and see a {} it {}, what would you like to do?".format( room.description, room.enemies[0].name, room.enemies[0].description) else: speech = "You enter a{} and see a {} it {}, what would you like to do?".format( room.description, room.enemies[0].name, room.enemies[0].description) reprompt = 'Do you attack?' card_title = 'New Room' card_text = speech return build_response(speech, card_title, card_text, reprompt, False)
def test_init_alive(self): character = Character(1) assert character.alive
def test_add_more_experience_than_a_level(self): player = Character(1) player.add_experience(12) self.assertEqual(player.experience, 2) self.assertEqual(player.level, 2)
def test_add_experience_of_one_level(self): player = Character(1) player.add_experience(10) self.assertEqual(player.experience, 0) self.assertEqual(player.level, 2)
def test_init_factions(self): character = Character(1) assert not character.factions
def test_add_experience_less_than_one_level(self): player = Character(1) player.add_experience(6) self.assertEqual(player.experience, 6)
def test_heal_self2(self): character = Character(1) character.heal_self() character.health = 100 print(character.heal_self()) assert character.health == 600
from main import Character Sorcerer = Character() Sorcerer.character_class = 'Sorcerer' Sorcerer.level = 6 Sorcerer.vigor = 9 Sorcerer.attunement = 16 Sorcerer.endurance = 8 Sorcerer.vitality = 7 Sorcerer.strength = 7 Sorcerer.dexterity = 12 Sorcerer.intelligence = 16 Sorcerer.faith = 7 Sorcerer.luck = 12
def test_self_damage(self): player = Character(1) original_health = player.health player.deal_damage(player) assert original_health == player.health
def test_heal_self3(self): character = Character(1) character.health = 100 character.heal_self() character.heal_self() assert character.health == 1000
from main import Character Herald = Character() Herald.character_class = 'Herald' Herald.level = 9 Herald.vigor = 12 Herald.attunement = 10 Herald.endurance = 9 Herald.vitality = 12 Herald.strength = 12 Herald.dexterity = 11 Herald.intelligence = 8 Herald.faith = 13 Herald.luck = 14
def test_init_level(self): character = Character(1) assert character.level == 1
from main import Character Mercenary = Character() Mercenary.character_class = 'Mercenary' Mercenary.level = 8 Mercenary.vigor = 11 Mercenary.attunement = 12 Mercenary.endurance = 11 Mercenary.vitality = 10 Mercenary.strength = 10 Mercenary.dexterity = 16 Mercenary.intelligence = 10 Mercenary.faith = 8 Mercenary.luck = 9
def test_init_mana(self): character = Character(1) assert character.mana == 20
from main import Character Warrior = Character() Warrior.character_class = 'Warrior' Warrior.level = 7 Warrior.vigor = 14 Warrior.attunement = 6 Warrior.endurance = 12 Warrior.vitality = 11 Warrior.strength = 16 Warrior.dexterity = 9 Warrior.intelligence = 8 Warrior.faith = 9 Warrior.luck = 11
def test_increment_stamina(self): player = Character(1) player.stamina = 20 player.increment_stamina() assert player.stamina == 25
from main import Character Cleric = Character() Cleric.character_class = 'Cleric' Cleric.level = 7 Cleric.vigor = 10 Cleric.attunement = 14 Cleric.endurance = 9 Cleric.vitality = 7 Cleric.strength = 12 Cleric.dexterity = 8 Cleric.intelligence = 7 Cleric.faith = 16 Cleric.luck = 13
def test_increment_excessive_stamina(self): player = Character(1) player.increment_stamina() assert player.stamina == 100