public Dictionary <PopType, int> getYesVotesByType(IReformValue reform, ref Dictionary <PopType, int> divisionPopulationResult) { // division by pop types Dictionary <PopType, int> divisionVotersResult = new Dictionary <PopType, int>(); foreach (PopType popType in PopType.getAllPopTypes()) { divisionVotersResult.Add(popType, 0); divisionPopulationResult.Add(popType, 0); foreach (Province province in ownedProvinces) { foreach (PopUnit pop in province.AllPops.Where(x => x.Type == popType)) { if (pop.getSayingYes(reform)) { divisionPopulationResult[popType] += pop.population.Get();// * pop.getVotingPower(); if (pop.CanVoteInOwnCountry()) { divisionVotersResult[popType] += pop.population.Get();// * pop.getVotingPower(); } } } } } return(divisionVotersResult); }
private void RefreshInfoAboutVotes(Procent procentVotersSayedYes, Procent procentPopulationSayedYes, Dictionary <PopType, int> divisionVotersResult, Dictionary <PopType, int> divisionPopulationResult) { if (Game.Player.government == Government.Despotism) { descriptionText.text += "\nNobody to vote - Despot rules everything"; } else { descriptionText.text += "\n" + procentVotersSayedYes + " of voters want this reform ( "; foreach (PopType type in PopType.getAllPopTypes()) { if (divisionVotersResult[type] > 0) { Procent res = new Procent(divisionVotersResult[type] / (float)Game.Player.Provinces.getPopulationAmountByType(type)); descriptionText.text += res + " of " + type + "; "; } } descriptionText.text += ")"; } descriptionText.text += "\n" + procentPopulationSayedYes + " of population want this reform ( "; foreach (PopType type in PopType.getAllPopTypes()) { if (divisionPopulationResult[type] > 0) { Procent res = new Procent(divisionPopulationResult[type] / (float)Game.Player.Provinces.getPopulationAmountByType(type)); descriptionText.text += res + " of " + type + "; "; } } descriptionText.text += ")"; }
private void refresh(bool callRebuildDropDown) { table.Refresh(); //if (Game.Player.movements != null) movementsText.text = Game.Player.movements.getString(); if (movementsText.preferredHeight > 90 && movementsText.preferredHeight < 130) { movementsText.text += "\n\n\n\n"; } movementsHorizontalScrollBar.value = 0; if (selectedReform == null) { voteButton.interactable = false; voteButton.GetComponentInChildren <Text>().text = "Select reform"; descriptionText.text = "Select reform from left"; forceDecisionButton.GetComponent <ToolTipHandler>().SetText(""); voteButton.GetComponent <ToolTipHandler>().SetText(""); } //did selected reform else { if (callRebuildDropDown) // meaning changed whole reform { rebuildDropDown(); } descriptionText.text = selectedReform + " reforms " + selectedReform.getDescription() + "\nCurrently: " + selectedReform.getValue() + " " + selectedReform.getValue().getDescription() + "\nSelected: "; //if (selectedReformValue != null) if (selectedReformValue != selectedReform.getValue()) { descriptionText.text += selectedReformValue + " " + selectedReformValue.getDescription(); } else { descriptionText.text += "current"; } //// Procent procentPopulationSayedYes = new Procent(0f); Procent procentVotersSayedYes = Game.Player.getYesVotes(selectedReformValue, ref procentPopulationSayedYes); Dictionary <PopType, int> divisionPopulationResult = new Dictionary <PopType, int>(); Dictionary <PopType, int> divisionVotersResult = Game.Player.getYesVotesByType(selectedReformValue, ref divisionPopulationResult); if (selectedReformValue != selectedReform.getValue()) { if (Game.Player.government.getValue() != Government.Despotism) { descriptionText.text += "\n" + procentVotersSayedYes + " of voters want this reform ( "; foreach (PopType type in PopType.getAllPopTypes()) { if (divisionVotersResult[type] > 0) { Procent res = new Procent(divisionVotersResult[type] / (float)Game.Player.getPopulationAmountByType(type)); descriptionText.text += res + " of " + type + "; "; } } descriptionText.text += ")"; } else { descriptionText.text += "\nNobody to vote - Despot rule everything"; } descriptionText.text += "\n" + procentPopulationSayedYes + " of population want this reform ( "; foreach (PopType type in PopType.getAllPopTypes()) { if (divisionPopulationResult[type] > 0) { Procent res = new Procent(divisionPopulationResult[type] / (float)Game.Player.getPopulationAmountByType(type)); descriptionText.text += res + " of " + type + "; "; } } descriptionText.text += ")"; } if (selectedReformValue != null)// && selectedReformValue != selectedReform.getValue()) { if (procentVotersSayedYes.get() >= Options.votingPassBillLimit || Game.Player.government.getValue() == Government.Despotism) { // has enough voters voteButton.interactable = selectedReformValue.allowed.isAllTrue(Game.Player, selectedReformValue, out voteButton.GetComponent <ToolTipHandler>().text); forceDecisionButton.GetComponent <ToolTipHandler>().SetText(voteButton.GetComponent <ToolTipHandler>().GetText()); forceDecisionButton.interactable = false; voteButton.GetComponentInChildren <Text>().text = "Vote for " + selectedReformValue; } else // not enough voters { voteButton.interactable = false; forceDecisionButton.interactable = selectedReformValue.allowed.isAllTrue(Game.Player, selectedReformValue, out forceDecisionButton.GetComponent <ToolTipHandler>().text); voteButton.GetComponent <ToolTipHandler>().SetText(forceDecisionButton.GetComponent <ToolTipHandler>().GetText()); voteButton.GetComponentInChildren <Text>().text = "Not enough votes"; forceDecisionButton.GetComponent <ToolTipHandler>().text += "\n\nForcing decision against people's desires will drop loyalty!"; } } } }