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); }
public void Deserialize(BBS bbs, string s) { Dopewars_Location temploc = Utils.DeserializeXmlString <Dopewars_Location>(s); LocationId = temploc.LocationId; HasPub = temploc.HasPub; HasGunStore = temploc.HasGunStore; HasLoanShark = temploc.HasLoanShark; HasBank = temploc.HasBank; HasHospital = temploc.HasHospital; Drugs = new List <Dopewars_Drug>(); foreach (Dopewars_Drug drug in temploc.Drugs) { Drugs.Add(drug); } }