package com.micer.easyball.pojo.Dto;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
public class ClubStatisticsDto
{
    /**
     *  总场次
     */
    private Long session;

    /**
     *  胜场
     */
    private Long win;

    /**
     *  平局
     */
    private Long tie;

    /**
     *  负场
     */
    private Long lose;

    /**
     *  进球（正）
     */
    private Long ourGoal;

    /**
     *  进球（负）
     */
    private Long opponentGoal;

    /**
     *  Top射手
     */
    private List<PlayerDto> topShooter;

    /**
     *  Top出场
     */
    private List<PlayerDto> topPlayer;

    /**
     *  Top助攻
     */
    private List<PlayerDto> topAssister;

    /**
     *  球员数据统计
     *  包括进球，出场，助攻统计
     */
    private List<PlayerDto> playerList;

    public ClubStatisticsDto()
    {
        this.setSession(0L);
        this.setWin(0L);
        this.setTie(0L);
        this.setLose(0L);
        this.setOurGoal(0L);
        this.setOpponentGoal(0L);
        this.playerList = new ArrayList<>();
        this.topAssister = new ArrayList<>();
        this.topPlayer = new ArrayList<>();
        this.topShooter = new ArrayList<>();
    }

    /**
     * 寻找球员是否存在
     */
    public int findPlayer(String playerId)
    {
        int pos = 0;
        for (PlayerDto playerDto: playerList)
        {
            if (playerDto.getPlayerId().equals(playerId))
            {
                return pos;
            }
            pos++;
        }
        return -1;
    }
}
