import { Action } from "@ngrx/store";
import { Attack } from "../model/attack.model";

export const REQUEST_ATTACKS_LIST = 'REQUEST_ATTACKS_LIST';
export const SET_ATTACKS_LIST = 'SET_ATTACKS_LIST';
export const ADD_ATTACK = 'ADD_ATTACK';
export const UPDATE_ATTACK = 'UPDATE_ATTACK';
export const REMOVE_ATTACK = 'REMOVE_ATTACK';
export const UPDATE_SEARCH = 'UPDATE_SEARCH';
export const UPDATE_SORT = 'UPDATE_SORT';

export class RequestAttacksListAction implements Action{
    readonly type = REQUEST_ATTACKS_LIST;
}

export class SetAttacksListAction implements Action{
    readonly type = SET_ATTACKS_LIST;
    constructor(public attacks: Attack[]){ }
}

export class AddAttackAction implements Action{
    readonly type = ADD_ATTACK;
    constructor(public attack: Attack){}
}


export class UpdateAttackAction implements Action{
    readonly type = UPDATE_ATTACK;
    constructor(public attack: Attack){}
}


export class RemoveAttackAction implements Action{
    readonly type = REMOVE_ATTACK;
    constructor(public id: number){}
}

export class UpdateSearchAction implements Action{
    readonly type = UPDATE_SEARCH;
    constructor(public search: String){}
}

export class UpdateSortAction implements Action{
    readonly type = UPDATE_SORT;
    constructor(public by: String, public reverse: Boolean){}
}

export type AttacksActions = 
    RequestAttacksListAction | 
    SetAttacksListAction |
    AddAttackAction |
    UpdateAttackAction |
    RemoveAttackAction |
    UpdateSearchAction |
    UpdateSortAction;