X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=newdungeon.py;h=68dbc39b1130c13d697758aa1dab9a03a2167015;hb=e49ba9fb2bae5fa4cba7342f952f77565eef837f;hp=87ac249850a58072dada4a6291f59d2169e023a1;hpb=4ac41aa14808e0ed9e6cbeaacf90f9465ef4380e;p=open-adventure.git diff --git a/newdungeon.py b/newdungeon.py index 87ac249..68dbc39 100755 --- a/newdungeon.py +++ b/newdungeon.py @@ -3,8 +3,48 @@ # This is the new open-adventure dungeon generator. It'll eventually # replace the existing dungeon.c It currently outputs a .h and .c pair # for C code. - -import yaml +# +# The nontrivial part of this is the compilation of the YAML for +# movement rules to the travel array that's actually used by +# playermove(). This program first compiles the YAML to a form +# identical to the data in section 3 of the old adventure.text file, +# then a second stage packs that data into the travel array. +# +# Here are the rules of the intermediate form: +# +# Each row of data contains a location number (X), a second +# location number (Y), and a list of motion numbers (see section 4). +# each motion represents a verb which will go to Y if currently at X. +# Y, in turn, is interpreted as follows. Let M=Y/1000, N=Y mod 1000. +# If N<=300 it is the location to go to. +# If 300500 message N-500 from section 6 is printed, +# and he stays wherever he is. +# Meanwhile, M specifies the conditions on the motion. +# If M=0 it's unconditional. +# If 0