Skip to content

Commit

Permalink
Fixed report on timeout and correct level in report (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelmerT authored and trottier committed Oct 3, 2019
1 parent c22cf91 commit f185047
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions games/002_EngagingConsistently/src/EngagingConsistently.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,26 @@ bool playEngagingConsistently() {
}
}

if (!timeout) {
// Send report
Log.info("Sending report");
String extra = String::format(
"{\"pos_tries\":%u,\"neg_tries\":%u", countSuccesses(), countMisses());
if (challengeComplete) {extra += ",\"challengeComplete\":1";}
extra += "}";

hub.Report(
Time.format(gameStartTime, TIME_FORMAT_ISO8601_FULL), // play_start_time
PlayerName, // player
currentLevel, // level
String(foodtreatWasEaten), // result
reactionTime, // duration -> linked to level and includes tray movement
1, // foodtreat_presented
foodtreatWasEaten, // foodtreatWasEaten
extra // extra field
);
}

// Check if we're ready for next challenge
if (currentLevel == MAX_LEVEL) {
addResultToPerformanceHistory(foodtreatWasEaten);
Expand All @@ -263,7 +283,7 @@ bool playEngagingConsistently() {
}

// Decrease level if bad performance in this level
// BAD_PERFORMACE is really high, so will never come here
// TOO_MANY_MISSES is really high, so will never come here
if (countMisses() >= TOO_MANY_MISSES) {
if (currentLevel > 1) {
currentLevel--;
Expand All @@ -272,24 +292,6 @@ bool playEngagingConsistently() {
}
}

// Send report
Log.info("Sending report");
String extra = String::format(
"{\"pos_tries\":%u,\"neg_tries\":%u", countSuccesses(), countMisses());
if (challengeComplete) {extra += ",\"challengeComplete\":1";}
extra += "}";

hub.Report(
Time.format(gameStartTime, TIME_FORMAT_ISO8601_FULL), // play_start_time
PlayerName, // player
currentLevel, // level //TODO is this the correct level?
String(foodtreatWasEaten), // result
reactionTime, // duration -> linked to level and includes tray movement
1, // foodtreat_presented
foodtreatWasEaten, // foodtreatWasEaten
extra // extra field
);

// printPerformanceArray();

hub.SetDIResetLock(false); // allow DI board to reset if needed between interactions
Expand Down

0 comments on commit f185047

Please sign in to comment.