package seng302.Networking.Messages;

import seng302.Networking.Messages.Enums.MessageType;

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

/**
 * Created by fwy13 on 25/04/17.
 */
public class RaceStatus  extends AC35Data {

    private long currentTime;
    private int raceID;
    private int raceStatus;
    private long expectedStartTime;
    private int windDirection;
    private int windSpeed;
    private int raceType;
    private List<BoatStatus> boatStatuses;
    private static final double windDirectionScalar =  360.0 / 32768.0; // 0x8000 / 360

    public RaceStatus(long currentTime, int raceID, int raceStatus, long expectedStartTime, int windDirection, int windSpeed, int raceType, List<BoatStatus> boatStatuses){
        super(MessageType.RACESTATUS);
        this.currentTime = currentTime;
        this.raceID = raceID;
        this.raceStatus = raceStatus;
        this.expectedStartTime = expectedStartTime;
        this.windDirection = windDirection;
        this.windSpeed = windSpeed;
        this.raceType = raceType;
        this.boatStatuses = boatStatuses;//note this is a copy so any alterations to the parent will affect this.
    }



    ///Getters.

    public long getCurrentTime()
    {
        return currentTime;
    }

    public int getRaceID()
    {
        return raceID;
    }

    /**
     *
     * @return race status number
     */
    public int getRaceStatus()
    {
        return raceStatus;
    }

    public long getExpectedStartTime()
    {
        return expectedStartTime;
    }

    public int getWindDirection()
    {
        return windDirection;
    }

    public int getWindSpeed()
    {
        return windSpeed;
    }

    public int getRaceType()
    {
        return raceType;
    }

    public List<BoatStatus> getBoatStatuses()
    {
        return boatStatuses;
    }

    public boolean isNotActive() {
        return raceStatus == 0;
    }

    public boolean isWarning() {
        return raceStatus == 1;
    }

    public boolean isPreparatory() {
        return raceStatus == 2;
    }

    public boolean isStarted() {
        return raceStatus == 3;
    }

    public boolean isFinished() {
        return raceStatus == 4;
    }

    public boolean isRetired() {
        return raceStatus == 5;
    }

    public boolean isAbandoned() {
        return raceStatus == 6;
    }

    public boolean isPostponed() {
        return raceStatus == 7;
    }

    public boolean isTerminated() {
        return raceStatus == 8;
    }

    public boolean isStartTimeSet() {
        return raceStatus != 9;
    }

    public boolean isPrestart() {
        return raceStatus == 10;
    }

    public double getScaledWindDirection() {
        return (double) windDirection * windDirectionScalar;
    }
}
