Skip to content

Commit

Permalink
Pushing atmogen
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea committed Nov 6, 2011
1 parent 74b8137 commit 8eacd2d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
20 changes: 20 additions & 0 deletions lib/vimcity/atmogen.rb
@@ -0,0 +1,20 @@
class AtmoGen < Building

def initialize
@symbol = ['o|o',
'|o|']
@height = 2
@width = 3
@cost = 1000
@capacity = 0
@workers_required = 30
@description = "Produces oxygen"
@bonuses = "Permits to expand your city on the planet, can store 2000 Oxygen units"
end

def add_to_city(city)
city.atmogen+=1
super(city)
end

end
8 changes: 4 additions & 4 deletions lib/vimcity/city.rb
Expand Up @@ -7,7 +7,7 @@ def initialize(coins=10000, population=0)
@coins = coins
@population = population
@population_cap = 0
@free_workers = 0
@free_workers = population
@money_per_second = 0
@people_per_second = 0
@oxygen = 1000
Expand All @@ -23,11 +23,11 @@ def update
@free_workers+=@people_per_second/12.5*@happiness
end

@oxygen -= @population
@oxygen -= @population/5

@coins -= @atmogen*10/12.5 if @oxygen < @atmogen.round*2000
@coins -= @atmogen*5/12.5 if @oxygen < @atmogen.round*2000

@oxygen += @atmogen*30/12.5 if @oxygen < @atmogen * 2000
@oxygen += @atmogen*100/12.5 if @oxygen < @atmogen * 2000
@oxygen=0 if @oxygen < 0

#@happiness-=0.001
Expand Down
2 changes: 1 addition & 1 deletion lib/vimcity/farm_a.rb
Expand Up @@ -8,7 +8,7 @@ def initialize
@width = 6
@cost = 1000
@capacity = 0
@workers_required = 20
@workers_required = 10
@description = "Produces purple grass, a desirable commodity"
@bonuses = "Goods sell for 2c a worker, maximum of 20"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vimcity/starport.rb
Expand Up @@ -8,7 +8,7 @@ def initialize
@width = 3
@cost = 2000
@capacity = 0
@workers_required = 40
@workers_required = 20
@description = "Allows for interstellar travel"
@bonuses = "Boosts your city's population"
end
Expand Down
25 changes: 21 additions & 4 deletions lib/vimcity/vim_city_game.rb
Expand Up @@ -103,16 +103,33 @@ def display_menu

def init_city
#load city stuff here when we get to it
@city = City.new()
@city = City.new(5000, 100)

house1 = Seitch.new()
house1.add_to_city(@city)
@map.add_building(house1,34, 24)
print_area_to_buffer(@main_buffer, 34, 24, house1.symbol)
house2 = Seitch.new()
house2.add_to_city(@city)
@map.add_building(house1,34, 24)
@map.add_building(house2,34, 24)
print_area_to_buffer(@main_buffer, 35, 24, house2.symbol)
house3 = Seitch.new()
house3.add_to_city(@city)
@map.add_building(house3,34, 24)
print_area_to_buffer(@main_buffer, 34, 25, house3.symbol)
starport = Starport.new()
starport .add_to_city(@city)
@map.add_building(starport,30, 30)
print_area_to_buffer(@main_buffer, 30, 30, starport.symbol)
farm = FarmA.new()
farm .add_to_city(@city)
@map.add_building(farm ,37, 24)
print_area_to_buffer(@main_buffer, 37, 24, farm.symbol)
atmo = AtmoGen.new()
atmo .add_to_city(@city)
@map.add_building(atmo ,38, 26)
print_area_to_buffer(@main_buffer, 34, 30, atmo .symbol)

end

def init_cursor
Expand All @@ -127,8 +144,8 @@ def update_status_bar
@status_buffer[1] = " "*@width
print_to_buffer(@status_buffer, 1, 0, "Money: #{@city.coins.round}")
print_to_buffer(@status_buffer, 1, 18, "Population: #{@city.population.round} / #{@city.population_cap}")
#print_to_buffer(@status_buffer, 1, 36, "Population Cap: #{@city.population_cap}")
print_to_buffer(@status_buffer, 1, 40, "Oxygen: #{@city.oxygen.round}")
print_to_buffer(@status_buffer, 1, 40, "Free Workers: #{@city.free_workers.round}")
print_to_buffer(@status_buffer, 1, 87, "Oxygen: #{@city.oxygen.round}")
VIM::evaluate("genutils#MoveCursorToWindow(2)")
end

Expand Down

0 comments on commit 8eacd2d

Please sign in to comment.