//- Election public void Election() { AbendParlament(); #region Update Seats List <Party> parties = new List <Party>(); List <int> partie_values = new List <int>(); foreach (Citizen citizen in City.Citizens) { Party local = citizen.GetVote(); if (local == null) { continue; } if (parties.Contains(local)) { partie_values[parties.FindIndex(x => x.ID == local.ID)] += 1; } else { parties.Add(local); partie_values.Add(1); } } int[] seat_nums = new int[partie_values.Count]; int sum_votes = 0; for (int i = 0; i < partie_values.Count; i++) { sum_votes += partie_values[i]; } for (int i = 0; i < parties.Count; i++) { double relation = (double)partie_values[i] / sum_votes; int num_of_legal_seats = (int)(MaxSeats * relation); for (int j = 0; j < num_of_legal_seats; j++) { ParlamentSeat seat = new ParlamentSeat(); seat.Person = GetPerson(parties[i]); seat_nums[i]++; Seats.Add(seat); } } //- Regardles of the %-num of any party, one seat is guaranted for (int i = 0; i < parties.Count; i++) { if (seat_nums[i] == 0) { ParlamentSeat seat = new ParlamentSeat(); seat.Person = GetPerson(parties[i]); seat_nums[i]++; MaxSeats++; Seats.Add(seat); } } for (int i = 0; i < parties.Count; i++) { PartyAmounts.Add(new PartyAmount(parties[i], seat_nums[i])); } #endregion RulingParties = GetMajority(); Cancelor = GetPerson(RulingParties[0]); //- New Round-Dates LastElection = Engine.Game.Current; NextElection = new Round(LastElection.Number + GovernmentPeriode); Log.Write("Election over:\n" + "Winner: '" + Cancelor.Party.Name + "' with new '" + TitleCancelor + "' " + Cancelor.Name); }
public void AddSeat(Seat Seat) { Seats.Add(Seat); }
private void GeneratingLayout() { try { IEnumerable <Seat> objScreenSeats = new SeatLayoutConfig().GetScreeSeats(Convert.ToInt32(cmbScreen.SelectedValue), 0, 0); if (objScreenSeats == null || objScreenSeats.Count() == 0) { itmSeats.ItemsSource = Seats; return; } int columns = objScreenSeats.ToList <Seat>().Max(w => w.ColumnValue); var groupList = objScreenSeats.ToList <Seat>().GroupBy(l => l.ScreenClassId) .Select(cl => new Seat { ScreenClassId = cl.First().ScreenClassId, RowValue = cl.Max(c => c.RowValue), ColumnValue = cl.Max(c => c.ColumnValue), DisplayOrder = cl.First().DisplayOrder, ScreenClass = cl.First().ScreenClass }).ToList(); int rowsforAllClasses = groupList.Sum(w => w.RowValue); foreach (Seat objscreenClass in groupList.OrderBy(w => w.DisplayOrder)) { int rows = objscreenClass.RowValue; IEnumerable <Seat> objSubClassSeatsList = objScreenSeats.Where(w => w.ScreenClassId == objscreenClass.ScreenClassId); Seats.Add(new SeatProperties() { CheckboxVisibility = Visibility.Visible, Column = objscreenClass.ScreenClassId, ColumnText = Convert.ToString(objscreenClass.ScreenClassId), DisplayText = objscreenClass.ScreenClass, Id = 0, IsChecked = false, IsEnabled = false, Row = objscreenClass.ScreenClassId, RowNum = objscreenClass.ScreenClassId, RowText = Convert.ToString(objscreenClass.ScreenClassId), ScreenClassId = objSubClassSeatsList.FirstOrDefault().ScreenClassId, SeatColor = Helper.ReturnColor("INACTIVE"), SeatHeight = 25, SeatOrientation = Orientation.Horizontal, SeatWidth = (25 * columns) + 50, TextVisibility = Visibility.Visible, VendorId = objscreenClass.VendorId }); for (int row = 1; row <= rows; row++) { GenerateRowNameColumn(objSubClassSeatsList.Where(w => w.RowValue == row).FirstOrDefault(), true, objSubClassSeatsList.Where(w => w.RowValue == row && w.FK_SeatStatus_ID == 1).Count() > 0); foreach (Seat objSeat in objSubClassSeatsList.Where(w => w.RowValue == row).OrderBy(w => w.ColumnValue)) { GenerateRowNameColumn(objSeat, false); } int currentRowColumns = objSubClassSeatsList.ToList <Seat>().Where(w => w.RowValue == row).Count() > 0 ? objSubClassSeatsList.ToList <Seat>().Where(w => w.RowValue == row).Count() : 0; if (groupList.Where(w => w.ColumnValue == columns).Count() != groupList.Count()) { currentRowColumns = currentRowColumns - 1; } if (currentRowColumns > 0 && currentRowColumns < columns) { for (int i = currentRowColumns; i <= columns; i++) { GenerateRowNameColumn(new Seat(), false); } } } } itmSeats.Width = (25 * (columns + (groupList.Count > 1 ? 2 : 1)));// + 50; itmSeats.Height = (30 * (rowsforAllClasses + groupList.Count())); itmSeats.ItemsSource = Seats; } catch (Exception ex) { ManageLoadingDataVisibility(false); LogExceptions.LogException(ex); } }
public void addSeat(Seat seat) { Seats.Add(seat); }
public void AddSeat(int[] seat) { Seats.Add(seat); }