Sep-19-2017, 02:34 PM
sorry, i failed my last answer, i correct it :
(so, dmg_min would be 150 instead of 50 and dmg_max should be 220 instead of 120)
and the "dps" output would be "dps : 1850 "instead of "dps = 850", that it was i want from the start
and i have no idea how to code that
thanks for help
sorry for the new answer
class Weapon(object): def __init__(self, name, speed, dmg_min, dmg_max, wrange, gems_nb): self.name = name self.speed = speed self.dmg_min = dmg_min self.dmg_max = dmg_max self.wrange = wrange self.gems_nb = gems_nb def infos(self): print "Name = {}".format(self.name) print "Damage range = {}".format(self.wrange) print "Dps = {}".format((self.dmg_min + self.dmg_max) / 2 * self.speed) print "Nb gems = {}".format(self.gems_nb) print "Golden gem: {}".format(0) class Sword(Weapon): def __init__(self, name='sword', speed=None, dmg_min=None, dmg_max=None, wrange=None, gems_nb=None, gems=[]): super(Sword, self).__init__(name, speed, dmg_min, dmg_max, wrange, gems_nb) self.gems = gems self.gems_nb = gems_nb class Gem(object): def __init__(self, name, gems): return excalibur = Sword('Excalibur', 10, 50, 120, "50-120", 1) gold_gem = Gem("Golden gem", 100) excalibur.infos() # excalibur.add_gem(gold_gem)
Output:Name = Excalibur
Damage range = 50-120
Dps = 850
Nb gems = 1
Golden gem: 0
but actually the new problem is that my " excalibur " should have one gem, and one gem means damage = damage + 100(so, dmg_min would be 150 instead of 50 and dmg_max should be 220 instead of 120)
and the "dps" output would be "dps : 1850 "instead of "dps = 850", that it was i want from the start
and i have no idea how to code that
thanks for help
sorry for the new answer