Time function added

This commit is contained in:
Woosle Park
2019-04-11 01:59:11 -04:00
parent 89f53a159a
commit ba549c6012
15 changed files with 68 additions and 199 deletions

View File

@@ -176,6 +176,8 @@ public class GameServer implements Runnable {
user.getControlledUnit().getCpu().reset();
int cost = user.getControlledUnit().getCpu().execute(timeout);
user.getControlledUnit().spendEnergy(cost);
user.addTime(cost);
} catch (Exception e) {
LogManager.LOGGER.severe("Error executing " + user.getUsername() + "'s code");
e.printStackTrace();

View File

@@ -70,6 +70,10 @@ public class User implements MongoSerializable {
return user;
}
public void addTime(int time){
this.stats.incrementStat("executionTime", time);
}
public String getUserCode() {
return userCode;
}

View File

@@ -58,7 +58,7 @@ public class UserStatsHelper {
ArrayList<Map.Entry<User, Map<String, Integer>>> rows = new ArrayList<>();
ArrayList<Map.Entry<User, ArrayList>> vaults = new ArrayList<>(this.getTopNSetLength("completedVaults", n));
ArrayList<Map.Entry<User, Integer>> deaths = new ArrayList<>(this.getTopN("deathCount", n));
ArrayList<Map.Entry<User, Integer>> deaths = new ArrayList<>(this.getTopN("death", n));
ArrayList<Map.Entry<User, Integer>> time = new ArrayList<>(this.getTopN("executionTime", n));
ArrayList<Map.Entry<User, Integer>> distance = new ArrayList<>(this.getTopN("walkDistance", n));
@@ -66,7 +66,7 @@ public class UserStatsHelper {
User user = vaults.get(i).getKey();
Map<String, Integer> allStats = new HashMap();
allStats.put("completedVaults", vaults.get(i).getValue().size());
allStats.put("deathCount", deaths.get(i).getValue());
allStats.put("death", deaths.get(i).getValue());
allStats.put("executionTime", time.get(i).getValue());
allStats.put("walkDistance", distance.get(i).getValue());
rows.add(new AbstractMap.SimpleEntry<>(user, allStats));

View File

@@ -26,7 +26,7 @@
<tr>
<td>$row.getKey().getUsername()</td>
<td>$row.getValue().get("completedVaults")</td>
<td>$row.getValue().get("deathCount")</td>
<td>$row.getValue().get("death")</td>
<td>$row.getValue().get("executionTime")</td>
<td>$row.getValue().get("walkDistance")</td>
</tr>