mirror of
https://github.com/Oreolek/gamebookformat.git
synced 2024-06-26 03:41:04 +03:00
Fixed bugs in importing and exporting map file with sections not in gamebook.
This commit is contained in:
parent
d886b26210
commit
d10177efd6
15
sections.py
15
sections.py
|
@ -19,9 +19,9 @@ class Section:
|
|||
|
||||
def format(self, references):
|
||||
pass
|
||||
|
||||
|
||||
class ShuffledSections:
|
||||
def __init__(self, as_list, from_nr, to_nr, from_name):
|
||||
def __init__(self, as_list, from_nr, to_nr, from_name, nr_sections):
|
||||
self.as_list = as_list
|
||||
self.from_nr = from_nr
|
||||
self.to_nr = to_nr
|
||||
|
@ -29,6 +29,8 @@ class ShuffledSections:
|
|||
self.name_to_nr = {}
|
||||
for n in from_name:
|
||||
self.name_to_nr[n] = to_nr[from_name[n]]
|
||||
for nr in nr_sections:
|
||||
self.name_to_nr[nr_sections[nr]] = nr
|
||||
|
||||
class Book:
|
||||
def __init__(self):
|
||||
|
@ -61,10 +63,12 @@ class Book:
|
|||
to_nr = {}
|
||||
shuffled = self.sections[:]
|
||||
for p in self.nr_sections.values():
|
||||
shuffled.remove(self.from_name[p])
|
||||
if p in self.from_name:
|
||||
shuffled.remove(self.from_name[p])
|
||||
random.shuffle(shuffled)
|
||||
for nr in range(1, self.max + 1):
|
||||
if self.nr_sections.has_key(nr):
|
||||
if (self.nr_sections.has_key(nr)
|
||||
and self.nr_sections[nr] in self.from_name):
|
||||
section = self.from_name[self.nr_sections[nr]]
|
||||
elif len(shuffled):
|
||||
section = shuffled.pop()
|
||||
|
@ -74,7 +78,8 @@ class Book:
|
|||
from_nr[nr] = section
|
||||
if section:
|
||||
to_nr[section] = nr
|
||||
return ShuffledSections(as_list, from_nr, to_nr, self.from_name.copy())
|
||||
return ShuffledSections(as_list, from_nr, to_nr, self.from_name.copy(),
|
||||
self.nr_sections)
|
||||
|
||||
class Item (object):
|
||||
def __init__(self, name):
|
||||
|
|
12
todo.org
12
todo.org
|
@ -1,4 +1,4 @@
|
|||
* TODO [21/47] [44%]
|
||||
* TODO [23/47] [48%]
|
||||
- [X] Debug output
|
||||
- [X] DOT output
|
||||
- [X] LaTeX output
|
||||
|
@ -22,11 +22,8 @@
|
|||
- [X] Enable link if not having an item
|
||||
- [X] Enable link if not having a codeword
|
||||
- [X] Make sure dropped items can not be picked up again
|
||||
- [ ] 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.
|
||||
- [ ] Fix problem with map file from other book sometimes crashing formatter
|
||||
- [ ] Keys from formatted book should be added to map file, not replace it
|
||||
- [X] Fix problem with map file from other book sometimes crashing formatter
|
||||
- [X] Keys from formatted book should be added to map file, not replace it
|
||||
- [ ] More formatting possibilities in sections
|
||||
Look at existing gamebooks to get ideas.
|
||||
- [ ] Book option to set max section number to use
|
||||
|
@ -51,3 +48,6 @@
|
|||
- [ ] Document Gamebook format
|
||||
- [ ] HTML CSS
|
||||
- [ ] Higher level text-language for Gamebooks
|
||||
- [ ] 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.
|
||||
|
|
Loading…
Reference in a new issue