First pass at charsheet

This commit is contained in:
Eric Fredricksen
2010-07-06 00:04:37 -07:00
parent a5295df3ce
commit 73fe1bf0a7
4 changed files with 48 additions and 58 deletions
+14
View File
@@ -1,6 +1,20 @@
// TODO These code bits don't really belong here, but this is the only shared bit of js // TODO These code bits don't really belong here, but this is the only shared bit of js
function template(id, data) {
var tmpl = $("#" + id).html();
var brag = tmpl.replace(/\$([_A-Za-z.]+)/g, function (str, p1) {
var dict = data;
$.each(p1.split("."), function (i,v) {
if (!dict) return true;
dict = dict[v];
return null;
});
return dict || '';
});
return brag;
}
// From http://baagoe.com/en/RandomMusings/javascript/ // From http://baagoe.com/en/RandomMusings/javascript/
// Johannes Baagøe <baagoe@baagoe.com>, 2010 // Johannes Baagøe <baagoe@baagoe.com>, 2010
function Mash() { function Mash() {
+32
View File
@@ -171,4 +171,36 @@
<br> <br>
Cheats: Cheats:
</body> </body>
<script type="text/charsheet" id="sheet">
$Traits.Name [$hostname]
$Traits.Race $Traits.Class
Level $Traits.level (exp. $ExpBar.position/$ExpBar.max)
Plot stage: $Plots.last ($PlotBar.Hint)
Quest: $Quests.last ($QuestBar.Hint)
Stats:
STR $Stats.STR
CON $Stats.CON
DEX $Stats.DEX
INT $Stats.INT
WIS $Stats.WIS HP Max $Stats.HP_Max
CHA $Stats.CHA MP Max $Stats.MP_Max
Equipment:
$Equips.___
Spell Book:
$Spells.___
Inventory ($EncumBar.Hint):
$Inventory.___
-- $date
-- Progress Quest 6.3.web - http://progressquest.com/
</script>
</html> </html>
+1 -47
View File
@@ -815,53 +815,7 @@ function ExportCharSheet() {
} }
function CharSheet() { function CharSheet() {
var f = ''; return template("sheet", game);
function Wr(a) { f = f + a; }
function WrLn(a) { if (a != undefined) Wr(a); Wr("\r\n"); }
Wr(Get(Traits,'Name'));
if (GetHostName())
Wr(' [' + GetHostName() + ']');
WrLn;
WrLn(Get(Traits,'Race') + ' ' + Get(Traits,'Class'));
WrLn(Format('Level %d (exp. %d/%d)', [GetI(Traits,'Level'), ExpBar.Position, ExpBar.Max]));
//WrLn('Level ' + Get(Traits,'Level') + ' (' + ExpBar.Hint + ')');
WrLn;
if (Plots.length() > 0)
WrLn('Plot stage: ' + Plots.last().text() + ' (' + PlotBar.Hint + ')');
if (Quests.length() > 0)
WrLn('Quest: ' + Quests.last().text() + ' (' + QuestBar.Hint + ')');
WrLn();
WrLn( 'Stats:');
WrLn( Format(' STR%7d', [GetI(Stats,'STR')]));
WrLn( Format(' CON%7d', [GetI(Stats,'CON')]));
WrLn( Format(' DEX%7d', [GetI(Stats,'DEX')]));
WrLn( Format(' INT%7d', [GetI(Stats,'INT')]));
WrLn( Format(' WIS%7d HP Max%7d', [GetI(Stats,'WIS'), GetI(Stats,'HP Max')]));
WrLn( Format(' CHA%7d MP Max%7d', [GetI(Stats,'CHA'), GetI(Stats,'MP Max')]));
WrLn();
WrLn( 'Equipment:');
for (var i = 1; i <= Equips.length()-1; ++i) {
if (Get(Equips,i))
WrLn( ' ' + LeftStr(Equips[i].Caption + ' ', 12) + Get(Equips,i));
}
WrLn();
WrLn( 'Spell Book:');
for (var s = 0; s < Spells.length(); ++s)
WrLn(' ' + Spells.label(s) + ' ' + Get(Spells,s));
WrLn();
WrLn( 'Inventory (' + EncumBar.Hint + '):');
WrLn( ' ' + Indefinite('gold piece', GetI(Inventory, 'Gold')));
for (var ii = 2; ii <= Items.length()-1; ++ii) {
if (Pos(' of ', Inventory[ii].Caption) > 0)
WrLn( ' ' + Definite(Inventory[ii].Caption, GetI(Inventory,ii)));
else
WrLn( ' ' + Indefinite(Items[ii].Caption, GetI(Inventory,ii)));
}
WrLn();
WrLn( '-- ' + DateTimeToStr(Now));
WrLn( '-- Progress Quest 6.2 - http://progressquest.com/');
return f;
} }
+1 -11
View File
@@ -54,17 +54,7 @@ $(document).ready(function () {
}); });
function brag(sheet) { function brag(sheet) {
var tmpl = $("#badge").html(); var brag = $(template("badge", sheet));
var brag = tmpl.replace(/\$([A-Za-z.]+)/g, function (str, p1) {
var dict = sheet;
$.each(p1.split("."), function (i,v) {
if (!dict) return true;
dict = dict[v];
return null;
});
return dict || '';
});
brag = $(brag);
if (sheet.motto) if (sheet.motto)
brag.find(".bs").text('"' + sheet.motto + '"'); brag.find(".bs").text('"' + sheet.motto + '"');
return brag; return brag;