Since returning -1 is perfectly acceptable for this method, let's be robust in handling an call to it for an unknown player; we already checked for unknown opponents.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@435 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -279,7 +279,7 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate
|
|||||||
/**
|
/**
|
||||||
* Computes updated ratings for the players of this game. The default implementation uses the
|
* Computes updated ratings for the players of this game. The default implementation uses the
|
||||||
* {@link GameObject#winners} field to determine winners and losers and uses a FIDE/ELO
|
* {@link GameObject#winners} field to determine winners and losers and uses a FIDE/ELO
|
||||||
* algorithm to comptue updated ratings.
|
* algorithm to compute updated ratings.
|
||||||
*/
|
*/
|
||||||
protected void updateRatings ()
|
protected void updateRatings ()
|
||||||
{
|
{
|
||||||
@@ -313,7 +313,7 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate
|
|||||||
* final rating adjustment, which is then added to the player's previous rating and bounded to
|
* final rating adjustment, which is then added to the player's previous rating and bounded to
|
||||||
* the rating range. <em>Note:</em> provisional players (those with experience of less than 20)
|
* the rating range. <em>Note:</em> provisional players (those with experience of less than 20)
|
||||||
* will be treated as having, at most, the default rating when used as an opponent in
|
* will be treated as having, at most, the default rating when used as an opponent in
|
||||||
* calculatons for a non-provisional player.
|
* calculations for a non-provisional player.
|
||||||
*
|
*
|
||||||
* @return the player's updated rating or -1 if none of the opponents could be applicably rated
|
* @return the player's updated rating or -1 if none of the opponents could be applicably rated
|
||||||
* against this player.
|
* against this player.
|
||||||
@@ -322,7 +322,14 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate
|
|||||||
{
|
{
|
||||||
float totDeltaR = 0; // the total delta rating
|
float totDeltaR = 0; // the total delta rating
|
||||||
int opponents = 0;
|
int opponents = 0;
|
||||||
|
|
||||||
Rating prating = _ratings.get(_playerIds[pidx]);
|
Rating prating = _ratings.get(_playerIds[pidx]);
|
||||||
|
if (prating == null) {
|
||||||
|
// be robust
|
||||||
|
log.warning("Computing ratings for unknown player [where=" + where() +
|
||||||
|
", pidx=" + pidx + "].");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (int ii = 0; ii < _playerIds.length; ii++) {
|
for (int ii = 0; ii < _playerIds.length; ii++) {
|
||||||
Rating orating = _ratings.get(_playerIds[ii]);
|
Rating orating = _ratings.get(_playerIds[ii]);
|
||||||
|
|||||||
Reference in New Issue
Block a user