Example #1
0
 internal User(
     ulong id,
     string username,
     string discriminator,
     DateTime createdAt,
     Notifier notifier,
     ulong balance,
     ulong tokenBalance,
     ulong debt,
     Dictionary <string, ItemData> items,
     Dictionary <string, DateTime> cooldowns,
     Dictionary <string, long> stats,
     Dictionary <string, MeritData> merits,
     HuskBrain brain, Husk husk,
     UserConfig config) : base(id, username, discriminator, createdAt, config)
 {
     Username      = username;
     Discriminator = discriminator;
     Balance       = balance;
     TokenBalance  = tokenBalance;
     Debt          = debt;
     Items         = items ?? new Dictionary <string, ItemData>();
     Cooldowns     = cooldowns ?? new Dictionary <string, DateTime>();
     Stats         = stats ?? new Dictionary <string, long>();
     Merits        = merits ?? new Dictionary <string, MeritData>();
     Brain         = brain ?? new HuskBrain();
     Husk          = husk;
 }
Example #2
0
 public User(IUser user) : base(user)
 {
     Balance           = 0;
     TokenBalance      = 0;
     Debt              = 0;
     Items             = new Dictionary <string, ItemData>();
     Cooldowns         = new Dictionary <string, DateTime>();
     InternalCooldowns = new Dictionary <string, DateTime>();
     Stats             = new Dictionary <string, long>();
     Merits            = new Dictionary <string, MeritData>();
     Brain             = new HuskBrain();
     Husk              = null;
 }
Example #3
0
        // takes the items, and gives the money.
        public void ApplySell(Husk husk, HuskBrain brain, ref ulong balance)
        {
            foreach ((string key, int value) in ItemIds)
            {
                husk.Backpack.ItemIds[key] -= value;

                if (husk.Backpack.ItemIds[key] == 0)
                {
                    husk.Backpack.ItemIds.Remove(key);
                }
            }

            balance += Value;
        }
Example #4
0
        // adds the items, and takes the money.
        public void ApplyBuy(Husk husk, HuskBrain brain, ref ulong balance, string marketId = null)
        {
            foreach ((string key, int value) in ItemIds)
            {
                if (!husk.Backpack.ItemIds.TryAdd(key, value))
                {
                    husk.Backpack.ItemIds[key] += value;
                }

                if (!string.IsNullOrWhiteSpace(marketId))
                {
                    brain.Catalogs[marketId].ItemIds[key] -= value;
                }
            }

            balance -= Value;
        }