Build Status Code Climate

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