Extracted the Bang stats system into reusable land. Too late for Yohoho, but

Whirled will benefit.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@251 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2007-03-20 17:23:18 +00:00
parent 6b2b9ecbbb
commit e6ab89f313
14 changed files with 1449 additions and 0 deletions
@@ -0,0 +1,71 @@
//
// $Id$
package com.threerings.stats.data;
import java.io.IOException;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* Used to track a single integer statistic.
*/
public class IntStat extends Stat
{
/**
* Returns the value of this integer statistic.
*/
public int getValue ()
{
return _value;
}
/**
* Sets this statistic's value to the specified value.
*
* @return true if the stat was modified, false if not.
*/
public boolean setValue (int value)
{
if (value != _value) {
_value = value;
_modified = true;
return true;
}
return false;
}
/**
* Increments this statistic by the specified delta value.
*
* @return true if the stat was modified, false if not.
*/
public boolean increment (int delta)
{
return setValue(_value + delta);
}
@Override // documentation inherited
public String valueToString ()
{
return String.valueOf(_value);
}
@Override // documentation inherited
public void persistTo (ObjectOutputStream out, AuxDataSource aux)
throws IOException
{
out.writeInt(_value);
}
@Override // documentation inherited
public void unpersistFrom (ObjectInputStream in, AuxDataSource aux)
throws IOException, ClassNotFoundException
{
_value = in.readInt();
}
/** Contains the integer value of this statistic. */
protected int _value;
}