from classes.enemy import Enemy enemy = Enemy(200, 60) print("HP :", enemy.get_hp())
from classes.enemy import Enemy # Relative paths are written with '.' NOT '/' enemy = Enemy(200, 60) print("HP: ", enemy.get_hp())
from classes.enemy import Enemy enemy = Enemy(200, 60) print("Hp:", enemy.get_hp())
from classes.enemy import Enemy enemy1 = Enemy(50, 80) enemy2 = Enemy(150, 180) enemy3 = Enemy(250, 280) print(enemy1.get_hp()) print(enemy2.get_hp()) print(enemy3.get_hp())
from classes.enemy import Enemy enemy = Enemy(200, 60) print("Hp is :", enemy.get_hp())
player1.heal(item_val) print(bc.OKGREEN + player1.name + ' healed for ' + str(item_val) + 'HP.' + bc.ENDC) elif item_type == 'attack': enemy1.take_dmg(item_val) print(bc.OKGREEN + player1.name + ' used ' + item.name + '. It dealt ' + str(item_val) + ' damage.' + bc.ENDC) elif item_type == 'elixir': player1.heal_mp(item_val) player1.heal(item_val) print(bc.OKGREEN + 'Increased HP and MP by ' + str(item_val) + '.' + bc.ENDC) item.use_item(1) else: print(bc.WARNING + bc.BOLD + 'You don\'t have any ' + item.name + 'left.' + bc.ENDC) continue print('') if enemy1.get_hp() >= 0: for player1 in players: enemy_choice = 1 dmg_enemy = enemy1.generate_damage() player1.take_dmg(dmg_enemy) print(bc.OKBLUE + "The Beast attacked " + player1.name + '. ' + player1.name + " lost " + str(dmg_enemy) + 'HP.' + bc.ENDC) print('--------------------') player_1.print_stats() player_2.print_stats() enemy1.print_stats() if player_1.get_hp() == 0 and player_2.get_hp() == 0: print(bc.WARNING + 'The Beast killed both of you.' + bc.ENDC)
from classes.enemy import Enemy enemy = Enemy(200, 60) print("HP:", enemy.get_hp(), "MP:", enemy.get_mp())
''''' import random playerhp = 200 enmyatkl = 50 enmyatkh = 80 while playerhp > 0: dmg = random.randrange(enmyatkl, enmyatkh) playerhp = playerhp - dmg if playerhp <= 20: playerhp = 20 print('you have been hit by HP amounting to', dmg, 'your reduced hp is', playerhp) if playerhp == 20: print("you have been knocked out and last damage was", dmg) break ''''' from classes.enemy import Enemy enemy = Enemy(200,54) print(enemy.get_hp())
import random from classes.enemy import Enemy enemy1 = Enemy(200, 60) print('Hp: ', enemy1.get_hp()) enemy2 = Enemy(75, 90) ''' playerhp = 260 ennemyatkl = 60 ennemyatkh = 80 while playerhp > 0: dmg = random.randrange( ennemyatkl, ennemyatkh) playerhp -= dmg if playerhp <= 30: playerhp = 30 print('Ennemy strikes for',dmg,'points of damage. Current HP is ', playerhp) if playerhp > 30: continue print("You have low health. You've been teleported to the nearest inn") break '''
from classes.enemy import Enemy #imports the class 'Enemy' from the file 'enemy.py' in the directory 'classes' #because we imported the class 'Enemy' it can do be called out in this script enemy = Enemy(200,60) #creates an object from the class of Enemy with 200hp and 60mp print(enemy.get_hp()) #prints out the hp print(enemy.get_mp()) #prints out the mp ''' option 2 class Enemy: #a class is a blueprint hp = 200 #now all enemys have 200hp def __init__(self, atklow, atkhigh): #creates init function to input low and high attacks self.atklow = atklow self.atkhigh = atkhigh def getAtk(self): #function within a class will put 'self' as its parameter print("atk is", self.atklow) def getHP(self): print("HP is", self.hp) enemy1 = Enemy(40, 49) #asign 'enemy1' as type of the class Enemy enemy1.getAtk() #calls out the getAtk function enemy1.getHP() #call out the getHP function enemy2 = Enemy(75, 90) #repeat for 'enemy2' enemy2.getAtk() enemy2.getHP()
from classes.enemy import Enemy enemy = Enemy(200, 60) print("hp", enemy.get_hp()) ''' import random class Enemy: hp = 600 # This is used to intiliaze and to make the values more dynamic def __init__(self, atkl, atkh): self.atkl = atkl self.atkh = atkh def getatk(self): print("Enemy attack is : ", self.atkl) def gethp(self): print(" Enemy Hp is :", self.hp) enemy1 = Enemy(40, 60) enemy1.getatk() enemy1.gethp() enemy2 = Enemy(90, 100) enemy2.getatk() enemy2.gethp()