Sha256: 260bf61c95ea239393ad43258890aa9988907046d95d4ed471fe9123ce5ba325

Contents?: true

Size: 442 Bytes

Versions: 1

Compression:

Stored size: 442 Bytes

Contents

class PirateGame::Bridge

  attr_accessor :items, :stage_items

  def initialize(items, stage_items)
    @items       = items
    @stage_items = stage_items
  end

  def sample_item
    item = @stage_items.sample

    # if we selected an item in the current bridge
    # reselect a new item 80% of the time
    if items.include?(item) && items.size < stage_items.size
      item = sample_item if rand > 0.2
    end

    return item
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pirate_game-0.0.1 lib/pirate_game/bridge.rb