! _Shade_ ! Special source-code edition ! Copyright 2000-2002 Andrew Plotkin ! http://www.eblong.com/zarf/if.html ! This source code is provided for personal, educational use only. ! See README file for details. Class FloorSand with name 'sand' 'sand', ! will be adjusted later short_name [; print "sand on the ", (string) self.self_word, " floor"; !print " ['", (address) (self.&name)-->0, ! "' '", (address) (self.&name)-->1, "']"; rtrue; ], parse_name [ wd gotsand num lastwd alt1 alt2 addr; addr = self.&name; alt1 = addr-->0; alt2 = addr-->1; wd = NextWord(); while (WordInProperty(wd, self.self_name, name) || wd == 'sand' or 'on' or 'in' or 'of' or 'floor' or alt1 or alt2) { if (wd == 'sand' or alt1 or alt2) gotsand = true; lastwd = wd; num++; wd = NextWord(); } if (~~gotsand) return 0; if (num > 0 && lastwd == 'on' or 'in') return num-1; return num; ], article "some", number 0, partinvent [; switch (self.number) { 0: print "[BUG] no sand"; 1: print "a trace of sand"; 2: print "a trail of sand"; 3: print "some sand"; 4: print "a thin layer of sand"; 5: print "a heavy layer of sand"; 6: print "an inch of sand"; 7: print "inches of sand"; 8: print "ankle-deep sand"; default: print "hills of sand"; } rtrue; ], description [; switch (self.number) { 0: "[BUG] No sand present"; 1: "A trace of sand is visible on the ", (string) self.self_word, " floor."; 2: "A trail of sand is visible on the ", (string) self.self_word, " floor."; 3: "Sand is spilled across the ", (string) self.self_word, " floor."; 4: "There is a thin layer of sand on the ", (string) self.self_word, " floor."; 5: "There is a heavy layer of sand on the ", (string) self.self_word, " floor."; 6: "Sand lies an inch deep across the ", (string) self.self_word, " floor."; 7: "Sand lies inches deep across the ", (string) self.self_word, " floor."; 8: "The sand on the ", (string) self.self_word, " floor is ankle-deep."; default: "Sand fills the ", (string) self.self_word, "."; } ], before [; Take: if (OIU(self)) rtrue; switch (self.number) { 0, 1, 2: print "You scrape up a pinch of sand"; default: print "You pick up a pinch of sand"; } ". It runs through your fingers; it's sand."; BlowOn: if (OIU(self)) rtrue; "A few grains of sand tumble away."; Push, Pull: if (OIU(self)) rtrue; print "You push the sand around with your foot."; if (self.number <= 4) print " It scrapes uncomfortably against the floor."; new_line; rtrue; Insert: if (OIU(self)) rtrue; if (second ~= glass) "That won't hold sand."; if (glass notin player) "You're not holding the glass."; if (sand in glass) "The glass is already full."; move sand to glass; PronounNotice(sand); if (self.number <= 2) print "You scrape together enough sand to fill the glass."; else print "You scoop up a glassful of sand."; if (water in glass) { remove water; print " The water in the glass turns cloudy as the sand falls in; then it seems to retreat, until the sand is as dry as that at your feet. Strange."; } new_line; rtrue; Drink, Taste: if (OIU(self)) rtrue; "You cannot drink sand."; Dig: if (OIU(self)) rtrue; switch (self.number) { 0 to 3: "There's hardly enough sand there to dig in."; 4 to 6: "You scrape the sand away until the floor shows. It wasn't an even layer to begin with, of course."; 7, 8: "You scrape the sand away until a bit of floor shows. But the sand pours back down as soon as you stop."; default: "You cannot seem to find the floor."; } Find: "It's hard to miss."; ], receive_sand [; <>; ], receive_water [; <>; ], has static; [ BumpSand obj newval addr; if (~~(obj ofclass FloorSand)) { switch (obj) { kitchen: obj = kitchensand; bathroom: obj = bathroomsand; shower: obj = showersand; Apartment: obj = livingsand; default: print_ret "[BUG] BumpSand(", (name) obj, ")"; } } if (obj notin obj.self_obj) { move obj to obj.self_obj; obj.self_obj.sand_obj = obj; } if (newval == 0) { obj.number++; } else { if (obj.number < newval) obj.number = newval; } addr = obj.&name; addr-->1 = 'sand'; switch (obj.number) { 0: addr-->0 = 'buggy'; 1: addr-->0 = 'trace'; 2: addr-->0 = 'trail'; 3: addr-->0 = 'some'; 4: addr-->0 = 'thin'; addr-->1 = 'layer'; 5: addr-->0 = 'heavy'; addr-->1 = 'layer'; 6: addr-->0 = 'inch'; 7: addr-->0 = 'inches'; 8: addr-->0 = 'ankle'; addr-->1 = 'deep'; default: addr-->0 = 'hills'; addr-->1 = 'hill'; } ]; FloorSand kitchensand with self_obj kitchen, self_name kitchen, self_word "kitchen"; FloorSand bathroomsand with self_obj bathroom, self_name bathroom, self_word "bathroom"; FloorSand livingsand with self_obj Apartment, self_name apartmentproxy, self_word "living room"; FloorSand showersand with self_obj shower, self_name shower, self_word "shower"; Class SandQuantity with description "The sand is white and pure.", before [; Take: if (OIU(self)) rtrue; print_ret "You take a pinch of sand from the ", (string) self.self_name, ", and let it trickle back."; BlowOn: if (OIU(self)) rtrue; "A few grains of sand tumble away."; Drink, Taste, Eat: if (OIU(self)) rtrue; "You cannot drink sand."; Drop: if (~~IndirectlyContains(player, self)) "You haven't got that."; "A bit of sand sifts out, but most of it seems to be solidly packed in."; Dig: if (OIU(self)) rtrue; "As far as you can tell, it's sand all the way down."; ], has scenery; SandQuantity jarsand "jarful of sand" with name 'jarful' 'of' 'sand', self_name "jar", before [; Empty, EmptyT: <>; ]; SandQuantity boxsand "boxful of sand" with name 'boxful' 'of' 'sand', self_name "box", before [; Empty, EmptyT: <>; ]; Class SinkSand class SandQuantity, with short_name [; print "sand in the ", (string) self.self_name; rtrue; ], parse_name [ wd gotsand num lastwd; wd = NextWord(); while (wd == self.self_word or 'sink' || wd == 'sand' or 'on' or 'in') { if (wd == 'sand') gotsand = true; lastwd = wd; num++; wd = NextWord(); } if (~~gotsand) return 0; if (num > 0 && lastwd == 'on' or 'in') return num-1; return num; ], article "some", before [; Insert: if (OIU(self)) rtrue; if (second ~= glass) "That won't hold sand."; if (glass notin player) "You're not holding the glass."; if (sand in glass) "The glass is already full."; move sand to glass; PronounNotice(sand); print "You scoop up a glassful of sand."; if (water in glass) { remove water; print " The water in the glass turns cloudy as the sand falls in; then it seems to retreat, until the sand is as dry as that in the sink. Strange."; } new_line; rtrue; EmptyT: <>; ], receive_water "You pour the water into the sink, where it soaks into the sand.", receive_sand "You add your sand to the sink's burden."; SinkSand kitchensinksand with self_word 'kitchen', self_name "kitchen sink"; SinkSand bathsinksand with self_word 'bathroom', self_name "bathroom sink"; SandQuantity sand "glassful of sand" with name 'glassful' 'of' 'sand', self_name "glass", before [ ix jx; Drop: if (~~IndirectlyContains(player, self)) "You haven't got that."; remove self; ix = FindFloorZone(player); if (ix) jx = ix.sand_obj; if (jx && jx.number >= 3) "The sand pours to the ground and is lost."; if (jx) { if (jx.number < 2) BumpSand(jx); } else { if (ix) BumpSand(ix); } "The sand scatters across the floor."; EmptyT: <>; Insert, PutOn: if (~~IndirectlyContains(player, self)) "You haven't got that."; if (second provides receive_sand) { if (OIU(second)) rtrue; ix = second.receive_sand(); if (ix) { if (ix ~= 2) remove self; rtrue; } } if (second == d_obj) <>; "Sand will do that no good."; ];