package de.uka.ipd.consensus.impl;

import de.uka.ipd.consensus.foundation.ConsensusFoundationManager;
import de.uka.ipd.consensus.foundation.logging.LoggingManager;
import de.uka.ipd.consensus.foundation.schema.User;
import de.uka.ipd.consensus.foundation.scoring.ScoringEvent;
import de.uka.ipd.consensus.foundation.scoring.ScoringListener;

/**
 * A very simple implementation of a <code>ScoringListener</code>.
 * @author  Thomas Much
 * @version 2006-06-14
 */
public class ScoringListenerImpl implements ScoringListener {
	
	private LoggingManager logging;

	
	/**
	 * TODO
	 * @param cfm
	 */
	public ScoringListenerImpl(ConsensusFoundationManager cfm) {
		// alternativ Konstruktor ohne Parameter und zusätzlich mit Properties als 1. Parameter
		this.logging = cfm.getLoggingManager();
		logging.debug("ScoringListener " + this.getClass().getName() + " created.");
	}

	
	/**
	 * TODO
	 */
	public void score(ScoringEvent event) {
		
		User user = event.getUser();

		// für jede Aktion vergeben wir einfach einen Punkt
		// (Anreiz, um möglichst viel mit dem System herumzuspielen):
		double newscore = user.getScore() + 1.0;
		user.setScore( newscore );

		logging.debug(user + " scored! (event-type: " + event.getId()+ ", new score: " + newscore + ")");
	}

	
	/**
	 * An empty implementation, does nothing.
	 * TODO
	 */
	public void scored(ScoringEvent event) { }

}
