Example #1
0
        public List <DopeUser> AllUsers()
        {
            List <DopeUser>  dopelist = new List <DopeUser>();
            List <IdAndKeys> idklist  = _dataInterface.GetAllUserDefinedFieldsWithKey("DOPEWARS");

            foreach (IdAndKeys idk in idklist)
            {
                dopelist.Add(DopeUser.Deserialize(_bbs, idk.Keys["data"]));
            }
            return(dopelist);
        }
Example #2
0
        void LoadUser()
        {
            //Load User Record if there is one.
            string dustr = _dataInterface.GetUserDefinedField(_bbs.CurrentUser.UserId, "DOPEWARS");

            if (dustr == "")
            {
                // 012345678901234567890123456789012345678909
                _bbs.Write("~c1~l1It looks like this is your first time.~l1Enter a nickname to use:~c7");
                string nick = _bbs.Input(true, false, false);
                _bbs.WriteLine("~l1~c1Setting up your account, ~c7" + nick + "~c1.~p1.~p1.");
                //New User
                CurrentUser = new DopeUser()
                {
                    UserId       = _bbs.CurrentUser.UserId,
                    Turns        = 24,
                    Cash         = 1000,
                    Firepower    = 1,
                    Carry        = 100,
                    Health       = 100,
                    Location     = 0,
                    Posse        = 0,
                    Debt         = 2000,
                    LastTurnUsed = DateTime.Now,
                    Nick         = nick,
                };
                Dopewars_Drug dd = new Dopewars_Drug()
                {
                    Drug_Id = WEED,
                    Units   = 1,
                    Price   = Dope_Low[WEED]
                };
                CurrentUser.Drugs.Add(dd);
                SaveUser();
            }
            else
            {
                CurrentUser = DopeUser.Deserialize(_bbs, dustr);
                TimeSpan since_last = DateTime.Now - CurrentUser.LastTurnUsed;
                CurrentUser.Turns       += since_last.Hours;
                CurrentUser.LastTurnUsed = DateTime.Now;
                SaveUser();
            }
        }