protected override void SetInitialRandomValues() { Type = WinConditionType.TotalElectionsWon; // GetRandomType(); Time = WinConditionTime.Value; // GetRandomTime(); if (Time == WinConditionTime.Year) { ConditionValue = GetRandomConditionValue(MinYear, MaxYear, StepYear); } else { if (Type == WinConditionType.TotalElectionsWon) { ConditionValue = GetRandomConditionValue(MinElectionWins, MaxElectionWins, StepElectionWins); } else if (Type == WinConditionType.TotalSeatsWon) { ConditionValue = GetRandomConditionValue(MinSeatWins, MaxSeatWins, StepSeatWins); } else if (Type == WinConditionType.TotalDistrictsWon) { ConditionValue = GetRandomConditionValue(MinDistrictWins, MaxDistrictWins, StepDistrictWins); } else if (Type == WinConditionType.TotalVotes) { ConditionValue = GetRandomConditionValue(MinTotalVotes, MaxTotalVotes, StepTotalVotes); } } }
/// <summary> /// Returns the winner party. If the game is not over yet, returns null. /// </summary> private Party GetWinner(WinConditionType type, WinConditionTime time, int conditionValue) { switch (time) { case WinConditionTime.Year: if (Game.Year < conditionValue) { return(null); } else { return(GetCurrentLeader(type)); } case WinConditionTime.Value: Party leader = GetCurrentLeader(type); switch (type) { case WinConditionType.TotalElectionsWon: if (leader.TotalElectionsWon < conditionValue) { return(null); } else { return(leader); } case WinConditionType.TotalSeatsWon: if (leader.TotalSeatsWon < conditionValue) { return(null); } else { return(leader); } case WinConditionType.TotalDistrictsWon: if (leader.TotalDistrictsWon < conditionValue) { return(null); } else { return(leader); } case WinConditionType.TotalVotes: if (leader.TotalVotes < conditionValue) { return(null); } else { return(leader); } } throw new System.Exception("Win condition type not handled"); } throw new System.Exception("Win condition time not handled"); }