private void ActionOptionList_SelectedIndexChanged(object sender, EventArgs e) { CaravanRoute caravanRoute = cityV.actionOptionList.SelectedItem as CaravanRoute; if (caravanRoute is null) { cityV.actionOptionLabel.Visible = false; cityV.button1.Visible = false; cityV.button1.Click -= Button1_Click; return; } cityV.actionOptionLabel.Visible = true; cityV.button1.Visible = true; cityV.actionOptionLabel.Text = caravanRoute.Description; cityV.button1.Text = "Join Caravan"; cityV.button1.Click += Button1_Click; }
private bool DetermineRoute(City c) { List <string> profitableItems = new List <string>(); foreach (var item in items) { int sellPrice = c.DetermineLocalFoodPrice(nation.GetPrice(item.item.name)); if (sellPrice > item.Cost && !profitableItems.Contains(item.item.name)) { profitableItems.Add(item.item.name); } } if (profitableItems.Count > 0) { CaravanRoute possibleRoute = new CaravanRoute(city, c, this, profitableItems, Math.Min(wealth / 10, 1000)); if (possibleRoute.PredictProfit() > 0) { routes.Add(possibleRoute); return(true); } } return(false); }