Created
November 20, 2012 23:33
-
-
Save douglascamata/4122010 to your computer and use it in GitHub Desktop.
Score!
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
def calculate | |
bet_scores_per_type = { | |
winner_fighter_id: { @result[:winner_fighter_id] => 10 }, | |
fight_victory_type_id: { @result[:fight_victory_type_id] => 30}, | |
round: { @result[:details][:round] => 50} | |
} | |
user_bets_per_type = { | |
winner_fighter_id: @betting[:bet_fighter_id], | |
fight_victory_type_id: @betting[:fight_victory_type_id] | |
round: @betting[:details][:round] | |
} | |
user_score = 0 | |
user_bets_per_type.each do |type, bet| | |
user_score += bet_scores_per_type[type][bet] if bet_scores_per_type[type].has_key?(bet) | |
end | |
user_core | |
end |
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
def calculate | |
score = 0 | |
score += 20 if @result[:winner_fighter_id] == @betting[:bet_fighter_id] | |
score += 30 if @result[:fight_victory_type_id] == @betting[:fight_victory_type_id] | |
score += 50 if @result[:details][:round] == @betting[:details][:round] | |
score | |
end |
passalini
commented
Nov 21, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment