def test_get_vital_status_level_one(self):
     status_proportion = [0.5, 0.5, 0.7, 0.9, 0.8]
     v_status = VitalStatus(10, 10, 10, 10, 10, status_proportion, 0)
     status_level_one = v_status.get_vital_status_at_level(1)
     self.assertEqual(v_status.health, status_level_one.health)
     self.assertEqual(v_status.attack, status_level_one.attack)
     self.assertEqual(v_status.magic_power, status_level_one.magic_power)
     self.assertEqual(v_status.magic_defense,
                      status_level_one.magic_defense)
     self.assertEqual(v_status.defense, status_level_one.defense)
 def test_get_vital_status_level_five(self):
     status_proportion = [0.5, 0.5, 0.5, 0.5, 0.5]
     v_status = VitalStatus(10, 10, 10, 10, 10, status_proportion, -1)
     status_level_two = v_status.get_vital_status_at_level(5)
     v_status_two = VitalStatus(50, 50, 50, 50, 50, status_proportion, -1)
     self.assertEqual(v_status_two.health, status_level_two.health)
     self.assertEqual(v_status_two.attack, status_level_two.attack)
     self.assertEqual(v_status_two.magic_power,
                      status_level_two.magic_power)
     self.assertEqual(v_status_two.defense, status_level_two.defense)
     self.assertEqual(v_status_two.magic_defense,
                      status_level_two.magic_defense)
 def test_get_vital_status_level_two(self):
     status_proportion = [0.5, 0.5, 0.7, 0.9, 0.8]
     v_status = VitalStatus(10, 10, 10, 10, 10, status_proportion, -1)
     status_level_two = v_status.get_vital_status_at_level(2)
     v_status_two = VitalStatus(15, 15, 17, 19, 18, status_proportion, -1)
     self.assertEqual(v_status_two.health, status_level_two.health)
     self.assertEqual(v_status_two.attack, status_level_two.attack)
     self.assertEqual(v_status_two.magic_power,
                      status_level_two.magic_power)
     self.assertEqual(v_status_two.defense, status_level_two.defense)
     self.assertEqual(v_status_two.magic_defense,
                      status_level_two.magic_defense)
 def test_single_vital_status_default(self):
     raises = False
     try:
         VitalStatus(10, 3, 4, 6, 20, None, 1)
     except:
         raises = True
     self.assertFalse(raises)
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 1, 1, 0, 3, 1, 0, 1, 3,
    0, 1, 1, 0, 2, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 3, 0, 0, 0, 1, 1, 0, 1, 1, 0,
    1, 1, 0, 1, 1, 0, 3, 1, 0, 2, 3, 0, 1, 1, 0, 0, 0, 0, 0, 0, 5, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1
]
ROWS = 9
COLS = 9

board_map = BoardMap(ROWS, COLS)
board_map.create_squares_of_boardmap(SQUARES)

game = Game(board_map)

status_proportion = [0.5, 0.5, 0.7, 0.9, 0.8]
extra_level = 1
v_status_character = VitalStatus(10, 3, 4, 6, 20, status_proportion,
                                 extra_level)

v_status_weapon_1 = VitalStatus(2, 3, -1, 5, 1, None, 1)
v_status_weapon_2 = VitalStatus(2, 3, -2, 4, 1, None, 0)
v_status_weapon_3 = VitalStatus(2, 3, 5, 5, 3, None, -1)
v_status_weapon_4 = VitalStatus(2, 3, -1, 5, 1, None, 1)
v_status_weapon_5 = VitalStatus(1, 1, 1, 1, 1, None, 0)

weapon_1 = Weapon("Super sword", "This sword cuts what it wants.",
                  v_status_weapon_1)
weapon_2 = Weapon("Super shield", "This sword cuts what it wants.",
                  v_status_weapon_2)
weapon_3 = Weapon("Super hat", "This hat makes you invisible.",
                  v_status_weapon_3)
weapon_4 = Weapon("Super boots",
                  "Those boots let you pass though poisoned rivers.",
import unittest
from print_map.game_objects import Weapon
from print_map.game_objects import VitalStatus

status_proportion = [0.5, 0.5, 0.7, 0.9, 0.8]
v_status_normal = VitalStatus(10, 10, 10, 10, 10, status_proportion)
v_status_normal_positive = VitalStatus(10, 10, 10, 10, 10, status_proportion,
                                       1)
v_status_negative = VitalStatus(10, 10, 10, 10, 10, status_proportion, -1)

name_weapon_1 = "Super Sword"
name_weapon_2 = "Super Shield"
description_weapon_1 = "This sword can cut everything"
description_weapon_2 = "This shield can repel all the attacks"


class MyTestCase(unittest.TestCase):
    def test_create_single_weapon(self):
        weapon = Weapon(name_weapon_1, description_weapon_1, v_status_normal)
        self.assertIsNotNone(weapon)

    def test_create_short_name(self):
        self.assertRaises(Exception, Weapon, '.', description_weapon_1,
                          v_status_normal)

    def test_create_short_description(self):
        self.assertRaises(Exception, Weapon, name_weapon_1, '.....',
                          v_status_normal)

    def test_create_none_v_status(self):
        self.assertRaises(Exception, Weapon, name_weapon_1,
 def test_single_vital_status(self):
     status_proportion = [0.5, 0.5, 0.7, 0.9, 0.8]
     extra_level = 1
     v_status = VitalStatus(10, 3, 4, 6, 20, status_proportion, extra_level)
     self.assertFalse(None, v_status)
 def test_negative_extra_level(self):
     status_proportion = [0.5, 0.5, 0.7, 0.9, 0.8]
     v_status = VitalStatus(10, 3, 4, 6, 20, status_proportion, -1)
     self.assertIsNotNone(v_status)
Ejemplo n.º 9
0
import unittest
from print_map.game_objects import Monster, VitalStatus, Weapon

vital_status_monster = VitalStatus(10, 4, 3, 10, 3, None, None)
vital_status_weapon = VitalStatus(1, 1, 1, 1, 1, None, None)

weapon_monster = Weapon('Super sword', ' This sword cuts what it wants.',
                        vital_status_weapon)


class MyTestCase(unittest.TestCase):
    def test_correct_initiation(self):
        raises = False
        try:
            uses_magic = False
            monster = Monster('Goomba', uses_magic, vital_status_monster,
                              weapon_monster)
        except:
            raises = True
        self.assertFalse(raises)

    def test_correct_initiation_without_weapon(self):
        raises = False
        try:
            uses_magic = False
            monster = Monster('Goomba', uses_magic, vital_status_monster)
        except:
            raises = True
        self.assertFalse(raises)

    def test_initiation_without_name(self):
from print_map.game_objects import Battle, BoardMap, Character, Weapon, VitalStatus,\
    Monster, Position, ConsoleInterface, Game

SQUARES = [
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 1, 1, 0, 3, 1, 0, 1, 3,
    0, 1, 1, 0, 2, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 3, 0, 0, 0, 1, 1, 0, 1, 1, 0,
    1, 1, 0, 1, 1, 0, 3, 1, 0, 2, 3, 0, 1, 1, 0, 0, 0, 0, 0, 0, 5, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1
]
ROWS = 9
COLS = 9

status_proportion = [0.5, 0.5, 0.7, 0.9, 0.8]
extra_level = 1

v_status_character = VitalStatus(30, 5, 5, 5, 5, status_proportion,
                                 extra_level)
v_status_monster_1 = VitalStatus(25, 4, 4, 4, 4, None, None)
v_status_monster_2 = VitalStatus(100000, 2000, 3000, 5000, 5000, None, None)

v_status_weapon_1 = VitalStatus(2, 3, -1, 5, 1, None, 0)
v_status_weapon_2 = VitalStatus(2, 3, -2, 4, 1, None, 0)
v_status_weapon_3 = VitalStatus(2, 3, 5, 5, 3, None, -1)
v_status_weapon_4 = VitalStatus(2, 3, -1, 5, 1, None, 1)
v_status_weapon_5 = VitalStatus(1, 1, 1, 1, 1, None, 0)

weapon_1 = Weapon("Super sword", "This sword cuts what it wants.",
                  v_status_weapon_1)
weapon_2 = Weapon("Super shield", "This sword cuts what it wants.",
                  v_status_weapon_2)
weapon_3 = Weapon("Super hat", "This hat makes you invisible.",
                  v_status_weapon_3)
Ejemplo n.º 11
0
from print_map.game_objects import Battle, BoardMap, Character, ConsoleInterface, Monster, \
    Game, Position, VitalStatus, Weapon

SQUARES = [
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 1, 1, 0, 3, 1, 0, 1, 3,
    0, 1, 1, 0, 2, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 3, 0, 0, 0, 1, 1, 0, 1, 1, 0,
    1, 1, 0, 1, 1, 0, 3, 1, 0, 2, 3, 0, 1, 1, 0, 0, 0, 0, 0, 0, 5, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1
]
ROWS = 9
COLS = 9

board_map = BoardMap(ROWS, COLS)
board_map.create_squares_of_boardmap(SQUARES)

status_proportion = [0.5, 0.5, 0.7, 0.9, 0.8]
v_status_character = VitalStatus(10, 3, 4, 6, 20, status_proportion)

character_1 = Character("Onion knight", False, v_status_character)
character_2 = Character("Time knight", False, v_status_character)

game = Game(board_map)
game.append_character_list([character_1])

if __name__ == '__main__':
    game.start_game_only_movement()