/// <summary> /// Handles the 1 event of the createCityButton_Click control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> private void createCityButton_Click_1(object sender, RoutedEventArgs e) { if (selectedUnit is ITeacher) { bool hasCity = false; foreach (IPlayer player in players) { foreach (ICity city in player.Cities) { if (city.IsAtPosition(selectedUnit.Position)) { hasCity = true; } } } if (!hasCity) { ITeacher selectedTeacher = selectedUnit as ITeacher; ICity City = selectedTeacher.CreateCity(selectedTeacher.Position, mapViewer.Map, players[currentPlayerIndex]); players[currentPlayerIndex].Cities.Add(City); selectedTeacher.HP = 0; selectedTeacher.Movement = 0; players[currentPlayerIndex].Units.Remove(selectedUnit); } else { Log.Instance.Write("Une ville possède déjà cette case."); } } mapViewer.Redraw(); }