@Override public boolean evaluate(StatSet aStatSet) { if (aStatSet.getAttribute() != LIFETIME) { return false; } return (aStatSet.getStat(WINS) + aStatSet.getStat(LOSSES)) >= THRESHOLD; }
@Test public void testUpdateStats() throws Exception { final StatSetFactory statFactory = new StatSetFactory(); gameStats = statFactory.generateRandomGameStats(true, MAX_TIME_PLAYED); player.updateStats(gameStats); for (StatKey key : StatKey.values()) { assertEquals(gameStats.getStat(key), player.getStat(key)); } }
@Test public void testEvaluateAchievements() throws Exception { gameStats = new StatSet(GAME); gameStats.setStat(WINS, ACHIEVEMENT_THRESHOLD); player.updateStats(gameStats); expect(achievement.evaluate(gameStats)).andReturn(true); expect(achievement.evaluate(lifetimeStats)).andReturn(false); achievement.claim(); expectLastCall().once(); replay(achievement); player.evaluateAchievements(); verify(achievement); }