Created
October 16, 2012 18:33
-
-
Save brkane/3901109 to your computer and use it in GitHub Desktop.
SimpleDelegator space_merchant?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# space_merchant | |
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + '/../lib') | |
require 'space_merchant' | |
include SpaceMerchant | |
player = SpaceMerchant::Player.instance | |
puts | |
puts "Welcome to Space Merchant #{SpaceMerchant::VERSION}, " + | |
"the Ruby Quiz game!" | |
puts | |
print "What would you like to be called, pilot? " | |
loop do | |
name = gets.chomp | |
if name =~ /\S/ | |
player[:name] = name | |
puts "#{player[:name]} it is." | |
puts | |
puts "May you find fame and fortune here in the Ruby Galaxy..." | |
puts | |
break | |
else | |
print "Please enter a name: " | |
end | |
end | |
player[:credits] = 1000 | |
# we initialize player[:location], it should be changed to move the player | |
player[:location] = SpaceMerchant::Galaxy.instance.starting_location | |
catch(:quit) do | |
# primary event loop | |
loop { player[:location].handle_event(player) } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# space_merchant.rb | |
require 'singleton' | |
require 'delegate' | |
module SpaceMerchant | |
VERSION = "1.0" | |
# We will use a basic Hash, but feel free to add methods to it | |
class Player | |
include Singleton | |
def initialize | |
@game_data = SimpleDelegator.new({}) | |
end | |
end | |
end | |
require 'space_merchant/galaxy' | |
require 'space_merchant/sector' | |
require 'space_merchant/station' | |
require 'space_merchant/planet' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try