1
0
Fork 0
mirror of https://github.com/Oreolek/gamebookformat.git synced 2024-06-26 03:41:04 +03:00

haselse hack to enable or disable one link the opposite of the previous one

This commit is contained in:
Pelle Nilsson 2013-06-10 19:13:45 +02:00
parent c4a777ebad
commit ec7a054d42
6 changed files with 28 additions and 9 deletions

View file

@ -13,19 +13,22 @@ turn to [[the_end]]. If you do not have the codeword
[hasnot code]fun[/hasnot], you may turn to [[notsofun]].
If you have the codeword [has code]fun[/has], you may instead
turn to [[cheater]].
Otherwise see [[forced]].
Otherwise see [[haselsetest]].
* notsofun
This is just to demonstrate choices allowed when not
having a codeword. Now go on to [[forced]].
having a codeword. Now go on to [[haselsetest]].
* cheater
Cheater! There is no way you can have codeword fun.
* forced
OK, if you have the codeword [has code]warrior[/has], turn to
[[auto the_end]] otherwise go back to [[second]]. Although
* haselsetest
OK, if you have the codeword [haselse code]warrior[/has],
you may turn to
[[auto the_end]] otherwise you may go back to [[second]]. Although
we both know you have that codeword.
If you have the codeword [haselse code]fun[/has] you may turn
to [[cheater]], without it you can go to [[notsofun]].
* the_end
That was easy.

View file

@ -0,0 +1 @@
[HAS ELSE %(arg1)s]%(inner)s[/HAS]

View file

@ -83,8 +83,9 @@
},
'runActions' : function(e) {
// FIXME handle auto links that must be followed if possible
var enableNextLink = true;
var hasElseScope = false;
var hasElseEnable = false;
Array.prototype.forEach.call(e.childNodes, function(c) {
if (/sectionref$/.test(c.className)) {
if (enableNextLink) {
@ -92,7 +93,12 @@
} else {
gamebook.disableLink(c);
}
enableNextLink = true;
if (hasElseScope) {
enableNextLink = hasElseEnable;
hasElseScope = false;
} else {
enableNextLink = true;
}
} else if (c.className === 'collect') {
gamebook.player.collect(c.dataset.type, c.dataset.name);
} else if (c.className === 'add') {
@ -109,6 +115,11 @@
c.dataset.what);
console.log("has not " + c.dataset.type +
" " + c.dataset.what + " " + enableNextLink);
} else if (c.className === 'haselse') {
enableNextLink = gamebook.player.has(c.dataset.type,
c.dataset.what);
hasElseScope = true;
hasElseEnable = !enableNextLink;
}
});
},

View file

@ -0,0 +1,2 @@
<span class="haselse" data-type="%(arg1)s"
data-what="%(inner)s">%(inner)s</span>

View file

@ -0,0 +1 @@
\textit{%(inner)s}

View file

@ -1,4 +1,4 @@
* TODO [24/48] [50%]
* TODO [25/53] [47%]
- [X] Debug output
- [X] DOT output
- [X] LaTeX output
@ -27,7 +27,8 @@
- [X] Make inventory and codewords generic
They are the same, sort of, and it might be good to be able to
add other similar entities as well, like skills or spells or whatever.
- [ ] Otherwise/else handling for has (or has not).
- [X] Otherwise/else handling for has.
- [ ] Disable all links after finding an auto link (that is enabled).
- [ ] Book option to set pdf layout (page size and number of columns)
- [ ] Book option to set title
- [ ] Book option to set author