public void processOptionB()
    {
        eventDecisionTwoPanel.SetActive(false);
        closeToolTips();
        App    app         = UnityEngine.Object.FindObjectOfType <App>();
        int    playerIndex = app.GetHumanIndex();
        Nation player      = State.getNations()[playerIndex];
        Nation otherMajor  = State.getNation(currentEvent.OtherMajor);

        Province disputedProvince = State.getProvince(currentEvent.Province);
        Nation   otherNation      = State.getNation(currentEvent.OtherMajor);

        if (currentEvent.OtherMinor > -1)
        {
            otherNation = State.getNation(currentEvent.OtherMinor);
        }
        if (currentEvent.EventType == MyEnum.eventType.riotResponce)
        {
            nextEventTurn(player);
        }
        else if (currentEvent.EventType == MyEnum.eventType.referendumDemanded)
        {
            // Accept....
            if (eventLogic.referendum(player, otherNation, currentEvent.OtherMinor, disputedProvince))
            {
                // Province Leaves!
                DecisionEvent newEvent = new DecisionEvent();
                eventLogic.initializeProvinceLeaveEvent(newEvent, currentEvent);
                currentEvent = newEvent;
                showDecisionPanel(player);
            }
            else
            {
                DecisionEvent newEvent = new DecisionEvent();
                eventLogic.initializeProvinceStaysEvent(newEvent, currentEvent);
                currentEvent = newEvent;
                showDecisionPanel(player);
            }
        }


        else if (currentEvent.EventType == MyEnum.eventType.AI_Attacks)
        {
            otherMajor = State.getNation(currentEvent.OtherMajor);
            war        = new War(otherMajor, player, disputedProvince.getIndex(), currentEvent.OtherMinor);
            if (war.AmphibiousAttack)
            {
                DecisionEvent newEvent = new DecisionEvent();
                eventLogic.initializeDecideIfUseNavyDefend(newEvent, currentEvent);
                currentEvent = newEvent;
                showDecisionPanel(player);
            }
            prepareWarPanel(player, otherMajor, war);
        }

        else if (currentEvent.EventType == MyEnum.eventType.notificationOfCrackdown)
        {
            DecisionEvent newEvent = new DecisionEvent();
            eventLogic.initializeAskIfBoycott_AI_Event(newEvent, currentEvent);
            currentEvent = newEvent;
            showDecisionPanel(player);
        }

        else if (currentEvent.EventType == MyEnum.eventType.AI_RejectsReferendum)
        {
            // Don't declare war but maybe boycott
            DecisionEvent newEvent = new DecisionEvent();
        }

        else if (currentEvent.EventType == MyEnum.eventType.askIfBoycott)
        {
            PlayerPayer.loseFace(player);
        }

        else if (currentEvent.EventType == MyEnum.eventType.end)
        {
            nextEventTurn(player);
        }

        else if (currentEvent.EventType == MyEnum.eventType.AI_AcceptsReferendum)
        {
            DecisionEvent newEvent = new DecisionEvent();
            if (eventLogic.referendum(otherMajor, player, currentEvent.OtherMinor, disputedProvince))
            {
                eventLogic.initalizeAI_ReferendumVotesYes(newEvent, currentEvent);
                currentEvent = newEvent;
                showDecisionPanel(player);
            }
            else
            {
                eventLogic.initalizeAI_ReferendumVotesNo(newEvent, currentEvent);
                currentEvent = newEvent;
                showDecisionPanel(player);
            }
        }

        nextEventTurn(player);
    }
Пример #2
0
    public void respondToProvinceRiots(Nation nation, Province prov)
    {
        Debug.Log("Respond to Province Riots");
        int           numberOfDisruptedProvinces = PlayerCalculator.getNumberOfDisrputedProvinces(nation);
        bool          sameCulture           = true;
        int           nationWithSameCulture = nation.getIndex();
        EventRegister eventLogic            = State.eventRegister;

        App    app        = UnityEngine.Object.FindObjectOfType <App>();
        int    humanIndex = app.GetHumanIndex();
        Nation human      = State.getNations()[humanIndex];

        if (!nation.culture.Equals(prov.getCulture()))
        {
            sameCulture           = false;
            nationWithSameCulture = Utilities.findNationWithThisCulture(prov.getCulture());
        }

        if (prov.isColony)
        {
            if (nation.GetColonialPoints() > 0)
            {
                //crack down on riots
                nation.SpendColonialPoints(1);
            }
            else
            {
                prov.setRioting(true);
            }
        }
        else if (!prov.isColony)
        {
            if (sameCulture)
            {
                if (nation.InfulencePoints > 0)
                {
                    standardProvinceResponse(nation, prov, -1, -1);
                }
                else
                {
                    prov.setRioting(true);
                }
            }
            // Now consider cases where the prov is not a colony and does not share the same culture as its owner

            else if (!prov.isColony && !sameCulture)
            {
                if (nation.InfulencePoints > 0)
                {
                    Debug.Log("Not colony and not same culture");
                    //Consider who might get angry with the crackdown
                    int    otherNationIndex = Utilities.findNationWithThisCulture(prov.getCulture());
                    Nation otherNation      = State.getNation(otherNationIndex);
                    Debug.Log("Other Nation is: " + otherNation.getName());
                    int    minorNationIndex = -1;
                    Nation minorNation      = new Nation();
                    if (otherNation.getType() == MyEnum.NationType.minor)
                    {
                        minorNationIndex = otherNation.getIndex();
                        minorNation      = otherNation;
                        otherNationIndex = PlayerCalculator.getMostFavouredMajorNation(otherNation);
                        // The other nation is the guardian, not the owner of the nation
                        otherNation = State.getNation(otherNationIndex);
                    }
                    int otherStrength = 0;
                    int selfStrength  = PlayerCalculator.CalculateArmyScore(nation);
                    // Will anger another great power
                    int relations = nation.Relations[otherNationIndex];
                    //This value is just for tests
                    if (relations < 85)
                    {
                        Debug.Log("here");
                        standardProvinceResponse(nation, prov, otherNationIndex, minorNationIndex);
                    }
                    else
                    {
                        if (State.mapUtilities.shareLandBorder(nation, otherNation))
                        {
                            otherStrength = PlayerCalculator.CalculateArmyScore(otherNation);
                        }
                        else
                        {
                            otherStrength = PlayerCalculator.CalculateNavalProjection(otherNation);
                        }

                        if (otherStrength * 1.15 < selfStrength)
                        {
                            //Not too afraid
                            standardProvinceResponse(nation, prov, otherNationIndex, minorNationIndex);
                            if (demandReferendum(otherNation, nation, prov))
                            {
                                if (acceptRefDemand(nation, otherNation, prov))
                                {
                                    referendum(nation, otherNation, prov);
                                }
                                else
                                {
                                    //nation refuses to hold a referendum
                                    if (warOverRejection(otherNation, nation, prov))
                                    {
                                        War war = new War(otherNation, nation, prov.getIndex(), minorNationIndex);
                                        war.warBetweenAI(otherNation, nation);
                                    }
                                    else if (boycottOverRefDemandRejection(otherNation))
                                    {
                                        otherNation.addBoycott(nation.getIndex());
                                        //....................
                                    }
                                    else
                                    {
                                        // Backdown
                                        PlayerPayer.loseFace(otherNation);
                                    }
                                }
                            }
                        }

                        if (otherStrength * 1.3 < selfStrength)
                        {
                            // Prefer not to provicate other nation, but might do so if situation calls for it

                            int roll = Random.Range(1, 100);
                            if (roll < 50)
                            {
                                nation.InfulencePoints--;
                                prov.adjustDiscontentment(1);
                                if (otherNation.getIndex() == humanIndex)
                                {
                                    DecisionEvent newEvent = new DecisionEvent();
                                    if (minorNationIndex == -1)
                                    {
                                        eventLogic.initalizeInformedOfCrackdownEvent(newEvent, human, nation, prov);
                                    }
                                    else
                                    {
                                        eventLogic.initalizeInformedOfCrackdownEvent(newEvent, human, nation, prov, minorNationIndex);
                                    }
                                    eventLogic.DecisionEvents.Enqueue(newEvent);
                                }
                                else if (demandReferendum(otherNation, nation, prov))
                                {
                                    if (acceptRefDemand(nation, otherNation, prov))
                                    {
                                        referendum(nation, otherNation, prov);
                                    }
                                    else
                                    {
                                        if (warOverRejection(otherNation, nation, prov))
                                        {
                                            War war = new War(otherNation, nation, prov.getIndex(), minorNationIndex);
                                            war.warBetweenAI(otherNation, nation);
                                        }
                                    }
                                }
                                else
                                {
                                    prov.setRioting(true);
                                }
                            }

                            else
                            {
                                prov.setRioting(true);
                            }
                        }
                        else
                        {
                            // Don't want to f**k with these guys
                            prov.setRioting(true);
                        }
                    }
                }
                else
                {
                    Debug.Log("No Influence Points");
                    prov.setRioting(true);
                    // Just for now
                    nation.InfulencePoints++;
                }
            }
        }
    }