mirror of
https://bitbucket.org/grumdrig/pq-web.git
synced 2026-09-29 08:44:00 -06:00
First pass at charsheet
This commit is contained in:
@@ -1,6 +1,20 @@
|
||||
// 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/
|
||||
// Johannes Baagøe <baagoe@baagoe.com>, 2010
|
||||
function Mash() {
|
||||
|
||||
@@ -171,4 +171,36 @@
|
||||
<br>
|
||||
Cheats:
|
||||
</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>
|
||||
|
||||
@@ -815,53 +815,7 @@ function ExportCharSheet() {
|
||||
}
|
||||
|
||||
function CharSheet() {
|
||||
var f = '';
|
||||
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;
|
||||
return template("sheet", game);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,17 +54,7 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
function brag(sheet) {
|
||||
var tmpl = $("#badge").html();
|
||||
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);
|
||||
var brag = $(template("badge", sheet));
|
||||
if (sheet.motto)
|
||||
brag.find(".bs").text('"' + sheet.motto + '"');
|
||||
return brag;
|
||||
|
||||
Reference in New Issue
Block a user