Example #1
0
    public void InitiateCountryAction(GameAction gameAction)
    {
        Country selectedCountry = worldMap.currentSelectedCountry;

        if (selectedCountry == null)
        {
            PostMessageToBoard("Cannot perform action because no country is selected", Color.red);
            return;
        }
        else if (gameAction.actionName.Equals("Coup d'état") && selectedCountry.traits.Exists(x => x.name.Equals("Militaristic")))
        {
            PostMessageToBoard("Cannot perform Coup d'état on a Militaristic country", Color.red);
        }
        else if (PlayerProfile.instance.trait.Equals("Peaceful"))
        {
            if (gameAction.actionName.Equals("Coup d'état") || gameAction.actionName.Equals("Revolution"))
            {
                PostMessageToBoard("Cannot perform violent actions", Color.red);
                return;
            }
        }

        int actionCost = selectedCountry.GetActionCost(gameAction);

        if (actionCost > influencePoint)
        {
            PostMessageToBoard("Insufficient influence point to perform action: " + gameAction.actionName + " in country: " + selectedCountry.name, Color.red);
            return;
        }

        PostMessageToBoardWithTime("You performed action: " + gameAction.actionName);

        TimeSpan bonusDuration = new TimeSpan(0, 0, 0, 0);

        if (gameAction.actionName.Equals("Publish Books") && selectedCountry.traits.Exists(x => x.name.Equals("Educated")))
        {
            bonusDuration = new TimeSpan(30, 0, 0, 0);
        }

        actions.AddLast(delegate(DateTime date) {
            Debug.Log("Action " + gameAction.actionName + " is picked up in the queue");
            influencePoint -= actionCost;
            selectedCountry.AddEffect(new Effect(gameAction.actionName, gameAction.baseRate, currentDate, date.Add(gameAction.baseDuration + bonusDuration), gameAction.resistenceModifier));
        });
    }