Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Version bump to 0.2.2

  • Loading branch information...
commit 4722272ef7d212c90e4014cb74c67a5b3a931a35 1 parent 4f7d419
@jwoertink authored
View
9 README.rdoc
@@ -39,15 +39,11 @@ Options are normally numbers 1 through 5 or so.
== Current Issues
-* Current Location is updated before flying away
* All drugs are always available
-* Not tested on windows
* Battles with DEA agents are skewed and you're most likely to lose :(
-* Need some text updates to help you figure out what choices to make
* No way to exit game mid way
* Drugs stay in your bag after you've sold them all
-* Drug prices change after purchasing them even in the same city. They should only change per day
-* Not able to take from your savings more than what's in your wallet >_<
+* Standardize color scheme
== Upgrades
@@ -57,4 +53,5 @@ Options are normally numbers 1 through 5 or so.
* Allow purchasing of weapons, and bags (maybe other items)
* Fluctuating interest rates depending on which city you start in
* Fight more than 1 agent at a time
-* Large bonus for killing an agent
+* Large bonus for killing an agent
+* Implement time restraints
View
2  VERSION
@@ -1 +1 @@
-0.2.1
+0.2.2
View
6 lib/application.rb
@@ -1,12 +1,12 @@
require 'win32console' if RUBY_PLATFORM =~ /mingw/
require 'highline/import'
require 'utilities'
-require 'game'
+require 'city'
require 'player'
require 'drug'
require 'bank'
require 'agent'
-
+require 'game'
module Application
extend Utilities
@@ -14,7 +14,7 @@ module Application
# This just kicks off the application.
def self.run!
echo(Utilities::GAME_TITLE, :green, 0)
- key = ask("[S]tart a new game or [Q]uit?") { |q| q.echo = true }
+ key = ask("[S]tart a new game or [Q]uit?")
if key.downcase.eql?('s')
player_name = ask(game_text(:greeting))
View
2  lib/bank.rb
@@ -5,7 +5,7 @@ class Bank
def initialize
@loan_amount = 0
@savings_account = 0
- @interest = 1.5
+ @interest = 0.25
end
def increase_loan(amount)
View
21 lib/city.rb
@@ -0,0 +1,21 @@
+class City
+ attr_accessor :name, :drugs
+
+ LOCATIONS = ["Las Vegas", "New York", "Miami", "Amsterdam", "Frankfurt", "El-Jazier"]
+
+ def initialize(options = {})
+ @name = options[:name] ||= LOCATIONS.sort_by { rand }.first
+ gather_drugs
+ end
+
+ def gather_drugs
+ @drugs = []
+ @drugs += Drug::TYPES.collect { |d| Drug.new({name: d, price: market_price_for_drug, quantity: 0}) }
+ end
+
+ # currently returns a random number
+ def market_price_for_drug
+ rand(500) + 10
+ end
+
+end
View
8 lib/drug.rb
@@ -3,16 +3,14 @@ class Drug
TYPES = ["weed", "ecstacy", "shrooms", "oxycotin", "acid", "ruffies", "crack", "cocaine", "heroin", "crystal meth"]
- def self.street_price
- rand(500) + 10
- end
-
def initialize(defaults = {})
defaults.each_pair { |key,value| instance_variable_set("@#{key}", value) }
+ @sellable = true
end
def can_be_sold?
- true
+ @sellable
end
+
end
View
107 lib/game.rb
@@ -1,8 +1,6 @@
class Game
include Utilities
- LOCATIONS = ["Las Vegas", "New York", "Miami", "Amsterdam", "Frankfurt", "El-Jazier"]
-
def initialize(defaults = {})
defaults.each_pair { |key,value| instance_variable_set("@#{key}", value) }
end
@@ -21,21 +19,21 @@ def days_remaining
#Maybe this should be moved?
def select_menu(menu_option)
- case menu_option
- when "1"
+ case menu_option.to_i
+ when 1
buyers_menu
- when "2"
+ when 2
sellers_menu
- when "3"
+ when 3
airport_menu
- when "4"
+ when 4
bank_menu
- when "5"
+ when 5
check_stats_menu
else
- echo(game_text(:bad_selection), :red)
+ echo(game_text(:bad_selection), :red, 0)
echo(game_text(:main_menu), :blue, 0)
- menu_option = ask("Select your option:")
+ menu_option = ask("Select your option: ", Integer) { |q| q.in = 1..5 }
select_menu(menu_option)
end
end
@@ -44,27 +42,24 @@ def buyers_menu
echo(game_text(:buyers_menu), :blue, 0)
available_options = []
drugs = []
- Drug::TYPES.each_with_index do |drug, select_number|
- dime_bag = Drug.new({name: drug, price: Drug.street_price, quantity: 0})
- drugs << dime_bag
- max_amount = @player.wallet / dime_bag.price
- echo("#{select_number + 1}. #{dime_bag.name} @ $#{dime_bag.price} {#{max_amount}}", :cyan, 0)
+ @current_location.drugs.each_with_index do |drug, select_number|
+ drugs << drug
+ max_amount = @player.wallet / drug.price
+ echo("#{select_number + 1}. #{drug.name} @ $#{drug.price} {#{max_amount}}", :cyan, 0)
available_options << (select_number + 1)
end
loop do
- menu_option = ask("Select your option:")
- if (menu_option =~ /\d+/).to_i >= 0 and available_options.include?(menu_option.to_i)
- drug = drugs[menu_option.to_i - 1]
- amount = ask("How Many?")
- decrease = (drug.price * amount.to_i)
- if @player.can_buy_drug?(drug.price, amount.to_i)
- @player.add_to_drugs({drug.name => amount.to_i})
- @player.wallet -= decrease
- echo("You have $#{@player.wallet} left.", :cyan)
- break
- else
- echo("You can't buy that many.", :red)
- end
+ menu_option = ask("Select your option: ", Integer) { |q| q.in = available_options.map(&:to_i) }
+ drug = drugs[menu_option.to_i - 1]
+ amount = ask("How Many? ", Integer) { |q| q.above = 0 }
+ decrease = (drug.price * amount.to_i)
+ if @player.can_buy_drug?(drug.price, amount.to_i)
+ @player.add_to_drugs({drug.name => amount.to_i})
+ @player.wallet -= decrease
+ echo("You have $#{@player.wallet} left.", :cyan)
+ break
+ else
+ echo("You can't buy that many.", :red)
end
end
end
@@ -74,27 +69,23 @@ def sellers_menu
i = 0
drugs = []
@player.drugs.each_pair do |drug, amount|
- dime_bag = Drug.new({name: drug, price: Drug.street_price, quantity: amount})
+ dime_bag = Drug.new({name: drug, price: @current_location.market_price_for_drug, quantity: amount})
echo("#{i + 1}. #{dime_bag.name} x #{dime_bag.quantity} @ $#{dime_bag.price}ea", :cyan, 0)
drugs << dime_bag
i +=1
end
loop do
- menu_option = ask("Select your option:")
- if (menu_option =~ /\d+/).to_i >= 0 and (0..i).to_a.include?(menu_option.to_i)
- drug = drugs[menu_option.to_i - 1]
- amount = ask("How many?")
- if amount.to_i <= @player.drugs[drug.name]
- @player.remove_from_drugs({drug.name => amount.to_i})
- increase = drugs[menu_option.to_i - 1].price * amount.to_i
- @player.wallet += increase
- echo("You made $#{increase}", :cyan)
- break
- else
- echo("You can't sell more then #{drug.quantity} of #{drug.name}.", :red, 0)
- end
+ menu_option = ask("Select your option: ", Integer) { |q| q.in = 0..i }
+ drug = drugs[menu_option - 1]
+ amount = ask("How many? ", Integer)
+ if amount.to_i <= @player.drugs[drug.name]
+ @player.remove_from_drugs({drug.name => amount.to_i})
+ increase = drugs[menu_option.to_i - 1].price * amount.to_i
+ @player.wallet += increase
+ echo("You made $#{increase}", :cyan)
+ break
else
- echo("You must select an option", :red, 0)
+ echo("You can't sell more then #{drug.quantity} of #{drug.name}.", :red, 0)
end
end
end
@@ -102,21 +93,17 @@ def sellers_menu
def airport_menu
city_options = ""
available_options = []
- Game::LOCATIONS.each_with_index do |city, select_number|
- next if @current_location.eql?(city)
+ City::LOCATIONS.each_with_index do |city, select_number|
+ next if @current_location.name.eql?(city)
available_options << (select_number + 1)
city_options += "#{select_number + 1}. #{city}\n"
end
- echo(game_text(:airport_menu, {current_city: @current_location ,city_options: city_options}), :blue, 0)
+ echo(game_text(:airport_menu, {current_city: @current_location.name ,city_options: city_options}), :blue, 0)
loop do
- menu_option = ask("Select your option:")
- if (menu_option =~ /\d+/).to_i >= 0 and available_options.include?(menu_option.to_i)
- @current_location = Game::LOCATIONS[menu_option.to_i - 1]
- echo("You fly to #{@current_location}", :cyan)
- break
- else
- echo("You must select an option", :red, 0)
- end
+ menu_option = ask("Select your option: ", Integer) { |q| q.in = available_options.map(&:to_i) }
+ @current_location = City.new(name: City::LOCATIONS[menu_option.to_i - 1])
+ echo("You fly to #{@current_location.name}", :cyan)
+ break
end
@player.end_turn!
@@ -128,7 +115,7 @@ def bank_menu
loop do
case menu_option
when "1" # Take out a loan
- amount = ask("How much?")
+ amount = ask("How much do you need?")
@player.wallet += amount.to_i
@player.bank_account.increase_loan(amount.to_i)
echo("You now have $#{@player.wallet}", :cyan)
@@ -144,7 +131,8 @@ def bank_menu
break
end
when "3" # Put money into savings
- amount = ask("How much?")
+ puts "You have $#{@player.wallet} on you."
+ amount = ask("How much do you want to deposit?")
if amount.to_i > @player.wallet
echo("Sorry, you don't have that much money.", :red)
else
@@ -153,8 +141,9 @@ def bank_menu
break
end
when "4" # Take money from savings
- amount = ask("How much?")
- if amount.to_i > @player.wallet
+ puts "You have $#{@player.bank_account.savings_account} in savings."
+ amount = ask("How much do you want to take out?")
+ if amount.to_i > @player.bank_account.savings_account
echo("Sorry, you don't have that much money.", :red)
else
@player.wallet += amount.to_i
@@ -172,7 +161,7 @@ def bank_menu
def check_stats_menu
echo(game_text(:check_stats_menu), :blue, 0)
- str = "Current Location: #{@current_location}\n"
+ str = "Current Location: #{@current_location.name}\n"
str << "Days remaining: #{days_remaining}\n"
echo(@player.stats << str, :yellow)
end
View
4 lib/player.rb
@@ -96,7 +96,7 @@ def start_turn!
def end_turn!
bank_account.add_daily_interest
- battle_agent if agent_encounter?
+ battle_agent if encounter_agent?
@end_of_turn = true
end
@@ -104,7 +104,7 @@ def end_of_turn?
@end_of_turn
end
- def agent_encounter?
+ def encounter_agent?
Agent.near_by?
end
View
4 lib/utilities.rb
@@ -4,7 +4,7 @@ module Utilities
GAME_TITLE = <<-MSG
******************
-* Dopewars v1.1
+* Dopewars v#{File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))}
*
******************
MSG
@@ -16,7 +16,7 @@ def echo(message, colour = :white, wait_time = 2)
end
def game_defaults
- {playable: true, days: 30, current_day: 0, current_location: Game::LOCATIONS.sort_by { rand }.first}
+ {playable: true, days: 30, current_day: 0, current_location: City.new}
end
def game_text(key, vars = {})
View
5 text.yml
@@ -10,7 +10,7 @@ game:
3. Fly to a new city\n
4. Go to the bank.\n
5. Check stats."
- bad_selection: "You must choose a menu option"
+ bad_selection: "You must choose an available menu option"
check_stats_menu:
"**********************\n******* STATS ********\n**********************"
bank_menu:
@@ -21,8 +21,7 @@ game:
4. Take money from savings.\n
5. Leave"
airport_menu:
- "********************\n***** AIRPORT ******\n********************\nYou are currently in %{current_city}.\nWhich City would you like to fly to?\n
- %{city_options}"
+ "********************\n***** AIRPORT ******\n********************\nYou are currently in %{current_city}.\nWhich City would you like to fly to?\n%{city_options}"
sellers_menu:
"**********************\n**** SELL DRUGS ******\n**********************\nWhich of your drugs would you like to sell?"
buyers_menu:
Please sign in to comment.
Something went wrong with that request. Please try again.