class Tile
Attributes
built_on[R]
options[R]
x[R]
y[R]
Public Class Methods
new(x, y)
click to toggle source
# File lib/demigodGame/Tile.rb, line 10 def initialize(x, y) @x = x @y = y @type = '.' end
Public Instance Methods
accepts?(order)
click to toggle source
Checks if an order is valid
# File lib/demigodGame/Tile.rb, line 27 def accepts?(order) return false if !order || !order.match( /\A\w\Z/) # vaild command @options.each do |check| # checks which order was given return true if (check.to_s == order) end false end
build(building)
click to toggle source
Adds building to tile, doesn't check if valid building
# File lib/demigodGame/Tile.rb, line 21 def build(building) @built_on = building @buildable = [] end
check_cost(order, resources)
click to toggle source
# File lib/demigodGame/Tile.rb, line 36 def check_cost(order, resources) cost = GameData.get_price(order) puts cost # checks each resource for the correct amount cost.each do |resource, amount| return false if amount > resources[resource] end return true end
to_s()
click to toggle source
# File lib/demigodGame/Tile.rb, line 16 def to_s "#{@type}#{@built_on}" end