function Roll(min, max){
return Math.round(Math.floor(Math.random() * (max - min + 1)) + min);
}
function OnStart(){
app.LoadPlugin("UIExtras");
uix = app.CreateUIExtras();
app.EnableBackKey(false);
thm = app.CreateTheme("Dark");
thm.SetBackColor("#ff303030");
home = app.CreateLayout("linear","VCenter,FillXY");
lTop = app.CreateLayout("linear","horizontal");
TopTxtContainer = app.CreateLayout("linear","horizontal,left");
ttl = app.GetAppName();
ttl = app.CreateText(ttl,0.8, 0.085,"Left,AutoScale");
ttl.SetTextSize(48);
ttl.SetMargins(0,0,0,0);
ttl.SetPadding(0,0,0,0);
ttl.SetFontFile("assets/Roboto.ttf");
TopTxtContainer.AddChild(ttl);
lTop.AddChild(TopTxtContainer);
home.AddChild(lTop);
trow = app.CreateLayout("linear","VCenter");
trow.SetSize(1.0,0.915);
res = app.CreateText("", 0.3, 0.3, "Bold,AutoScale,Top");
res.SetTextSize(96);
trow.AddChild(res);
layBtn = app.CreateLayout("linear", "horizontal");
def = ["D4","D6","D10","D12","D20"];
for(i=0;i<5;i++){
btn = app.CreateButton(def[i],0.15,0.1);
btn.SetOnTouch(calc);
layBtn.AddChild(btn);
}
trow.AddChild(layBtn);
home.AddChild(trow);
app.AddLayout(home);
app.SetTheme(thm);
}
function calc(){
switch(btn.GetText()){
case "D4":
chr = Roll(1,4)
if(chr>4){chr--}
res.SetText(chr);
break;
case "D6":
chr = Roll(1,6)
if(chr>6){chr--}
res.SetText(chr);
break;
case "D10":
chr = Roll(1,10)
if(chr>10){chr--}
res.SetText(chr);
break;
case "D12":
chr = Roll(1,12)
if(chr>12){chr--}
res.SetText(chr);
break;
case "D20":
chr = Roll(1,20)
if(chr>20){chr--}
res.SetText(chr);
break;
}
}Digite o código aqui...function random(min,max) {
return Math.random()*(max-min)+min
}