using System;
using System.Collections.Generic;
using GTANetworkAPI;

namespace ReallifeGamemode.Server.Job
{
  public class MuellmannData
  {
    private Player client1;
    private Player client2;
    public Vehicle vehicle;
    private int trashCount = 0;

    public MuellmannData(Vehicle vehicle)
    {
      this.vehicle = vehicle;
    }

    public void setClientToData(Player player)
    {
      if (client1 == player || client2 == player)
      {
        Console.WriteLine("Spieler schon gespeichert");
        return;
      }

      if (client1 == null) { client1 = player; return; }
      else if (client2 == null) { client2 = player; return; }
      else if (client1 != null && client2 != null) { Console.WriteLine("kein Platz"); }
    }

    public void removeClientFromData(Player player)
    {
      if (client1 == player) { client1 = null; }
      if (client2 == player) { client2 = null; }
    }

    public int getTrashCount()
    {
      return trashCount;
    }

    public void setTrashCount(int i)
    {
      trashCount = i;
    }

    public List<Player> getClientsFromData()
    {
      List<Player> tempList = new List<Player>();
      if (client1 != null) { tempList.Add(client1); }
      if (client2 != null) { tempList.Add(client2); }
      return tempList;
    }

    public MuellmannData getDataFromClient(Player player)
    {
      if (client1 != player && client2 != player)
        return null;
      return this;
    }

    public bool hasFreePlace()
    {
      if (client1 != null && client2 != null)
        return false;
      return true;
    }

    public Player getPartnerClient(Player player)
    {
      if (client1 != player && client2 != player)
        return null;

      if (client1 == player) { return client2; }
      if (client2 == player) { return client1; }
      return null;
    }
  }
}
