Fixes to game.id to make it more reasonably reflect title of game also add an alert if try to go to non-existent location
Fixes to game.id to make it more reasonably reflect title of game also add an alert if try to go to non-existent location
diff --git a/css/game.css b/css/game.css
index 2a0bc4d..4dc92bc 100644
--- a/css/game.css
+++ b/css/game.css
@@ -203,7 +203,7 @@ x-action
}
#main-nav .nav-label
{
- font-size: 18pt;
+ font-size: 14pt;
margin: auto;
text-align: left;
width: 170px;
@@ -214,7 +214,7 @@ x-action
}
#main-nav .nav-info
{
- font-size: 18pt;
+ font-size: 14pt;
margin: 0px auto 15px auto;
text-align: left;
width: 170px;
diff --git a/js/game.js b/js/game.js
index 6ff7760..7014a6e 100644
--- a/js/game.js
+++ b/js/game.js
@@ -29,7 +29,10 @@ var tl = {
"en": {
"init_slot_states_load" : "Load",
"init_slot_states_save" : "Save",
- "restore_state_invalid_game" : "Does not appear to be a valid game save"
+ "restore_state_invalid_game" :
+ "Does not appear to be a valid game save",
+ "move_object_failed" : "moveObject(object_id, location) failed.\n" +
+ "Either the object or location does not exist.\n"
}
};
/**
@@ -823,15 +826,19 @@ class Game
*/
constructor()
{
- let game_elt = tag('x-game')[0];
+ let title_elt = tag('title')[0];
+ if (!title_elt) {
+ title_elt = tag('x-game')[0];
+ }
this.reload = false; //current
let doc_length = 0;
let middle_five = "";
- if (game_elt) {
- doc_length = game_elt.innerHTML.length;
+ if (title_elt) {
+ doc_length = title_elt.innerHTML.length;
if (doc_length > 8) {
- middle_five = game_elt.innerHTML.slice(
- Math.floor(doc_length/2), 5);
+ let half_length = Math.floor(doc_length/2);
+ middle_five = title_elt.innerHTML.slice(
+ half_length, half_length + 5);
}
}
// a semi-unique code for this particular game
@@ -1354,6 +1361,8 @@ class Game
{
let move_object = this.objects[object_id];
if (!move_object || !this.locations[destination_id]) {
+ alert(tl[locale]['move_object_failed'] +
+ "\nmoveObject('" + object_id + "', '" + destination_id + "')");
return false;
}
if (move_object.hasOwnProperty("position")) {