Skip to content

Commit

Permalink
hotfix: crash on reportgame
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonp committed Jul 11, 2014
1 parent d1164a5 commit 9e2f834
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
23 changes: 3 additions & 20 deletions botspade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,7 @@ def user_is_an_admin?(user)
total_won = 0
winner_count = 0
if first.downcase == "win"
@gamesdb[Time.now.utc.to_s] = "win"
if @gamesdb["wincount"]
@gamesdb["wincount"] = @gamesdb["wincount"] + 1
else
@gamesdb["wincount"] = 1
end
db_set_game(1)
@betsdb.keys.each do |bettor|
bet_amount = @betsdb[bettor][0]
win_loss = @betsdb[bettor][1]
Expand All @@ -432,14 +427,8 @@ def user_is_an_admin?(user)
give_points(bettor, winnings)
end
end
save_data_silent
elsif first.downcase == "loss"
@gamesdb[Time.now.utc.to_s] = "loss"
if @gamesdb["losscount"]
@gamesdb["losscount"] = @gamesdb["losscount"] + 1
else
@gamesdb["losscount"] = 1
end
db_set_game(2)
@betsdb.keys.each do |bettor|
bet_amount = @betsdb[bettor][0]
win_loss = @betsdb[bettor][1]
Expand All @@ -451,12 +440,7 @@ def user_is_an_admin?(user)
end
end
elsif first.downcase == "tie"
@gamesdb[Time.now.utc.to_s] = "tie"
if @gamesdb["tiecount"]
@gamesdb["tiecount"] = @gamesdb["tiecount"] + 1
else
@gamesdb["tiecount"] = 1
end
db_set_game(3)
@betsdb.keys.each do |bettor|
bet_amount = @betsdb[bettor][0]
win_loss = @betsdb[bettor][1]
Expand All @@ -469,7 +453,6 @@ def user_is_an_admin?(user)
end
end
@betsdb = {}
save_data_silent
msg channel, "Bets tallied. #{total_won.to_s} #{@botmaster} Points won by #{winner_count.to_s} gambler(s)."
end
end
Expand Down
3 changes: 3 additions & 0 deletions botspade_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def get_wins_losses
return wins_losses
end

def db_set_game(status)
return true if @db.execute( "INSERT INTO games ( status, timestamp ) VALUES ( ?, ? )", [status, Time.now.utc.to_i])
end

def db_checkins_get(user_id)
checkin = @db.execute( "SELECT timestamp FROM checkins WHERE user_id = ? ORDER BY timestamp DESC LIMIT 1", [user_id] ).first
Expand Down

0 comments on commit 9e2f834

Please sign in to comment.