mirror of
https://github.com/Oreolek/gamebookformat.git
synced 2024-06-26 03:41:04 +03:00
Xor (ex-haselse) and Auto modifiers on secrion references.
This commit is contained in:
parent
ec7a054d42
commit
18c76ce0b0
|
@ -13,22 +13,35 @@ 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 [[haselsetest]].
|
||||
Otherwise see [[xortest]].
|
||||
|
||||
* notsofun
|
||||
This is just to demonstrate choices allowed when not
|
||||
having a codeword. Now go on to [[haselsetest]].
|
||||
having a codeword. Now go on to [[autotest]] (autotest)
|
||||
or [[xortest]] (xor test).
|
||||
|
||||
* autotest
|
||||
If you have codeword [has code]warrior[/has] turn to
|
||||
[[auto noautotest]].
|
||||
Otherwise you can go to the end at [[the_end]] or back to
|
||||
[[start]].
|
||||
|
||||
* noautotest
|
||||
If you have the codeword [has code]fun[/has] turn
|
||||
to [[auto cheater]].
|
||||
Otherwise you can go to the end at [[the_end]] or to the
|
||||
xortest at [[xortest]].
|
||||
|
||||
* cheater
|
||||
Cheater! There is no way you can have codeword fun.
|
||||
|
||||
* haselsetest
|
||||
OK, if you have the codeword [haselse code]warrior[/has],
|
||||
* xortest
|
||||
OK, if you have the codeword [has code]warrior[/has],
|
||||
you may turn to
|
||||
[[auto the_end]] otherwise you may go back to [[second]]. Although
|
||||
[[xor 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]].
|
||||
If you have the codeword [has code]fun[/has] you may turn
|
||||
to [[xor cheater]], without it you can go to [[notsofun]].
|
||||
|
||||
* the_end
|
||||
That was easy.
|
||||
|
|
|
@ -34,6 +34,7 @@ class OutputFormat (object):
|
|||
def format_section(self, section, references):
|
||||
i = 0
|
||||
res = ""
|
||||
# FIXME refactor for readability once good tests are in place
|
||||
while i < len(section.text):
|
||||
ref_start = section.text.find('[[', i)
|
||||
tag_start = section.text.find('[', i)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
[HAS ELSE %(arg1)s]%(inner)s[/HAS]
|
1
templates/html/auto.html
Normal file
1
templates/html/auto.html
Normal file
|
@ -0,0 +1 @@
|
|||
<span class="auto"></span>
|
|
@ -84,21 +84,23 @@
|
|||
|
||||
'runActions' : function(e) {
|
||||
var enableNextLink = true;
|
||||
var hasElseScope = false;
|
||||
var hasElseEnable = false;
|
||||
var hasXorScope = false;
|
||||
var hasAutoScope = false;
|
||||
var xorEnableNext = false;
|
||||
var autoDisableAllRemainingLinks = false;
|
||||
Array.prototype.forEach.call(e.childNodes, function(c) {
|
||||
if (/sectionref$/.test(c.className)) {
|
||||
if (enableNextLink) {
|
||||
if (enableNextLink && !autoDisableAllRemainingLinks) {
|
||||
gamebook.enableLink(c);
|
||||
if (hasAutoScope) {
|
||||
autoDisableAllRemainingLinks = true;
|
||||
}
|
||||
} else {
|
||||
gamebook.disableLink(c);
|
||||
}
|
||||
if (hasElseScope) {
|
||||
enableNextLink = hasElseEnable;
|
||||
hasElseScope = false;
|
||||
} else {
|
||||
enableNextLink = true;
|
||||
}
|
||||
enableNextLink = !(hasXorScope && !xorEnableNext);
|
||||
hasAutoScope = false;
|
||||
hasXorScope = false;
|
||||
} else if (c.className === 'collect') {
|
||||
gamebook.player.collect(c.dataset.type, c.dataset.name);
|
||||
} else if (c.className === 'add') {
|
||||
|
@ -115,11 +117,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;
|
||||
} else if (c.className === 'xor') {
|
||||
hasXorScope = true;
|
||||
xorEnableNext = !enableNextLink;
|
||||
} else if (c.className === 'auto') {
|
||||
hasAutoScope = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
<span class="haselse" data-type="%(arg1)s"
|
||||
data-what="%(inner)s">%(inner)s</span>
|
1
templates/html/xor.html
Normal file
1
templates/html/xor.html
Normal file
|
@ -0,0 +1 @@
|
|||
<span class="xor"></span>
|
|
@ -1 +0,0 @@
|
|||
\textit{%(inner)s}
|
9
todo.org
9
todo.org
|
@ -1,4 +1,4 @@
|
|||
* TODO [25/53] [47%]
|
||||
* TODO [27/59] [45%]
|
||||
- [X] Debug output
|
||||
- [X] DOT output
|
||||
- [X] LaTeX output
|
||||
|
@ -28,12 +28,15 @@
|
|||
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.
|
||||
- [X] Otherwise/else handling for has.
|
||||
- [ ] Disable all links after finding an auto link (that is enabled).
|
||||
- [X] Redesign otherwise/else to use xor tag on section reference.
|
||||
- [X] Disable all links after finding an auto link (that is enabled).
|
||||
- [ ] Default templates. (templates/default?)
|
||||
- [ ] Book option to set pdf layout (page size and number of columns)
|
||||
- [ ] Book option to set title
|
||||
- [ ] Book option to set author
|
||||
- [ ] Book option to set date
|
||||
- [ ] Quote strings to not break formatting.
|
||||
- [ ] Include other templates from a template.
|
||||
- [ ] Template for book introduction (including rules etc)
|
||||
Sections with some markup (has number 0?) are added as chapters
|
||||
of introduction, otherwise formatted identical to other sections.
|
||||
|
@ -56,6 +59,8 @@
|
|||
- [ ] Buy (optionally decrease a counter to add something to a collection)
|
||||
- [ ] Sell (optionally increase a counter to drop something to a collection)
|
||||
- [ ] Pick a (maximum) number of things from those found in a section
|
||||
- [ ] Macros for input(quests etc etc). Generate one or more sections.
|
||||
- [ ] Macros that can add content to sections (pre or post).
|
||||
- [ ] Some way to insert character sheet in book introduction
|
||||
- [ ] Some way to insert dice at bottom of pages for LaTeX
|
||||
- [ ] Some way to insert optional random numbers table at end of book
|
||||
|
|
Loading…
Reference in a new issue