Пример #1
2
def main():
    armor_effect = [ArmorEffect('frost'), ArmorEffect('fire')]
    weapon_effect = [WeaponEffect('frost', 20, 2), WeaponEffect('fire', 1, 2)]
    temp = [
        Warrior('Abe',
                health=300,
                weapons=[
                    Sword(name='Frost Sword', effects=weapon_effect[0]),
                    Sword()
                ]),
        Warrior('Bjorn',
                health=300,
                weapons=[Sword()],
                armor=Armor(effects=armor_effect)),
        Warrior('Sigmair',
                health=300,
                weapons=[Sword(), Bow(effects=weapon_effect[1])])
    ]

    while True:
        if len(temp) > 1:
            duel = random.sample(temp, 2)
            if duel[1].health > 0 and duel[0].health > 0:
                duel[0].attack(duel[1])
                print()
                if duel[1].health == 0:
                    temp.remove(duel[1])
        elif len(temp) == 1:
            break
        else:
            print("Недостаточно участников.")
            break
Пример #2
0
def main():
    # Create 2 Warriors
    paul = Warrior("Paul", 50, 30, 10)
    sam = Warrior("Sam", 50, 30, 10)
    print(paul)
    print(sam)

    # Create Battle object
    battle1 = battle.Battle()
    print(battle1)
    # Initiate Battle
    battle1.startFight(paul, sam)
Пример #3
0
 def check_encounter(self, hero):
     #randomized value to determine if a user meets a enemy
     if (randint(0, 100) <= (self.encounter_rate * 100)):
         #create new enemy and pop a name from the list
         #if the list is empty then enter the final boss
         if (len(self.enemy_names) > 0):
             enemy_temp = self.enemy_names.pop()
             enemy = None
             _type = enemy_temp["type"]
             _name = enemy_temp["name"]
             if (_type == "warrior"):
                 print("You have encountered {} the warrior".format(_name))
                 enemy = Warrior(_name, False)
             elif (_type == "knight"):
                 print("You have encountered {} the knight".format(_name))
                 enemy = Knight(_name, "", False)
             elif (_type == "sorceress"):
                 print(
                     "You have encountered {} the sorceress".format(_name))
                 enemy = Sorceress(_name, False)
             elif (_type == "theif"):
                 print("You have encountered {} the theif".format(_name))
                 enemy = Theif(_name, False)
             for i in range(hero.level + self.level_inc):
                 enemy.level_up()
             return hero.enter_battle(enemy)
         else:
             return self.summon_boss(hero)
     print("Nothing around here...")
     return True
Пример #4
0
 def __init__(self, charT):
     if charT == 'H':
         self.h = Hacker()
         self.charType = "Hacker"
     elif charT == 'W':
         self.h = Warrior()
         self.charType = "Warrior"
     self.maxHP = self.h.getHP()
     self.strength = self.h.getStr()
     self.defense = self.h.getDef()
Пример #5
0
 def __init__(self):
     #read name file to load all the names and their types
     enemies = []
     self._file = os.getcwd() + "\\frozen_enemy.txt"
     enemies = self.read_enemy_file(self._file)
     Environment.__init__(self, "Frozen Mountains of Absolute Doom",
                          enemies, 0.75, randint(1, 2))
     self.boss = Warrior("The Great Ice Giant, Halafor", False)
     self.boss.hero_stats.hit_points += 250
     self.boss.hero_stats.mana_points += 150
     self.boss.hero_stats.attack_power += 70
     self.boss.hero_stats.defense += 70
Пример #6
0
def choose_hero():
    #Choose your hero
        print("""
    1. Warrior
      A hero with great strength and                          
      the ability to enhance that strength
      through anger
      
    2. Knight 
      The noblest of heroes, a true defensive
      powerhouse, armed with a sheild and
      healing magic, this hero shines in defense
      
    3. Theif     
      Not the typical hero candidate, but a 
      powerful one nonetheless, with the ability
      to sneak and deal heavy damage on an opponent
      of much greater and lesser strength 
      
    4. Sorceress
      A powerful mage hero who's abilities are not
      limited to their skillset of multiple magic 
      types but the ability to create their own
      spell with the possibility of dealing
      huge damage
        """)
        choice = 0
        while(1): 
            try:
                choice = int(input("Choose what kind of hero you want to be: "))
                if(choice > 0 and choice < 5):
                    name = input("Please enter your name: ")
                    if(choice == 1):
                        #warrior
                        return Warrior(name)
                        break
                    elif(choice == 2):
                        #knight
                        familia = input("As a knight you must have a family name: ")
                        return Knight(name, familia)
                        break
                    elif(choice == 3):
                        #theif
                        return Theif(name)
                        break
                    elif(choice == 4):
                        #sorceress
                        return Sorceress(name)
                        break
                else:
                    print("Please enter a number between 1 and 4")
            except ValueError:
                print("Please enter a whole number") 
Пример #7
0
def getCharacter():
    print("Warrior     Mage     Ranger")
    character = None
    answer = raw_input("Answer:")
    if answer.lower() in ['w','warrior']:
        character = Warrior()
    if answer.lower() in ['m','mage']:
        character = Mage() #Character("mage")
    if answer.lower() in ['r','ranger']:
        character = Ranger() #Character("ranger")
    if answer.lower() in ['quit','q']:
        sys.exit()
    return character
Пример #8
0
    def __init__(self, level):
        self.__warrior = Warrior()

        if level < 10:
            self.__warrior.set_speed(10)
            self.__warrior.set_attack(10)
            self.__warrior.set_defense(10)
        elif level >= 10 and level < 20:
            self.__warrior.add_sword()
        elif level >= 20 and level < 30:
            self.__warrior.add_sword()
            self.__warrior.add_armor()
        elif level >= 30 and level <= 50:
            self.__warrior.add_sword()
            self.__warrior.add_armor()
            self.__warrior.add_boots()
Пример #9
0
 def initialize_all(self):
     print("Welcome to Kafustrok. Light blesses you. ")
     for i in range(self._DIMENSION):
         for j in range(self._DIMENSION):
             self._lands[i][j] = Land()
     for i in range(self._total_num):
         pos = self.get_un_occupied_position()
         if i < self._m:
             self.lands[pos.x][pos.y].occupied_obj = Monster(pos.x, pos.y, i, self)
         elif i < self._m + self._e:
             self.lands[pos.x][pos.y].occupied_obj = Elf(pos.x,pos.y, i - self._m, self)
         elif i < self._m + self._e + self._w:
             self.lands[pos.x][pos.y].occupied_obj = Warrior(pos.x, pos.y, i - self._m - self._e, self)
             self._teleportable_obj.append(self.lands[pos.x][pos.y].occupied_obj)
         else:
             self.lands[pos.x][pos.y].occupied_obj = Potion(pos.x, pos.y, i - self._m - self._e - self._w, self)
             self._teleportable_obj.append(self.lands[pos.x][pos.y].occupied_obj)
Пример #10
0
def main():
    art = Noble("King Arthur")
    lance = Noble("Lancelot du Lac")
    jim = Noble("Jim")
    linus = Noble("Linus Torvalds")
    billie = Noble("Bill Gates")

    cheetah = Warrior("Tarzan", 10)
    wizard = Warrior("Merlin", 15)
    theGovernator = Warrior("Conan", 12)
    nimoy = Warrior("Spock", 15)
    lawless = Warrior("Xena", 20)
    mrGreen = Warrior("Hulk", 8)
    dylan = Warrior("Hercules", 3)

    jim.hire(nimoy)
    lance.hire(theGovernator)
    art.hire(wizard)
    lance.hire(dylan)
    linus.hire(lawless)
    billie.hire(mrGreen)
    art.hire(cheetah)

    jim.display()
    lance.display()
    art.display()
    linus.display()
    billie.display()

    art.fire(cheetah)
    art.display()

    art.battle(lance)
    jim.battle(lance)
    linus.battle(billie)
    billie.battle(lance)
Пример #11
0
def enter():
    game_world.clear()
    global UI
    global HP_BAR
    UI = load_image('Images//status_pane.png')
    HP_BAR = load_image('Images//hp_bar.png')
    global charImage
    charImage = load_image('Images//warriorLR.png')
    global font
    font = load_image('Images//font2x.png')

    global eatSound
    eatSound = load_wav('Sounds//snd_item.wav')
    global lvlUpSound
    lvlUpSound = load_wav('Sounds//snd_levelup.wav')
    lvlUpSound.set_volume(64)
    global bgm
    bgm = load_music('Sounds//game.mp3')
    bgm.set_volume(128)
    bgm.repeat_play()

    global maps
    maps = map.Map(1)
    game_world.add_object(maps, 0)
    global floorTriggers
    floorTriggers = floorTrigger.FloorTrigger(18 * 32, 6 * 32)
    floorTriggers.set_background(maps)
    game_world.add_object(floorTriggers, 1)

    global monsters
    monsters = []
    # monster = Monster(176, 240)
    # monster2 = Monster(240, 240)  # spawn in 240, 240
    n = 0
    while n < 12:
        t = random.randint(0, 1)
        mx = random.randint(0, map.tileX - 1)
        my = random.randint(0, map.tileY - 1)
        if map.map1[my][mx] == 2:
            n += 1
            if t == 0:
                monsters.append(Monster(mx * 32 + 16, my * 32 + 16))
            else:
                monsters.append(Scorpio(mx * 32 + 16, my * 32 + 16))
    game_world.add_objects(monsters, 1)

    global items
    items = []
    game_world.add_objects(items, 1)

    # game_world.add_object(monster, 1)
    # game_world.add_object(monster2, 1)

    global warrior
    warrior = Warrior()
    game_world.add_object(warrior, 1)

    global once
    once = Once()

    maps.set_center_object(warrior)
    warrior.set_background(maps)
    for monster in monsters:
        monster.set_background(maps)
Пример #12
0
from warrior import Warrior

class Fight:

    @staticmethod
    def start_fight(warrior_1, warrior_2):

        while warrior_1.hp > 0 and warrior_2.hp > 0:
            
            warrior_1.hp = warrior_1.hp - warrior_2.attack() + warrior_1.block()
            
            print(f"{warrior_1.name}:  {warrior_1.hp}")

            warrior_2.hp = warrior_2.hp - warrior_1.attack() + warrior_2.block()
            
            print(f"{warrior_2.name}:  {warrior_2.hp}")
            
            if warrior_1.hp <= 0:
                return warrior_2.name
            
            elif warrior_2.hp <= 0:
                return warrior_1.name

warrior_kratos = Warrior("Kratos",100, 10)
warrior_subzero = Warrior("Subzero",100, 10)

winner = Fight.start_fight(warrior_kratos,warrior_subzero)

print(f"{winner} has won!")
Пример #13
0
Classes and Inheritance in python

Created on Tue Apr  2 14:53:55 2019
2
@author: Tyler Steele
"""

from warrior import Warrior
from knight import Knight
from sorceress import Sorceress
"""
  Example Scenario
"""

# Create 3 characters
player = Warrior('Tyler')
ally = Knight('Lancelot')
enemy = Sorceress('Witch')

# Display beginning stats
player.display_stats()
enemy.display_stats()
ally.display_stats()

player.reckless_strike(enemy)
ally.critical_strike(enemy)

# Display stats after physical attacks
player.display_stats()
enemy.display_stats()
ally.display_stats()
Пример #14
0
 def create_knight():    # the basic class
     knight = Warrior('Knight', 100, 40, 70, 50)
     return knight
Пример #15
0
from random import randint
from mag import Mag
from warrior import Warrior

#выбор класса
print('''Здравствуйте, выберите вашего персонажа(бета 1.2)
P.S. Игра сделана за 4.5 часа не удивляйтесь что все через одно место''')
choose = int(input('Введите 1 для Мага, 2 для Воина, 3 для рандома: '))
while True:
    if choose == 1:
        player = Mag(randint(450, 900), randint(80, 160), randint(5, 15), randint(200, 300))
        print("Вы маг")
        break
    elif choose == 2:
        player = Warrior(randint(650, 1100), randint(40, 120), randint(100, 120), randint(20, 30))
        print("Вы воин")
        break
    elif choose == 3:
        choose = randint(1, 2)
    else:
        print('Error')
        choose = int(input('Введите 1 для Мага, 2 для Воина, 3 для рандома: '))
print(player)


#Генерация противника
random_enemy = randint(1, 2)
if random_enemy == 1:
    enemy1 = Mag(randint(450, 900), randint(80, 160), randint(5, 15), randint(200, 300))
    print("Противник это маг")
elif random_enemy == 2:
Пример #16
0
 def setUp(self) -> None:
     self.warrior = Warrior("male", "elf", "Mae", "ciupaga")
Пример #17
0
 def __init__(self, player_warrior_name, enemy_warrior_name, health):
     self.player_warrior = Warrior(player_warrior_name, health)
     self.enemy_warrior = Warrior(enemy_warrior_name, health)
     self.max_health = health
from medic import Medic
from explorer import Explorer
from warrior import Warrior
from game_character import GameCharacter
from termcolor import colored, cprint
import datetime
import time
import random
from progress.bar import FillingCirclesBar

# The variable responsible for ending the game loop
game_loop = True

# Creating instances for team_a characters from user
team_a_warrior_name = input("Team A, enter your warrior name : ")
a_warrior = Warrior(team_a_warrior_name, 100, 100)

team_a_medic_name = input("Team A, enter your medic name : ")
a_medic = Medic(team_a_medic_name, 100, 100)

team_a_explorer_name = input("Team A, enter your explorer name : ")
a_explorer = Explorer(team_a_explorer_name, 100, 100)

# List of team_a object to be used when the player chooses the function attribute
list_team_a = [a_warrior, a_medic, a_explorer]

# Creating instances for team_a characters from player
team_b_warrior_name = input("\nTeam B, enter your warrior name: ")
b_warrior = Warrior(team_b_warrior_name, 100, 100)

team_b_medic_name = input("Team B, enter your medic name: ")
Пример #19
0
from warrior import Warrior

w1 = Warrior(10)
print(w1)
w2 = Warrior(0)
print(w2)
Пример #20
0
 def testGenerateName(self):
     self.warrior2 = Warrior(sex="male")
     name = self.warrior2.generate_name()
     self.warrior2.name = name
     self.assertEqual(self.warrior2.name, name)
Пример #21
0
from warrior import Warrior
from Weapon import Weapon
from Shield import Shield

import random

name1 = "The best of the best"
name2 = "Superhero"

warrior1 = Warrior(name1, 100, Weapon("hero's weapon", 50, 50),
                   Shield("hero's shield", 70, (10, 20)))
warrior2 = Warrior(name2, 100, Weapon("superhero's weapon", 50, 50),
                   Shield("superhero's shield", 70, (10, 20)))

anyoneAlive = True

while anyoneAlive:
    prHp = warrior2.GetHp()
    anyoneAlive = not warrior1.Attack(warrior2)
    nowHp = warrior2.GetHp()
    print(name1 + " нанес удар в размере " + str(prHp - nowHp))
    if (not anyoneAlive): break

    prHp = warrior1.GetHp()
    anyoneAlive = not warrior2.Attack(warrior1)
    nowHp = warrior1.GetHp()
    print(name2 + " нанес удар в размере " + str(prHp - nowHp))

if (warrior1.GetHp() <= 0): print(name2 + " победил!")
else:
    print(name1 + " победил!")
Пример #22
0
 def create_goblin():    # agile but weak
     goblin = Warrior('Goblin', 70, 30, 90, 60)
     return goblin
Пример #23
0
 def testTypeName(self):
     self.warrior3 = Warrior()
     typing_name = self.warrior3.type_name()
     self.warrior3.name = typing_name
     self.assertEqual(self.warrior3.name, typing_name)
Пример #24
0
 def create_dragon():    # the killer
     dragon = Warrior('Dragon', 300, 150, 10, 10)
     return dragon
Пример #25
0
 def create_ogre():    # strong but clumsy
     ogre = Warrior('Ogre', 150, 80, 20, 40)
     return ogre
Пример #26
0
from combat import Combat
from warrior import Warrior
from mage import Mage
from ranger import Ranger

if __name__ == "__main__":
    testPlayer = Warrior()
    testMonster = Warrior()
    print "You attack a testMonster"
    Combat(Warrior(), testMonster)
    print "You attack a mage"
    Combat(Mage(), Mage())
    print "You attack a Ranger"
    Combat(Mage(), Ranger())