mirror of
https://github.com/roflmuffin/CounterStrikeSharp.git
synced 2025-12-07 00:16:36 -08:00
Co-authored-by: B3none <ablackham2000@gmail.com> Co-authored-by: B3none <24966460+B3none@users.noreply.github.com>
33 lines
815 B
C#
33 lines
815 B
C#
using CounterStrikeSharp.API.Core;
|
|
using MySharedTypes.Contracts;
|
|
|
|
namespace WithSharedTypes;
|
|
|
|
public class BalanceHandler : IBalanceHandler
|
|
{
|
|
private readonly CCSPlayerController _player;
|
|
|
|
// This could be a database, a file, or a dictionary like this.
|
|
internal static readonly Dictionary<CCSPlayerController, decimal> Balances = new();
|
|
|
|
public BalanceHandler(CCSPlayerController player)
|
|
{
|
|
_player = player;
|
|
}
|
|
|
|
public decimal Balance
|
|
{
|
|
get => Balances.TryGetValue(_player, out var balance) ? balance : 0;
|
|
set => Balances[_player] = value;
|
|
}
|
|
|
|
public decimal Add(decimal amount)
|
|
{
|
|
return Balance += amount;
|
|
}
|
|
|
|
public decimal Subtract(decimal amount)
|
|
{
|
|
return Balance -= amount;
|
|
}
|
|
} |