function - Python class taking in only two arguments? -
so have python class named player()
takes in total of 20 arguments simple combat algorithm. problem is, when import player()
, combat function main file, , have imported correctly, error:
traceback (most recent phone call last): file "c:\users\thomas\desktop\paradisium\main_draft.py", line 53, in <module> combat(player1,player2) typeerror: __init__() missing 18 required positional arguments: 'speed', 'agility', 'endurance', 'hitpoints', 'hpregen', 'epregen', 'originalhp', 'originalep', 'originalmp', 'mp', 'mgkregen', 'mgkdefence', 'mgkattack', 'debuff', 'buff', 'settype', 'weapon', , 'name'
as can see, it's importing correctly , grabbing player()
class, reason it's taking in 2 of 20 variables defined here:
player1=player(90,20,50,90,20,1000,.03,1,1000,20,20,20,1,90,100,2,2,3,none,"somerled murdoch")
i don't know if i'm importing wrong or that, , i'm pretty sure there no limit variables in class.
edit, here's code:
the player()
class:
class player (object): def __init__(self, physicalattack, defence, speed, agility, endurance, hitpoints, hpregen, epregen, originalhp, originalep, originalmp, mp, mgkregen, mgkdefence, mgkattack, debuff, buff, settype, weapon, name):
the combat()
function:
def combat(player1,player2):
the lines beingness imported main file:
import combatalgorithmdraft player=combatalgorithmdraft.player combat=combatalgorithmdraft.player
the lines beingness called in main file:
player1=player(90,20,50,90,20,1000,.03,1,1000,20,20,20,1,90,100,2,2,3,none,"somerled murdoch") player2=player(60,70,60,50,20,1100,.01,1,1100,20,0,0,0,60,0,2,2,0,0,"the black knight") combat(player1,player2)
combat=combatalgorithmdraft.player
did mean this?
combat=combatalgorithmdraft.combat
in case, conventional way import things other modules current namespace is
from combatalgorithmdraft import player, combat
python function class import
No comments:
Post a Comment