Skip to content

Commit

Permalink
up calc formula
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldb committed Jul 16, 2014
1 parent 9e271b8 commit 8a85b5f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
56 changes: 43 additions & 13 deletions lib/sportdb/play/models/tip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,21 @@ def calc_points_worker
## check n.V. - after extra time/a.e.t

if( game.score1et.present? && game.score2et.present? && score1et.present? && score2et.present?)

if(((game.score1et == game.score2et) && (score1et == score2et)) ||
((game.score1et > game.score2et) && (score1et > score2et)) ||
((game.score1et < game.score2et) && (score1et < score2et)))
pts += 1

### note: disqualify (no pts) if tip for regular time is NOT draw/tie
###
if score1 == score2
pts += 1

# ergebnis richtig? extra point
if game.score1et == score1et && game.score2et == score2et
pts += 1
end
end
end
end

Expand All @@ -176,10 +186,20 @@ def calc_points_worker

if(((game.score1p > game.score2p) && (score1p > score2p)) ||
((game.score1p < game.score2p) && (score1p < score2p)))
pts += 1

### note: disqualify (no pts) if tip for regular and extra time is NOT draw/tie
###
if score1 == score2 && score1et == score2et
pts += 1

# ergebnis richtig? extra point
if game.score1p == score1p && game.score2p == score2p
pts += 1
end
end
end
end

pts
end

Expand All @@ -196,9 +216,9 @@ def calc_points_str
buf
end


## todo: use tip-fail, tip-bingo, etc.

def bingo_style_class
if incomplete?
# show missing label for upcoming games only
Expand All @@ -213,11 +233,11 @@ def bingo_style_class
pts = calc_points()
if pts == 0
'fail'
elsif pts == 1
elsif pts == 1 || pts == 2
'bingo'
elsif pts == 2
'bingoo'
elsif pts == 3
'bingoo'
elsif pts >= 4 # note; use greater 4 for now - add more bingooo states? how to deal w/ custom points - normalize - how ??
'bingooo'
else
'' # unknown state; return empty (css) class
Expand All @@ -240,11 +260,11 @@ def bingo_win_style_class
pts = calc_points()
if pts == 0
''
elsif pts == 1
elsif pts == 1 || pts == 2
'bingo'
elsif pts == 2
'bingoo'
elsif pts == 3
'bingoo'
elsif pts >= 4
'bingooo'
else
'' # unknown state; return empty (css) class
Expand Down Expand Up @@ -278,6 +298,16 @@ def bingo_text
'♣♣ 2 Pkte - Jaaa!'
elsif pts == 3
'♣♣♣ 3 Pkte - Jaaaaa!'
elsif pts == 4
'♣♣♣ 4 Pkte - Jaaaaaa!'
elsif pts == 5
'♣♣♣ 5 Pkte - Jaaaaaaa!'
elsif pts == 6
'♣♣♣ 6 Pkte - Jaaaaaaaa!'
elsif pts == 7
'♣♣♣ 7 Pkte - Jaaaaaaaaa!'
elsif pts == 8
'♣♣♣ 8 Pkte - Wahnsinnn!' # max points? 2pt+2pt + (1pt+1pt) + (1pt+1pt)
else
'' # unknown state; return empty (css) class
end
Expand Down Expand Up @@ -326,7 +356,7 @@ def score_str
else
str = "#{score1_str} : #{score2_str}"
end

##### FIX: make extendable!!
# if calc
# str_calc_team1 = calc_team1_id.blank? ? '' : calc_team1.tag
Expand Down
3 changes: 2 additions & 1 deletion lib/sportdb/play/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module SportDb
module Play
VERSION = '0.2.4'
VERSION = '0.2.5'
end
end

0 comments on commit 8a85b5f

Please sign in to comment.