<commit_before>import { put, select, take } from 'redux-saga/effects';

import { makeSelectPrivKey, makeSignerAddrSelector } from '../../AccountProvider/selectors';
import { makeMyCardsSelector } from '../../Seat/selectors';
import { nickNameByAddress } from '../../../services/nicknames';
import { formatNtz } from '../../../utils/amountFormatter';
import * as storageService from '../../../services/sessionStorage';

import { addMessage, bet, show, net, UPDATE_RECEIVED } from '../actions';
import {
  lastAmountByAction,
  isSbTurnByAction,
  isBbTurnByAction,
  is0rTurnByAction,
  isShowTurnByAction,
  hasNettingInAction,
  makeSbSelector,
  makeSelectWinners,
} from '../selectors';


export function* updateScanner(pokerHelper) {
  // toggle variables to avoid duplicate requests
  const payedBlind = {};
  const showed = {};
  const netted = {};

  while (true) { //eslint-disable-line
    const action = yield take(UPDATE_RECEIVED);
    // fetch state if not existing
    const myAddr = yield select(makeSignerAddrSelector());
    const privKey = yield select(makeSelectPrivKey());
    const sb = yield select(makeSbSelector(), { params: { tableAddr: action.tableAddr } });

    const toggleKey = action.tableAddr + action.hand.handId;

    // do nothing if hand data missing
    if (!action.hand || !action.hand.lineup) {
      continue; // eslint-disable-line no-continue
    }

    let complete;

    try {
      complete = pokerHelper.isHandComplete(action.hand.lineup, action.hand.dealer, action.hand.state);
    } catch (e) {
      continue; // eslint-disable-line no-continue
    }

    // check if turn to pay small blind
    if (!complete) {
      if (isSbTurnByAction(action, { address: myAddr, sb }) && !payedBlind[toggleKey]) {
        payedBlind[toggleKey] = true;
        yield put(bet(action.tableAddr, action.hand.handId, sb, privKey));
        continue; // eslint-disable-line no-continue
      }
      // check if turn to pay big blind
      if (isBbTurnByAction(action, { address: myAddr, sb }) && !payedBlind[toggleKey]) {
        payedBlind[toggleKey] = true;
        yield put(bet(action.tableAddr, action.hand.handId, sb * 2, privKey));
        continue; // eslint-disable-line no-continue
      }

      // check if turn to pay 0 receipt
      if (is0rTurnByAction(action, { address: myAddr, sb }) && !payedBlind[toggleKey]) {
        payedBlind[toggleKey] = true;
        yield put(bet(action.tableAddr, action.hand.handId, 0, privKey));
        continue; // eslint-disable-line no-continue
      }
<commit_msg>Reset payedBlind flag on hand reset (#759)<commit_after>import { put, select, take } from 'redux-saga/effects';

import { makeSelectPrivKey, makeSignerAddrSelector } from '../../AccountProvider/selectors';
import { makeMyCardsSelector } from '../../Seat/selectors';
import { nickNameByAddress } from '../../../services/nicknames';
import { formatNtz } from '../../../utils/amountFormatter';
import * as storageService from '../../../services/sessionStorage';

import { addMessage, bet, show, net, UPDATE_RECEIVED } from '../actions';
import {
  lastAmountByAction,
  isSbTurnByAction,
  isBbTurnByAction,
  is0rTurnByAction,
  isShowTurnByAction,
  hasNettingInAction,
  makeSbSelector,
  makeSelectWinners,
} from '../selectors';


export function* updateScanner(pokerHelper) {
  // toggle variables to avoid duplicate requests
  const payedBlind = {};
  const showed = {};
  const netted = {};

  while (true) { //eslint-disable-line
    const action = yield take(UPDATE_RECEIVED);
    // fetch state if not existing
    const myAddr = yield select(makeSignerAddrSelector());
    const privKey = yield select(makeSelectPrivKey());
    const sb = yield select(makeSbSelector(), { params: { tableAddr: action.tableAddr } });

    const toggleKey = action.tableAddr + action.hand.handId;

    // do nothing if hand data missing
    if (!action.hand || !action.hand.lineup) {
      continue; // eslint-disable-line no-continue
    }

    let complete;

    try {
      complete = pokerHelper.isHandComplete(action.hand.lineup, action.hand.dealer, action.hand.state);
    } catch (e) {
      continue; // eslint-disable-line no-continue
    }

    // reset payedBlind on hand revert after undefined distribution
    if (action.hand.cards && action.hand.cards.length === 0) {
      payedBlind[toggleKey] = false;
    }

    // check if turn to pay small blind
    if (!complete) {
      if (isSbTurnByAction(action, { address: myAddr, sb }) && !payedBlind[toggleKey]) {
        payedBlind[toggleKey] = true;
        yield put(bet(action.tableAddr, action.hand.handId, sb, privKey));
        continue; // eslint-disable-line no-continue
      }
      // check if turn to pay big blind
      if (isBbTurnByAction(action, { address: myAddr, sb }) && !payedBlind[toggleKey]) {
        payedBlind[toggleKey] = true;
        yield put(bet(action.tableAddr, action.hand.handId, sb * 2, privKey));
        continue; // eslint-disable-line no-continue
      }

      // check if turn to pay 0 receipt
      if (is0rTurnByAction(action, { address: myAddr, sb }) && !payedBlind[toggleKey]) {
        payedBlind[toggleKey] = true;
        yield put(bet(action.tableAddr, action.hand.handId, 0, privKey));
        continue; // eslint-disable-line no-continue
      }

{'fraction_non_alphanumeric': 0.13236404833836857, 'fraction_numerical': 0.0026435045317220545, 'mean_word_length': 3.148003132341425, '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': '406586', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1603, 'n_words': 398}