{"size": 902, "ext": "js", "max_stars_repo_path": "src/Reducers/PokemonReducer.js", "max_stars_repo_name": "koteswar375/PokemonReactApp", "max_stars_repo_stars_event_min_datetime": "2021-11-18T21:24:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-18T21:24:25.000Z", "max_issues_repo_path": "src/Reducers/PokemonReducer.js", "max_issues_repo_name": "koteswar375/PokemonReactApp", "max_issues_repo_issues_event_min_datetime": "2022-02-15T06:34:05.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-28T01:46:36.000Z", "max_forks_repo_path": "src/Reducers/PokemonReducer.js", "max_forks_repo_name": "koteswar375/PokemonReactApp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 25.7714285714, "max_line_length": 87, "alphanum_fraction": 0.5731707317}
export const CAPTURE = 'CAPTURE';
export const RELEASE = 'RELEASE';
export const ADD = 'ADD';



const pokemonReducer = (state, action) => {
    const capture = () => ({
        pokemons: state.pokemons.filter(obj => obj !== action.pokemon),
        capturedPokemons: [...state.capturedPokemons, action.pokemon]
    });

    const release = () => ({
        pokemons: [...state.pokemons, action.pokemon],
        capturedPokemons:  state.capturedPokemons.filter(obj => obj !== action.pokemon)
    });

    const add = () => ({
        pokemons: [...state.pokemons, action.pokemon],
        capturedPokemons:  [...state.capturedPokemons]
    })

    switch (action.type) {
        case RELEASE:
            return release();
        case CAPTURE:
            return capture();
        case ADD:
            return add()
        default:
            return state;
    }
};

export default pokemonReducer;