Example #1
0
 public void resetTypist(CharacterSource newTypist) {
   try {
     scoreLock.lock();
     if (typist != null) typist.removeCharacterListener(this);
     typist = newTypist;
     if (typist != null) typist.addCharacterListener(this);
   } finally {
     scoreLock.unlock();
   }
 }
Example #2
0
 public void resetScore() {
   try {
     scoreLock.lock();
     score = 0;
     char2type = -1;
     setScore();
   } finally {
     scoreLock.unlock();
   }
 }
Example #3
0
 public void resetGenerator(CharacterSource newGenerator) {
   try {
     scoreLock.lock();
     if (generator != null) generator.removeCharacterListener(this);
     generator = newGenerator;
     if (generator != null) generator.addCharacterListener(this);
   } finally {
     scoreLock.unlock();
   }
 }
Example #4
0
 public void newCharacter(CharacterEvent ce) {
   scoreLock.lock();
   try {
     if (ce.source == generator) {
       if (char2type != -1) {
         score--;
         setScore();
       }
       char2type = ce.character;
     } else {
       if (char2type != ce.character) {
         score--;
       } else {
         score++;
         char2type = -1;
       }
     }
     setScore();
   } finally {
     scoreLock.unlock();
   }
 }