2
Read only comments in English, the question of self is in comments in the code, now the events will be down there.
class LOL:
class Champions:
class MasterYi:
def __init__(self):
#YiAttributes
self.YiAD = 66
self.YiLevel = 1
self.YiQ = 25 + self.YiAD
def Name(self):
return 'MasterYi'
class Q:
def Use(self, target):
print( "[MasterYi] Q In %s" % ( target ) )
def Damage(self):
return self.YiQ #Como Eu Conseguiria Pegar O self.YiQ Da Classe MasterYi ?
class Zed:
def __init__(self):
#ZedAttributes
self.ZedAD = 84
self.ZedLevel = 1
self.ZedQ = 75 + self.ZedAD
def Name(self):
return 'Zed'
class Q:
def Use(self, target):
print( "[Zed] Q In %s" % ( target ) )
def Damage(self):
return self.ZedQ #Mesmo Caso Do self.YiQ
class Match:
def Start(self, Tuple):
print( "------ Starting Match ------\n" )
if (len(Tuple) == 1):
print( "Champions: %s" % ( Tuple[0].Name() ) )
elif (len(Tuple) == 2):
print( "Champions: %s, %s" % ( Tuple[0].Name(), Tuple[1].Name() ) )
def Finish(self):
print( "\n------ Finishing Match ------" )
#Creating Objects
Match = LOL.Match()
MasterYi = LOL.Champions.MasterYi()
Zed = LOL.Champions.Zed()
#Starting
Match.Start( ( MasterYi, Zed ) )
MasterYi.Q().Use( Zed.Name() )
print( "YiQ Damage: %g" % ( MasterYi.Q().Damage() ) )
#Finishing
Match.Finish()
I would need an event within the Masteryi class that would cause every time the self.Yilevel variable was incremented into 1, variables like self.Yiad and others that I didn’t put in the code here, to be incremented into specific values.
I left the creation part of the objects in the code because then you can already take and test the code.
And also how I make the increment of self.YiLevel
in the code, I could together already do the increment in the other variables together, but in the future, in this code, I will need to know how to do custom events whether I want to or not, so I’d rather ask a question with a simpler example.
Another detail these two classes 'Masteryi' and 'Zed' are similar, but there will be dozens more classes and I guarantee that the majority will be different, in these two the calculation of self. Q works almost in the same way, but in other classes it will be for example self. Q = 30 + self.AP others will do self type percentage calculations. Q = self.AP * 30 / 100 + self.AD * 10 / 100.
So not always will be (some number + the AD), still has the question that n is only Q
and yes (Q, W, E, R)
But the idea of not repeating the code I understood. is a class problem within class or whatever ?
– axell-brendow
And also has the following question not all the 'Champions' the
Q
work like this: Q = Q + AD some will be Q = Q + AD * 30 / 100, others Q = Q + AP each (Q, W, E, R) of each 'Champion' will be different.– axell-brendow
So will it be a different value for each magic? For example
ZedQ
,ZedW
,ZedE
...? @axell13– Lucio Rubens
Yeah, except not all spells are damage, like Zedw is a Skill who casts a shadow that mimics Zedq and Zede, Yiw is a magic that recovers life over four seconds. Each spell will almost always be treated differently, but not all as for example the Yiq and Zedq all two are the base damage of the magic 25, 75 respectively + the AD.
– axell-brendow
I edited the answer, see if that’s what you need. @axell13
– Lucio Rubens
What about the question of
Q
in other characters ? As I said sometimes it can be power = power + ((ad * 30) / 100) or power = power + ((ap * 80) / 100) or other calculations. I prefer to copy the class for example from Masteryi (from my code) and adapt the calculations of the evils for each one.– axell-brendow
I do not create a(a) function/constructor(
__init__
) passing a string that would be the calculation, because there are more than 120 Champions, there is no way I remember the calculation of each, mainly because it is not 120 * 4 (Q,W,E,R), so I would have to be looking all the time.– axell-brendow
And there is also the question that not all Q,W,E,R has damage, some give attributes with armor penetration, true damage, attack speed, armor and etc, are you reading the comments I am writing ? it seems that no.
– axell-brendow
I think you want the code ready, for sure you’ll have to adapt the code as you prefer according to your need, I’m doing you a favor. For every problem you mentioned there is a solution, just think! Hugs @axell13
– Lucio Rubens
ok I prefer to make the classes the way I was, I prefer to copy a class and adapt the calculations of the spellings I find easier.
– axell-brendow
Mainly because I don’t want to spend all the time parameters such as ad, ap, level and etc, after all each Champion will be different. I want to have them ready, I want ease in the future, so I assemble the classes, instead of passing parameters only create the object of my Champion, ready.
– axell-brendow
He even looked at the ideone? At the end has a class
LOL
, where I already define Champions.. Do you prefer to create 120 Champions and manually insert all methods, variables, where much is the same code? Have you thought in the future how difficult it will be to maintain this code?.... @axell13– Lucio Rubens
the only problem even is the question of randomness in the calculations of each Champion (This does not know what to do)...
– axell-brendow
If the code is Python2 and not Python3, do not forget that the classes have all who inherit from "Object"
– jsbueno