Ejemplo n.º 1
0
        public void SellDrugs(int drug_id, int units, int price)
        {
            Dopewars_Drug dd = Drugs.FirstOrDefault(p => p.Drug_Id.Equals(drug_id));

            if (dd != null)
            {
                dd.Units -= units;
                Cash     += units * price;
            }
        }
Ejemplo n.º 2
0
        Dopewars_Location Location_Init(int hood)
        {
            Random            r   = new Random(DateTime.Now.Millisecond);
            Dopewars_Location loc = new Dopewars_Location()
            {
                LocationId   = hood,
                HasBank      = (Dope_Banks.Contains(hood)),
                HasGunStore  = (Dope_Gunstores.Contains(hood)),
                HasHospital  = (Dope_Hospitals.Contains(hood)),
                HasLoanShark = (hood == BRONX),
                HasPub       = (Dope_Pubs.Contains(hood)),
                Drugs        = new List <Dopewars_Drug>()
            };

            //Figure out what drugs we have for sale or buyers here.
            for (int drug = WEED; drug <= SPEED; drug++)
            {
                //The odds of this being for sale here depend on the hood and drug
                bool Has = (r.Next(1, 100) <= Dope_Hood_ForSale_Chance[hood, drug]);
                if (Has)
                {
                    Dopewars_Drug dd = new Dopewars_Drug()
                    {
                        Drug_Id = drug,
                        Price   = PriceForDrug(drug, hood)
                    };
                    loc.Drugs.Add(dd);
                }
                //The odds of there being buyers here depend on the hood and drug
                //Has = (r.Next(1, 100) < Dope_Hood_Buyers_Chance[hood, drug]);
                //if (Has)
                //{
                //    Dopewars_Drug dd = new Dopewars_Drug();
                //    dd.Drug_Id = drug;
                //    Dopewars_Drug ds = Locations[hood].Drugs_Selling.FirstOrDefault(p => p.Drug_Id.Equals(drug));
                //    if (ds == null)
                //    {
                //        dd.Price = PriceForDrug(drug, hood);
                //    }
                //    else
                //    {
                //        dd.Price = ds.Price;
                //    }
                //    Locations[hood].Drugs_Buying.Add(dd);
                //}
            }

            return(loc);
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
0
        public void BuyDrugs(int drug_id, int units, int price)
        {
            //Do they have this one already?
            Dopewars_Drug dd = Drugs.FirstOrDefault(p => p.Drug_Id.Equals(drug_id));

            if (dd == null)
            {
                dd = new Dopewars_Drug()
                {
                    Drug_Id = drug_id, Units = 0, Price = 0
                };
                Drugs.Add(dd);
            }
            int currentpaid = dd.Price * dd.Units;
            int newpaid     = (int)((currentpaid + price) / (dd.Units + units)); //New average price

            dd.Units += units;
            dd.Price  = newpaid;
        }
Ejemplo n.º 5
0
        void Travel()
        {
            if (CurrentUser.Turns > 0)
            {
                //Show list of locations
                ListLocations();
                //Prompt for which location to travel to
                bool locpicked = false;
                while (!locpicked)
                {
                    _bbs.Write("~c7Where To?");
                    char l = _bbs.GetChar();
                    if ((l >= '0') && (l <= '9'))
                    {
                        CurrentLocation = int.Parse(l.ToString());
                        locpicked       = true;
                    }
                    else
                    {
                        _bbs.WriteLine("~l1~c2Pick an actual f*****g location.~p1");
                        ListLocations();
                    }
                }
                //Init that location
                _bbs.WriteLine("~c1" + Dope_Hoods[CurrentLocation] + "!");
                CurrentUser.Location = CurrentLocation;
                _bbs.WriteLine("~l1~c1Travelling to ~c4" + Dope_Hoods[CurrentLocation] + "~c1.~p1.~p1.~p1.");
                Locations[CurrentLocation] = Location_Init(CurrentLocation);
                Random r = new Random(DateTime.Now.Millisecond);
                Dead = false;
                //Random police encounter
                if (r.Next(0, 100) <= Dope_Hood_Police_Encounter_Chance[CurrentLocation])
                {
                    Police();
                }
                else
                {
                    _bbs.WriteLine("~c1You manage to evade the cops.~p1");
                }
                if (!Dead)
                {
                    if (CurrentUser.Debt > 0)
                    {
                        CurrentUser.Debt = (int)(CurrentUser.Debt * 1.1f);
                    }
                    if (CurrentUser.Debt >= 100000)
                    {
                        //TODO
                        //Loan shark kicks your ass, kills 1 bitch each turn until all bitches are gone,
                        //Then kicks your ass for 10% health per turn until you die or pay up.
                        if (CurrentUser.Posse > 0)
                        {
                            _bbs.WriteLine("~l1~c2You owe the Loan Shark too much money.~l1To demonstrate his annoyance...~l1, he has one of your posse killed.");
                            CurrentUser.Posse--;
                        }
                        else
                        {
                            _bbs.WriteLine("~l1~c2You owe the Loan Shark too much money.~l1He sends some guys around...~l1They beat the living shit out of you.");
                            CurrentUser.Health -= 10;
                            if (CurrentUser.Health <= 0)
                            {
                                Dead = true; //dumbass.
                            }
                        }
                    }
                    if (!Dead)
                    {
                        //Random Lady on the Subay bullshit
                        _bbs.WriteLine("~l1~c1A lady on the subway says: ~c3'" + Dope_Lady[r.Next(0, Dope_Lady.Length - 1)] + "'~c1~p1");

                        //Random Bull Market Events
                        if (r.Next(0, 100) <= 30)  //20% chance, need to change this to per-neighborhood
                        {
                            int           bulldrug = r.Next(0, DRUG_HI);
                            Dopewars_Drug dd       = Locations[CurrentLocation].Drugs.FirstOrDefault(p => p.Drug_Id.Equals(bulldrug));
                            if (dd == null)
                            {
                                dd = new Dopewars_Drug()
                                {
                                    Drug_Id = bulldrug,
                                    Price   = PriceForDrug(bulldrug, CurrentLocation)
                                };
                                Locations[CurrentLocation].Drugs.Add(dd);
                            }
                            _bbs.WriteLine("~c8" + Dope_Bull[bulldrug] + "~c1");
                            Locations[CurrentLocation].Drugs.First(p => p.Drug_Id.Equals(bulldrug)).Price *= 8;
                        }
                        //Random Bear Market Events
                        if (r.Next(0, 100) <= 30)  //20% chance, need to change this to per-neighborhood
                        {
                            int           beardrug = r.Next(0, DRUG_HI);
                            Dopewars_Drug dd       = Locations[CurrentLocation].Drugs.FirstOrDefault(p => p.Drug_Id.Equals(beardrug));
                            if (dd == null)
                            {
                                dd = new Dopewars_Drug()
                                {
                                    Drug_Id = beardrug,
                                    Price   = PriceForDrug(beardrug, CurrentLocation)
                                };
                                Locations[CurrentLocation].Drugs.Add(dd);
                            }
                            _bbs.WriteLine("~c6" + Dope_Bear[beardrug] + "~c1");
                            Locations[CurrentLocation].Drugs.First(p => p.Drug_Id.Equals(beardrug)).Price /= 8;
                        }
                        //Robbed?
                        if (r.Next(0, 100) <= 20)  //20% chance, need to change this to per-neighborhood
                        {
                            int robamt = r.Next(1, CurrentUser.Cash / 2);
                            if (CurrentUser.Cash > 0)
                            {
                                if (CurrentUser.Cash >= robamt)
                                {
                                    CurrentUser.Cash -= robamt;
                                }
                                else
                                {
                                    robamt           = CurrentUser.Cash;
                                    CurrentUser.Cash = 0;
                                }
                                _bbs.WriteLine("~l1~c2You got robbed on the subway!~l1They took ~c1$" + robamt.ToString() + "~c2!");
                            }
                        }

                        //Gift?
                        if (r.Next(0, 100) <= 20)  //20% chance, need to change this to per-neighborhood
                        {
                            int giftdrug = r.Next(0, DRUG_HI);
                            int giftamt  = r.Next(1, 10);
                            _bbs.WriteLine("~l1~c7You run into a friend on the subway.~l1He gives you ~c1" + giftamt.ToString() + " " + Dope_Units[giftdrug] + " ~c7of ~c1" + Dope_Drugs[giftdrug] + "~c7.");
                            if (CurrentUser.Carrying() + giftamt <= CurrentUser.Capacity())
                            {
                                CurrentUser.GiftDrugs(giftdrug, giftamt);
                            }
                            else
                            {
                                _bbs.WriteLine("~l1~c2Unfortunately, you can't carry that much.");
                            }
                        }

                        //Offered Gun?
                        if (r.Next(0, 100) <= 20)  //20% chance, need to change this to per-neighborhood
                        {
                            OfferGun();
                        }

                        //Offered Bitch?
                        if (r.Next(0, 100) <= 20)  //20% chance, need to change this to per-neighborhood
                        {
                            OfferBitch();
                        }

                        //Offered Drugs?
                        if (r.Next(0, 100) <= 20)  //20% chance, need to change this to per-neighborhood
                        {
                            int offerdrug  = r.Next(0, DRUG_HI);
                            int offeramt   = r.Next(10, 50);
                            int offerprice = (int)(Dope_Low[offerdrug] * .8);
                            _bbs.WriteLine("~c7A guy comes up to you on the subway and offers you ~c1" + offeramt.ToString() + " " + Dope_Units[offerdrug] + " ~c7of~c1 " + Dope_Drugs[offerdrug] + "~c7 for ~c1$" + offerprice.ToString() + "~c7.");
                            if (CurrentUser.Cash > offerprice)
                            {
                                if (CurrentUser.Carrying() + offeramt <= CurrentUser.Capacity())
                                {
                                    _bbs.Write("Buy it ");
                                    if (_bbs.YesNo(true, true))
                                    {
                                        CurrentUser.BuyDrugs(offerdrug, offeramt, offerprice);
                                    }
                                }
                                else
                                {
                                    _bbs.WriteLine("~l1~c2Unfortunately, you can't carry that much.");
                                }
                            }
                            else
                            {
                                _bbs.WriteLine("~l1~c2Unfortunately, you can't afford it.");
                            }
                        }

                        _bbs.WriteLine("~l1~c8You arrive at your destination. ~l1~k1");
                        CurrentUser.Turns--;
                        CurrentUser.LastTurnUsed = DateTime.Now;

                        //Entering Location, does it have a bank?
                        if (Locations[CurrentLocation].HasBank)
                        {
                            _bbs.Write("~l1~c7Visit the bank~c1");
                            if (_bbs.YesNo(true, true))
                            {
                                Bank();
                            }
                        }
                        //                   does it have the loan shark?
                        if (Locations[CurrentLocation].HasLoanShark)
                        {
                            _bbs.Write("~l1~c7Visit the loan shark~c1");
                            if (_bbs.YesNo(true, true))
                            {
                                Loan_Shark();
                            }
                        }
                        //                   does it have a pub?
                        if (Locations[CurrentLocation].HasPub)
                        {
                            _bbs.Write("~l1~c7Visit the pub~c1");
                            if (_bbs.YesNo(true, true))
                            {
                                Pub();
                            }
                        }
                        //                   does it have a gun store?
                        if (Locations[CurrentLocation].HasGunStore)
                        {
                            _bbs.Write("~l1~c7Visit the gun store~c1");
                            if (_bbs.YesNo(true, true))
                            {
                                GunStore();
                            }
                        }
                        //Here's where we drop back to the main loop
                    }
                    else
                    {
                        //You died.  Dumbass.
                    }
                }
                else
                {
                    //you died.  Dumbass.
                }
                if (Dead)
                {
                    _bbs.WriteLine("~l1~c2Congratulations, dumbass.  You're dead.~p4");
                    DeleteUser();
                    //Quit game completely.
                }
                SaveUser();
            }
            else
            {
                _bbs.WriteLine("~s1~c2Out of turns for today, no more travel.~p3");
            }
        }
Ejemplo n.º 6
0
        public void Sell()
        {
            try
            {
                _bbs.Write("~s1~d2" + Utils.Center("Sell Drugs", Columns) + "~d0");
                //List drugs for sale in this hood
                List_Drugs(CurrentUser.Drugs, true, true);
                _bbs.Write("~d2" + Utils.Center("Local Prices", Columns) + "~d0");
                List_Drugs(Locations[CurrentLocation].Drugs, false, false);
                _bbs.Write("~d2" + Utils.SPC(Columns) + "~d0");
                _bbs.Write("~c7Which drug:~c1");
                string dr = _bbs.Input(true, false, true);
                if (dr != "")
                {
                    if (int.TryParse(dr, out int drug))
                    {
                        //Do they have it to sell
                        if (drug < CurrentUser.Drugs.Count)
                        {
                            Dopewars_Drug dd = CurrentUser.Drugs.Where(p => p.Units > 0).ToList()[drug];
                            Dopewars_Drug ld = Locations[CurrentLocation].Drugs.FirstOrDefault(p => p.Drug_Id.Equals(dd.Drug_Id));
                            if (ld != null)
                            {
                                _bbs.Write("~l1~c7How many " + Dope_Units[dd.Drug_Id] + "?~c1");
                                string un    = _bbs.Input(true, false, true);
                                int    units = 0;
                                if (un != "")
                                {
                                    if (int.TryParse(un, out units))
                                    {
                                        //DO they have that many to sell?
                                        if (units <= dd.Units)
                                        {
                                            //Confirm @ price
                                            _bbs.Write("~l1~c7Sell ~c1" + units.ToString() + " " + Dope_Units[dd.Drug_Id] + "~c7 of " + Dope_Drugs[dd.Drug_Id].ToLower() + " for ~c1$" + units * ld.Price + " ~c7");
                                            if (_bbs.YesNo(true, true))
                                            {
                                                _bbs.WriteLine("~c1Selling drugs.~p1.~p1.~p1.~p2");
                                                CurrentUser.SellDrugs(dd.Drug_Id, units, ld.Price);
                                                SaveUser();
                                            }
                                        }
                                        else
                                        {
                                            _bbs.WriteLine("~c2You don't have that many!~p4");
                                        }
                                    }
                                    else
                                    {
                                        goto notanumber;
                                    }
                                }
                                else
                                {
                                    goto notanumber;
                                }
                            }
                            else
                            {
                                _bbs.WriteLine("~l1~c2There are no buyers for that here!~p4");
                            }
                        }
                        else
                        {
                            _bbs.WriteLine("~l1~c2Pick something that's actually on the menu.?~p4");
                        }
                    }
                    else
                    {
                        goto notanumber;
                    }
                }
                else
                {
                    goto notanumber;
                }
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in Dopewars.Sell: " + e);
            }
            return;

notanumber:
            _bbs.WriteLine("~l1~c2That's not a number, asshole!~p4");
        }
Ejemplo n.º 7
0
        public void Buy()
        {
            try
            {
                _bbs.Write("~s1~d2" + Utils.Center("Buy Drugs", Columns) + "~d0");
                //List drugs for sale in this hood
                List_Drugs(Locations[CurrentLocation].Drugs, true, false);
                _bbs.Write("~d2" + Utils.SPC(Columns) + "~d0");
                _bbs.WriteLine("~c4You Have ~c1$" + CurrentUser.Cash.ToString() + ".");
                _bbs.Write("~d2" + Utils.SPC(Columns) + "~d0");
                _bbs.Write("~c7Which drug:~c1");
                string dr = _bbs.Input(true, false, true);
                if (dr != "")
                {
                    if (int.TryParse(dr, out int drug))
                    {
                        //Is this drug actually available?
                        if (drug < Locations[CurrentLocation].Drugs.Count)
                        {
                            Dopewars_Drug dd = Locations[CurrentLocation].Drugs[drug];
                            _bbs.Write("~l1~c7How many " + Dope_Units[dd.Drug_Id] + "?~c1");
                            string un    = _bbs.Input(true, false, true);
                            int    units = 0;
                            if (un != "")
                            {
                                if (int.TryParse(un, out units))
                                {
                                    //Can they afford it?
                                    if ((units * dd.Price) <= CurrentUser.Cash)
                                    {
                                        //Can they carry it?
                                        if (units + CurrentUser.Carrying() <= CurrentUser.Capacity())
                                        {
                                            _bbs.WriteLine("~l1~c1Buying drugs.~p1.~p1.~p1.~p2");
                                            //F*****g buy it, then.
                                            CurrentUser.Cash -= units * dd.Price;
                                            CurrentUser.BuyDrugs(dd.Drug_Id, units, units * dd.Price);
                                            SaveUser();
                                        }
                                        else
                                        {
                                            _bbs.WriteLine("~l1~c2You can't carry that much.~p4");
                                        }
                                    }
                                    else
                                    {
                                        _bbs.WriteLine("~l1~c2You can't afford it, bitch!~p4");
                                    }
                                }
                                else
                                {
                                    goto notanumber;
                                }
                            }
                            else
                            {
                                goto notanumber;
                            }
                        }
                        else
                        {
                            _bbs.WriteLine("~l1~c2Pick something that's actually on the menu.?~p4");
                        }
                    }
                    else
                    {
                        goto notanumber;
                    }
                }
                else
                {
                    goto notanumber;
                }
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in Dopewars.Buy(): " + e);
            }
            return;

notanumber:
            _bbs.WriteLine("~l1~c2That's not a number, asshole!~p4");
        }