! ---------------------------------------------------------------------------- ! Balances 961216 One of the standard Inform 6 example games ! ! created: 25.9.94 ! updated: 6.10.94 ! modernised: 11.12.95 ! translated to Inform 6: 8.5.96 ! minor bugs fixed: 16.12.96 ! ! This short story was written to demonstrate large-scale programming of ! the parser, and features multiple objects, complicated plurals, variable ! verbs, objects named by the player and questions. The spell-casting ! system is written in a "safe" way so that it could easily be transplanted. ! ! Needs Inform 6, library 6/1 or later to compile. ! ---------------------------------------------------------------------------- Release 5; Serial "961216"; Switches d; Constant Story "BALANCES"; Constant Headline "^An Interactive Short Story ^Copyright (c) 1994, 1995, 1996 by Graham Nelson.^"; Constant OBJECT_SCORE 5; Constant MAX_SCORE 51; Include "Parser"; Include "VerbLib"; ! ---------------------------------------------------------------------------- ! The white featureless cubes from "Spellbreaker", which can be identified ! by being written on with the magic burin, so that their names are given ! by the player in the course of play ! ! A particularly witty thing to do is to give several of them the same name, ! or to frotz some of them to distinguish them from the others... ! And the game will have no problem with this. ! ---------------------------------------------------------------------------- Array cube_text_buffer -> 8; Global the_named_word = 0; Global from_char; Global to_char; Class FeaturelessCube with number 0 0 0 0, ! There's room for 8 bytes of text in these 4 entries description "A perfect white cube, four inches on a side.", parse_name [ i j flag; if (parser_action==##TheSame) { for (i=0:i<8:i++) if ((parser_one.&number)->i ~= (parser_two.&number)->i) return -2; return -1; } for (::i++) { j=NextWord(); flag=0; if (j=='cube' or 'white' || (j=='featureless' or 'blank' && ((self.&number)->0) == 0)) flag=1; if (j=='cubes') { flag=1; parser_action=##PluralFound; } if (flag==0 && ((self.&number)->0) ~= 0) { wn--; if (TextReader(0)==0) return i; for (j=0: j<8: j++) if ((self.&number)->j ~= cube_text_buffer->j) return i; flag=1; } if (flag==0) return i; } ], article "a", short_name [ i; if (((self.&number)->0) == 0) print "featureless white cube"; else { print "~"; while (((self.&number)->i) ~= 0) print (char) (self.&number)->i++; print "~ cube"; } rtrue; ], plural [; self.short_name(); print "s"; ], baptise [ i; wn = the_named_word; if (TextReader(1)==0) return i; for (i=0: i<8: i++) (self.&number)->i = cube_text_buffer->i; self.article="the"; print_ret "It is now called ", (the) self, "."; ], has scored; ! Copies word "wn" from what the player most recently typed, putting it as ! plain text into cube_text_buffer, returning false if no such word is there [ TextReader flag point i j len; if (flag==1 && from_char~=to_char) { for (i=from_char, j=0:i<=to_char && j<7:i++) { cube_text_buffer->j = buffer->i; if (buffer->i ~= ' ' or ',' or '.') j++; } for (:j<8:j++) cube_text_buffer->j = 0; from_char=0; to_char=0; rtrue; } for (i=0:i<8:i++) cube_text_buffer->i = 0; if (wn > parse->1) { wn++; rfalse; } i=wn*4+1; j=parse->i; point=j+buffer; len=parse->(i-1); for (i=0:ii = point->i; wn++; rtrue; ]; Object burin "magic burin" with name "magic" "magical" "burin" "pen", description "This is a magical burin, used for inscribing objects with words or runes of magical import. Such a burin also gives you the ability to write spell scrolls.", before [; WriteOn: if (second ofclass FeaturelessCube) { if (second notin player) "Writing on a cube is such a fiddly process that you need to be holding it in your hand first."; if (burin notin player) "You would need some powerful implement for that."; second.baptise(); rtrue; } if (second ofclass SpellBook) "If a burin could write in a spell book, you wouldn't need the gnusto spell!"; if (second ofclass Scroll) "You cannot write just anything on the magic parchment of a scroll: you can only ~copy~ a spell to it."; ]; [ WriteOnSub; "Graffiti is banned."; ]; [ CopyToSub; if (burin notin player) "You need to be holding the burin to copy a spell."; if (second ofclass SpellBook) "If a burin could write in a spell book, you wouldn't need the gnusto spell!"; if (~~(second ofclass Scroll)) "You can only copy spells to scrolls."; if (child(second)~=0) "The scroll is already full of incantation."; "The scroll is not blank, only illegible."; ];