using System;
using UnityEngine;
namespace GrassCutter
{
public enum TreatId : byte { Beer = 0, Cigar = 1 }
///
/// What the two vending machines on the deck sell for a kilo of grass, and the boost each one gives the one who had it.
/// Personal and kept on this machine only: everyone buys their own, and a boost is gone when the match ends.
///
public static class Treats
{
public const float CostKg = 1f;
/// A pack for the belt: this many at once (for as many kilos), and a slot holds at most PackMost.
public const int PackSize = 3, PackMost = 6;
public const float Seconds = 150f;
/// Grass Beer: the blade cuts this much wider.
public const float BeerMow = 1.4f;
/// Herb Cigar: you walk and run this much faster.
public const float CigarMove = 1.3f;
static float _beerUntil = -1f, _cigarUntil = -1f;
public static event Action Started;
public static float Left(TreatId t) => Mathf.Max(0f, (t == TreatId.Beer ? _beerUntil : _cigarUntil) - Time.time);
public static bool On(TreatId t) => Left(t) > 0f;
public static float MowMul => On(TreatId.Beer) ? BeerMow : 1f;
public static float MoveMul => On(TreatId.Cigar) ? CigarMove : 1f;
public static string Name(TreatId t) => t == TreatId.Beer ? Loc.T("Grass Beer") : Loc.T("Herb Cigar");
public static string Boost(TreatId t) => t == TreatId.Beer ? Loc.T("Liquid Courage") : Loc.T("Second Wind");
public static string Effect(TreatId t) => t == TreatId.Beer ? Loc.T("+40% cutting width") : Loc.T("+30% walking speed");
public static string Icon(TreatId t) => t == TreatId.Beer ? "icon_treat_beer" : "icon_treat_cigar";
/// The boost starts (or starts over: a second can doesn't stack, it tops the clock back up).
public static void Begin(TreatId t)
{
if (t == TreatId.Beer) _beerUntil = Time.time + Seconds;
else _cigarUntil = Time.time + Seconds;
Started?.Invoke(t);
}
public static void Clear() { _beerUntil = _cigarUntil = -1f; }
}
}