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

New list option.

This commit is contained in:
Pelle Nilsson 2014-02-28 22:18:56 +01:00
parent 3ace9a743a
commit 51798b3928
15 changed files with 635 additions and 0 deletions

View file

@ -0,0 +1,79 @@
title = Items
author = Pelle Nilsson
= Info
This file is for testing the list option.
This section should not be listed.
* 1 start
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]] or go to the autotest at [[autotest]].
* tjunction
You have reached a t-junction.
Here you find a [found item]key[/found]
and a [found item]stick[/found].
You can go west to [[door]], or
east to [[curse]].
* door
There is a locked door here.
If you have a [has item]key[/has] you can use that to
open the door, see [[inside]]. Being right before the link
should be enough for the formatter to figure out that the
key is required to be allowed to follow the link.
Else you can try to open with the [has item]sword[/has],
if you have it, see [[attempt_break_door_with_sword]].
Hopefully the magic is good enough to pair
pre-conditions to links, or more markup must be added later.
You could also try to go back to pick up the key, see [[tjunction]].
* attempt_break_door_with_sword
OK. The door is broken, but so is the [drop item]sword[/drop].
Turn to [[inside]].
* curse
There is a [found item]cursed bracelet[/found] here. You can go on to
[[portal]] or go back to [[tjunction]]. You can also drop the
[has item]stick[/has] for no particular reason if you have it,
see [[drop_stick]].
* drop_stick
OK [drop item]stick[/drop] dropped. Turn back to [[tjunction]] to confirm
stick can not be picked up again even if the text says it is there
(books work that way, although ideally this dynamic version should
provide some hints that it is no longer there).
* portal
A magic portal ahead will only allow you to pass if you did not pick up the
[hasnot item]cursed bracelet[/hasnot], leading you to [[treasure]].
If you have the [has item]cursed bracelet[/has]
you have to go back to [[tjunction]] instead.
Actually feel free to head back to [[tjunction]] either way.
* treasure
You found [found item]something valuable[/found], but there is no way forward,
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
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

@ -0,0 +1 @@
--option list

20
expected/itemslist.debug Normal file
View file

@ -0,0 +1,20 @@
BEGIN DEBUG OUTPUT
Book title: Items
Number of sections: 12
Info
This file is for testing the list option. This section should not be listed.
Turn to 1 to begin.
1 (start) - 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 12 or go to the autotest at 2.
2 (autotest) - If you have the [HAS item]stick[/HAS] then you must turn immediately to ((automatic))12, 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 ((automatic))5, again ignoring everything that follows. You drop the [DROP item]something valuable[/DROP] here if you have it, then go on to 7.
3 (won) - Congratulations, you won.
4 (cut_rope) - OK. That was fun. Turn to 3.
5 (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 4. You can also run to the autotest at 2. Otherwise turn to 3.
6 (treasure) - You found [FOUND item]something valuable[/FOUND], but there is no way forward, so you head back to 12.
7 (portal) - A magic portal ahead will only allow you to pass if you did not pick up the [HAS NOT item]cursed bracelet[/HAS NOT], leading you to 6. If you have the [HAS item]cursed bracelet[/HAS] you have to go back to 12 instead. Actually feel free to head back to 12 either way.
8 (drop_stick) - OK [DROP item]stick[/DROP] dropped. Turn back to 12 to confirm stick can not be picked up again even if the text says it is there (books work that way, although ideally this dynamic version should provide some hints that it is no longer there).
9 (curse) - There is a [FOUND item]cursed bracelet[/FOUND] here. You can go on to 7 or go back to 12. You can also drop the [HAS item]stick[/HAS] for no particular reason if you have it, see 8.
10 (attempt_break_door_with_sword) - OK. The door is broken, but so is the [DROP item]sword[/DROP]. Turn to 5.
11 (door) - There is a locked door here. If you have a [HAS item]key[/HAS] you can use that to open the door, see 5. Being right before the link should be enough for the formatter to figure out that the key is required to be allowed to follow the link. Else you can try to open with the [HAS item]sword[/HAS], if you have it, see 10. Hopefully the magic is good enough to pair pre-conditions to links, or more markup must be added later. You could also try to go back to pick up the key, see 12.
12 (tjunction) - You have reached a t-junction. Here you find a [FOUND item]key[/FOUND] and a [FOUND item]stick[/FOUND]. You can go west to 11, or east to 9.
END DEBUG OUTPUT

25
expected/itemslist.dot Normal file
View file

@ -0,0 +1,25 @@
digraph gamebook {
1->12
1->2
2->12
2->5
2->7
4->3
5->4
5->2
5->3
6->12
7->6
7->12
7->12
8->12
9->7
9->12
9->8
10->5
11->5
11->10
11->12
12->11
12->9
}

226
expected/itemslist.html Normal file
View file

@ -0,0 +1,226 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Items</title>
<script type="text/javascript" src="gamebookformatplay.js"></script>
<link rel="stylesheet" href="gamebookformat.css"
type="text/css" />
<script>
if (typeof gamebook !== 'undefined') {
gamebook.id = 'itemslist';
}
</script>
</head>
<body>
<div class="hideintrolink nodisplay"
onclick="gamebook.hideIntroSections()">(hide instructions)</div>
<div class="gamebook">
<div class="introsection">
<div class="introsectionheading">Info</div>
<div class="introsectionbody">
This file is for testing the list option. This section should not be listed.
</div>
</div>
<div class="resumelink nodisplay"
onclick="gamebook.loadGame()">Resume saved game.</div>
<div class="startlink"
onclick="gamebook.turnTo(1)">Turn to 1 to begin.</div>
<script>
if (typeof gamebook !== 'undefined' && gamebook.hasSavedGame()) {
var resumeLinks = document.getElementsByClassName('resumelink');
Array.prototype.forEach.call(resumeLinks, function(e) {
e.classList.remove('nodisplay');
});
}
</script>
<div class="section" id="section1">
<div class="sectionnumber" id="para1">1</div>
<div class="sectiontext">
Demonstrating how to manage player <span class="collect" data-type="item"
data-name="Inventory">Inventory</span>. You start the book carrying a <span class="add" data-type="item"
data-what="sword">sword</span> and a <span class="add" data-type="item"
data-what="shield">shield</span>. Turn to <a class="sectionref enabledlink" data-ref="12"
href="#section12">12</a> or go to the autotest at <a class="sectionref enabledlink" data-ref="2"
href="#section2">2</a>.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(1, document.getElementById('section1'));
}
</script><div class="section" id="section2">
<div class="sectionnumber" id="para2">2</div>
<div class="sectiontext">
If you have the <span class="has" data-type="item" data-what="stick">stick</span> then you must turn immediately to <span class="auto"></span><a class="sectionref enabledlink" data-ref="12"
href="#section12">12</a>, and everything else in this section is ignored. You find a <span class="add" data-type="item"
data-what="book">book</span> here. If you have the <span class="has" data-type="item" data-what="sword">sword</span> you must turn immediately to <span class="auto"></span><a class="sectionref enabledlink" data-ref="5"
href="#section5">5</a>, again ignoring everything that follows. You drop the <span class="drop" data-type="item"
data-what="something valuable">something valuable</span> here if you have it, then go on to <a class="sectionref enabledlink" data-ref="7"
href="#section7">7</a>.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(2, document.getElementById('section2'));
}
</script><div class="section" id="section3">
<div class="sectionnumber" id="para3">3</div>
<div class="sectiontext">
Congratulations, you won.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(3, document.getElementById('section3'));
}
</script><div class="section" id="section4">
<div class="sectionnumber" id="para4">4</div>
<div class="sectiontext">
OK. That was fun. Turn to <a class="sectionref enabledlink" data-ref="3"
href="#section3">3</a>.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(4, document.getElementById('section4'));
}
</script><div class="section" id="section5">
<div class="sectionnumber" id="para5">5</div>
<div class="sectiontext">
There is a rope here that can be cut using a <span class="has" data-type="item" data-what="sword">sword</span>. If you have one and want to do that, see <a class="sectionref enabledlink" data-ref="4"
href="#section4">4</a>. You can also run to the autotest at <a class="sectionref enabledlink" data-ref="2"
href="#section2">2</a>. Otherwise turn to <a class="sectionref enabledlink" data-ref="3"
href="#section3">3</a>.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(5, document.getElementById('section5'));
}
</script><div class="section" id="section6">
<div class="sectionnumber" id="para6">6</div>
<div class="sectiontext">
You found <span class="found enabledlink" data-type="item"
data-what="something valuable"
>something valuable</span>
, but there is no way forward, so you head back to <a class="sectionref enabledlink" data-ref="12"
href="#section12">12</a>.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(6, document.getElementById('section6'));
}
</script><div class="section" id="section7">
<div class="sectionnumber" id="para7">7</div>
<div class="sectiontext">
A magic portal ahead will only allow you to pass if you did not pick up the <span class="hasnot" data-type="item"
data-what="cursed bracelet">cursed bracelet</span>, leading you to <a class="sectionref enabledlink" data-ref="6"
href="#section6">6</a>. If you have the <span class="has" data-type="item" data-what="cursed bracelet">cursed bracelet</span> you have to go back to <a class="sectionref enabledlink" data-ref="12"
href="#section12">12</a> instead. Actually feel free to head back to <a class="sectionref enabledlink" data-ref="12"
href="#section12">12</a> either way.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(7, document.getElementById('section7'));
}
</script><div class="section" id="section8">
<div class="sectionnumber" id="para8">8</div>
<div class="sectiontext">
OK <span class="drop" data-type="item"
data-what="stick">stick</span> dropped. Turn back to <a class="sectionref enabledlink" data-ref="12"
href="#section12">12</a> to confirm stick can not be picked up again even if the text says it is there (books work that way, although ideally this dynamic version should provide some hints that it is no longer there).
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(8, document.getElementById('section8'));
}
</script><div class="section" id="section9">
<div class="sectionnumber" id="para9">9</div>
<div class="sectiontext">
There is a <span class="found enabledlink" data-type="item"
data-what="cursed bracelet"
>cursed bracelet</span>
here. You can go on to <a class="sectionref enabledlink" data-ref="7"
href="#section7">7</a> or go back to <a class="sectionref enabledlink" data-ref="12"
href="#section12">12</a>. You can also drop the <span class="has" data-type="item" data-what="stick">stick</span> for no particular reason if you have it, see <a class="sectionref enabledlink" data-ref="8"
href="#section8">8</a>.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(9, document.getElementById('section9'));
}
</script><div class="section" id="section10">
<div class="sectionnumber" id="para10">10</div>
<div class="sectiontext">
OK. The door is broken, but so is the <span class="drop" data-type="item"
data-what="sword">sword</span>. Turn to <a class="sectionref enabledlink" data-ref="5"
href="#section5">5</a>.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(10, document.getElementById('section10'));
}
</script><div class="section" id="section11">
<div class="sectionnumber" id="para11">11</div>
<div class="sectiontext">
There is a locked door here. If you have a <span class="has" data-type="item" data-what="key">key</span> you can use that to open the door, see <a class="sectionref enabledlink" data-ref="5"
href="#section5">5</a>. Being right before the link should be enough for the formatter to figure out that the key is required to be allowed to follow the link. Else you can try to open with the <span class="has" data-type="item" data-what="sword">sword</span>, if you have it, see <a class="sectionref enabledlink" data-ref="10"
href="#section10">10</a>. Hopefully the magic is good enough to pair pre-conditions to links, or more markup must be added later. You could also try to go back to pick up the key, see <a class="sectionref enabledlink" data-ref="12"
href="#section12">12</a>.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(11, document.getElementById('section11'));
}
</script><div class="section" id="section12">
<div class="sectionnumber" id="para12">12</div>
<div class="sectiontext">
You have reached a t-junction. Here you find a <span class="found enabledlink" data-type="item"
data-what="key"
>key</span>
and a <span class="found enabledlink" data-type="item"
data-what="stick"
>stick</span>
. You can go west to <a class="sectionref enabledlink" data-ref="11"
href="#section11">11</a>, or east to <a class="sectionref enabledlink" data-ref="9"
href="#section9">9</a>.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(12, document.getElementById('section12'));
}
</script> <div id="counters" class="counters">
</div>
<div id="counterTemplate" class="counterTemplate">
<span class="counterheading"></span>
<span class="countercontents"></span>
</div>
</div>
<div id="collections" class="collections">
</div>
<div id="collectionTemplate" class="collectionTemplate">
<span class="collectionheading"></span>
<span class="collectioncontents"></span>
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.prepare();
}
</script>
<div class="displayintrolink nodisplay"
onclick="gamebook.showIntroSections()">(show instructions)</div>
</div>
</body>
</html>

128
expected/itemslist.rtf Normal file
View file

@ -0,0 +1,128 @@
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww14140\viewh14860\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
\f0\b\fs24 \cf0
\b \qc Items
\b0\
\
\b \qc Info
\b0\
\ql This file is for testing the list option. This section should not be listed. \
\
\b Turn to 1 to begin.
\b0\
\
\b \qc 1
\b0\
\ql Demonstrating how to manage player Inventory. You start the book carrying a sword and a shield. Turn to \b 12
\b0
or go to the autotest at \b 2
\b0
. \
\
\b \qc 2
\b0\
\ql If you have the stick then you must turn immediately to \b 12
\b0
, and everything else in this section is ignored. You find a book here. If you have the sword you must turn immediately to \b 5
\b0
, again ignoring everything that follows. You drop the something valuable here if you have it, then go on to \b 7
\b0
. \
\
\b \qc 3
\b0\
\ql Congratulations, you won. \
\
\b \qc 4
\b0\
\ql OK. That was fun. Turn to \b 3
\b0
. \
\
\b \qc 5
\b0\
\ql There is a rope here that can be cut using a sword. If you have one and want to do that, see \b 4
\b0
. You can also run to the autotest at \b 2
\b0
. Otherwise turn to \b 3
\b0
. \
\
\b \qc 6
\b0\
\ql You found something valuable, but there is no way forward, so you head back to \b 12
\b0
. \
\
\b \qc 7
\b0\
\ql A magic portal ahead will only allow you to pass if you did not pick up the cursed bracelet, leading you to \b 6
\b0
. If you have the cursed bracelet you have to go back to \b 12
\b0
instead. Actually feel free to head back to \b 12
\b0
either way. \
\
\b \qc 8
\b0\
\ql OK stick dropped. Turn back to \b 12
\b0
to confirm stick can not be picked up again even if the text says it is there (books work that way, although ideally this dynamic version should provide some hints that it is no longer there). \
\
\b \qc 9
\b0\
\ql There is a cursed bracelet here. You can go on to \b 7
\b0
or go back to \b 12
\b0
. You can also drop the stick for no particular reason if you have it, see \b 8
\b0
. \
\
\b \qc 10
\b0\
\ql OK. The door is broken, but so is the sword. Turn to \b 5
\b0
. \
\
\b \qc 11
\b0\
\ql There is a locked door here. If you have a key you can use that to open the door, see \b 5
\b0
. Being right before the link should be enough for the formatter to figure out that the key is required to be allowed to follow the link. Else you can try to open with the sword, if you have it, see \b 10
\b0
. Hopefully the magic is good enough to pair pre-conditions to links, or more markup must be added later. You could also try to go back to pick up the key, see \b 12
\b0
. \
\
\b \qc 12
\b0\
\ql You have reached a t-junction. Here you find a key and a stick. You can go west to \b 11
\b0
, or east to \b 9
\b0
. \
\
}

142
expected/itemslist.tex Normal file
View file

@ -0,0 +1,142 @@
\documentclass[a5paper,onecolumn]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[hidelinks]{hyperref}
\usepackage{graphicx}
\usepackage[top=3.3cm, bottom=3.3cm, left=2cm, right=2cm]{geometry}
\newif\ifpdf
\ifx\pdfoutput\undefined
\pdffalse
\else
\ifnum\pdfoutput=1
\pdftrue
\else
\pdffalse
\fi
\fi
\title{Items}
\author{Pelle Nilsson}
\date{}
\newcounter{sectionnr}
\begin{document}
\maketitle
\clearpage
\thispagestyle{empty}
\pagestyle{empty}
\subsection*{\begin{center} \textbf{Info} \end{center}}
\noindent
This file is for testing the list option. This section should not be listed.
\vspace{1em}
Turn to 1 to begin.
\phantomsection
\refstepcounter{sectionnr}
\label{section1}
\subsection*{\begin{center} \textbf{1} \end{center}}
\noindent
Demonstrating how to manage player Inventory. You start the book carrying a \textbf{sword} and a \textbf{shield}. Turn to \textbf{\autoref{section12}} or go to the autotest at \textbf{\autoref{section2}}.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section2}
\subsection*{\begin{center} \textbf{2} \end{center}}
\noindent
If you have the \textit{stick} then you must turn immediately to \textbf{\autoref{section12}}, and everything else in this section is ignored. You find a \textbf{book} here. If you have the \textit{sword} you must turn immediately to \textbf{\autoref{section5}}, again ignoring everything that follows. You drop the \textit{something valuable}
here if you have it, then go on to \textbf{\autoref{section7}}.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section3}
\subsection*{\begin{center} \textbf{3} \end{center}}
\noindent
Congratulations, you won.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section4}
\subsection*{\begin{center} \textbf{4} \end{center}}
\noindent
OK. That was fun. Turn to \textbf{\autoref{section3}}.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section5}
\subsection*{\begin{center} \textbf{5} \end{center}}
\noindent
There is a rope here that can be cut using a \textit{sword}. If you have one and want to do that, see \textbf{\autoref{section4}}. You can also run to the autotest at \textbf{\autoref{section2}}. Otherwise turn to \textbf{\autoref{section3}}.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section6}
\subsection*{\begin{center} \textbf{6} \end{center}}
\noindent
You found \textbf{something valuable}, but there is no way forward, so you head back to \textbf{\autoref{section12}}.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section7}
\subsection*{\begin{center} \textbf{7} \end{center}}
\noindent
A magic portal ahead will only allow you to pass if you did not pick up the \textit{cursed bracelet}, leading you to \textbf{\autoref{section6}}. If you have the \textit{cursed bracelet} you have to go back to \textbf{\autoref{section12}} instead. Actually feel free to head back to \textbf{\autoref{section12}} either way.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section8}
\subsection*{\begin{center} \textbf{8} \end{center}}
\noindent
OK \textit{stick}
dropped. Turn back to \textbf{\autoref{section12}} to confirm stick can not be picked up again even if the text says it is there (books work that way, although ideally this dynamic version should provide some hints that it is no longer there).
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section9}
\subsection*{\begin{center} \textbf{9} \end{center}}
\noindent
There is a \textbf{cursed bracelet} here. You can go on to \textbf{\autoref{section7}} or go back to \textbf{\autoref{section12}}. You can also drop the \textit{stick} for no particular reason if you have it, see \textbf{\autoref{section8}}.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section10}
\subsection*{\begin{center} \textbf{10} \end{center}}
\noindent
OK. The door is broken, but so is the \textit{sword}
. Turn to \textbf{\autoref{section5}}.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section11}
\subsection*{\begin{center} \textbf{11} \end{center}}
\noindent
There is a locked door here. If you have a \textit{key} you can use that to open the door, see \textbf{\autoref{section5}}. Being right before the link should be enough for the formatter to figure out that the key is required to be allowed to follow the link. Else you can try to open with the \textit{sword}, if you have it, see \textbf{\autoref{section10}}. Hopefully the magic is good enough to pair pre-conditions to links, or more markup must be added later. You could also try to go back to pick up the key, see \textbf{\autoref{section12}}.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section12}
\subsection*{\begin{center} \textbf{12} \end{center}}
\noindent
You have reached a t-junction. Here you find a \textbf{key} and a \textbf{stick}. You can go west to \textbf{\autoref{section11}}, or east to \textbf{\autoref{section9}}.
\vspace{1em}
\end{document}

12
expected/itemslist.txt Normal file
View file

@ -0,0 +1,12 @@
1 start
2 autotest
3 won
4 cut_rope
5 inside
6 treasure
7 portal
8 drop_stick
9 curse
10 attempt_break_door_with_sword
11 door
12 tjunction

View file

View file

View file

View file

@ -0,0 +1 @@
%(name)s (%(nr)d)

View file

@ -0,0 +1 @@
%(nr)d %(name)s

View file

View file