Exemplo n.º 1
0
        public static void GiveViewersPoints()
        {
            Log.Message($"Total viewers to reward points: {TCText.ColoredText(viewers.Count.ToString(), ColorLibrary.BlueGreen)}");

            if (Ledgers.Instance == null)
            {
                Log.Error("ledger instance null");
                return;
            }

            Ledger activeLedger = Ledgers.ActiveLedger();

            if (activeLedger == null)
            {
                Log.Error("Current Active Ledger is null. Report to mod author.");
                return;
            }

            foreach (Viewer viewer in viewers)
            {
                LedgerRecord ledgerRecord = activeLedger.GetLedgerRecord(viewer.Username, viewer.Service);

                ledgerRecord.PointBalance += ToolkitPointsSettings.pointsPerReward;
            }
        }
Exemplo n.º 2
0
        public LedgerRecord GetLedgerRecord(string username, Service service)
        {
            Viewer viewer;

            if (ViewerController.ViewerExists(service, username))
            {
                viewer = ViewerController.GetViewer(service, username);
            }
            else
            {
                viewer = ViewerController.CreateViewer(service, username, 0);
            }

            LedgerRecord ledgerRecord;

            ledgerRecord = LedgerRecords.Find((lr) => lr.Username == username && lr.Service == service);

            if (ledgerRecord == null)
            {
                ledgerRecord = new LedgerRecord()
                {
                    Username     = username,
                    Service      = service,
                    PointBalance = 0
                };
            }

            return(ledgerRecord);
        }
Exemplo n.º 3
0
        public static void AddPoints(string username, Service service, int points)
        {
            if (points < 1)
            {
                Log.Error("Cannot add negative or zero points");
                return;
            }

            Ledger ledger = Ledgers.ActiveLedger();

            LedgerRecord ledgerRecord = ledger.GetLedgerRecord(username, service);

            ledgerRecord.PointBalance += points;
        }