1
0
Fork 0
mirror of https://github.com/Oreolek/gamebookformat.git synced 2024-05-17 00:18:20 +03:00

Disabling everything after enabled auto link.

This means that if forced to follow instructions to turn to
some section, nothing else later in the current section will
have an effect (eg counters or collections), which should
be what the player expects.
This commit is contained in:
Pelle Nilsson 2013-06-18 23:40:27 +02:00
parent 6b2b16555f
commit 9280be8e38
2 changed files with 16 additions and 5 deletions

View file

@ -5,7 +5,7 @@ Demonstrating how to manage player [collect item]Inventory[/collect].
You start
the book carrying a [add item]sword[/add]
and a [add item]shield[/add].
Turn to [[tjunction]].
Turn to [[tjunction]] or go to the autotest at [[autotest]].
* tjunction
You have reached a t-junction.
@ -56,6 +56,7 @@ so you head back to [[tjunction]].
* inside
There is a rope here that can be cut using a [has item]sword[/has].
If you have one and want to do that, see [[cut_rope]].
You can also run to the autotest at [[autotest]].
Otherwise turn to [[won]].
* cut_rope
@ -63,3 +64,11 @@ OK. That was fun. Turn to [[won]].
* won
Congratulations, you won.
* autotest
If you have the [has item]stick[/has] then you must turn
immediately to [[auto tjunction]], and everything else in this
section is ignored. You find a [add item]book[/add] here.
If you have the [has item]sword[/has] you must turn
immediately to [[auto inside]], again ignoring everything
that follows. You drop the [drop item]something valuable[/drop]
here if you have it, then go on to [[portal]].

View file

@ -254,7 +254,7 @@ var gamebook = {
var hasXorScope = false;
var hasAutoScope = false;
var xorEnableNext = false;
var autoDisableAllRemainingLinks = (
var autoDisableAllRemaining = (
gamebook.player.started
&& e.classList.contains('introsectionbody'));
Array.prototype.forEach.call(e.childNodes, function(c) {
@ -262,10 +262,10 @@ var gamebook = {
return;
}
if (c.classList.contains('sectionref')) {
if (enableNextLink && !autoDisableAllRemainingLinks) {
if (enableNextLink && !autoDisableAllRemaining) {
gamebook.enableLink(c);
if (hasAutoScope) {
autoDisableAllRemainingLinks = true;
autoDisableAllRemaining = true;
}
} else {
gamebook.disableLink(c);
@ -273,6 +273,8 @@ var gamebook = {
enableNextLink = !(hasXorScope && !xorEnableNext);
hasAutoScope = false;
hasXorScope = false;
} else if (autoDisableAllRemaining) {
return; // no further actions will be taken after enabled auto
} else if (c.classList.contains('collect')) {
gamebook.player.collect(c.dataset.type, c.dataset.name);
} else if (c.classList.contains('add')) {
@ -318,7 +320,7 @@ var gamebook = {
gamebook.enableRandomLinkAfter);
c.classList.add("enabledlink");
c.classList.remove("disabledlink");
autoDisableAllRemainingLinks = true;
autoDisableAllRemaining = true;
}
});
},