Sha256: 8522593cf06ddc732741f5d20d4b9661a30229aa14470d78047c51a4ffc21cd6

Contents?: true

Size: 865 Bytes

Versions: 1

Compression:

Stored size: 865 Bytes

Contents

require_relative 'player'

module StudioGame

  class ClumsyPlayer < Player
	attr_reader :boost_factor

	def initialize(name, health=100, boost_factor=1)
		super(name, health)
		@boost_factor = boost_factor
	end

	def w00t
		@boost_factor.times { super }
	end


	def found_treasure(treasure) 
		damaged_treasure = Treasure.new(treasure.name, treasure.points / 2.0) 
		super(damaged_treasure)
	end
  end
  
end

if __FILE__ == $0
	clumsy = StudioGame::ClumsyPlayer.new("klutz", 105, 3)

	hammer = StudioGame::Treasure.new(:hammer, 50)
	clumsy.found_treasure(hammer)
	clumsy.found_treasure(hammer)
	clumsy.found_treasure(hammer)

	crowbar = StudioGame::Treasure.new(:crowbar, 400)
	clumsy.found_treasure(crowbar)

	clumsy.each_found_treasure do |treasure|
		puts "#{treasure.points} total #{treasure.name} points"
	end
	puts "#{clumsy.points} grand total points"

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
studio_game_kb-1.0 lib/studio_game/clumsy_player.rb