cleanup
This commit is contained in:
1 parent
d33d08fc03
commit
74e225b229
2 files changed
+15
-19
No files matched your search
+12
-19
@@ -3,7 +3,7 @@
|
||||
require 'hand'
|
||||
require 'combinations'
|
||||
|
||||
def score(hand_string, verbose=false)
|
||||
def score(hand_string)
|
||||
# split into an array of two character strings (each representing a card)
|
||||
cards = hand_string.scan(/../)
|
||||
|
||||
@@ -26,16 +26,6 @@ def score(hand_string, verbose=false)
|
||||
ten_card_hand = Hand.new(cards.join)
|
||||
best_hands,best_score = [ten_card_hand],ten_card_hand.score if ten_card_hand.score > best_score
|
||||
|
||||
# DEBUG
|
||||
if verbose then
|
||||
best_hands.each do |h|
|
||||
puts "#{h.score} points for a #{h.score_name}"
|
||||
puts h
|
||||
puts
|
||||
end
|
||||
puts "#{best_score} TOTAL POINTS"
|
||||
end
|
||||
|
||||
# return score
|
||||
[best_score, best_hands]
|
||||
end
|
||||
@@ -75,8 +65,10 @@ PlayerNames = {
|
||||
|
||||
total = Hash.new(0)
|
||||
|
||||
puts '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
|
||||
puts '<html><head>'
|
||||
puts '<title>Super Babel Scoring</title>'
|
||||
puts '<meta http-equiv="content-type" content="text/html; charset=UTF-8">'
|
||||
puts '<link href="css/tripoli.simple.css" type="text/css" rel="stylesheet">'
|
||||
puts '<!--[if IE]><link rel="stylesheet" type="text/css" href="css/tripoli.simple.ie.css"><![endif]-->'
|
||||
puts ' <style type="text/css">
|
||||
@@ -90,32 +82,33 @@ puts ' <style type="text/css">
|
||||
puts '</head><body>'
|
||||
puts '<div class="content" style="text-align:left;margin:20px auto;padding:20px">'
|
||||
puts '<h1>Hand Log</h1>'
|
||||
puts "<table>"
|
||||
puts "<tr><th>Player</th><th colspan=2>Hands</th><th>Score</th><th>Total</th></tr>"
|
||||
puts '<table>'
|
||||
puts '<tr><th>Player</th><th colspan=2>Hands</th><th>Score</th><th>Total</th></tr>'
|
||||
even = false
|
||||
IO.readlines(ARGV[0]).each do |line|
|
||||
player,cards = line.chomp.split(/,/)
|
||||
score,hands = score(cards)
|
||||
total[player.downcase] += score
|
||||
evenorodd = even ? "even" : "odd"
|
||||
evenorodd = even ? 'even' : 'odd'
|
||||
even = !even
|
||||
puts "<tr class=\"#{evenorodd}\">"
|
||||
puts " <td>#{PlayerNames[player]} [#{player}]</td>"
|
||||
puts " <td>#{PlayerNames[player]}<br/>[#{player}]</td>"
|
||||
colspan = 3 - hands.size
|
||||
hands.each do |h|
|
||||
puts " <td colspan=\"#{colspan}\">"
|
||||
h.to_s.gsub(/ /,'').split(',').each { |card| puts "<img src=\"img/#{card}.gif\">" }
|
||||
h.to_s.split(/, ?/).each { |card| puts "<img src=\"img/#{card}.gif\">" }
|
||||
puts "<br/>#{h.score_name} (#{h.score})</td>"
|
||||
end
|
||||
puts " <td>#{score}</td>"
|
||||
puts " <td>#{total[player]}</td>"
|
||||
puts "</tr>"
|
||||
puts '</tr>'
|
||||
end
|
||||
puts "</table>"
|
||||
puts '</table>'
|
||||
|
||||
puts '<br/><hr/><br/>'
|
||||
|
||||
puts '<h1>Total Scores</h1>'
|
||||
total.sort { |a,b| a[1] <=> b[1] }.reverse.each { |s| puts "#{PlayerNames[s[0]]} [#{s[0]}] - #{s[1]}<br/>" }
|
||||
total.sort { |a,b| a[1] <=> b[1] }.reverse.each { |s| puts "#{s[1]} - #{PlayerNames[s[0]]} [#{s[0]}]<br/>" }
|
||||
|
||||
puts '</div>'
|
||||
puts '</body>'
|
||||
@@ -7,3 +7,6 @@ eileen,2c3s4c5d6h7s8d9sthjs
|
||||
randy,as3s4s5s6s7s8s9stsjs
|
||||
jen,asadacah6s7s8s9stsjs
|
||||
jen,asadackskd7s8s9stsjs
|
||||
jen,asadacksks2c8h5stdjs
|
||||
francois,2c3s4c5d6h7s8d9sthjs
|
||||
stephanie,as3s4s5s6s7s8s9stsjs
|
||||
Reference in new issue
Block a user