using UnityEngine;
namespace GrassCutter
{
/// Server side of the cheat console (host only): wallet and perks, no strings attached.
public partial class TeamState
{
public void ServerSetMoney(double value)
{
if (!IsServer) return;
Money.Value = System.Math.Max(0d, value);
Save();
}
/// Set a perk to a level (clamped to its max), with the same side effects as buying it.
public void ServerSetPerk(PerkId id, int level)
{
if (!IsServer || id >= PerkId.Count) return;
var def = GameDefs.Perk(id);
int was = Level(id);
level = Mathf.Clamp(level, 0, def.maxLevel);
if (level == was) return;
Perks[(int)id] = (byte)level;
if (level > was) PurchasedRpc("Cheats", def.maxLevel > 1 ? Loc.Key(def.nameEn, GameDefs.ToRoman(level)) : Loc.Key(def.nameEn));
}
/// Hand a player a tool, as if they had bought it.
public void ServerGiveTool(PlayerAgent p, ToolId t)
{
if (!IsServer || !p) return;
p.Owned.Value |= (ushort)(1 << (int)t);
SaveCrew(p);
}
}
}