Sha256: 87d83e72ed109dc0313da75a10da5126c6dc03f765d337602fb614b99ebc3d99
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
module Degica class Game def initialize # setup rooms rooms = RoomLoader.load # spawn actor in random room starting_room = rooms.sample @actor = Actor.new(starting_room) # game objects @@objects = OpenStruct.new(rooms: rooms, actor: @actor) # generate starting room starting_room.generate! end def self.objects @@objects end def start ANSI.clear_screen puts "Welcome to" puts ANSI.highlight(File.read(Degica.root + '/data/images/degica_quest.txt'), :yellow) puts "Type (actions) to see what actions you can perform.".highlight puts "\n" + @@objects.actor.describe + "\n\n" loop do input = Readline.readline("#{prompt}> ", true) exit if input == "exit" begin context = Context.new(@actor) case output = context.instance_eval(input) when String # remove quotes in console i.e. > "string" puts output when Actionable @actor.focus = output message = output.describe puts message unless message.nil? when NilClass puts @actor.describe else puts CodeRay.scan(output.inspect, :ruby).terminal end rescue Exception => e puts e.message end puts end end private def prompt @actor.focus&.prompt end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
degica-1.0.0 | lib/degica/game.rb |