Ceetar commited on
Commit
0daefef
1 Parent(s): 8061c4b

random stats working

Browse files
Files changed (1) hide show
  1. app.py +30 -19
app.py CHANGED
@@ -43,26 +43,37 @@ def describe(names,wis,char,str,int,dex,con):
43
 
44
  return result
45
 
46
-
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
- iface = gr.Interface(fn=describe, inputs=[gr.Textbox(label="Your DND character",show_label=True),
49
- gr.Number(label="Wisdom",show_label=True),
50
- gr.Number(label="Charisma",show_label=True),
51
- gr.Number(label="Strength",show_label=True),
52
- gr.Number(label="Intelligence",show_label=True),
53
- gr.Number(label="Dexterity",show_label=True),
54
- gr.Number(label="Constitution",show_label=True)],
 
 
 
 
 
 
 
55
 
56
- outputs=gr.Textbox(label="The character",show_label=True))
57
- iface.launch()
58
 
59
 
60
- def stat(n_dice, dice_rank):
61
- results = [ # Generate n_dice numbers between [1,dice_rank]
62
- random.randint(1, dice_rank)
63
- for n
64
- in range(n_dice)
65
- ]
66
- lowest = min(results) # Find the lowest roll among the results
67
- results.remove(lowest) # Remove the first instance of that lowest roll
68
- return sum(results) # Return the sum of the remaining results.
 
43
 
44
  return result
45
 
46
+ def stat( ndice, dicerank):
47
+ # return ndice + dicerank
48
+ answer=[]
49
+ for x in range(6) :
50
+ results = [ # Generate ndice numbers between [1,dice_rank]
51
+ random.randint(1, dicerank)
52
+ for n
53
+ in range(ndice)
54
+ ]
55
+ lowest = min(results) # Find the lowest roll among the results
56
+ results.remove(lowest) # Remove the first instance of that lowest roll
57
+ answer.append(sum(results)) # Return the sum of the remaining results.
58
+
59
+ return answer
60
 
61
+ with gr.Blocks() as statBlock:
62
+ gr.Markdown("Your characters stats")
63
+ nameBox = gr.Textbox(label="Your DND character",show_label=True)
64
+ wisBox = gr.Number(label="Wisdom",show_label=True,precision=0,minimum=1,maximum=18)
65
+ charBox = gr.Number(label="Charisma",show_label=True,precision=0)
66
+ strBox =gr.Number(label="Strength",show_label=True,precision=0)
67
+ intBox =gr.Number(label="Intelligence",show_label=True,precision=0)
68
+ dexBox =gr.Number(label="Dexterity",show_label=True,precision=0)
69
+ conBox =gr.Number(label="Constitution",show_label=True,precision=0)
70
+ dice = gr.Number(value=4,precision=0,visible=False)
71
+ dice.visible = False
72
+ rollButt = gr.Button(value="Roll Stats")
73
+
74
+ outputBox=gr.Textbox(label="The character",show_label=True)
75
 
76
+ rollButt.click(stat, inputs=[dice,gr.Number(value=6, visible=False,precision=0)],outputs=[wisBox,charBox,strBox,intBox,dexBox,conBox])
77
+ statBlock.launch()
78
 
79