<commit_before>#include "Arduino.h"
#include "Game.h"

Game::Game() {
}

void Game::init() {
  restart(1);
}

int Game::p1Score() { return _p1Score; }
int Game::p2Score() { return _p2Score; }
int Game::server()  { return _server;  }

bool Game::over() {
  return (_p1Score >= 11 || _p2Score >= 11) && abs(_p1Score - _p2Score) >= 2;
}

void Game::updateScore(int p1, int p2) {
  // The loop will constantly update the score, so we only act if it has changed
  if ((p1 != _p1Score) || (p2 != _p2Score)) {
    _p1Score = p1;
    _p2Score = p2;
    _serves++;

    Serial.print("Updating scores ");
    Serial.print(_p1Score);
    Serial.print(" ");
    Serial.print(_p2Score);
    Serial.print("   ");
    Serial.println(over());

    if (_serves == 2) {
      _serves = 0;
      _server = _server == 1 ? 2 : 1;
    }
  }
}

void Game::restart(int serve) {
  _p1Score = 0;
  _p2Score = 0;
  _server = 1;
  _serves = 0;
}<commit_msg>Fix setting server on restart<commit_after>#include "Arduino.h"
#include "Game.h"

Game::Game() {
}

void Game::init() {
  restart(1);
}

int Game::p1Score() { return _p1Score; }
int Game::p2Score() { return _p2Score; }
int Game::server()  { return _server;  }

bool Game::over() {
  return (_p1Score >= 11 || _p2Score >= 11) && abs(_p1Score - _p2Score) >= 2;
}

void Game::updateScore(int p1, int p2) {
  // The loop will constantly update the score, so we only act if it has changed
  if ((p1 != _p1Score) || (p2 != _p2Score)) {
    _p1Score = p1;
    _p2Score = p2;
    _serves++;

    Serial.print("Updating scores ");
    Serial.print(_p1Score);
    Serial.print(" ");
    Serial.print(_p2Score);
    Serial.print("   ");
    Serial.println(over());

    if (_serves == 2) {
      _serves = 0;
      _server = _server == 1 ? 2 : 1;
    }
  }
}

void Game::restart(int serve) {
  _p1Score = 0;
  _p2Score = 0;
  _server = serve;
  _serves = 0;
}
{'fraction_non_alphanumeric': 0.1703940362087327, 'fraction_numerical': 0.03887113951011715, 'mean_word_length': 3.058315334773218, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5141081', 'n_tokens_mistral': 764, 'n_tokens_neox': 731, 'n_words': 180}