brotherjustice
Programmer
I'll paste here all my code near the end in the displayclic and displayclicbox objects i've fudged up in terms of master slave relationships ala tk. I only a few hairs left so rather than pull them out i thought maybe someone could give me a hand. It would be greatly appreciated.
# this object is the foundation of the program it holds all the values required for and place
#on the dial at each clic. That is speed, attack, defense and damage will each be a clic box
# each containing a value, a color, a superpower and a position in a particular clic on which
#4 clicboxes are contained
# this object is the foundation of the program it holds all the values required for and place
#on the dial at each clic. That is speed, attack, defense and damage will each be a clic box
# each containing a value, a color, a superpower and a position in a particular clic on which
#4 clicboxes are contained
Code:
class clicbox:
def __init__(self,value=0,color="white",superpower="none",pos=0):
self.value=value
self.color=color
self.superpower=superpower
self.pos=pos
def add(self,value,color,superpower,pos):
self.value=value
self.color=color
self.superpower=superpower
self.pos=pos
#it is a containerclass designed to keep track of all the clicboxes for a given clic on a dial
class clic:
def __init__(self,value1,color1,superpower1,pos1,value2,color2,superpower2,pos2,value3,color3,superpower3,pos3,value4,color4,superpower4,pos4):
# ,list=[],y=clicbox()):
list=[]#this list is to be populated with clic objects later proper information hiding will be used
y=clicbox()#fuck off peter this a temporay clicbox name y
self.list = list
self.y = y
self.value1=value1
self.color1=color1
self.superpower1=superpower1
self.pos1=pos1
self.value2=value2
self.color2=color2
self.superpower2=superpower2
self.pos2=pos2
self.value3=value3
self.color3=color3
self.superpower3=superpower3
self.pos3=pos3
self.value4=value4
self.color4=color4
self.superpower4=superpower4
self.pos4=pos4
#this section adds 4 clic boxes to the clic.list(remember each position contains a clic box)
#speed
y.add(value=self.value1, color=self.color1, superpower=self.superpower1, pos=self.pos1)
list.append(copy.deepcopy(y))
#attack
y.add(value=self.value2, color=self.color2, superpower=self.superpower2,pos=self.pos2)
list.append(copy.deepcopy(y))
#defense
y.add(value=self.value3, color=self.color3, superpower=self.superpower3, pos=self.pos3)
list.append(copy.deepcopy(y))
#damage
y.add(value=self.value4, color=self.color4, superpower=self.superpower4,pos=self.pos4)
list.append(copy.deepcopy(y))
# def mycopy(self,x):
# return copy.deepcopy(x)
pass
#the dial class is a blue print for a representation of all the clic values on a particular
#hero. It contains a [] which is used to store the clics a hero contains.
class dial:
def __init__(self,clic1=clicbox(),clic2=clicbox(),clic3=clicbox(),clic4=clicbox(),clic5=clicbox(),clic6=clicbox(),clic7=clicbox(),clic8=clicbox(),clic9=clicbox(),clic10=clicbox(),clic11=clicbox(),clic12=clicbox()):
thedial=[]
self.thedial=thedial
thedial.append(clic1)
thedial.append(clic2)
thedial.append(clic3)
thedial.append(clic4)
thedial.append(clic2)
thedial.append(clic3)
thedial.append(clic4)
thedial.append(clic5)
thedial.append(clic6)
thedial.append(clic7)
thedial.append(clic8)
thedial.append(clic9)
thedial.append(clic10)
thedial.append(clic11)
thedial.append(clic12)
pass
#the class hero is a blueprint contain all that is need to make a hero
#it contains a dial for that hero as well as other values such as name rank and point value
class hero:
def __init__(self,range,numberofattacks,name,team,level,set,points,collect,thisdial=dial()):
self.points=points
self.collect=collect
self.thisdial=thisdial
self.range=range
self.numberofattacks=numberofattacks
self.name=name
self.team=team
self.level=level
self.set=set
self.herodial=thisdial.thedial
import copy
def printclic(x):#this function is just for test purposes
print "SPEED:"
print
print x.list[0].value
print x.list[0].color
print x.list[0].superpower
#print x.list[0].pos
print
print "ATTACK"
print x.list[1].value
print x.list[1].color
print x.list[1].superpower
#print x.list[1].pos
print
print "DEFENSE"
print
print x.list[2].value
print x.list[2].color
print x.list[2].superpower
#print x.list[2].pos
print
print "DAMAGE"
print
print x.list[3].value
print x.list[3].color
print x.list[3].superpower
#print x.list[3].pos
#clics for skrull warrior rookie
crap1 = clic(6,"white","none",1,7,"white","none",1,15,"white","none",1,1,"white","none",1)
crap2 = clic(5,"white","none",2,5,"white","none",2,13,"white","none",2,1,"white","none",2)
crap3 = clic(5,"white","none",3,5,"white","none",3,12,"white","none",3,1,"white","none",3)
crap4 = clic(5,"white","none",4,4,"white","none",4,12,"white","none",4,1,"white","none",4)
testdial=dial(crap1,crap2,crap3,crap4)
skrullwarrior1=hero(8,1,"Skrull Warrior","Skrulls",1,"infinity challange",14,"022" ,testdial)
#clics for skrull warrior experienced
crap5 = clic(7,"white","none",1,7,"white","none",1,15,"white","none",1,2,"white","none",1)
crap6 = clic(6,"white","none",2,6,"white","none",2,13,"white","none",2,1,"white","none",2)
crap7 = clic(5,"white","none",3,5,"white","none",3,13,"white","none",3,1,"white","none",3)
crap8 = clic(5,"white","none",4,4,"white","none",4,12,"white","none",4,1,"white","none",4)
testdial=dial(crap5,crap6,crap7,crap8)
skrullwarrior2=hero(8,1,"Skrull Warrior","Skrulls",2,"infinity challange",16,"023" ,testdial)
#print skrullwarrior1.collect
#print skrullwarrior2.collect
#clics for skrull warrior experienced
#printclic(skrullwarrior1.thisdial.thedial[0])
#printclic(skrullwarrior1.thisdial.thedial[1])
#print (testdial.thedial[0][0]).value
from Tkinter import *
class Application(Frame):
def __init__(self,heman=hero(0,1,"noname","none",1,"hypertime",23,00), master=None):
Frame.__init__(self, master)
self.herox=heman
self.pack()
self.create()#Widgets()
def create(self):
#herox = self.heman
name1 = Label(self, text =self.herox.name)
name1.grid(row=0, column=4, columnspan=4)
if self.herox.level==1:
xplevel=Label(self,text="rookie",bg="yellow")
elif self.herox.level==2:
xplevel=Label(self,text="experienced",bg="blue")
elif self.herox.level==3:
xplevel=Label(self,text="veteran",bg="red")
xplevel.grid(row=0,column=10,columnspan=4)
Label(self,text="ATTACKS: "+str(self.herox.numberofattacks)).grid(row=8,column=6,columnspan=4)
upper= Label(self, text="Click Number")
upper1= Label(self, text=" 1 ")
upper2= Label(self, text=" 2 ")
upper3= Label(self, text=" 3 ")
upper4= Label(self, text=" 4 ")
upper5= Label(self, text=" 5 ")
upper6= Label(self, text=" 6 ")
upper7= Label(self, text=" 7 ")
upper8= Label(self, text=" 8 ")
upper9= Label(self, text=" 9 ")
upper10= Label(self, text=" 10 ")
upper11= Label(self, text=" 11 ")
upper12= Label(self, text=" 12 ")
upper.grid(row=2, column=0)
upper1.grid(row=2, column=1)
upper2.grid(row=2, column=2)
upper3.grid(row=2, column=3)
upper4.grid(row=2, column=4)
upper5.grid(row=2, column=5)
upper6.grid(row=2, column=6)
upper7.grid(row=2, column=7)
upper8.grid(row=2, column=8)
upper9.grid(row=2, column=9)
upper10.grid(row=2, column=10)
upper11.grid(row=2, column=11)
upper12.grid(row=2, column=12)
speedq= Label(self, text="SPEED")
attackq= Label(self, text="ATTACK")
defenseq= Label(self, text="DEFENSE")
damageq= Label(self, text="DAMAGE")
speedq.grid(row=3, column=0)
attackq.grid(row=4)
defenseq.grid(row=5)
damageq.grid(row=6)
Label(self,text="TEAM: " + self.herox.team).grid(row=7,column=0,columnspan=2)
Label(self,text="POINTS: " + str(self.herox.points),fg="red").grid(row=7,column=1,columnspan=6)
Label(self,text="NUMBER: " + str(self.herox.collect)).grid(row=7,column=5,columnspan=6)
Label(self,text="SET: " + self.herox.set).grid(row=8,column=0,columnspan=4)
Label(self,text="RANGE: " + str(self.herox.range)).grid(row=0,column=0,columnspan=2)
x=0
# print len(herox.thisdial.thedial)
while x<(len(self.herox.thisdial.thedial[x].list)):
Label(self,text=(self.herox.herodial[x].list[0]).value ,bg=(self.herox.herodial[x].list[0]).color).grid(row=3, column=x+1)
Label(self,text=(self.herox.herodial[x].list[1]).value ,bg=(self.herox.herodial[x].list[1]).color).grid(row=4, column=x+1)
Label(self,text=(self.herox.herodial[x].list[2]).value ,bg=(self.herox.herodial[x].list[2]).color).grid(row=5, column=x+1)
Label(self,text=(self.herox.herodial[x].list[3]).value ,bg=(self.herox.herodial[x].list[3]).color).grid(row=6, column=x+1)
if self.herox.herodial[x].list[3].color == "black":
Label(self, text=(self.herox.herodial[x].list[3]).value, bg=(self.herox.herodial[x].list[3]).color, fg="white").grid(row=6, column=x+1)
if self.herox.herodial[x].list[2].color == "black":
Label(self, text=(self.herox.herodial[x].list[2]).value, bg=(self.herox.herodial[x].list[2]).color, fg="white").grid(row=5, column=x+1)
if self.herox.herodial[x].list[1].color == "black":
Label(self, text=(self.herox.herodial[x].list[1]).value, bg=(self.herox.herodial[x].list[1]).color, fg="white").grid(row=4, column=x+1)
if self.herox.herodial[x].list[0].color == "black":
Label(self, text=(self.herox.herodial[x].list[0]).value, bg=(self.herox.herodial[x].list[0]).color, fg="white").grid(row=3, column=x+1)
x=x+1
z=len(self.herox.herodial[x].list)
while z <12:
Label(self,text="KO" ,bg="white",fg="red").grid(row=3, column=z+1)
Label(self,text="KO" ,bg="white",fg="red").grid(row=4, column=z+1)
Label(self,text="KO" ,bg="white",fg="red").grid(row=5, column=z+1)
Label(self,text="KO" ,bg="white",fg="red").grid(row=6, column=z+1)
z = z + 1
#app = Application(skrullwarrior2)
#app1 =Application(skrullwarrior1)
#app1.mainloop()
#app.mainloop()
#mydisplay()
#print skrullwarrior1.herodial[0].list[0].value
class displayclicbox:
def __init__(self,temptk,boxname,col,rowd):
self.temptk=temptk
Label(self,self.temptk,text=boxname,font = ("arial", 16)).grid(row=0,column=col,columnspan=2)
self.valuebox=Listbox(clicwindow,height=20,width=2,selectmode=SINGLE,exportselection=0)
self.valuebox.grid(column=col,row=rowd)
self.valuechoices=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
for item in self.valuechoices:
self.valuebox.insert(END,item)
self.colorbox=Listbox(HeroEntry,height=12,width=10,selectmode=SINGLE,exportselection=0)
self.colorbox.grid(column=col+1,row=rowd)
self.colorchoices=["PURPLE","BROWN","DARK BLUE","GREEN","BLUE","ORANGE","YELLOW","RED","GREY","BLACK","WHITE"]
for item in self.colorchoices:
self.colorbox.insert(END,item)
def getvalue(self):
return self.valuebox.get(self.valuebox.curselection())
def getcolor(self):
return self.colorbox.get(self.colorbox.curselection())
class displayclic:
def __init__(self,windowq):
self.currentpos=0
self.HeroEntry=windowq
self.HeroEntry.title("Hero Enty Form")
self.speed=displayclicbox(self.HeroEntry,"SPEED",1,2)
self.attack=displayclicbox(self.HeroEntry,"ATTACK",5,2)
self.defense=displayclicbox(self.HeroEntry,"DEFENSE",9,2)
self.damage=displayclicbox(self.HeroEntry,"DAMAGE",13,2)
self.tempcliclist=[]
self.btn = Button(self.HeroEntry, text = "NEXT CLICK", command=addclicp)
self.btn.grid(row=3,column=1,columnspan=3)
self.btn = Button(self.HeroEntry, text="END",command="end clic entry")
self.passthis=self.Heroentry
def getwindowcrap():
return self.passthis
def addclicp():
speedval=self.speed.getvalue
speedcol=self.speed.getcolor
attackval=self.attack.getvalue
attackcol=self.attack.getcolor
defenseval=self.defense.getvalue
defensecol=self.defense.getcolor
damageval=self.damage.getvalue
damagecol=sel.fdamage.getcolor
tempclic=clic(speedval,speedcol,getpower("SPEED",speedcol),self.currentpos,attackval,attackcol,getpower("ATTACK",attackcol),self.currentpos,defenseval,defensecol,getpower("DEFENSE",defensecol),self.currentpos,damageval,damagecol,getpower("DAMAGE",damagecol),self.currentpos)
self.tempcliclist[self.currentpos]=copy.deepcopy(tempclic)
self.currentpos=self.currentpos + 1
###/could be module made just for assigning powers based on color and type
def getpower(powertype,color):
if powertype=="SPEED":
power=getspeed(color)
elif powertype=="ATTACK":
power=getattack(color)
elif powertype=="DEFENSE":
power=getdefense(color)
elif powertype=="DAMAGE":
power=getdamage(color)
return power
def getspeed(color="none"):
speedpowers=["NONE","CHARGE","FLURRY","MINDCONTROL","LEAP/CLIMB","PHASING","STEALTH","RUNNING SHOT","FORCE BLAST","HYPERSONIC SPEED","PLASTICITY"]
speedcolors=["WHITE","GREEN","RED","BLUE","ORANGE","YELLOW","BLACK","GRAY","PURPLE","BROWN","DARK BLUE"]
i=0
while i<=9:
if color == speedcolors [i]:
return speedpowers [i]
else:
i = i + 1
def getattack(color="none"):
attackpowers=["NONE","SUPER STRENGTH","BLADES/CLAWS/FANGS","INCAPACITATE","ENERGY EXPLOSION","PULSE WAVE","STEAL ENERGY","TELEKINESIS","SMOKE CLOUD","POISON","PSYCHIC BLAST","SUPER STRENGTH"]
attackcolors=["WHITE","GREEN","RED","BLUE","ORANGE","YELLOW","BLACK","GRAY","PURPLE","BROWN","DARK BLUE","GREEN"]
i=0
while i<=10:
if color==attackcolors [i]:
return attackpowers [i]
else:
i = i + 1
####HERE
def getdefense(color="none"):
defensepowers=["NONE","ENERGY SHEILD/DEFLECTION","SUPER SENSES","BARRIER","TOUGHNESS","DEFEND","REGENERATION","INVULNERABILITY","WILLPOWER","IMPERVIOUS","MASTERMIND"]
defensecolors=["WHITE","GREEN","RED","BLUE","ORANGE","YELLOW","BLACK","GRAY","PURPLE","BROWN","DARK BLUE"]
i=0
while i<=9:
if color==defensecolors [i]:
return defensepowers [i]
else:
i = i + 1
def getdamage(color="none"):
damagepowers=["NONE","ENHANCEMENT","RANGED COMBAT EXPERT","PROBABILITY CONTROL","BATTLE FURY","SUPPORT","OUTWIT","LEADERSHIP","CLOSE COMBAT EXPERT","PERPLEX","SHAPE CHANGE"]
damagecolors=["GREEN","RED","BLUE","ORANGE","SUPPORT","BLACK","GRAY","PURPLE","BROWN","DARK BLUE"]
i=0
while i<=9:
if color==damagecolors [i]:
return damagepowers [i]
else:
i = i + 1
HeroEntry=Tk()
crap=displayclic(HeroEntry)