public static void LeaderAttemptsFosterRelationship_TriggerRejectDecision(Tribe sourceTribe, Tribe targetTribe, float chanceOfRejecting, long eventId)
    {
        World world = sourceTribe.World;

        bool acceptOffer = targetTribe.GetNextLocalRandomFloat(RngOffsets.FOSTER_TRIBE_RELATION_EVENT_TARGETTRIBE_LEADER_ACCEPT_OFFER) > chanceOfRejecting;

        Clan targetDominantClan = targetTribe.DominantFaction as Clan;

        if (targetTribe.IsUnderPlayerFocus || targetDominantClan.IsUnderPlayerGuidance)
        {
            Decision handleOfferDecision;

            handleOfferDecision = new HandleFosterTribeRelationAttemptDecision(sourceTribe, targetTribe, acceptOffer, eventId);              // Give player options

            if (targetDominantClan.IsUnderPlayerGuidance)
            {
                world.AddDecisionToResolve(handleOfferDecision);
            }
            else
            {
                handleOfferDecision.ExecutePreferredOption();
            }
        }
        else if (acceptOffer)
        {
            HandleFosterTribeRelationAttemptDecision.LeaderAcceptsOffer(sourceTribe, targetTribe, eventId);
        }
        else
        {
            HandleFosterTribeRelationAttemptDecision.LeaderRejectsOffer(sourceTribe, targetTribe, eventId);
        }
    }
    public override void Trigger()
    {
        bool attemptFoster = _sourceTribe.GetNextLocalRandomFloat(RngOffsets.FOSTER_TRIBE_RELATION_EVENT_MAKE_ATTEMPT) < _chanceOfMakingAttempt;

        if (_sourceTribe.IsUnderPlayerFocus || _originalSourceDominantClan.IsUnderPlayerGuidance)
        {
            Decision fosterDecision = new FosterTribeRelationDecision(_sourceTribe, _targetTribe, attemptFoster, _chanceOfRejectingOffer, Id);

            if (_originalSourceDominantClan.IsUnderPlayerGuidance)
            {
                World.AddDecisionToResolve(fosterDecision);
            }
            else
            {
                fosterDecision.ExecutePreferredOption();
            }
        }
        else if (attemptFoster)
        {
            FosterTribeRelationDecision.LeaderAttemptsFosterRelationship(_sourceTribe, _targetTribe, _chanceOfRejectingOffer, Id);
        }
        else
        {
            FosterTribeRelationDecision.LeaderAvoidsFosteringRelationship(_sourceTribe, _targetTribe);
        }
    }
Exemple #3
0
    public override void Trigger()
    {
        bool attemptFoster = _sourceTribe.GetNextLocalRandomFloat(RngOffsets.MERGE_TRIBES_EVENT_MAKE_ATTEMPT) < _chanceOfMakingAttempt;

        if (_sourceTribe.IsUnderPlayerFocus || _originalSourceDominantClan.IsUnderPlayerGuidance)
        {
            Decision mergeDecision = new MergeTribesDecision(_sourceTribe, _targetTribe, attemptFoster, _chanceOfRejectingOffer, Id);

            if (_originalSourceDominantClan.IsUnderPlayerGuidance)
            {
                World.AddDecisionToResolve(mergeDecision);
            }
            else
            {
                mergeDecision.ExecutePreferredOption();
            }
        }
        else if (attemptFoster)
        {
            MergeTribesDecision.LeaderAttemptsMergeTribes(_sourceTribe, _targetTribe, _chanceOfRejectingOffer, Id);
        }
        else
        {
            MergeTribesDecision.LeaderAvoidsMergeTribesAttempt(_sourceTribe, _targetTribe);
        }
    }
Exemple #4
0
    public override void Trigger()
    {
        bool attemptToOpen = _tribe.GetNextLocalRandomFloat(RngOffsets.OPEN_TRIBE_EVENT_MAKE_ATTEMPT) < _chanceOfMakingAttempt;

        if (_tribe.IsUnderPlayerFocus || _originalDominantClan.IsUnderPlayerGuidance)
        {
            Decision openDecision = new OpenTribeDecision(_tribe, attemptToOpen, Id);

            if (_originalDominantClan.IsUnderPlayerGuidance)
            {
                World.AddDecisionToResolve(openDecision);
            }
            else
            {
                openDecision.ExecutePreferredOption();
            }
        }
        else if (attemptToOpen)
        {
            OpenTribeDecision.LeaderOpensTribe(_tribe);
        }
        else
        {
            OpenTribeDecision.LeaderAvoidsOpeningTribe(_tribe);
        }
    }
Exemple #5
0
    public static long CalculateTriggerDate(Tribe tribe)
    {
        float randomFactor = tribe.GetNextLocalRandomFloat(RngOffsets.MERGE_TRIBES_EVENT_CALCULATE_TRIGGER_DATE);

        randomFactor = Mathf.Pow(randomFactor, 2);

        float isolationPreferenceValue = tribe.GetPreferenceValue(CulturalPreference.IsolationPreferenceId);

        float isolationPrefFactor = 2 * isolationPreferenceValue;

        isolationPrefFactor = Mathf.Pow(isolationPrefFactor, 4);

        float cohesionPreferenceValue = tribe.GetPreferenceValue(CulturalPreference.CohesionPreferenceId);

        float cohesionPrefFactor = 2 * (1 - cohesionPreferenceValue);

        cohesionPrefFactor = Mathf.Pow(cohesionPrefFactor, 4);

        float dateSpan = (1 - randomFactor) * DateSpanFactorConstant * isolationPrefFactor * cohesionPrefFactor;

        long triggerDateSpan = (long)dateSpan + CellGroup.GenerationSpan;

        if (triggerDateSpan < 0)
        {
            Debug.LogWarning("updateSpan less than 0: " + triggerDateSpan);

            triggerDateSpan = CellGroup.MaxUpdateSpan;
        }

        long triggerDate = tribe.World.CurrentDate + triggerDateSpan;

        if (triggerDate > World.MaxSupportedDate)
        {
            // nextDate is invalid, generate report
            Debug.LogWarning(
                "MergeTribesDecisionEvent.CalculateTriggerDate - triggerDate (" + triggerDate +
                ") greater than MaxSupportedDate (" + World.MaxSupportedDate +
                "). triggerDateSpan: " + triggerDateSpan + ", randomFactor: " + randomFactor +
                ", cohesionPrefFactor: " + cohesionPrefFactor);

            triggerDate = int.MinValue;
        }

        return(triggerDate);
    }
    public static void LeaderAllowsSplit(Clan splitClan, Clan dominantClan, Tribe originalTribe, float tribeChanceOfSplitting, long eventId)
    {
        World world = originalTribe.World;

        bool tribePreferSplit = originalTribe.GetNextLocalRandomFloat(RngOffsets.TRIBE_SPLITTING_EVENT_TRIBE_PREFER_SPLIT) < tribeChanceOfSplitting;

        if (originalTribe.IsUnderPlayerFocus || dominantClan.IsUnderPlayerGuidance)
        {
            Decision tribeDecision;

            if (tribeChanceOfSplitting >= 1)
            {
                tribeDecision = new TribeSplitDecision(originalTribe, splitClan, dominantClan, eventId); // Player that controls dominant clan can't prevent splitting from happening
            }
            else
            {
                tribeDecision = new TribeSplitDecision(originalTribe, splitClan, dominantClan, tribePreferSplit, eventId); // Give player options
            }

            if (dominantClan.IsUnderPlayerGuidance)
            {
                world.AddDecisionToResolve(tribeDecision);
            }
            else
            {
                tribeDecision.ExecutePreferredOption();
            }
        }
        else if (tribePreferSplit)
        {
            TribeSplitDecision.LeaderAllowsSplit(splitClan, dominantClan, originalTribe);
        }
        else
        {
            TribeSplitDecision.LeaderPreventsSplit(splitClan, dominantClan, originalTribe, eventId);
        }
    }
    public static void LeaderDemandsInfluence_TriggerRejectDecision(Clan demandClan, Clan dominantClan, Tribe originalTribe, float chanceOfRejecting, long eventId)
    {
        World world = originalTribe.World;

        bool acceptDemand = originalTribe.GetNextLocalRandomFloat(RngOffsets.CLAN_DEMANDS_INFLUENCE_EVENT_ACCEPT_DEMAND) > chanceOfRejecting;

        if (originalTribe.IsUnderPlayerFocus || dominantClan.IsUnderPlayerGuidance)
        {
            Decision dominantClanDecision;

            if (chanceOfRejecting <= 0)
            {
                dominantClanDecision = new DominantClanHandlesInfluenceDemandDecision(originalTribe, demandClan, dominantClan, eventId);                  // Player that controls dominant clan can't reject demand
            }
            else
            {
                dominantClanDecision = new DominantClanHandlesInfluenceDemandDecision(originalTribe, demandClan, dominantClan, acceptDemand, eventId);                  // Give player options
            }

            if (dominantClan.IsUnderPlayerGuidance)
            {
                world.AddDecisionToResolve(dominantClanDecision);
            }
            else
            {
                dominantClanDecision.ExecutePreferredOption();
            }
        }
        else if (acceptDemand)
        {
            DominantClanHandlesInfluenceDemandDecision.LeaderAcceptsDemand(demandClan, dominantClan, originalTribe, eventId);
        }
        else
        {
            DominantClanHandlesInfluenceDemandDecision.LeaderRejectsDemand(demandClan, dominantClan, originalTribe, eventId);
        }
    }