@kyklaed

Не наследует, в чем ошибка?

Всем привет, помогите найти ошибку не наследует класс, не могу разобраться почему, наверно недостаточно теорию знаю , но если у меня множественное наследование то супер должен быть один ?

ошибка:
AttributeError: 'FightHvM' object has no attribute 'health_monster'

from hero import *
from monsters import *
from fightsystem import *
import sys
import random
from fightsystem import *

class FightHvM(FightSystem,WarriorHero,ClawMonster):
    def __init__(self):
        super(FightHvM,self).__init__()
        self.startfight()

    def startfight(self):

        print("1 - head, 2 - body, 3 - heand, 4 - legs")

        print(self.get_healthH())
        print(self.get_healthM())

        while self.get_healthH() > 0 and self.get_healthM() > 0:
            actdam = {1: self.damagetohead, 2: self.damagetobody, 3: self.damagetoheand, 4: self.damagetolegs}
            getdam = {1: self.get_damagetohead, 2: self.get_damagetobody, 3: self.get_damagetoheand, 4: self.get_damagetolegs}
            variant = int(input("= "))
            if variant in actdam.keys():
                actdam[variant]()
                damage_hero = getdam[variant]()
                print("damage hero = ",damage_hero)
                if damage_hero >= self.get_healthM():
                    print("the monster lost")
                    break
                else:
                    self.set_healthM(damage_hero)
                    print("hero damage to monster ", damage_hero)
            else:
                print("error")

            self.damageM()
            damage_monster = self.get_damageM()
            if damage_monster >= self.get_healthH():
                print("the hero lost")
                break
            else:
                self.set_healthH(damage_monster)
                print("monster damage to hero ", damage_monster)

            print(self.get_healthH(),  self.get_healthM())
  • Вопрос задан
  • 170 просмотров
Пригласить эксперта
Ответы на вопрос 1
@deliro
1) Почитай про MRO
2) У твоего инстанса нет атрибута health_monster, а он где-то требуется, это всё, что можно извлечь из твоего куска.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы