<commit_before>import actions from '../actions/GameActionCreators'

const initialState = {
  resources: {
    money: 500,
    manpower: 20000,
    siridium: 1000,
    meganium: 500,
    vylerium: 80,
    technology: 3,
  },
  provinces: {
    'a': {
      owner: 'albertoblaz',
      id: 1,
      name: 'a',
      resources: {
        money: 13,
        manpower: 40,
      },
    },
    'b': {
      owner: 'albertoblaz',
      id: 2,
      name: 'a',
      resources: {
        money: 7,
        manpower: 70,
      },
    },
    'c': {
      owner: 'adriantom3',
      id: 3,
      name: 'a',
      resources: {
        money: 3,
        manpower: 19,
      },
    },
  },
}

const malusAfterConquest = (state, province) => ({
  money: state.provinces[province].money * 0.5,
  manpower: state.provinces[province].manpower * 0.5,
})

const handlers = {
  [actions.START_GAME]: (state, action) =>
    Object.assign({}, state, initialState),

  [actions.CONQUER_PROVINCE]: (state, action) =>
    Object.assign({}, state, {
      provinces: {
        [action.province]: {
          owner: action.player,
          resources: malusAfterConquest(state, action.province),
        },
      },
    }),
}

export default (reducer) =>
  (state = initialState, action) =>
    reducer(handlers, state, action)<commit_msg>Show/Hide contextual menu<commit_after>import actions from '../actions/GameActionCreators'

const initialState = {
  isMenuOpen: false,
  activeProvinceId: '',

  resources: {
    money: 500,
    manpower: 20000,
    siridium: 1000,
    meganium: 500,
    vylerium: 80,
    technology: 3,
  },

  provinces: {
    'a': {
      owner: 'albertoblaz',
      id: 1,
      name: 'a',
      resources: {
        money: 13,
        manpower: 40,
      },
    },
    'b': {
      owner: 'albertoblaz',
      id: 2,
      name: 'a',
      resources: {
        money: 7,
        manpower: 70,
      },
    },
    'c': {
      owner: 'adriantom3',
      id: 3,
      name: 'a',
      resources: {
        money: 3,
        manpower: 19,
      },
    },
  },
}

const malusAfterConquest = (state, province) => ({
  money: state.provinces[province].money * 0.5,
  manpower: state.provinces[province].manpower * 0.5,
})

const handlers = {
  [actions.START_GAME]: (state, action) =>
    Object.assign({}, state, initialState),

  [actions.CONQUER_PROVINCE]: (state, action) =>
    Object.assign({}, state, {
      provinces: {
        [action.province]: {
          owner: action.player,
          resources: malusAfterConquest(state, action.province),
        },
      },
    }),

  [actions.SHOW_MENU_PROVINCE]: (state, action) =>
    Object.assign({}, state, {
      isMenuOpen: true,
      activeProvinceId: action.provinceId,
    }),

  [actions.HIDE_MENU]: (state) =>
    Object.assign({}, state, {
      isMenuOpen: false,
      activeProvinceId: '',
    }),
}

export default (reducer) =>
  (state = initialState, action) =>
    reducer(handlers, state, action)
{'fraction_non_alphanumeric': 0.15542818610923803, 'fraction_numerical': 0.024275118004045852, 'mean_word_length': 2.1766595289079227, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6690388', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1027, 'n_words': 210}