Project

randprize

0.0
No commit activity in last 3 years
No release in over 3 years
Select a random prize from a list with odds
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Build Status Code Climate Gem Version

randprize gem

Given a hash of prizes and odds randomly return a prize.

Prize Hash with odds

@headstails={ "T"=> {'odds'=> 2,'name'=>'win tails','value'=>0},"H"=> {'odds'=> 2,'name'=>'win heads','value'=>1}}
@dice={}
1.upto(6) {|i| @dice[i.to_s]= {'odds'=> 6,'name'=>"rolled #{i}",'value'=>i} }
@large={ "GP"=> {'odds'=> 100,'name'=>'grandprize','value'=>50000},"H"=> {'odds'=> 'REMAINING','name'=>'win heads','value'=>1}}

The REMAINING flag fills in rest of prize deck with the value and should have value 0 for prize statistics

Usage

@headstails={ "T"=> {'odds'=> 2,'name'=>'win tails','value'=>0},"H"=> {'odds'=> 2,'name'=>'win heads','value'=>1}}
@pm=Randprize::ManagePrizes.new
@pm.prize_list(@headstails)
aprize=@pm.random_prize