1
0
Fork 0
mirror of https://github.com/Oreolek/gamebookformat.git synced 2024-04-29 23:59:22 +03:00

Added test for listing only sections with some tag.

Noted that unfortunately a missingto setting is required for this to work,
and the missingto section will be included in the list.
Not ideal perhaps for things like listening todo-tagged sections.
This commit is contained in:
Pelle Nilsson 2014-02-28 22:59:10 +01:00
parent a144e3cc94
commit df7ea9838a
9 changed files with 320 additions and 1 deletions

View file

@ -0,0 +1,87 @@
title = Items
author = Pelle Nilsson
missingto = end_todo
= Info
This file is for testing the list option.
This section should not be listed.
Using the options given in the options file for this gamebook,
only the sections tagged as todo will 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 :todo:
(This section needs some work!)
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 :todo:
Need to write this section.
Sorry for it being a dead-end for now.
* 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]].
* end_todo :todo:
There has to be a section set as missingto (ie this section), otherwise
generating a list with only todo sections will fail (as one of them
references non-todo sections). Unfortunate side-effect is that this
section will always be included in the list.
TODO figure out some fix for this.

View file

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

View file

@ -0,0 +1,11 @@
BEGIN DEBUG OUTPUT
Book title: Items
Number of sections: 3
Info
This file is for testing the list option. This section should not be listed. Using the options given in the options file for this gamebook, only the sections tagged as todo will be listed.
Turn to 1 to begin.
1 (end_todo) - There has to be a section set as missingto (ie this section), otherwise generating a list with only todo sections will fail (as one of them references non-todo sections). Unfortunate side-effect is that this section will always be included in the list. TODO figure out some fix for this.
2 (curse) - Need to write this section. Sorry for it being a dead-end for now.
3 (tjunction) - (This section needs some work!) Here you find a [FOUND item]key[/FOUND] and a [FOUND item]stick[/FOUND]. You can go west to 1, or east to 2.
END DEBUG OUTPUT

View file

@ -0,0 +1,4 @@
digraph gamebook {
3->1
3->2
}

101
expected/itemstaglist.html Normal file
View file

@ -0,0 +1,101 @@
<!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 = 'itemstaglist';
}
</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. Using the options given in the options file for this gamebook, only the sections tagged as todo will 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">
There has to be a section set as missingto (ie this section), otherwise generating a list with only todo sections will fail (as one of them references non-todo sections). Unfortunate side-effect is that this section will always be included in the list. TODO figure out some fix for this.
</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">
Need to write this section. Sorry for it being a dead-end for now.
</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">
(This section needs some work!) 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="1"
href="#section1">1</a>, or east to <a class="sectionref enabledlink" data-ref="2"
href="#section2">2</a>.
</div>
</div>
<script>
if (typeof gamebook !== 'undefined') {
gamebook.addSection(3, document.getElementById('section3'));
}
</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>

41
expected/itemstaglist.rtf Normal file
View file

@ -0,0 +1,41 @@
{\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. Using the options given in the options file for this gamebook, only the sections tagged as todo will be listed. \
\
\b Turn to 1 to begin.
\b0\
\
\b \qc 1
\b0\
\ql There has to be a section set as missingto (ie this section), otherwise generating a list with only todo sections will fail (as one of them references non-todo sections). Unfortunate side-effect is that this section will always be included in the list. TODO figure out some fix for this. \
\
\b \qc 2
\b0\
\ql Need to write this section. Sorry for it being a dead-end for now. \
\
\b \qc 3
\b0\
\ql (This section needs some work!) Here you find a key and a stick. You can go west to \b 1
\b0
, or east to \b 2
\b0
. \
\
}

67
expected/itemstaglist.tex Normal file
View file

@ -0,0 +1,67 @@
\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. Using the options given in the options file for this gamebook, only the sections tagged as todo will be listed.
\vspace{1em}
Turn to 1 to begin.
\phantomsection
\refstepcounter{sectionnr}
\label{section1}
\subsection*{\begin{center} \textbf{1} \end{center}}
\noindent
There has to be a section set as missingto (ie this section), otherwise generating a list with only todo sections will fail (as one of them references non-todo sections). Unfortunate side-effect is that this section will always be included in the list. TODO figure out some fix for this.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section2}
\subsection*{\begin{center} \textbf{2} \end{center}}
\noindent
Need to write this section. Sorry for it being a dead-end for now.
\vspace{1em}
\phantomsection
\refstepcounter{sectionnr}
\label{section3}
\subsection*{\begin{center} \textbf{3} \end{center}}
\noindent
(This section needs some work!) Here you find a \textbf{key} and a \textbf{stick}. You can go west to \textbf{\autoref{section1}}, or east to \textbf{\autoref{section2}}.
\vspace{1em}
\end{document}

View file

@ -0,0 +1,3 @@
1 end_todo
2 curse
3 tjunction

View file

@ -1,4 +1,4 @@
* TODO [56/79] [70%]
* TODO [56/80] [70%]
** DONE Debug output
** DONE DOT output
** DONE LaTeX output
@ -129,6 +129,10 @@
** TODO Higher level text-language for Gamebooks
** TODO BGG forum output (.bgg)
** TODO Verify gamebook
** TODO Fix broken references in list option output for some tag
When using the list option, and only including only sections for a tag,
there currently has to be a missingto section, and that section is always
listed even if it is not tagged.
** TODO Add json output file containing sections, counters, collections etc.
This output format down-prioed because requires some changes to handle new-lines.
All previously supported formats handles new-lines in text without problems, JSON do not.