public static int GetInput(Dictionary <string, int> options, Player player) { FormDataObject data = new FormDataObject(); PlayersOptionsForm form = new PlayersOptionsForm(data, Program.form.gamepics, options, player); while (data.getData() == null) { form.ShowDialog(); } int val = (int)data.getData(); return(val); }
public virtual int ChoseOption(/*Dictionary<string, int> possibleActions,*/ Possibilities optiontype) { Dictionary <string, int> roundOptions = new Dictionary <string, int>(); int val = 0; string text = null; switch ((int)optiontype) { case (int)Possibilities.General: foreach (PlayerAction action in Enum.GetValues(typeof(PlayerAction))) { roundOptions.Add(action.ToString(), (int)action); } break; case (int)Possibilities.Traincard: foreach (Cardoptions option in Enum.GetValues(typeof(Cardoptions))) { roundOptions.Add(option.ToString(), (int)option); } break; case (int)Possibilities.visibleTraincards: foreach (TrainCard trCard in ActionsMethods.visibleTraincards) { text = trCard.ToString(); val = (int)(trCard.getColor()); List <int> vals = roundOptions.Values.ToList(); if (!vals.Contains(val)) { roundOptions.Add(text, val); } } break; case (int)Possibilities.stationCities: Program.logboek.WriteLine("Building a station: the available cities to build a station are:"); ActionsMethods.citylist.Sort(); foreach (City stad in ActionsMethods.citylist) { /****************************** * Showing the available stationcities *******************************/ if (stad.getStation() == null) { text += stad.getname() + '\t'; roundOptions.Add(stad.getname(), stad.getID()); } } Program.logboek.WriteLine(text); break; case (int)Possibilities.Railroad: City city1, city2 = null; foreach (Railroad road in ActionsMethods.network) { if (!road.isOccupied()) { List <int> IDs = roundOptions.Values.ToList(); city1 = road.getdestinations()[0]; city2 = road.getdestinations()[1]; if (!IDs.Contains(city1.getID())) { roundOptions.Add(city1.getname(), city1.getID()); } if (!IDs.Contains(city2.getID())) { roundOptions.Add(city2.getname(), city2.getID()); } } } break; case (int)Possibilities.Neighbours: City city3 = ActionsMethods.getCity(tempval); foreach (Railroad road in ActionsMethods.network) { if (road.getdestinations().Contains(city3) && !road.isOccupied()) { if (road.getdestinations()[0].getID() == city3.getID()) { if (!roundOptions.Keys.Contains(road.getdestinations()[1].getname())) { roundOptions.Add(road.getdestinations()[1].getname(), road.getdestinations()[1].getID()); } } else { if (!roundOptions.Keys.Contains(road.getdestinations()[0].getname())) { roundOptions.Add(road.getdestinations()[0].getname(), road.getdestinations()[0].getID()); } } } } break; } FormDataObject data = new FormDataObject(); PlayersOptionsForm form = new PlayersOptionsForm(data, Program.form.gamepics, roundOptions, this); form.ShowDialog(); while (data.getData() == null) { form.ShowDialog(); } val = (int)data.getData(); tempval = val; foreach (KeyValuePair <string, int> pair in roundOptions) { if (roundOptions[pair.Key] == val) { Program.logboek.WriteLine(string.Format("the player chose {0}, {1}", pair.Value, pair.Key)); } } return(val); }