Esempio n. 1
0
static void updateScore()
{
  if (lastRemotePeak != 0 || lastPeak != 0)
  {
    // Find the window from the periods from the pins
    long distance = abs(lastRemotePeak - lastPeak);

    uint8_t scoreValue = 0;
    if (distance < window)
    {
      uint16_t value = 100 - (100.0*distance/window);
      scoreValue = value*value/100.0;
      lastRemotePeak = 0;
      lastPeak = 0;
    }

    scoreMsgOut.colorIdx = getNextColor();
    if (scoreValue > 50)
    {
      sound.incVol();
    }
    else if (scoreValue < 20)
    {
      sound.decVol();
    }
    scoreMsgOut.score = scoreValue;
    scoreMsgOut.soundLevel = sound.getVol();
    scoreMsgOut.scoreNumber = scoreNumber + 1;
    comm.send((uint8_t*) &scoreMsgOut, sizeof(struct Score_msg));
    scoreMsgResent = 0;
    onNewScore(&scoreMsgOut);
  }
}
Esempio n. 2
0
Color AbstractChat::getColor(string name)
{
   if(mFromColors.count(name) == 0)    
      mFromColors[name] = getNextColor();          

   return mFromColors[name]; 
}
Esempio n. 3
0
// We received a new incoming chat message...  Add it to the list
void AbstractChat::newMessage(const string &from, const string &message, bool isPrivate, bool isSystem, bool fromSelf)
{
   // Don't display it if it is from a muted player
   if(mGame->isOnMuteList(from))
      return;

   // Choose a color
   Color color;

   if(fromSelf)
      color = Colors::white;                  
   else                                       
   {
      if(mFromColors.count(from) == 0)        // See if we have a color for this nick
         mFromColors[from] = getNextColor();  // If not, get one

      color = mFromColors[from];
   }

   mMessages[mMessageCount % MESSAGES_TO_RETAIN] = ChatMessage(from, message, color, isPrivate, isSystem);
   mMessageCount++;

   if(fromSelf && isPrivate)     // I don't think this can ever happen!  ==> Should be !fromSelf ?
      deliverPrivateMessage(from.c_str(), message.c_str());
}
Esempio n. 4
0
		bool invalid(std::string s, int from, int to)
		{
			if (getNextColor(s[to]) == s[from])
				return false;//valid
			return true;
		}