Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. lastTimeIdx = ''
  2. currentRoll = []
  3. lastRoll = []
  4. buffCounts = {
  5. 0 => 0,
  6. 1 => 0,
  7. 2 => 0,
  8. 3 => 0,
  9. 4 => 0,
  10. 5 => 0,
  11. 6 => 0
  12. }
  13.  
  14. def check_buff(event, buff, roll_array)
  15. if event.include?(buff) and event.include?('gains')
  16. if not roll_array.include? buff
  17. roll_array.push(buff)
  18. end
  19. elsif event.include?(buff) and event.include?('fades')
  20. if roll_array.include? buff
  21. roll_array.delete(buff)
  22. end
  23. end
  24. end
  25.  
  26. for fileno in 1..24
  27. File.open("#{fileno}.csv", 'r') do |csv|
  28. csv.gets #ignore first line
  29. while line = csv.gets
  30. parts = line.split(',')
  31.  
  32. if parts[0] != lastTimeIdx
  33. lastTimeIdx = parts[0]
  34. lastRoll = currentRoll.clone()
  35. end
  36.  
  37. #add previous rolls on new cast
  38. if parts[1].include?('casts') and parts[1].include?('Roll the Bones')
  39. buffCounts[lastRoll.length] += 1
  40. #puts parts[0] if lastRoll.length == 0
  41. end
  42.  
  43. check_buff(parts[1], 'Jolly Roger', currentRoll)
  44. check_buff(parts[1], 'Broadsides', currentRoll)
  45. check_buff(parts[1], 'Buried Treasure', currentRoll)
  46. check_buff(parts[1], 'Shark Infested Waters', currentRoll)
  47. check_buff(parts[1], 'True Bearing', currentRoll)
  48. check_buff(parts[1], 'Grand Melee', currentRoll)
  49. end
  50. end
  51. end
  52.  
  53. #add last cast
  54. buffCounts[lastRoll.length] += 1
  55.  
  56. puts buffCounts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement