ゲームのステータスを計算するアプリケーションを作成しています。
しかし、#属性攻撃力計算関数のところで引数絡みのエラーが発生してしまいます。
以下はエラー文です。
TypeError
1TypeError: Contact_point() missing 12 required positional arguments: 'contact', 'deffence', 'fire_1', 'water_1', 'earth_1', 'light_1', 'dark_1', 'fire_2', 'water_2', 'earth_2', 'light_2', and 'dark_2'
そして、プログラムは以下の通りです。
python3.10
1import tkinter as tk 2 3#物理攻撃力計算関数 4def Attack_point(attack,block): 5 return (attack * attack) / (attack + block) + 0.5 6 7#属性攻撃力計算関数 8def Contact_point(contact,deffence,fire_1,water_1,earth_1,light_1,dark_1,fire_2,water_2,earth_2,light_2,dark_2): 9 fire = fire_1 + (earth_2 - water_2) * 0.5 10 water = water_1 + (fire_2 - earth_2) * 0.5 11 earth = earth_1 + (water_2 - fire_2) * 0.5 12 all_contact = fire_1 + water_1 + earth_1 + light_1 + dark_1 13 if ((fire_1 > water_1) & (fire_1 > earth_1) & (fire_1 > light_1) & (fire_1 > dark_1)): 14 result = ((contact * contact) / (contact + deffence) + 0.5) * (fire + water + earth + light_1 + dark_1) * ((fire_1 / all_contact) / 100 + 0.5) 15 if ((water_1 > fire_1) & (water_1 > earth_1) & (water_1 > light_1) & (water_1 > dark_1)): 16 result = ((contact * contact) / (contact + deffence) + 0.5) * (fire + water + earth + light_1 + dark_1) * ((water_1 / all_contact) / 100 + 0.5) 17 if ((earth_1 > water_1) & (earth_1 > fire_1) & (earth_1 > light_1) & (earth_1 > dark_1)): 18 result = ((contact * contact) / (contact + deffence) + 0.5) * (fire + water + earth + light_1 + dark_1) * ((earth_1 / all_contact) / 100 + 0.5) 19 if ((light_1 > water_1) & (light_1 > earth_1) & (light_1 > fire_1) & (light_1 > dark_1)): 20 result = ((contact * contact) / (contact + deffence) + 0.5) * (fire + water + earth + light_1 + dark_1) * ((light_1 / all_contact) / 100 + 0.5) 21 if ((dark_1 > water_1) & (dark_1 > earth_1) & (dark_1 > light_1) & (dark_1 > fire_1)): 22 result = ((contact * contact) / (contact + deffence) + 0.5) * (fire + water + earth + light_1 + dark_1) * ((dark_1 / all_contact) / 100 + 0.5) 23 Contact_point() 24 25#トップレベルウインドウの表示 26root = tk.Tk() 27root.title("ひまスラ攻撃力チェック") 28root.geometry("350x500") 29 30#Labelウィジェットの生成 31label_1 = tk.Label(root,text="物理攻撃力") 32label_2 = tk.Label(root,text="属性攻撃力") 33label_3 = tk.Label(root,text="敵物理防御力") 34label_4 = tk.Label(root,text="敵属性防御力") 35label_5 = tk.Label(root,text="火属性攻撃力") 36label_6 = tk.Label(root,text="水属性攻撃力") 37label_7 = tk.Label(root,text="木属性攻撃力") 38label_8 = tk.Label(root,text="光属性攻撃力") 39label_9 = tk.Label(root,text="闇属性攻撃力") 40label_10 = tk.Label(root,text="火属性防御力") 41label_11 = tk.Label(root,text="水属性防御力") 42label_12 = tk.Label(root,text="木属性防御力") 43label_13 = tk.Label(root,text="光属性防御力") 44label_14 = tk.Label(root,text="闇属性防御力") 45 46label_15 = tk.Label(root,text="ステータスを入力してください。") 47 48#Entryウィジェットの生成 49attack = tk.Entry(width = 10) 50block = tk.Entry(width = 10) 51contact = tk.Entry(width = 10) 52deffence = tk.Entry(width = 10) 53fire_1 = tk.Entry(width = 10) 54water_1 = tk.Entry(width = 10) 55earth_1 = tk.Entry(width = 10) 56light_1 = tk.Entry(width = 10) 57dark_1 = tk.Entry(width = 10) 58fire_2 = tk.Entry(width = 10) 59water_2 = tk.Entry(width = 10) 60earth_2 = tk.Entry(width = 10) 61light_2 = tk.Entry(width = 10) 62dark_2 = tk.Entry(width = 10) 63 64#Buttonのハンドラ関数 65def judgement(): 66 a = int(attack.get()) 67 b = int(block.get()) 68 c = int(contact.get()) 69 d = int(deffence.get()) 70 f1 = int(fire_1.get()) 71 w1 = int(water_1.get()) 72 e1 = int(earth_1.get()) 73 l1 = int(light_1.get()) 74 d1 = int(dark_1.get()) 75 f2 = int(fire_2.get()) 76 w2 = int(water_2.get()) 77 e2 = int(earth_2.get()) 78 l2 = int(light_2.get()) 79 d2 = int(dark_2.get()) 80 81 s = Attack_point(a,b) + Contact_point(c,d,f1,w1,e1,l1,d1,f2,w2,e2,l2,d2) 82 label_15["text"] = "総合攻撃力:" + str(s) 83 84#Buttonウィジェットの生成 85button = tk.Button(root,text="計算実行",command = judgement) 86 87#各列の割合を指定 88root.columnconfigure(0,weight = 1) 89root.columnconfigure(1,weight = 1) 90root.columnconfigure(2,weight = 1) 91root.columnconfigure(3,weight = 1) 92 93#各行の割合を指定 94root.rowconfigure(0,weight = 1) 95root.rowconfigure(1,weight = 1) 96root.rowconfigure(2,weight = 1) 97root.rowconfigure(3,weight = 1) 98root.rowconfigure(4,weight = 1) 99root.rowconfigure(5,weight = 1) 100root.rowconfigure(6,weight = 1) 101root.rowconfigure(7,weight = 1) 102root.rowconfigure(8,weight = 1) 103root.rowconfigure(9,weight = 1) 104 105#1行目 106label_1.grid(column = 0,row = 0) 107attack.grid(column = 1,row = 0) 108label_3.grid(column = 2,row = 0) 109block.grid(column = 3,row = 0) 110 111#2行目 112label_2.grid(column = 0,row = 1) 113contact.grid(column = 1,row = 1) 114label_4.grid(column = 2,row = 1) 115deffence.grid(column = 3,row = 1) 116 117#3行目 118label_5.grid(column = 0,row = 2) 119fire_1.grid(column = 1,row = 2) 120label_10.grid(column = 2,row = 2) 121fire_2.grid(column = 3,row = 2) 122 123#4行目 124label_6.grid(column = 0,row = 3) 125water_1.grid(column = 1,row = 3) 126label_11.grid(column = 2,row = 3) 127water_2.grid(column = 3,row = 3) 128 129#5行目 130label_7.grid(column = 0,row = 4) 131earth_1.grid(column = 1,row = 4) 132label_12.grid(column = 2,row = 4) 133earth_2.grid(column = 3,row = 4) 134 135#6行目 136label_8.grid(column = 0,row = 5) 137light_1.grid(column = 1,row = 5) 138label_13.grid(column = 2,row = 5) 139light_2.grid(column = 3,row = 5) 140 141#7行目 142label_9.grid(column = 0,row = 6) 143dark_1.grid(column = 1,row = 6) 144label_14.grid(column = 2,row = 6) 145dark_2.grid(column = 3,row = 6) 146 147#8行目 148button.grid(column = 0,row = 7,columnspan = 3) 149 150#9行目 151label_15.grid(column = 0,row = 8,columnspan = 3) 152 153#トップレベルウインドウの表示 154root.mainloop()
Contact_point 関数の最後で Contact_point() を実行していますが、これは return result とするのではないでしょうか。