<commit_before>//
// Handles a reset, which can only be done if you are at a state to start a new hand
//

'use strict';

const gameService = require('../GameService');
const bjUtils = require('../BlackjackUtils');

module.exports = {
  handleIntent: function() {
    // We will ask them if they want to reset
    const res = require('../' + this.event.request.locale + '/resources');
    let speech;
    let reprompt;
    const game = this.attributes[this.attributes.currentGame];

    if (game.canReset) {
      speech = res.strings.RESET_CONFIRM;
      reprompt = res.strings.RESET_CONFIRM;
      this.handler.state = 'CONFIRMRESET';
    } else {
      speech = res.strings.TOURNAMENT_NORESET;
      reprompt = res.strings.TOURNAMENT_INVALIDACTION_REPROMPT;
    }

    bjUtils.emitResponse(this.emit, this.event.request.locale, null, null,
            speech, reprompt);
  },
  handleYesReset: function() {
    const res = require('../' + this.event.request.locale + '/resources');

    // Confirmed - let's reset
    gameService.initializeGame(this.attributes, this.event.session.user.userId);
    this.handler.state = 'NEWGAME';
    bjUtils.emitResponse(this.emit, this.event.request.locale, null, null,
            res.strings.RESET_COMPLETED, res.strings.RESET_REPROMPT);
  },
  handleNoReset: function() {
    // Nope, they are not going to reset - so go back to start a new game
    const res = require('../' + this.event.request.locale + '/resources');

    this.handler.state = 'NEWGAME';
    bjUtils.emitResponse(this.emit, this.event.request.locale, null, null,<commit_msg>Fix bug with reset<commit_after>//
// Handles a reset, which can only be done if you are at a state to start a new hand
//

'use strict';

const gameService = require('../GameService');
const bjUtils = require('../BlackjackUtils');

module.exports = {
  handleIntent: function() {
    // We will ask them if they want to reset
    const res = require('../' + this.event.request.locale + '/resources');
    let speech;
    let reprompt;
    const game = this.attributes[this.attributes.currentGame];

    if (game.canReset) {
      speech = res.strings.RESET_CONFIRM;
      reprompt = res.strings.RESET_CONFIRM;
      this.handler.state = 'CONFIRMRESET';
    } else {
      speech = res.strings.TOURNAMENT_NORESET;
      reprompt = res.strings.TOURNAMENT_INVALIDACTION_REPROMPT;
    }

    bjUtils.emitResponse(this.emit, this.event.request.locale, null, null,
            speech, reprompt);
  },
  handleYesReset: function() {
    const res = require('../' + this.event.request.locale + '/resources');

    // Confirmed - let's reset but preserve the timestamp
    const timestamp = this.attributes[this.attributes.currentGame].timestamp;
    gameService.initializeGame(this.attributes, this.event.session.user.userId);
    this.attributes[this.attributes.currentGame].timestamp = timestamp;
    this.handler.state = 'NEWGAME';
    bjUtils.emitResponse(this.emit, this.event.request.locale, null, null,
            res.strings.RESET_COMPLETED, res.strings.RESET_REPROMPT);
  },
  handleNoReset: function() {
    // Nope, they are not going to reset - so go back to start a new game
    const res = require('../' + this.event.request.locale + '/resources');

    this.handler.state = 'NEWGAME';
    bjUtils.emitResponse(this.emit, this.event.request.locale, null, null,
{'fraction_non_alphanumeric': 0.13059033989266547, 'fraction_numerical': 0.0, 'mean_word_length': 3.2095357590966125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '757698', 'n_tokens_mistral': 1037, 'n_tokens_neox': 1024, 'n_words': 249}