<commit_before>import initialState from './initialState';
import * as types from '../constants/actionTypes';
import { setDotsFromStartingDots } from '../utils/categoryStarter';

export default (state = initialState.character.backgrounds, action) => {
  switch (action.type) {
    case types.SET_STARTING_DOTS:
      const { category, trait, startingDots } = action.payload;

      if (category !== 'backgrounds') {
        return state;
      }

      return setDotsFromStartingDots(state, trait, startingDots);
    default:
      return state;
  }<commit_msg>Update backgrounds reducer to purchase dots<commit_after>import initialState from './initialState';
import * as types from '../constants/actionTypes';
import { setDotsFromStartingDots } from '../utils/categoryStarter';
import { addPurchasedDot } from '../utils/categoryPurchaser';

export default (state = initialState.character.backgrounds, action) => {
  let category, trait, startingDots;

  switch (action.type) {
    case types.SET_STARTING_DOTS:
      ({ category, trait, startingDots } = action.payload);

      if (category !== 'backgrounds') {
        return state;
      }

      return setDotsFromStartingDots(state, trait, startingDots);

    case types.PURCHASE_DOT:
      ({ category, trait } = action.payload);

      if (category !== 'backgrounds') {
        return state;
      }

      return addPurchasedDot(state, trait);
    default:
      return state;
  }
{'fraction_non_alphanumeric': 0.1168289290681502, 'fraction_numerical': 0.0, 'mean_word_length': 3.468944099378882, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6182463', 'n_tokens_mistral': 415, 'n_tokens_neox': 404, 'n_words': 103}