Last active
May 2, 2017 15:52
-
-
Save Mystler/5b655939659a07791c4298d3dd01c651 to your computer and use it in GitHub Desktop.
Roll the Bones Counting Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'set' | |
lastTimeIdx = '' | |
currentRoll = [] | |
lastRoll = [] | |
buffCounts = { | |
0 => 0, | |
1 => 0, | |
2 => 0, | |
3 => 0, | |
4 => 0, | |
5 => 0, | |
6 => 0 | |
} | |
combinations = Set.new | |
combinationCounts = { | |
0 => 0, | |
1 => 0, | |
2 => 0, | |
5 => 0 | |
} | |
def check_buff(event, buff, roll_array) | |
if event.include?(buff) and event.include?('gains') | |
if not roll_array.include? buff | |
roll_array.push(buff) | |
end | |
elsif event.include?(buff) and event.include?('fades') | |
if roll_array.include? buff | |
roll_array.delete(buff) | |
end | |
end | |
end | |
for fileno in 1..24 | |
File.open("#{fileno}.csv", 'r') do |csv| | |
csv.gets #ignore first line | |
while line = csv.gets | |
parts = line.split(',') | |
if parts[0] != lastTimeIdx | |
lastTimeIdx = parts[0] | |
lastRoll = currentRoll.clone() | |
end | |
#add previous rolls on new cast | |
if parts[1].include?('casts') and parts[1].include?('Roll the Bones') | |
buffCounts[lastRoll.length] += 1 | |
combinations.add(lastRoll.to_set) | |
#puts parts[0] if lastRoll.length == 0 | |
end | |
check_buff(parts[1], 'Jolly Roger', currentRoll) | |
check_buff(parts[1], 'Broadsides', currentRoll) | |
check_buff(parts[1], 'Buried Treasure', currentRoll) | |
check_buff(parts[1], 'Shark Infested Waters', currentRoll) | |
check_buff(parts[1], 'True Bearing', currentRoll) | |
check_buff(parts[1], 'Grand Melee', currentRoll) | |
end | |
end | |
end | |
#add last cast | |
buffCounts[lastRoll.length] += 1 | |
puts buffCounts | |
combinations.to_a.each do |b| | |
combinationCounts[b.length] += 1 | |
#puts b.to_a | |
#puts '===' | |
end | |
puts combinationCounts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment