mirror of
https://bitbucket.org/grumdrig/pq-web.git
synced 2026-09-29 08:44:00 -06:00
Update sim.js to work with current v8 and node
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
$Traits.Name the $Traits.Race [$hostname]
|
||||||
|
"$motto"
|
||||||
|
|
||||||
|
Level $Traits.Level $Traits.Class (exp. $ExpBar.position/$ExpBar.max)
|
||||||
|
|
||||||
|
Plot stage: $bestplot ($PlotBar.hint)
|
||||||
|
Quest: $bestquest ($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/
|
||||||
@@ -1,4 +1,15 @@
|
|||||||
//!/usr/bin/env v8
|
// This is an in-console simulation of Progress Quest. It's rather a
|
||||||
|
// hack job.
|
||||||
|
//
|
||||||
|
// Run it with node.js like so:
|
||||||
|
// $ node sim.js
|
||||||
|
// or using a modified v8 shell, like so:
|
||||||
|
// $ git clone git://github.com/grumdrig/v8
|
||||||
|
// $ (cd v8; scons sample=shell)
|
||||||
|
// $ v8/shell sim.js
|
||||||
|
//
|
||||||
|
// It's not realtime - simulation runs at maximum speed and the
|
||||||
|
// virtual time elapsed is displayed at each level-up.
|
||||||
|
|
||||||
var window = {
|
var window = {
|
||||||
location: {href: "#Woogle"},
|
location: {href: "#Woogle"},
|
||||||
@@ -67,7 +78,8 @@ if (typeof process !== "undefined") {
|
|||||||
var sys = require("sys");
|
var sys = require("sys");
|
||||||
var load = function (filename) {
|
var load = function (filename) {
|
||||||
var content = fs.readFileSync(filename);
|
var content = fs.readFileSync(filename);
|
||||||
global.eval.call(global, String(content));
|
require("vm").runInThisContext(content, filename);
|
||||||
|
//global.eval.call(global, String(content));
|
||||||
};
|
};
|
||||||
var print = function () {
|
var print = function () {
|
||||||
for (var i = 0, len = arguments.length; i < len; ++i) {
|
for (var i = 0, len = arguments.length; i < len; ++i) {
|
||||||
@@ -80,6 +92,7 @@ if (typeof process !== "undefined") {
|
|||||||
|
|
||||||
global.window = window;
|
global.window = window;
|
||||||
global.document = document;
|
global.document = document;
|
||||||
|
global.navigator = navigator;
|
||||||
global.$ = $;
|
global.$ = $;
|
||||||
print("node");
|
print("node");
|
||||||
} else {
|
} else {
|
||||||
@@ -96,7 +109,7 @@ var setInterval = global.setInterval = function (callback, interval) {
|
|||||||
timers.push({callback:callback, interval:interval});
|
timers.push({callback:callback, interval:interval});
|
||||||
return timers.length-1;
|
return timers.length-1;
|
||||||
};
|
};
|
||||||
var setTimeout = setInterval; // TODO: distinguish!
|
var setTimeout = global.setTimeout = setInterval; // TODO: distinguish!
|
||||||
|
|
||||||
load("config.js");
|
load("config.js");
|
||||||
|
|
||||||
@@ -106,6 +119,7 @@ print(cs, "characters");
|
|||||||
|
|
||||||
load("newguy.js");
|
load("newguy.js");
|
||||||
NewGuyFormLoad();
|
NewGuyFormLoad();
|
||||||
|
traits.Name = "Shienzid";
|
||||||
sold();
|
sold();
|
||||||
|
|
||||||
write("local.storage", JSON.stringify(window.localStorage.items));
|
write("local.storage", JSON.stringify(window.localStorage.items));
|
||||||
@@ -139,7 +153,7 @@ for (var j = 1, t = 0; j < 1001; ++j) {
|
|||||||
var tmpl = read("charsheet.txt");
|
var tmpl = read("charsheet.txt");
|
||||||
storage.loadSheet("Shienzid", function (sheet) {
|
storage.loadSheet("Shienzid", function (sheet) {
|
||||||
game = sheet;
|
game = sheet;
|
||||||
print(template(tmpl, sheet));
|
print(template(''+tmpl, sheet));
|
||||||
|
|
||||||
var l = 0;
|
var l = 0;
|
||||||
for (var i = 0; i < 1000000000; ++i) {
|
for (var i = 0; i < 1000000000; ++i) {
|
||||||
|
|||||||
Reference in New Issue
Block a user