Question: class Char: def init(self, name = ,cclass = Warrior, stats = [1,50,5,5,0,True,False,'False'): self.c = cclass self.name = name self.stats = {'LVL:stats[0], 'HP':stats[1), 'ATK':stats[2], 'DEF':stats 3].

class Char: def init(self, name = ",cclass = "Warrior", stats = [1,50,5,5,0,True,False",'False'): self.c = cclass self.name = name self.stats = {'LVL:stats[0], 'HP':stats[1), 'ATK':stats[2], 'DEF':stats 3]. 'EXP':stats 4], 'ALIVE':stats[5], 'POISONED':stats[6], 'FROZEN':stats 7]} self.calc_level - def_ repr_(self): outs =" outs+= Character Name: {0) of class {1): -".format(self.name,self.c) for k,v in self.stats.items): outs+='In {0): (1)'.format(k,v) return outs def calc_level (self): self.stats['LVL] = int(self.stats['EXP'**.5)+1 def attack(self,other): print(" {0) furiously attacks {1) with {2) attack. {1) has {3} defense." format/self.name,other.name,self.stats['ATK],other.st ats 'DEF') if self.stats ('ATK'>=other.stats ['DEF'): other.stats[HP') -= self.stats[ATK') print("InThat was a hit! The HP of {0) is now {1)".format(other.name,other.stats[HP'|)) [4:40pm, 13/02/2023] Harrendra: print("InYou missed and only made him angrier!") def new_char(existing): CC =" accept = False while not accept: n = input("InPlease input a new name:") accept = True for c in existing: if n == c.name: accept = False print( This name is taken, already") while not cc in ['w't',z']: cc = input("InPlease input a class, noble (0). (W)arrior, (T)ank, Wi(z) ard: "format(n)). lower() classes = {'w':'Warrior',t':'Tank",z':'Wizard' newc = Char(n,cclasses[cc]) print('InCharacter successfully created:' print(newc) return newc def play(chars): print("May the games begin. The following characters are present: ") for c in chars: print(c) print(") game_over = False turn = 0 while not game_over: [4:41pm, 13/02/2023] Harrendra: print(lt's the turn of noble {0) {1). Please select a player to attack:".format(chars[turn].c,chars[turn].name)) possible = 1 for i in range(len(chars)): if not i==turn: possible.append(i) print(" - ({0)): {1) named {2)".format(i,chars[i].c,chars[i].name)) se =-1 while not sel in possible: s = input('Selection: ' try: sel = int(s) except: print("That's not a valid choice") chars[turn).attack(chars[sel]) if chars(sel].stats['HP'|<=0: game_over=True print("That was it! {0) has died and the game is over.".format(chars[sel].name)) turn +=1 if turn==len(chars):turn=0 def main): chars = h entry =" print("Welcome to PSB Battle Game!") while not entry lower() in ['q'p': entry = input('In(N)ew character (P)|ay game (Q)uit Selection: ').lower() if entry == 'p' and len(chars)<2: print("InYou can't play with only one character. Create characters first") [4:41pm, 13/02/2023] Harrendra: entry = " ## You can't play with only one char elif entry == 'n' chars.append(new_char(chars)) entry =" elif entry == 'p': play(chars) elif entry == 'g': print(" OK, good bye") main( question: what wrong with this code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!