class Magic:
def __init__(self, magic, source, power):
self.magic = magic
self.source = source
self.power = power
def Use(self, target):
print("{source} {magic} In {target}".format(source=self.source, magic=self.magic, target=target))
def Damage(self):
return self.power
class Q(Magic, object):
def __init__(self, source, ad, power):
power = power + ad
Magic.__init__(self, 'Q', source, power)
class W(Magic, object):
def __init__(self, source, ad, power):
power = power + ad * 30 / 100
Magic.__init__(self, 'W', source, power)
class E(Magic, object):
def __init__(self, source, power):
self.source = source
self.power = power
Magic.__init__(self, 'E', source, power)
class R(Magic, object):
def __init__(self, source, ad, power):
power = power + ad / 100
Magic.__init__(self, 'R', source, power)
class Magics:
def __init__(self, source, ad, q, w, e, r):
self.Q = Q(source, ad, q)
self.W = W(source, ad, w)
self.E = E(source, e)
self.R = R(source, ad, r)
class Champion:
def __init__(self, name, ad, level, powerQ, powerW, powerE, powerR):
self.name = name
self.ad = ad
self.level = level
self.powerQ = powerQ
self.powerW = powerW
self.powerE = powerE
self.powerR = powerR
self.Magics = Magics(self.name, self.ad, self.powerQ, powerW, powerE, powerR)
class LOL:
@staticmethod
def MasterYi():
return Champion(name='MasterYi', ad=66, level=1, powerQ=25, powerW=14, powerE=20, powerR=99)
@staticmethod
def Zed():
return Champion(name='Zed', ad=84, level=1, powerQ=75, powerW=34, powerE=10, powerR=33)
class Match:
@staticmethod
def Start(Champions):
print("--- Start Match ---\n")
print("Champions: {champions}".format(champions=", ".join(c.name for c in Champions)))
@staticmethod
def Finish():
print("\n--- Finished Match ---")
MasterYi = LOL.MasterYi()
Zed = LOL.Zed()
Match.Start((MasterYi, Zed))
MasterYi.Magics.Q.Use(Zed.name)
print("YiQ Damage: {damage}".format(damage=MasterYi.Magics.Q.Damage()))
Zed.Magics.W.Use(MasterYi.name)
print("ZedW Damage: {damage}".format(damage=Zed.Magics.W.Damage()))
Match.Finish()
Y2xhc3MgTWFnaWM6CgogICAgZGVmIF9faW5pdF9fKHNlbGYsIG1hZ2ljLCBzb3VyY2UsIHBvd2VyKToKICAgICAgICBzZ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