diff TrainingScoreManager.h @ 38:fea11c3d1d94

tweaking endlessly
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Thu, 04 Dec 2014 17:03:01 +0000
parents 52dbd5b4cfa9
children 96ff7b41923a
line wrap: on
line diff
--- a/TrainingScoreManager.h	Wed Dec 03 11:38:26 2014 +0000
+++ b/TrainingScoreManager.h	Thu Dec 04 17:03:01 2014 +0000
@@ -35,8 +35,99 @@
 public:
     TrainingScoreManager(){
         totalScored = 0;
+    };
+    int getBandForDistance(float dist) const{
+        int band = -1;
+        auto dimComp = sqrt(TOTAL_NUM_PARAMS);
+        if (dist < TARGET_SCORE_CC_BAND*dimComp){
+            
+            band = 1;
+            
+        }else if (dist < TARGET_SCORE_CC_BAND*2*dimComp){
+            
+            band = 2;
+
+        }else if (dist < TARGET_SCORE_CC_BAND*3*dimComp){
+            
+            band = 3;
+
+        }else if (dist < TARGET_SCORE_CC_BAND*4*dimComp){
+
+            band = 4;
+            
+        }else if (dist < TARGET_SCORE_CC_BAND*6*dimComp){ // 30
+            
+            band = 5;
+
+            
+        }else if (dist < TARGET_SCORE_CC_BAND*9*dimComp){ // 45
+            
+            band = 6;
+
+            
+        }else{
+            
+            band = 7;
+
+            
+        }
+        return band;
+    };
+    
+    string getMessageForBand(int band) const{
+        stringstream msg;
+        if (band == 1){
+            
+            msg << "DOUBLE BULLSEYE!" << endl;
+            
+            
+        }else if (band == 2){
+
+            
+            msg << "SINGLE BULLSEYE!" << endl;
+            
+        }else if (band == 3){
+          
+            msg << "CLOSE..." << endl;
+            
+        }else if (band == 4){
+
+            msg << "OK...ISH" << endl;
+            
+        }else if (band == 5){ // 30
+
+            msg << "MEDIOCRE" << endl;
+            
+        }else if (band == 6){ // 45
+
+            msg << "POOR..." << endl;
+            
+        }else{
+
+            msg << "MISSED COMPLETELY!" << endl;
+            
+            
+        }
+        return msg.str();
     }
-    
+    ofColor getColorForBand(int band) const {
+        
+        
+        ofColor c;
+        if(band == 1){
+            
+            c = ofColor(255,255,0,255);     // yellow 1
+        }else if(band == 2){
+            c = ofColor(255,0,0,255);       // red 2
+        }else if(band == 3){
+            c = ofColor(45,45,255,255);     // blue 3
+        }else if(band == 4){
+            c = ofColor(0,255,0,255);       // green 4
+        }else{
+            c = ofColor(123,123,123,255);         // grey worst
+        }
+        return c;
+    };
     TrainingTestResult getScoreForAnswer(vector<int> targetParams,
                                          vector<int> startPosition,
                                          vector<int> answer,
@@ -61,53 +152,13 @@
         cout << "Preset index " << presetIndex << endl;
         cout << "whichInSequence " << whichInSequence << endl;
         
-        auto dimComp = sqrt(TOTAL_NUM_PARAMS);
-        int band = -1;
-        if (dist < TARGET_SCORE_CC_BAND*dimComp){
-     
-            band = 1;
-            
-            msg << "DOUBLE BULLSEYE!" << endl;
-            
-            
-        }else if (dist < TARGET_SCORE_CC_BAND*2*dimComp){
-       
-            band = 2;
-            
-            msg << "SINGLE BULLSEYE!" << endl;
-            
-        }else if (dist < TARGET_SCORE_CC_BAND*3*dimComp){
-       
-            band = 3;
-            msg << "CLOSE..." << endl;
-            
-        }else if (dist < TARGET_SCORE_CC_BAND*4*dimComp){
-           
-            band = 4;
-            msg << "OK...ISH" << endl;
-            
-        }else if (dist < TARGET_SCORE_CC_BAND*6*dimComp){ // 30
-           
-            band = 5;
-            msg << "MEDIOCRE" << endl;
-            
-        }else if (dist < TARGET_SCORE_CC_BAND*9*dimComp){ // 45
-           
-            band = 6;
-            msg << "POOR..." << endl;
-            
-        }else{
-           
-            band = 7;
-            msg << "MISSED COMPLETELY!" << endl;
-            
-            
-        }
-        msg << "Distance from target: " << dist << endl;
+        int band = getBandForDistance(dist);
+        
+        msg << getMessageForBand(band) << endl;
+        msg << "Distance: " << dist << endl;
         msg << "Score: " << round(TP*10) << endl;
         msg << "-----" << endl;
         msg << "Time allowed: " << timeAllowed/1000.0 << endl;
-
         msg << "-----" << endl;
 
         result.realDistanceToTarget = dist;
@@ -116,22 +167,7 @@
         result.score = int(round(TP*10.0));
         result.displayText = msg.str();
         result.difficultyLevel = difficulty;
-    
-        
-        ofColor c;
-        if(result.targetBandHit == 1){
-            
-            c = ofColor(255,255,0,255);     // yellow 1
-        }else if(result.targetBandHit == 2){
-            c = ofColor(255,0,0,255);       // red 2
-        }else if(result.targetBandHit == 3){
-            c = ofColor(45,45,255,255);     // blue 3
-        }else if(result.targetBandHit == 4){
-            c = ofColor(0,255,0,255);       // green 4
-        }else{
-            c = ofColor(123,123,123,255);         // grey worst
-        }
-        result.colorBand = c;
+        result.colorBand = getColorForBand(band);
 
         if(result.score > 0) totalScored += result.score;