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

DOT templates no longer relying on hack to get refs.

Also fixed bug in template for img that resulted in filename being
visible in some output formats.
This commit is contained in:
Pelle Nilsson 2013-06-26 18:46:54 +02:00
parent 6897e5e11a
commit 0936c768c3
15 changed files with 59 additions and 100 deletions

View file

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

View file

@ -16,7 +16,8 @@ Turn to 1 to begin.
This is the end. There is nothing more in this gamebook.
3
Third section. Again, its number is not known. You can go to the end at 2. This section has an image to show the syntax for doing that (same as images in bgg forums really). testimage.png
Third section. Again, its number is not known. You can go to the end at 2. This section has an image to show the syntax for doing that (same as images in bgg forums really).
4
This is the second section. It may or may not end up with number 2 in the generated gamebook. From here you can skip to the 2 or go to the third section at 3.

View file

@ -1,32 +1,21 @@
digraph gamebook {
1->2
2->9
Codewords1->2
warrior2->9
warrior4->3
4->2
4->5
fun4->5
4->8
4->3
6->4
fun6->5
6->3
6->5
7->6
6->4
warrior7->6
7->3
7->1
8->4
8->7
9->3
9->8
9->5
8->4
warrior9->3
fun9->8
fun9->5
9->4
}

View file

@ -1,21 +1,15 @@
digraph gamebook {
1->6
1->7
Life PointsGold101201->7
1->6
3->7
4->7
5->7
55->7
5->6
6->7
7->5
16->7
217->2
7->6
7->3
7->4
7->2
7->5
167->3
167->4
}

View file

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

View file

@ -10,7 +10,8 @@ Another Heading
Adventure begins in section 1.
1
This examples tests gamebook formatting, not so much game mechanics or references. Currently there is nothing here really. This section contains some tricky characters to quote, like } and { and " and ' and \. HTML will probably not like <div> or &boom;. There should be an image below as well. If something broke, turn to 2, otherwise turn to 3. testimage.png
This examples tests gamebook formatting, not so much game mechanics or references. Currently there is nothing here really. This section contains some tricky characters to quote, like } and { and " and ' and \. HTML will probably not like <div> or &boom;. There should be an image below as well. If something broke, turn to 2, otherwise turn to 3.
2
Bad.

View file

@ -1,36 +1,26 @@
digraph gamebook {
1->12
Inventoryswordshield1->12
1->2
2->7
2->12
2->5
stick2->12
booksword2->5
something valuable2->7
4->3
sword5->4
5->2
5->4
5->3
6->12
7->6
something valuable6->12
cursed bracelet7->6
cursed bracelet7->12
7->12
8->12
stick8->12
cursed bracelet9->7
9->12
9->7
9->8
10->5
11->10
11->5
stick9->8
sword10->5
key11->5
sword11->10
11->12
keystick12->11
12->9
12->11
}

View file

@ -1,12 +1,9 @@
digraph gamebook {
1->399
1->400
1->400
1->399
Pick a destination at random399->400
399->397
399->400
399->398
400->397
}

View file

@ -1,4 +1,4 @@
digraph gamebook {
1->2
shield50chain mail150spiderweb1->2
}

View file

@ -1,9 +1,10 @@
digraph gamebook {
1->5
1->4
1->2
2->4
4->3
4->2
5->3
}

View file

@ -1,18 +1,13 @@
digraph gamebook {
1->8
1->7
1->5
1->7
1->8
3->5
5->2
5->4
6->4
5->2
6->5
6->4
6->2
7->4
8->6

View file

@ -35,8 +35,7 @@ class OutputFormat (object):
formatted_text = self.format_section_body(section, refsdict)
return self.format_with_template("introsection", {
'name' : section.name,
'text' : formatted_text,
'refs' : '\n'.join(refsdict.getfound()) # hack for DOT output
'text' : formatted_text
})
def format_sections_begin(self, bookconfig):
@ -63,8 +62,7 @@ class OutputFormat (object):
return self.format_with_template("section", {
'nr' : section.nr,
'name' : section.name,
'text' : formatted_text,
'refs' : '\n'.join(refsdict.getfound()) # hack for DOT output
'text' : formatted_text
})
def format_section_body(self, section, references):
@ -115,8 +113,7 @@ class OutputFormat (object):
elif tagname in COUNTER_USE_TAGS and len(tagparts) > 1:
if tagparts[1] in self.counter_names:
references['counter'] = self.counter_names[tagparts[1]]
f = self.format_with_template(tagname,
references)
f = self.format_with_template(tagname, references)
if len(f) > 0:
res += f
else:
@ -150,7 +147,6 @@ class ReferenceFormatter (object):
def __init__(self, from_nr, name_to_nr, missingto, ref_template, quote):
self.from_nr = from_nr
self.name_to_nr = name_to_nr
self.found = set()
self.ref_template = ref_template
self.items = {'nr' : from_nr}
self.quote = quote
@ -167,13 +163,8 @@ class ReferenceFormatter (object):
'nr' : to_nr,
'from_nr' : self.from_nr
}
if key in self.name_to_nr:
self.found.add(res)
return res
def getfound(self):
return list(self.found)
def __setitem__(self, key, value):
self.items[key] = value

View file

@ -0,0 +1 @@

View file

@ -1 +0,0 @@
%(refs)s

View file

@ -0,0 +1 @@
%(text)s