/**
* Copyright 1999-2009 The Pegadi Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Base class for recording and displaying scores. This class
* can be used as it is, or it can be subclassed to provide
* specific information for a game. If this class is subclassed,
* the scoring methods in {@link org.pegadi.server.ServerImpl} must also be updated.
*
* @author HÃ¥vard Wigtil <havardw at pvv.org>
* @version $Revision$, $Date$
*/
package org.pegadi.games;
import java.util.Date;
public class Score implements java.io.Serializable {
/**
* An unique ID for this score.
*/
protected long ID;
/**
* The domain for this score.
*/
protected String domain;
/**
* The user's ID.
*/
protected String userID;
/**
* The user's full name.
*/
protected String userName;
/**
* The current score.
*/
protected long score;
/**
* Rank of this score in the domain.
*/
protected long rank;
/**
* The date this score was recorded, or the date the game was started for active games.
*/
protected Date date;
/**
* A flag set to <code>true</code> when the game represented by this score is active.
*/
protected boolean active;
/**
* Create a new score.
*
* @param domain The domain for the score.
* @param ID The score's ID.
* @param userID The user's ID.
* @param userName The user's full name.
*/
public Score(String domain, long ID, String userID, String userName) {
this.domain = domain;
this.ID = ID;
this.userID = userID;
this.userName = userName;
this.score = 0;
this.date = new Date();
this.active = true;
}
/**
* Returns the domain for this score.
*
* @return The domain.
*/
public String getDomain() {
return domain;
}
/**
* Returns the ID for this score.
*
* @return The ID.
*/
public long getID() {
return ID;
}
/**
* Returns the ID for the user.
*
* @return The ID.
*/
public String getUserID() {
return userID;
}
/**
* Returns the full name for the user.
*
* @return The name.
*/
public String getUserName() {
return userName;
}
/**
* Returns the score.
*
* @return The score.
*/
public long getScore() {
return score;
}
/**
* Sets a new score.
*
* @param score The new score.
*/
public void setScore(long score) {
this.score = score;
}
/**
* Returns the date for this score.
*
* @return The date this game was completed, or the date it was started for active games.
*/
public Date getDate() {
return date;
}
/**
* Sets the active status for this score.
*
* @param active Active status.
*/
public void setActive(boolean active) {
this.active = active;
}
/**
* Returns the active status for this score.
*
* @return Active status.
*/
public boolean isActive() {
return active;
}
/**
* Sets the rank for this score.
*
* @param rank The rank.
*/
public void setRank(long rank) {
this.rank = rank;
}
/**
* Returns the rank for this score.
*
* @return The rank.
*/
public long getRank() {
return rank;
}
}