Ejemplo n.º 1
0
        internal void AddTransaction(CurrencyTransaction transaction)
        {
            if (transaction.FundsDelta == 0 && transaction.ScienceDelta == 0 && transaction.ReputationDelta == 0)
            {
                return;
            }

            this.transactionDatabase.Add(transaction);

            if (transaction.FundsDelta != 0f)
            {
                this.fundingTransactions.Add(transaction);
            }

            if (transaction.ScienceDelta != 0f)
            {
                this.scienceTransactions.Add(transaction);
            }

            if (transaction.ReputationDelta != 0f)
            {
                this.reputationTransactions.Add(transaction);
            }

            this.CurrentFunds      += (double)transaction.FundsDelta;
            this.CurrentScience    += transaction.ScienceDelta;
            this.CurrentReputation += transaction.ReputationDelta;

            this.LogDebug("Added transaction: {0}", transaction);
        }
Ejemplo n.º 2
0
        public void OnReputationChangedHandler(float reputation, TransactionReasons reason)
        {
            if (reputation != this.CurrentReputation)
            {
                if (Mathf.Abs(reputation - this.CurrentReputation) < 0.01)
                {
                    this.CurrentReputation = reputation;
                    return;
                }

                CurrencyTransaction correction = new CurrencyTransaction(
                    Planetarium.GetUniversalTime(),
                    TransactionReasons.None,
                    0f,
                    0f,
                    reputation - this.CurrentReputation
                    );

                this.AddTransaction(correction);

                this.Log("Detected discrepancy in rep totals: admin shows {0}, VCT shows {1}; correcting with {2}.",
                         reputation,
                         this.CurrentReputation,
                         correction
                         );
            }
        }
Ejemplo n.º 3
0
        public void OnScienceChangedHandler(float science, TransactionReasons reason)
        {
            if (science != this.CurrentScience)
            {
                if (Mathf.Abs(science - this.CurrentScience) < 0.01)
                {
                    this.CurrentScience = science;
                    return;
                }

                CurrencyTransaction correction = new CurrencyTransaction(
                    Planetarium.GetUniversalTime(),
                    TransactionReasons.None,
                    0f,
                    science - this.CurrentScience,
                    0f
                    );

                this.AddTransaction(correction);

                this.Log("Detected discrepancy in science totals: R&D shows {0}, VCT shows {1}; correcting with {2}.",
                         science,
                         this.CurrentScience,
                         correction
                         );
            }
        }
Ejemplo n.º 4
0
        public void OnFundsChangedHandler(double funds, TransactionReasons reason)
        {
            if (funds != this.CurrentFunds)
            {
                if (Math.Abs(funds - this.CurrentFunds) < 0.01)
                {
                    this.CurrentFunds = funds;
                    return;
                }

                CurrencyTransaction correction = new CurrencyTransaction(
                    Planetarium.GetUniversalTime(),
                    TransactionReasons.None,
                    (float)(funds - this.CurrentFunds),
                    0f,
                    0f
                    );

                this.AddTransaction(correction);

                this.Log("Detected discrepancy in funds totals: admin shows {0}, VCT shows {1}; correcting with {2}.",
                         funds,
                         this.CurrentFunds,
                         correction
                         );
            }
        }
        private void updateTable()
        {
            double aggregateFunds      = Tracker.CurrentFunds;
            float  aggregateScience    = Tracker.CurrentScience;
            float  aggregateReputation = Tracker.CurrentReputation;

            for (int i = Tracker.TransactionList.Count - 1; i >= 0; i--)
            {
                CurrencyTransaction trans = Tracker.TransactionList[i];

                bool skipTrans = true;

                if (this.IncludeFunds && trans.FundsDelta != 0f)
                {
                    skipTrans = false;
                }

                if (this.IncludeScience && trans.ScienceDelta != 0f)
                {
                    skipTrans = false;
                }

                if (this.IncludeReputation && trans.ReputationDelta != 0f)
                {
                    skipTrans = false;
                }

                if (skipTrans)
                {
                    continue;
                }

                this.timeStampCol.Add(VOID_Tools.FormatDate(trans.TimeStamp));

                this.reasonCol.Add(Enum.GetName(typeof(TransactionReasons), trans.Reason));

                this.fundsDeltaCol.Add(VOID_CareerStatus.formatDelta(trans.FundsDelta, "#,##0.00"));
                this.fundsTotalCol.Add(aggregateFunds);
                aggregateFunds -= (double)trans.FundsDelta;

                this.scienceDeltaCol.Add(VOID_CareerStatus.formatDelta(trans.ScienceDelta, "#,##0"));
                this.scienceTotalCol.Add(aggregateScience);
                aggregateScience -= trans.ScienceDelta;

                this.repDeltaCol.Add(VOID_CareerStatus.formatDelta(trans.ReputationDelta, "#,##0"));
                this.repTotalCol.Add(aggregateReputation);
                aggregateReputation -= trans.ReputationDelta;

                this.waitToResize = 5;
            }
        }
Ejemplo n.º 6
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            ConfigNode[] transNodes = node.GetNodes(TRANSACTION_KEY);
            ConfigNode   transNode;

            for (int idx = 0; idx < transNodes.Length; idx++)
            {
                transNode = transNodes[idx];

                CurrencyTransaction trans = new CurrencyTransaction();

                trans.Load(transNode);

                this.AddTransaction(trans);
            }

            CurrencyTransaction.TransactionSorter sorter = new CurrencyTransaction.TransactionSorter(
                CurrencyTransaction.TransactionSorter.SortType.Time,
                CurrencyTransaction.TransactionSorter.SortOrder.Ascending
                );

            this.transactionDatabase.Sort(sorter);
            this.fundingTransactions.Sort(sorter);
            this.scienceTransactions.Sort(sorter);
            this.reputationTransactions.Sort(sorter);

            this.isNewGame = node.GetValue(NEWGAME_KEY, this.isNewGame);

            if (this.isNewGame)
            {
                this.RebalanceDatabase();
            }

            this.Log("Loaded.\n{0}", this.ToString());
        }
Ejemplo n.º 7
0
        internal void AddTransaction(CurrencyModifierQuery query)
        {
            CurrencyTransaction transaction = new CurrencyTransaction(Planetarium.GetUniversalTime(), query);

            this.AddTransaction(transaction);
        }