More tidying.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@410 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -87,14 +87,14 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate
|
|||||||
|
|
||||||
final int gameId = _gmgr.getGameConfig().getGameId();
|
final int gameId = _gmgr.getGameConfig().getGameId();
|
||||||
|
|
||||||
// enumerate our non-guest players
|
// enumerate our players
|
||||||
final Integer[] allPlayers = new Integer[_gmgr.getPlayerCount()];
|
final Rating[] ratings = new Rating[_gmgr.getPlayerCount()];
|
||||||
ArrayIntSet ratedSet = new ArrayIntSet();
|
ArrayIntSet ratedSet = new ArrayIntSet();
|
||||||
for (int ii = 0; ii < allPlayers.length; ii ++) {
|
for (int ii = 0; ii < ratings.length; ii ++) {
|
||||||
allPlayers[ii] = _gmgr.getPlayerPersistentId(_gmgr.getPlayer(ii));
|
ratings[ii] = new Rating(_gmgr.getPlayerPersistentId(_gmgr.getPlayer(ii)));
|
||||||
if (allPlayers[ii] != 0) {
|
if (ratings[ii].playerId != 0) {
|
||||||
// this is a player with a persistent id, a player we can rate
|
// this is a player with a persistent id, a player we can rate
|
||||||
ratedSet.add(allPlayers[ii]);
|
ratedSet.add(ratings[ii].playerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Integer[] ratedPlayers = ratedSet.toArray(new Integer[ratedSet.size()]);
|
final Integer[] ratedPlayers = ratedSet.toArray(new Integer[ratedSet.size()]);
|
||||||
@@ -109,29 +109,26 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now build the array we keep around until the end of the game
|
// now build the array we keep around until the end of the game
|
||||||
_tratings = new Rating[allPlayers.length];
|
for (Rating rating : ratings) {
|
||||||
for (int ii = 0; ii < _tratings.length; ii ++) {
|
if (rating.playerId == 0) {
|
||||||
if (allPlayers[ii] == 0) {
|
|
||||||
continue; // for guests we let the slot remain null
|
continue; // for guests we let the slot remain null
|
||||||
}
|
}
|
||||||
RatingRecord record = map.get(allPlayers[ii]);
|
RatingRecord record = map.get(rating.playerId);
|
||||||
// if the player had no previous record, initiate them at default values
|
if (record != null) {
|
||||||
_tratings[ii] = (record == null) ? new Rating(allPlayers[ii]) :
|
rating.rating = record.rating;
|
||||||
new Rating(allPlayers[ii], record.rating, record.experience);
|
rating.experience = record.experience;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleSuccess () {
|
public void handleSuccess () {
|
||||||
// stick our ratings into our manager
|
_ratings = ratings; // stick our ratings into the manager
|
||||||
_ratings = _tratings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleFailure (Exception e) {
|
public void handleFailure (Exception e) {
|
||||||
log.log(Level.WARNING, "Failed to load ratings [where=" + where() +
|
log.log(Level.WARNING, "Failed to load ratings [where=" + where() +
|
||||||
", id=" + gameId + "].", e);
|
", id=" + gameId + "].", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Rating[] _tratings;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,16 +301,6 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate
|
|||||||
this.rating = DEFAULT_RATING;
|
this.rating = DEFAULT_RATING;
|
||||||
this.experience = 0;
|
this.experience = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up a new {@link Rating} object with the given values.
|
|
||||||
*/
|
|
||||||
public Rating (int playerId, int rating, int experience)
|
|
||||||
{
|
|
||||||
this.playerId = playerId;
|
|
||||||
this.rating = rating;
|
|
||||||
this.experience = experience;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** An appropriately casted reference to our GameManager. */
|
/** An appropriately casted reference to our GameManager. */
|
||||||
|
|||||||
Reference in New Issue
Block a user