Implementing n# attempts to defuse the bomb via keypad

Store Forums Game Timer Pro General Discussion Implementing n# attempts to defuse the bomb via keypad

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #13653
    djairguilherme
    Participant

    Michael, I have developed some solutions for Escape Room here in Brazil and I have always indicated that my customers buy the Game Timer Pro, because I think the quality is excellent. In some cases, I have customized some needs for my clients. The most recent one involves the possibility that the player has some attempts to set the code via Keypad, before the bomb explodes.

    I made the following changes to the code:

    In file config.h, add the line:
    #define MAXCODES 3

    In the GameTimerPro.ino file, in the countdown function – defuse code section:

    if (defuseWire == DEFUSE_WIRE_CODE) {
            key = keypad.getKey();
            if (key > -1) {
              if ((!enteringCode) && (key <= 9)) {
                display.clear();
                display.setDisplayColon(false);
                display.printString("____");
                enteringCode = true;
                currentDigit = 1;
                currentValue = -1;
              }
    
              if (key <= 9) {
                display.setDigitNum(currentDigit, key);
                digits[currentDigit - 1] = key;
                currentDigit++;
                currentValue = -1;
                toggleCount = 0;
              }
    
              if ((key == KEY_STAR) || (key == KEY_POUND)) {
                enteringCode = false;
                display.clear();
                display.printCountdown(countdownSeconds);
                Serial.println (countdownSeconds);
              }
    
              // THIS BLOCK HERE IS WHAT I'VE CHANGED
    
              if (currentDigit > 4) {
                beep(3800, 30);
                int enteredCode = (digits[0] * 1000) + (digits[1] * 100) + (digits[2] * 10) + digits[3];
                countdownRunning = false;
                delay(500);
                if (enteredCode == defuseCode) {
                  isDefused = true;
                } else { // HERE
                  
                  if (currentCode < MAXCODES) { // CHECK IF MAX 
                    display.clear();
                    display.printString ("_Err");
                    enteringCode = true;
                    currentDigit = 1;
                    currentValue = -1;
                    currentCode ++;
                  } else {
                    currentCode = 1;
                    countdownSeconds = 0; // wrong code bomb explodes
                    
                  }
                } // END CHECK
              }
            }
    
            // if no current value yet, toggle an underscore
            if ((currentValue < 0) && (enteringCode)) {
              toggleCount++;
              if ((toggleCount % 10) == 0) {
                if ((toggleCount % 20) == 0) {
                  display.setDigitChar(currentDigit, '_');
                } else {
                  display.setDigitChar(currentDigit, ' ');
                }
              }
            }
          } // if defuse code
    #13657
    Michael
    Keymaster

    Nice work, Djair! Yes, I have made a similar customization for some escape room customers, too. I’m glad you are using the Game Timer Pro in Brazil for different escape room customers! Thank you for your business.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.