Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

restructing the whole game for a cleaner interface

  • Loading branch information...
commit ddc7b4f8a6c02ef2b755390b3684663606d96f34 1 parent e4ecbf7
@jwoertink authored
View
BIN  .DS_Store
Binary file not shown
View
1  .gitignore
@@ -0,0 +1 @@
+.DS_Store
View
1  .rvmrc
@@ -0,0 +1 @@
+rvm use 1.9.2@dopewars
View
2  Drug.rb
@@ -1,5 +1,3 @@
-require 'game'
-
class Drug
TYPES = ["weed", "ecstacy", "shrooms", "oxycotin", "acid", "ruffy", "crack", "cocaine", "heroin", "crystal meth"]
View
8 Game.rb
@@ -1,7 +1,3 @@
-require 'player'
-require 'drug'
-require 'bank'
-
class Game
LOCATIONS = ["Las Vegas", "New York", "Miami", "Amsterdam", "Frankfurt", "El-Jazier"]
@@ -44,4 +40,8 @@ def self.game_over
exit
end
+ def start!
+ puts "starting game"
+ end
+
end
View
3  Gemfile
@@ -0,0 +1,3 @@
+source "http://rubygems.org"
+
+gem "highline"
View
10 Gemfile.lock
@@ -0,0 +1,10 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ highline (1.6.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ highline
View
2  Player.rb
@@ -1,5 +1,3 @@
-require 'game'
-
class Player
attr_accessor :name, :drugs, :funds, :current_location, :days_remaining, :bank_account
View
24 README.rdoc
@@ -0,0 +1,24 @@
+= Dopewars v.1.1
+
+This is a Ruby port of the original dopewars/drugwars game.
+
+== Overview
+
+You are a drug dealer. Your goal is to buy and sell drugs and make money without being caught.
+You have 30 days to fly around the world making your purchases and selling your product.
+
+This is a one player game. As the player, your goal is to beat your previous score.
+You lose only if you get caught, or if you owe any money at the end of the game.
+
+Simple economy. Drug value is, to some degree, determined randomly by the day.
+
+== How to play
+
+ $ ruby dopewars.rb
+
+You will be walked through during gameplay. Type "S" to start, or "Q" to quit.
+
+
+== Installing
+
+ Clone the repo, or just copy down these files from Github
View
2  bank.rb
@@ -1,5 +1,3 @@
-require 'game'
-
class Bank
attr_accessor :loan_amount, :savings_account
View
111 dopewars.rb
@@ -1,51 +1,66 @@
-require "game"
+require 'rubygems'
+require 'bundler'
+Bundler.require
+require 'highline/import'
+Dir["#{File.expand_path(File.join(File.dirname(__FILE__)))}/*.rb"].each { |file| require file unless file.eql?(File.expand_path(__FILE__)) }
+include Utilities
-puts "Dopewars v1.0"
-puts "press 'S' to continue or any (other) key to quit."
-@game = Game.new
-answer = gets.chomp
-if answer.downcase.eql?('s')
- puts "Welcome new drug dealer, what is your name?"
- name = gets.chomp
- @player = Player.new(name)
- puts "Nice to meet you #{@player.name}. Here is $500.00 and some weed to get you started."
- sleep 2
- @player.add_to_drugs({"weed" => 5})
- @player.funds += 500
- puts "Now that you have that, there is one more thing you will need."
- sleep 2
- puts "Here is a special plane ticket, and boarding pass."
- sleep 2
- puts "This will allow you to travel to one of 6 special cities."
- sleep 2
- puts "You may also need this bag to carry stuff in. You have 30 days."
- sleep 3
- while @player.days_remaining > 0
- puts "What would you like to do?"
- puts "1. Buy drugs\n2. Sell drugs\n3. Fly to a new city\n4. Go to the bank.\n5. Check stats."
- puts "Select your option:"
- option = gets.chomp
- case option
- when 1.to_s
- @player.buy_drugs
- when 2.to_s
- @player.sell_drugs
- when 3.to_s
- @player.fly_to_city
- when 4.to_s
- @player.go_to_bank
- when 5.to_s
- @player.check_stats
- else
- puts "You must select a number 1 through 4"
- end
-
- @player.days_remaining -= 1
- @player.bank_account.add_daily_interest
- if Game.agent?
- Game.random_agent
- end
- end
+
+echo(Utilities::GAME_TITLE, :green, 0)
+key = ask("[S]tart a new game or [Q]uit?") { |q| q.echo = true }
+
+if key.downcase.eql?('s')
+ game = Game.new
+ game.start!
- puts "You've done it. You're now gangsta!"
+else
+ echo("Goodbye!", :red, 0)
+ exit
end
+
+
+# if answer.downcase.eql?('s')
+# puts "Welcome new drug dealer, what is your name?"
+# name = gets.chomp
+# @player = Player.new(name)
+# puts "Nice to meet you #{@player.name}. Here is $500.00 and some weed to get you started."
+# sleep 2
+# @player.add_to_drugs({"weed" => 5})
+# @player.funds += 500
+# puts "Now that you have that, there is one more thing you will need."
+# sleep 2
+# puts "Here is a special plane ticket, and boarding pass."
+# sleep 2
+# puts "This will allow you to travel to one of 6 special cities."
+# sleep 2
+# puts "You may also need this bag to carry stuff in. You have 30 days."
+# sleep 3
+# while @player.days_remaining > 0
+# puts "What would you like to do?"
+# puts "1. Buy drugs\n2. Sell drugs\n3. Fly to a new city\n4. Go to the bank.\n5. Check stats."
+# puts "Select your option:"
+# option = gets.chomp
+# case option
+# when 1.to_s
+# @player.buy_drugs
+# when 2.to_s
+# @player.sell_drugs
+# when 3.to_s
+# @player.fly_to_city
+# when 4.to_s
+# @player.go_to_bank
+# when 5.to_s
+# @player.check_stats
+# else
+# puts "You must select a number 1 through 4"
+# end
+#
+# @player.days_remaining -= 1
+# @player.bank_account.add_daily_interest
+# if Game.agent?
+# Game.random_agent
+# end
+# end
+#
+# puts "You've done it. You're now gangsta!"
+# end
View
13 dopewars.txt
@@ -1,13 +1,3 @@
-notes for "dope wars" game:
-
-Overview:
-You are a drug dealer. Your goal is to buy and sell drugs and make money without being caught.
-You have 30 days to fly around the world making your purchases and selling your product.
-
-This is a one player game, as the player, your goal is to beat your previous score.
-You lose only if you get caught, or if you owe any money.
-
-Simple economy. Drug value is, to some degree, determined randomly by the day (1..30).
Objects:
The player (you)
@@ -35,7 +25,7 @@ There are 10 types of drugs
3. cocaine
4. ecstasy
5. shrooms
- 6. ruffy
+ 6. ruffies
7. acid
8. crack
9. oxycotin
@@ -59,4 +49,3 @@ There are 3 bags
1. small back pack - holds 50 drugs and 1 weapon
2. briefcase - holds 100 drugs and 1 weapon
3. large case - holds 500 drugs and 2 weapons
-
View
17 utilities.rb
@@ -0,0 +1,17 @@
+module Utilities
+
+ GAME_TITLE = <<-MSG
+******************
+* Dopewars v1.1
+*
+******************
+MSG
+
+ def echo(message, colour, wait_time = 2)
+ const = ::HighLine.const_get(colour.to_s.upcase)
+ puts const
+ say("<%= color('#{message}', '#{const}') %>")
+ sleep wait_time
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.