public void DetermineWarAsIfNoPlayerInteraction(Faction faction, Faction factionInstigator) { this.unrestIsBrewing = false; DesiredOutcome rollForIntendedOutcome = Rand.Bool ? DesiredOutcome.CURRY_FAVOUR_FACTION_ONE : DesiredOutcome.BROKER_PEACE; if (faction.leader?.GetStatValue(StatDefOf.NegotiationAbility) != null) { var dialogue = new FactionWarDialogue(faction.leader, faction, factionInstigator, null); dialogue.DetermineOutcome(rollForIntendedOutcome, out _); Find.LetterStack.ReceiveLetter("MFI_FactionWarLeaderDecidedLabel".Translate(), WarIsOngoing ? "MFI_FactionWarLeaderDecidedOnWar".Translate(faction, factionInstigator) : "MFI_FactionWarLeaderDecidedAgainstWar".Translate(faction, factionInstigator), WarIsOngoing ? LetterDefOf.NegativeEvent : LetterDefOf.NeutralEvent); return; } else if (factionInstigator.leader?.GetStatValue(StatDefOf.NegotiationAbility) != null) { var dialogue = new FactionWarDialogue(factionInstigator.leader, factionInstigator, faction, null); dialogue.DetermineOutcome(rollForIntendedOutcome, out _); Find.LetterStack.ReceiveLetter("MFI_FactionWarLeaderDecidedLabel".Translate(), WarIsOngoing ? "MFI_FactionWarLeaderDecidedOnWar".Translate(factionInstigator, faction) : "MFI_FactionWarLeaderDecidedAgainstWar".Translate(factionInstigator, faction), WarIsOngoing ? LetterDefOf.NegativeEvent : LetterDefOf.NeutralEvent); return; } }
public static Int32?UpdateDesiredOutcomeToTemp(DesiredOutcome desOutcome, string User511, int JourneyId) { Patient_Journey_Transactions_DesiredOutcomes_Temp desiredOutcome = new Patient_Journey_Transactions_DesiredOutcomes_Temp(); desiredOutcome.Patient_Journey_Transactions_DesiredOutcomes_Temp_Id = desOutcome.DesiredOutcomeId; desiredOutcome.DesiredOutcomes = desOutcome.DesiredOutcomes; desiredOutcome.Description = desOutcome.Description; desiredOutcome.Evidence = desOutcome.Evidence; desiredOutcome.MODIFIED_By = User511; desiredOutcome.MODIFIED_Date = DateTime.Now; var response = dbPatientJourney.UpdateDesiredOutcomeToTemp(desiredOutcome); if (response != null) { var toBeApproved = dbPatientAdministration.ToBeApprovedJourney(JourneyId); Patient_Journey_VersionDetails_Temp versionDetails = new Patient_Journey_VersionDetails_Temp(); versionDetails.Patient_Journey_Temp_Id = Convert.ToInt32(JourneyId); versionDetails.Version_Comments = GlobalConstants.VersionCommentsConstants.DesiredUpdated; versionDetails.Version_Title = GlobalConstants.VersionTitleConstants.DesiredUpdated; versionDetails.Created_By = User511; versionDetails.Created_Date = DateTime.Now; versionDetails.Modified_By = User511; versionDetails.Modified_Date = DateTime.Now; versionDetails.IsApproved = false; var version = dbPatientAdministration.AddVersionDetailsToTemp(versionDetails); } return(response); }
public static FullPatientTransaction GetFullTransactionDetails(string StageId, string JourneyId) { List <Transaction> listTransactions = bsPatientAdministration.GetTransactions(StageId); List <AssociatedCost> listAssociatedCost = new List <AssociatedCost>(); List <DesiredOutcome> listDesiredOutcome = new List <DesiredOutcome>(); List <ClinicalIntervention> listClinicalIntervention = new List <ClinicalIntervention>(); List <Patient_Journey_Strategic_Moment> listStrategic = new List <Patient_Journey_Strategic_Moment>(); AssociatedCost assCost = null; DesiredOutcome desOutcome = null; ClinicalIntervention clinInter = null; if (listTransactions != null) { List <List <Patient_Journey_Transactions> > StrategicOutcome = dbPatientJourney.GetSMOMTransactions(Convert.ToInt32(StageId), Convert.ToInt32(JourneyId), out listStrategic); for (int i = 0; i < listTransactions.Count; i++) { StrategicMomentDetails strategicdata = null; if (StrategicOutcome != null) { listTransactions[i].StrategicMoment = new List <StrategicMomentDetails>(); for (int j = 0; j < StrategicOutcome.Count; j++) { if (StrategicOutcome[j].Exists(x => x.Patient_Journey_Transactions_Id == listTransactions[i].PatientJourneyTransactionId)) { strategicdata = new StrategicMomentDetails(); strategicdata.IsStrategic = 1; strategicdata.SMOMDescription = listStrategic[j].Description; strategicdata.SMOMTitle = listStrategic[j].Title; strategicdata.SMOMCategory = listStrategic[j].Category; strategicdata.StartStage = dbPatientJourney.GetStageName(listStrategic[j].Patient_Journey_Start_Stage_Id); strategicdata.EndStage = dbPatientJourney.GetStageName(listStrategic[j].Patient_Journey_End_Stage_Id); strategicdata.StartTransaction = dbPatientJourney.GetTransactionName(listStrategic[j].Patient_Journey_Start_Transaction_Id); strategicdata.EndTransaction = dbPatientJourney.GetTransactionName(listStrategic[j].Patient_Journey_End_Transaction_Id); listTransactions[i].StrategicMoment.Add(strategicdata); } else { strategicdata = new StrategicMomentDetails(); strategicdata.IsStrategic = 0; listTransactions[i].StrategicMoment.Add(strategicdata); } } } else { strategicdata = new StrategicMomentDetails(); strategicdata.IsStrategic = 0; listTransactions[i].StrategicMoment.Add(strategicdata); } assCost = new AssociatedCost(); var resultAsscost = dbPatientJourney.GetAssociatedCost(listTransactions[i].PatientJourneyTransactionId); if (resultAsscost != null) { assCost.AssociatedCostId = resultAsscost.Patient_Journey_Transactions_AssociatedCosts_Id; assCost.AssociatedCosts = resultAsscost.AssociatedCosts; assCost.Evidence = resultAsscost.Evidence; assCost.Description = resultAsscost.Description; } assCost.TransactionId = Convert.ToInt32(listTransactions[i].PatientJourneyTransactionId); listAssociatedCost.Add(assCost); desOutcome = new DesiredOutcome(); var resultdesOutcome = dbPatientJourney.GetDesiredOutcome(listTransactions[i].PatientJourneyTransactionId); if (resultdesOutcome != null) { desOutcome.DesiredOutcomeId = resultdesOutcome.Patient_Journey_Transactions_DesiredOutcomes_Id; desOutcome.DesiredOutcomes = resultdesOutcome.DesiredOutcomes; desOutcome.Evidence = resultdesOutcome.Evidence; desOutcome.Description = resultdesOutcome.Description; } desOutcome.TransactionId = Convert.ToInt32(listTransactions[i].PatientJourneyTransactionId); listDesiredOutcome.Add(desOutcome); clinInter = new ClinicalIntervention(); var resultClinInt = dbPatientJourney.GetClinicalIntervention(listTransactions[i].PatientJourneyTransactionId); if (resultClinInt != null) { clinInter.ClinicalInterventionId = resultClinInt.Patient_Journey_Trans_Clin_Interventions_Id; clinInter.ClinicalInterventionMasterId = resultClinInt.Clinical_Intervention_Master_Id; if (clinInter.ClinicalInterventionMasterId != null) { var clinicalInterventionMasterDetails = dbPatientAdministration.GetClinicalInterventionDetails(clinInter.ClinicalInterventionMasterId); clinInter.ClinicalInterventionTitle = clinicalInterventionMasterDetails.Select(x => x.Title).FirstOrDefault().ToString(); if (clinicalInterventionMasterDetails.Select(x => x.Image_Master_Id).FirstOrDefault() != null) { clinInter.ImageMasterId = (int)clinicalInterventionMasterDetails.Select(x => x.Image_Master_Id).FirstOrDefault(); clinInter.ImagePath = dbPatientAdministration.GetImagePath(clinInter.ImageMasterId); } } clinInter.Evidence = resultClinInt.Evidence; clinInter.Description = resultClinInt.Description; List <Patient_Journey_Trans_SubClin_Interventions> lstSubClinicalId = dbPatientJourney.GetSubClinicalIntervention(resultClinInt.Patient_Journey_Trans_Clin_Interventions_Id); if (lstSubClinicalId.Count > 0) { clinInter.SubClinicalId = new int[lstSubClinicalId.Count]; clinInter.SubClinicalImage = new string[lstSubClinicalId.Count]; clinInter.SubClinicalTitle = new string[lstSubClinicalId.Count]; for (int j = 0; j < lstSubClinicalId.Count; j++) { clinInter.SubClinicalId[j] = lstSubClinicalId[j].SubClinical_Intervention_Master_Id; clinInter.SubClinicalImage[j] = dbPatientAdministration.GetImagePath(lstSubClinicalId[j].SubClinical_Intervention_Master_Id); var subclinMaster = DefaultListBSForPJ.GetSubClinicalMasterData(); clinInter.SubClinicalTitle[j] = subclinMaster.Where(x => x.SubClinicalMasterId == lstSubClinicalId[j].SubClinical_Intervention_Master_Id).FirstOrDefault().SubClinicalName; } } } clinInter.TransactionId = Convert.ToInt32(listTransactions[i].PatientJourneyTransactionId); listClinicalIntervention.Add(clinInter); } } FullPatientTransaction fullTransaction = new FullPatientTransaction(); fullTransaction.Transactions = listTransactions; fullTransaction.AssociatedCosts = listAssociatedCost; fullTransaction.DesiredOutcomes = listDesiredOutcome; fullTransaction.ClinicalInterventions = listClinicalIntervention; return(fullTransaction); }
public static void DetermineOutcome(Faction favouredFaction, Faction burdenedFaction, Pawn pawn, DesiredOutcome desiredOutcome, out string factionWarNegotiationsOutcome, IIncidentTarget incidentTarget = null) { float badOutcomeWeightFactor = GetBadOutcomeWeightFactor(diplomacyPower: pawn.GetStatValue(stat: StatDefOf.NegotiationAbility)); float goodOutcomeWeightFactor = 1f / badOutcomeWeightFactor; factionWarNegotiationsOutcome = "Something went wrong with More Faction Interaction. Please contact mod author."; if (desiredOutcome == DesiredOutcome.CURRY_FAVOUR_FACTION_ONE || desiredOutcome == DesiredOutcome.CURRY_FAVOUR_FACTION_TWO) { tmpPossibleOutcomes.Clear(); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksFactionFavourDisaster(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_Disaster * badOutcomeWeightFactor), second: "MFI_FactionWarFavourFactionDisaster".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksFactionsFavourBackfire(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_Backfire * badOutcomeWeightFactor), second: "MFI_FactionWarFavourFactionBackFire".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksFactionsFavourFlounder(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_TalksFlounder), second: "MFI_FactionWarFavourFactionFlounder".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksFactionsFavourSuccess(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_Success * goodOutcomeWeightFactor), second: "MFI_FactionWarFavourFactionSuccess".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksFactionsFavourTriumph(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_Triumph * goodOutcomeWeightFactor), second: "MFI_FactionWarFavourFactionTriumph".Translate(favouredFaction.Name, burdenedFaction.Name))); Pair <Pair <Action, float>, string> outcome = tmpPossibleOutcomes.RandomElementByWeight(x => x.First.Second); outcome.First.First(); factionWarNegotiationsOutcome = outcome.Second; pawn.skills.Learn(sDef: SkillDefOf.Social, xp: 6000f, direct: true); } else if (desiredOutcome == DesiredOutcome.SABOTAGE) { tmpPossibleOutcomes.Clear(); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksSabotageDisaster(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn, incidentTarget: incidentTarget), second: BaseWeight_Disaster * badOutcomeWeightFactor), second: "MFI_FactionWarSabotageDisaster".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksSabotageBackfire(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_Backfire * badOutcomeWeightFactor), second: "MFI_FactionWarSabotageBackFire".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksSabotageFlounder(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_TalksFlounder), second: "MFI_FactionWarSabotageFlounder".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksSabotageSuccess(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_Success * goodOutcomeWeightFactor), second: "MFI_FactionWarSabotageSuccess".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksSabotageTriumph(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_Triumph * goodOutcomeWeightFactor), second: "MFI_FactionWarSabotageTriumph".Translate(favouredFaction.Name, burdenedFaction.Name))); Pair <Pair <Action, float>, string> outcome = tmpPossibleOutcomes.RandomElementByWeight(x => x.First.Second); outcome.First.First(); factionWarNegotiationsOutcome = outcome.Second; pawn.skills.Learn(sDef: SkillDefOf.Social, xp: 6000f, direct: true); } else if (desiredOutcome == DesiredOutcome.BROKER_PEACE) { tmpPossibleOutcomes.Clear(); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksBrokerPeaceDisaster(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_Disaster * badOutcomeWeightFactor), second: "MFI_FactionWarBrokerPeaceDisaster".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksBrokerPeaceBackfire(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_Backfire * badOutcomeWeightFactor), second: "MFI_FactionWarBrokerPeaceBackFire".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksBrokerPeaceFlounder(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_TalksFlounder), second: "MFI_FactionWarBrokerPeaceFlounder".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksBrokerPeaceSuccess(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_Success * goodOutcomeWeightFactor), second: "MFI_FactionWarBrokerPeaceSuccess".Translate(favouredFaction.Name, burdenedFaction.Name))); tmpPossibleOutcomes.Add(item: new Pair <Pair <Action, float>, string>(first: new Pair <Action, float>( first: () => Outcome_TalksBrokerPeaceTriumph(favouredFaction: favouredFaction, burdenedFaction: burdenedFaction, pawn: pawn), second: BaseWeight_Triumph * goodOutcomeWeightFactor), second: "MFI_FactionWarBrokerPeaceTriumph".Translate(favouredFaction.Name, burdenedFaction.Name))); Pair <Pair <Action, float>, string> outcome = tmpPossibleOutcomes.RandomElementByWeight(x => x.First.Second); outcome.First.First(); factionWarNegotiationsOutcome = outcome.Second; pawn.skills.Learn(sDef: SkillDefOf.Social, xp: 6000f, direct: true); } else { throw new NotImplementedException(); } }