All pastes #989744 Raw Edit

Anonymous

public ruby v1 · immutable
#989744 ·published 2008-04-19 17:53 UTC
rendered paste body
	def actualiza_puntuacion(s)		scores = Score.find(:all, :conditions => ["game_id = ?", self.id])		game = Game.find_by_id(self.id)		total = 0.0		if s then total += s end		for sc in scores do			total += sc.score		end		if !(scores.length == 0) then			if s				total = total / (scores.length + 1)			else				total = total / scores.length			end		end		game.total_score = total		game.save	end