Browse files

polish scoring cont.

  • Loading branch information...
1 parent 29d2d04 commit 4057243a2bfbb5f787eeed354bff31d2f46e932b @geraldb geraldb committed Jun 27, 2012
Showing with 29 additions and 31 deletions.
  1. +5 −19 app/models/calc_tip.rb
  2. +24 −12 app/models/tip.rb
View
24 app/models/calc_tip.rb
@@ -36,34 +36,20 @@ class CalcTip < Tip
def calc_points
pts = 0
- ## step 1: teams must match for any points (scoring)
+ ## note: teams must match for any points (scoring)
- if (complete? &&
+ if (complete? &&
game.team1_id == calc_team1_id &&
game.team2_id == calc_team2_id)
- if(((game.score1 == game.score2) && (score1 == score2)) ||
- ((game.score1 > game.score2) && (score1 > score2)) ||
- ((game.score1 < game.score2) && (score1 < score2)))
- pts += 1
- end
-
- # tordifferenz richtig? todo: auch fuer unentschieden???
- if((game.score1-game.score2) == (score1-score2))
- ## nb: for now now points for tordifferenz
- ### pts +=1
- end
-
- # ergebnis richtig?
- if game.score1 == score1 && game.score2 == score2
- pts += 2
- end
+ pts = calc_points_worker()
+
end
+
pts
end
-
private
def on_after_initialize
View
36 app/models/tip.rb
@@ -65,10 +65,11 @@ def export?
(score1.blank? && score2.blank? && score3.blank? && score4.blank? && score5.blank? && score6.blank?)==false
end
-
- def calc_points
+
+
+ def calc_points_worker
pts = 0
- if complete?
+
if(((game.score1 == game.score2) && (score1 == score2)) ||
((game.score1 > game.score2) && (score1 > score2)) ||
((game.score1 < game.score2) && (score1 < score2)))
@@ -88,20 +89,31 @@ def calc_points
## check n.V.
- if (game.score3.present? && game.score4.present? &&
- score3.present? && score4.present? &&
- game.score3 == score3 && game.score4 == score4)
- pts +=1
+ if (game.score3.present? && game.score4.present? && score3.present? && score4.present?)
+
+ if(((game.score3 == game.score4) && (score3 == score4)) ||
+ ((game.score3 > game.score4) && (score3 > score4)) ||
+ ((game.score3 < game.score4) && (score3 < score4)))
+ pts += 1
+ end
end
## check i.E.
- if (game.score5.present? && game.score6.present? &&
- score5.present? && score6.present? &&
- game.score5 == score3 && game.score6 == score4)
- pts +=1
+ if (game.score5.present? && game.score6.present? && score5.present? && score6.present?)
+
+ if(((game.score5 > game.score6) && (score5 > score6)) ||
+ ((game.score5 < game.score6) && (score5 < score6)))
+ pts += 1
+ end
end
- end
+
+ pts
+ end
+
+ def calc_points
+ pts = 0
+ pts = calc_points_worker() if complete?
pts
end

0 comments on commit 4057243

Please sign in to comment.