Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- COST = [50, 100, 400, 1200, 1200]
- DUST = [5, 20, 100, 400, 400]
- ODDS = [688, 923, 985, 990, 1000] # cumulative odds out of 1000
- MAX = [3, 3, 3, 3, 1] # number you want of each card
- CARDS_PER_TYPE = [57, 45, 22, 10, 20]
- got = [{}, {}, {}, {}, {}] # card ID => number of them
- rng = Random.new
- total_dust_reqd = 0
- total_dust_earnt = 0
- (0..4).each do |i|
- total_dust_reqd += (CARDS_PER_TYPE[i] * MAX[i] * COST[i])
- end
- got_counts = [0, 0, 0, 0, 0]
- packs = 0
- while total_dust_earnt < total_dust_reqd
- packs += 1
- 6.times do # 6 cards in a pack
- card_type_number = rng.rand(1000)
- card_type = 0
- while ODDS[card_type] < card_type_number
- card_type += 1
- end
- raise "wtf?" if card_type >= 5
- card = rng.rand(CARDS_PER_TYPE[card_type])
- if !got[card_type].has_key?(card)
- got[card_type][card] = 1
- total_dust_reqd -= COST[card_type]
- got_counts[card_type] += 1
- elsif got[card_type][card] < MAX[card_type]
- got[card_type][card] += 1
- total_dust_reqd -= COST[card_type]
- got_counts[card_type] += 1
- else
- total_dust_earnt += DUST[card_type]
- end
- end
- puts "After #{packs} packs, got #{got_counts[0]} C, #{got_counts[1]} R, #{got_counts[2]} E, #{got_counts[3]} L, #{got_counts[4]} UL, #{total_dust_earnt} dust, need #{total_dust_reqd} dust"
- end
- puts "Done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement