Ejemplo n.º 1
0
        public float Refund(IcPlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException(nameof(player));
            }

            string playerName = player.PlayerName;

            if (funds.TryGetValue(playerName, out float fundAmount))
            {
                funds.Remove(playerName);

                player.Money += fundAmount;
                player.SetObjectDirtyBit(DirtyBit.BitOccasional, true);

                DA.PagePlayer(player, $"You have been refunded {(int)fundAmount} credit(s) for the {DATranslationManager.Translate(BuildingObj)}.");

                return(fundAmount);
            }
            else
            {
                return(0.0f);
            }
        }
Ejemplo n.º 2
0
        public void AddFund(IcPlayer player, float fundAmount)
        {
            if (player == null)
            {
                throw new ArgumentNullException(nameof(player));
            }
            else if (fundAmount <= 0.0f)
            {
                throw new ArgumentOutOfRangeException($"Argument '{nameof(fundAmount)}' must be > 0");
            }

            string playerName = player.PlayerName;

            if (funds.ContainsKey(playerName))
            {
                funds[playerName] += fundAmount;
            }
            else
            {
                funds.Add(playerName, fundAmount);
            }

            player.Money -= fundAmount;
            player.SetObjectDirtyBit(DirtyBit.BitOccasional, true);
        }