classScenedefenter()puts"This scene is not yet configured. Subclass it and implement enter()."exit(1)endendclassEnginedefinitialize(scene_map)@scene_map=scene_mapenddefplay()current_scene=@scene_map.opening_scene()last_scene=@scene_map.next_scene('finished')whilecurrent_scene!=last_scenenext_scene_name=current_scene.enter()current_scene=@scene_map.next_scene(next_scene_name)end# be sure to print out the last scenecurrent_scene.enter()endendclassDeath<Scene@@quips=["You died. You kinda suck at this.","Your mom would be proud...if she were smarter.","Suck a luser.","I have a small puppy that's better at this.",]defenter()puts@@quips[rand(0..(@@quips.length-1))]exit(1)endendclassCentralCorridor<Scenedefenter()puts"'Hello!' A red dog says,"puts"\n"puts"'What are you doing here?'\n"print"> "action=$stdin.gets.chompifaction=="shoot!"puts"The dog avoid the bullet."puts"And shoot you with his eye."puts"You dead."return'death'elsifaction=="tell a joke"puts"You say:'Catch the ball!'"puts"The dog run away."return'laser_weapon_armory'elseputs"The dog says:'Get out!'"return'central_corridor'endendendclassLaserWeaponArmory<Scenedefenter()puts"enter 1 numbers:"code="#{rand(1..9)}"print"[keypad]> "guess=$stdin.gets.chompguesses=1whileguess!=code&&guesses<5puts"Wrong!"guesses+=1print"[keypad]> "guess=$stdin.gets.chompendifguess==codeputs"The door open."puts"You see a bridge."return'the_bridge'elseputs"Huge fire out from the door!\n"puts"You die."return'death'endendendclassTheBridge<Scenedefenter()puts"A large potato lies on the road.\n"puts"How you go through?\n"print"> "action=$stdin.gets.chompifaction=="throw the bomb"puts"The potato explode and the piece hit you."return'death'elsifaction=="slowly place the bomb"puts"You placed the bomb and run away."puts"You successfully sweep out the potato."return'escape_pod'elseputs"Nothing happened."return"the_bridge"endendendclassEscapePod<Scenedefenter()puts"There are 5 pods."good_pod=rand(1..5)print"[pod #]> "guess=$stdin.gets.chomp.to_iifguess!=good_podputs"Nothing happened.\n"puts"10 days passed, you dead."return'death'elseputs"win!"return'finished'endendendclassFinished<Scenedefenter()puts"Good job!"endendclassMap@@scenes={'central_corridor'=>CentralCorridor.new(),'laser_weapon_armory'=>LaserWeaponArmory.new(),'the_bridge'=>TheBridge.new(),'escape_pod'=>EscapePod.new(),'death'=>Death.new(),}definitialize(start_scene)@start_scene=start_sceneenddefnext_scene(scene_name)val=@@scenes[scene_name]returnvalenddefopening_scene()returnnext_scene(@start_scene)endenda_map=Map.new('central_corridor')a_game=Engine.new(a_map)a_game.play()