예제 #1
0
 public bool isValidGoal()
 {
     return(targetReformValue.IsAllowed(Country, targetReformValue));
 }
예제 #2
0
        private void refresh(bool callRebuildDropDown)
        {
            table.Refresh();
            movementsText.text = ToStringExtensions.ToString(Game.Player.Politics.AllMovements.OrderByDescending(x => x.getRelativeStrength(Game.Player).get()));
            if (movementsText.preferredHeight > 90 && movementsText.preferredHeight < 130)
            {
                movementsText.text += "\n\n\n\n";
            }

            movementsHorizontalScrollBar.value = 0;
            if (ReferenceEquals(selectedReformType, null))
            {
                voteButton.interactable = false;
                voteButton.GetComponentInChildren <Text>().text = "Select reform";
                descriptionText.text = "Select reform from left";
                forceDecisionButton.GetComponent <ToolTipHandler>().SetText("");
                voteButton.GetComponent <ToolTipHandler>().SetText("");
            }
            else //did selected reform
            {
                if (callRebuildDropDown) // meaning changed whole reform
                {
                    rebuildDropDown();
                }
                descriptionText.text = selectedReformType.ShortName + " reforms " + selectedReformType.FullName
                                       + "\nCurrently: ";

                // todo fix that mess in 3 places
                var isUnemploymentReformType = selectedReformType.Value as UnemploymentSubsidies.UnemploymentReformValue;
                if (isUnemploymentReformType == null)
                {
                    var isUBIReform = selectedReformType.Value as UBI.UBIReformValue;
                    if (isUBIReform == null)
                    {
                        var isPovertyAid = selectedReformType.Value as PovertyAid.PovertyAidReformValue;
                        if (isPovertyAid == null)
                        {
                            // default text
                            descriptionText.text += selectedReformType.Value;
                            var isNamedReformType = selectedReformType.Value as INameable;
                            if (isNamedReformType != null)
                            {
                                descriptionText.text += isNamedReformType.FullName;
                            }
                        }
                        else
                        {
                            descriptionText.text += isPovertyAid.ToString(Game.Player.market);
                        }
                    }
                    else
                    {
                        descriptionText.text += isUBIReform.ToString(Game.Player.market);
                    }
                }
                else
                {
                    descriptionText.text += isUnemploymentReformType.ToString(Game.Player.market);
                }


                descriptionText.text += "\nSelected: ";

                if (selectedReformType == selectedReformValue)
                {
                    descriptionText.text            += "current";
                    forceDecisionButton.interactable = false;
                    voteButton.interactable          = false;
                }
                else
                {
                    //else
                    {
                        var isUnempValue = selectedReformValue as UnemploymentSubsidies.UnemploymentReformValue;
                        if (isUnempValue != null)
                        {
                            descriptionText.text += isUnempValue.ToString(Game.Player.market);
                        }
                        else
                        {
                            var isPvrtREf = selectedReformValue as PovertyAid.PovertyAidReformValue;
                            if (isPvrtREf != null)
                            {
                                descriptionText.text += isPvrtREf.ToString(Game.Player.market);
                            }
                            else
                            {
                                var isUBIRfr = selectedReformValue as UBI.UBIReformValue;
                                if (isUBIRfr != null)
                                {
                                    descriptionText.text += isUBIRfr.ToString(Game.Player.market);
                                }
                                else
                                {
                                    var isNamedReformValue = selectedReformValue as INameable;
                                    if (isNamedReformValue != null)
                                    {
                                        descriptionText.text += isNamedReformValue.FullName;
                                    }
                                    else
                                    {
                                        descriptionText.text += selectedReformValue;
                                    }
                                }
                            }
                        }
                    }
                    Procent procentPopulationSayedYes = new Procent(0f);
                    Procent procentVotersSayedYes     = Game.Player.Provinces.getYesVotes(selectedReformValue, ref procentPopulationSayedYes);

                    Dictionary <PopType, int> divisionPopulationResult = new Dictionary <PopType, int>();
                    Dictionary <PopType, int> divisionVotersResult     = Game.Player.Provinces.getYesVotesByType(selectedReformValue, ref divisionPopulationResult);

                    RefreshInfoAboutVotes(procentVotersSayedYes, procentPopulationSayedYes, divisionVotersResult, divisionPopulationResult);

                    // Control buttons interactability && tooltips
                    if (selectedReformValue != null)
                    {
                        if (procentVotersSayedYes.get() >= Options.votingPassBillLimit && Game.Player.government != Government.Despotism)
                        { // can vote for reform
                            voteButton.interactable = selectedReformValue.IsAllowed(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 votes for reform or is despotism
                        {
                            voteButton.interactable          = false;
                            forceDecisionButton.interactable = selectedReformValue.IsAllowed(Game.Player, selectedReformValue, out forceDecisionButton.GetComponent <ToolTipHandler>().text);
                            voteButton.GetComponent <ToolTipHandler>().SetText(forceDecisionButton.GetComponent <ToolTipHandler>().GetText());
                            voteButton.GetComponentInChildren <Text>().text = "Not enough votes";
                            if (Game.Player.government == Government.Despotism)
                            {
                                forceDecisionButton.GetComponent <ToolTipHandler>().text += "\n\nPeople wouldn't be that angry if you force decisions as Despot";
                            }
                            else
                            {
                                forceDecisionButton.GetComponent <ToolTipHandler>().text += "\n\nForcing decision against people's desires will drop loyalty!";
                            }
                        }
                    }
                }
            }
        }