Global last_called = 1; Global explicit_flag = 0; Global tickets_taken = 0; Class Ticket(6) with number -1, name "ticket", description [; if (self.number==2306) "It is labelled ~First Prize~!"; if (self.number==5802) "It is labelled ~Nineteenth Prize~."; "~You lose,~ says the ticket, with a smily face. ~Try again!~"; ], short_name [; if (self.number==-1) rfalse; print "lottery ticket ", self.number; rtrue; ], parse_name [ i j w; i=0; if (NextWord()=='lottery') i++; else wn--; if (NextWord()=='tickets') { parser_action=##PluralFound; return i+1; } else wn--; if (NextWord()~='ticket') return 0; i++; w=TryNumber(wn); if (w==-1000) { explicit_flag = false; return i; } if (w==0) return 0; if (self.number==-1) { objectloop(j ofclass Ticket) if (w == j.number) return 0; } else { if (self.number~=w) return 0; } i++; last_called = w; explicit_flag = true; return i; ], before [; Examine: if (self in board) "It would be cheating to see what's written on the curled up tickets still in the board."; Cast: "~Get outta here, bub!~, the barker says, disgusted."; ]; Place Bazaar "Crowded Bazaar" with description "This is a crowded, noisy bazaar. Directly in front of you is a lottery! But the contemptuous-looking barker is doing a very poor trade: hardly anyone wants his first prize, the big cuddly toy elephant, or even his nineteenth prize, a featureless white cube.", each_turn [; switch(random(4)) { 1: "^~Roll up! Roll up! One silver piece for three goes!~"; 2: "^~Come on, then! Just a silver coin gets you three!~"; 3: "^~Think what you could win, all for one silver coin!~"; 4: "^~This could be your lucky day!~"; } ], before [; Learn: "~None of that!~ snaps the barker angrily, putting you off your study habits. He mutters about ~Enchanter cheats~, but under the circumstances you decide to let the insult pass."; ], cant_go "Everywhere, the crowds of jabbering natives block your way to all the good stalls. In fact, the only one you can get at is this dismal lottery."; Object -> board "lottery board" with credit 0, name "board" "lottery" "holes", description "There are a hundred holes each way, making, um, let's see, yes, ten thousand tickets in all. Still, there are nineteen prizes, so your odds must be, oh, well, not too awful anyway.", before [ i; LetGo: if (self.credit == 0) "The barker stabs you in the chest with his finger. ~That's a silver coin to you, bub!~"; if (explicit_flag) { objectloop (i ofclass Ticket) if (last_called == i.number) "That ticket's already taken."; } else { .RandomChoice; last_called = random(10000); objectloop (i ofclass Ticket) if (last_called == i.number) jump RandomChoice; } tickets_taken++; self.credit--; i = Ticket.create(); if (i == 0) "The barker looks metaphysically embarrassed. ~Um, Inform's object creation system seems not to have worked.~"; i.number = last_called; itobj = i; move i to player; give i moved proper; if (explicit_flag==0) print "Randomly picking from the ", 10001-tickets_taken, " numbered holes with tickets in, you "; else print "You "; print_ret "take ", (the) i, " out of the board."; Examine: ; Receive: if (noun ofclass Ticket) "~No changes of mind, that's your ticket now! Give it to me if you want to play it.~"; <>; default: "The barker is burly, and won't let you tamper with the board."; ], initial "Behind the barker is a huge drilled board, and inside each little numbered hole is a rolled-up lottery ticket." has static container open; Ticket -> -> ticket_in_board "rolled-up ticket from the board" with article "a"; Object -> barker "barker" with name "barker" "burly" "man", number 0, description "A boxer gone to seed who failed as a magician all down the coast, that'd be your guess.", life [; Attack, Kiss: "No way. He must weigh twice what you do."; Ask: switch(noun) { 'prize', 'prizes': "~Just one silver coin and a prize could be yours!~"; 'white', 'featureless', 'cube': "He blows the dust off it. ~Genuine antique, that.~"; 'elephant', 'toy', 'cuddly': "~Good quality merchandise,~ he says, in a way that suggests he can only spell one of those three words."; 'ticket', 'tickets', 'lottery': "~Three tickets for one silver coin!~"; default: "~Just play the game, bub.~"; } Order, Answer: "The barker glowers at you."; Give: if (noun ofclass Ticket) { remove noun; if (noun.number==2306) { move elephant to player; give elephant moved; remove pelephant; Bazaar.description = "This is a crowded, noisy bazaar. Directly in front of you is the lottery!"; "With very bad grace, the barker shoves the cuddly toy elephant into your arms."; } if (noun.number==5802) { move barker_cube to player; give barker_cube moved; remove pcube; Bazaar.description = "This is a crowded, noisy bazaar. Directly in front of you is the lottery!"; score=score+5; "With concealed relief, the barker shoves the featureless white cube into your hands."; } "~Bad luck! You lose!~"; } if (self.number==2) "~You've had enough goes already!~ he growls. No wonder trade is bad."; if (~~(noun ofclass Coin)) "~What do you call that? One silver coin to play!~"; if ((noun.&name)-->0 == 'bronze') "~Bronze! Not a chance, sunshine.~"; remove noun; board.credit = board.credit + 3; self.number++; if ((noun.&name)-->0 == 'gold') "Gleefully the barker snatches the gold coin. ~Sorry bub, no change. Business is slack today!~"; "Grudgingly the barker takes the silver coin and stands back to let you at the board, arms folded."; ], before [; Cast: switch(the_spell_was) { bozbar_spell: "He's not that much of an animal."; lobal_spell: "His problem is listening, not hearing."; caskly_spell: "For a moment his hair seems to comb itself. Irritated, he ruffles it again, and the spell dies an ignominious death."; yomin_spell: if (elephant has moved || barker_cube has moved) "The barker's mind is a heap of grumbles about lost prizes and scrawny Enchanters."; if (self hasnt general) { give self general; "~Hope that scrawny Enchanter doesn't pick 2306!~ thinks the barker (slowly)."; } "~If that mark does win, hope it's only worthless old 5802,~ ponders the barker."; } ], has animate scenery; Object -> prizes "prizes" with name "prize" "prizes", before [; "~Hands off those prizes!~"; ], has scenery; Object -> pelephant "prize elephant" with name "prize" "elephant" "cuddly" "toy", description "Pink, cuddly, toy, elephant. Says it all, really.", before [; Examine: ; default: "~Hands off those prizes!~"; ], has scenery; Object -> pcube "prize cube" with name "prize" "featureless" "white" "cube", description "Wouldn't you like to win it?", before [; Examine: ; default: "~Hands off those prizes!~"; ], has scenery; Object elephant "cuddly toy elephant" with name "cuddly" "toy" "elephant", description "Pink, cuddly, toy, elephant. Says it all, really.", before [; Cast: if (the_spell_was == bozbar_spell) "Let me get this straight. You, the enchanter who defeated Krill, the head of the Borphee Guild himself... are attempting to grow wings on a pink cuddly elephant?"; if (the_spell_was == yomin_spell) "Woolly."; ]; FeaturelessCube barker_cube "cube";