Get onload working somewhat for create screen

This commit is contained in:
Eric Fredricksen
2010-06-24 12:44:55 -07:00
parent 77b61b114f
commit 2bede6d1bf
2 changed files with 38 additions and 33 deletions
+12 -9
View File
@@ -4,6 +4,7 @@
<title>Progress Quest - Roll One Up</title>
<script src="jquery.js"></script>
<script src="config.js"></script>
<script src="newguy.js"></script>
<style>
input, button { display: inline; }
@@ -38,14 +39,14 @@ input, button { display: inline; }
<legend>Stats</legend>
<table>
<tr> <th> STR <td> 13 </tr>
<tr> <th> DEX <td> 34 </tr>
<tr> <th> CON <td> 23 </tr>
<tr> <th> INT <td> 12 </tr>
<tr> <th> WIS <td> 4 </tr>
<tr> <th> CHA <td> 12 </tr>
<tr> <th> STR <td id="STR">13</tr>
<tr> <th> CON <td id="CON">23</tr>
<tr> <th> DEX <td id="DEX">34</tr>
<tr> <th> INT <td id="INT">12</tr>
<tr> <th> WIS <td id="WIS">4</tr>
<tr> <th> CHA <td id="CHA">12</tr>
<tr> <th colspan=2> &nbsp; </tr>
<tr> <th> Total <td> 48 </tr>
<tr> <th> Total <td id="Total">48</tr>
</table>
<br>
@@ -69,10 +70,12 @@ input, button { display: inline; }
<script>
function fill(e, a, n) {
var def = Random(a.length);
for (var i = 0; i < a.length; ++i) {
var v = a[i].split("|")[0];
$("<div><input type=radio name=\"" + n + "\" value=" + v +">" +
v + "</div>").appendTo(e);
var check = def == i ? " checked " : " ";
$("<div><input type=radio name=\"" + n + "\" value=\"" + v + "\" " +
check +">" + v + "</div>").appendTo(e);
}
}
fill("#races", K.Races, "Race");
+26 -24
View File
@@ -1,13 +1,12 @@
/* copyright (c)2002-2010 Eric Fredricksen all rights reserved */
function UrlEncode(s) {
NewGuyForm.PoorCodeDesign.InputString = s;
return NewGuyForm.PoorCodeDesign.Encode;
function Random(n) {
return Math.floor(Math.random() * n);
}
function Roll(stat) {
stat.Tag = 3 + Random(6) + Random(6) + Random(6);
stat.Caption = IntToStr(stat.Tag);
stat.html(stat.Tag);
}
function Choose(n, k) {
@@ -20,21 +19,31 @@ function Choose(n, k) {
return result / d;
}
function TNewGuyForm_RollEm() {
ReRoll.Tag = RandSeed();
function RollEm() {
var STR = $("STR");
var CON = $("CON");
var DEX = $("DEX");
var INT = $("INT");
var WIS = $("WIS");
var CHA = $("CHA");
var Total = $("Total");
var ReRoll = $("ReRoll");
//ReRoll.Tag = RandSeed();
Roll(STR);
Roll(CON);
Roll(DEX);
Roll(INT);
Roll(WIS);
Roll(CHA);
Total.tag = STR.Tag + Con.Tag + DEX.Tag + Int.Tag + Wis.Tag + CHA.Tag;
Total.Caption = IntToStr(Total.Tag);
Total.tag = STR.Tag + CON.Tag + DEX.Tag + INT.Tag + WIS.Tag + CHA.Tag;
Total.html(Total.Tag);
/*
if (Total.Tag >= (63+18)) Total.Color = clRed
else if (Total.Tag > (4 * 18)) Total.Color = clYellow
else if (Total.Tag <= (63-18)) Total.Color = clGray
else if (Total.Tag < (3 * 18)) Total.Color = clSilver
else Total.Color = clWhite;
*/
}
function TNewGuyForm_RerollClick() {
@@ -48,20 +57,13 @@ function TNewGuyForm_Go() {
return mrOk == ShowModa();
}
function TNewGuyForm_FormShow() {
if (Tag > 0) {
Tag = 0;
Caption = 'Progress Quest - New Character';
if (MainForm.GetHostName != '')
Caption = Caption + ' [' + MainForm.GetHostName + ']';
Randomize();
RollEm();
with (Race)
ItemIndex = Random(Items.Count);
with (Klass)
ItemIndex = Random(Items.Count);
}
}
$(document).ready(function () {
//var caption = 'Progress Quest - New Character';
//if (MainForm.GetHostName != '')
// caption = caption + ' [' + MainForm.GetHostName + ']';
//Randomize();
RollEm();
});
function TNewGuyForm_UnrollClick() {
RandSeed = StrToInt(OldRolls.Items[0]);
@@ -103,8 +105,8 @@ function TNewGuyForm_SoldClick() {
if ((GetAccount() != '') || (GetPassword != ''))
url = StuffString(url, 8, 0, GetAccount() + ':' + GetPassword() + '@');
args = 'cmd=create' +
'&name=' + UrlEncode(Name.Text) +
'&realm=' + UrlEncode(MainForm.GetHostName) +
'&name=' + escape(Name.Text) +
'&realm=' + escape(MainForm.GetHostName) +
RevString;
ParseSoldResponse(DownloadString(url + args));
} catch (EWebError) {