public override void OnOpen(LocationConfig config) { bool rendezvousMode = AmbitionApp.GetModel <CharacterModel>().CreateRendezvousMode; ParisModel paris = AmbitionApp.Paris; IncidentModel story = AmbitionApp.Story; LocationVO location = paris.SaveLocation(config); _incident = story.GetIncident(config.IntroIncidentConfig?.name); _location = config.name; LocationNameText.text = AmbitionApp.Localize(ParisConsts.LABEL + _location); LocationDescriptionText.text = AmbitionApp.Localize(ParisConsts.DESCRIPTION + _location); LocationImage.sprite = config.LocationModalSprite; GoButtonText.text = AmbitionApp.Localize(rendezvousMode ? ParisConsts.PICK_LOC_BTN_LABEL : ParisConsts.GO_LOC_BTN_LABEL); if (!AmbitionApp.CheckIncidentEligible(_incident) && config.StoryIncidentConfigs != null) { foreach (IncidentConfig icon in config.StoryIncidentConfigs) { if (AmbitionApp.CheckIncidentEligible(icon?.name)) { _incident = story.GetIncident(icon.name); } } } List.SetIncident(_incident); }
// Chooses all of the new Daily locations whose requirements have been met // This ensures that the same locations aren't available on two consecutive days public void Execute(string[] pins) { ParisModel paris = AmbitionApp.Paris; if (paris.Daily == null && AmbitionApp.GetModel <CharacterModel>().Rendezvous == null && AmbitionApp.CheckRequirements(paris.ExploreParisRequirements)) { GameModel game = AmbitionApp.Game; LocationVO location = null; List <string> subset = new List <string>(); int num = paris.NumDailies; foreach (string pinID in pins) { location = paris.GetLocation(pinID); if (location != null && location.IsDiscoverable && !paris.Rendezvous.Contains(pinID) && (!location.IsOneShot || !paris.Completed.Contains(pinID)) && AmbitionApp.CheckRequirements(location.Requirements)) { if (!string.IsNullOrWhiteSpace(location.SceneID) || AmbitionApp.CheckIncidentEligible(location.IntroIncident)) { subset.Add(pinID); } else if (location.StoryIncidents != null) { foreach (string incidentID in location.StoryIncidents) { if (AmbitionApp.CheckIncidentEligible(incidentID)) { subset.Add(pinID); break; } } } } } if (subset.Count > num) { pins = Util.RNG.Shuffle(subset); paris.Daily = new string[num]; for (int i = num - 1; i >= 0; i--) { paris.Daily[i] = pins[i]; } } else { paris.Daily = subset.ToArray(); } } }
IncidentVO TakeRandom(IncidentVO[] incidents) { List <IncidentVO> eligible = new List <IncidentVO>(); foreach (IncidentVO incident in incidents) { if (AmbitionApp.CheckIncidentEligible(incident)) { eligible.Add(incident); } } return(Util.RNG.TakeRandom(eligible)); }
private bool CheckIncident() { IncidentModel model = AmbitionApp.GetModel <IncidentModel>(); while (model.Incident != null) // Iterates through incidents that meet requirements { if (AmbitionApp.CheckIncidentEligible(model.Incident)) { return(true); } model.NextIncident(); } return(false); }
public override void OnEnter() { RendezVO vous = AmbitionApp.Calendar.GetOccasions <RendezVO>()[0]; AmbitionApp.GetModel <GameModel>().Activity = ActivityType.Rendezvous; LocationVO location = AmbitionApp.Paris.GetLocation(vous.Location); IncidentVO incident; // This will crash if the rendezvous location is badly configured foreach (string ID in location.StoryIncidents) { AmbitionApp.Story.Incidents.TryGetValue(ID, out incident); if (incident != null && AmbitionApp.CheckIncidentEligible(incident)) { AmbitionApp.Story.Schedule(incident); return; } } // TODO: Evaluate Outfit for Rendezvous }
private IncidentVO GetLocationIncident(LocationVO location) { ParisModel paris = AmbitionApp.Paris; if (location == null || paris.IsComplete(location.ID)) { return(null); } AmbitionApp.GetModel <LocalizationModel>().SetLocation(location.ID); if (AmbitionApp.CheckIncidentEligible(location.IntroIncident)) { return(AmbitionApp.Story.GetIncident(location.IntroIncident)); } foreach (string incidentID in location.StoryIncidents) { if (AmbitionApp.CheckIncidentEligible(incidentID)) { return(AmbitionApp.Story.GetIncident(incidentID)); } } return(null); }
public void Execute(CalendarModel calendar) { IncidentModel story = AmbitionApp.Story; IncidentVO incident = story.Incident; if (incident == null && Util.RNG.Generate(100) < AmbitionApp.Game.PoliticalChance) { string[] incidentIDs = story.Types[IncidentType.Political]; List <IncidentVO> incidents = new List <IncidentVO>(); foreach (string incidentID in incidentIDs) { incident = story.GetIncident(incidentID); if (AmbitionApp.CheckIncidentEligible(incident) && !incident.IsScheduled) { incidents.Add(incident); } } if (incidents.Count > 0) { incident = Util.RNG.TakeRandom(incidents); AmbitionApp.SendMessage(CalendarMessages.SCHEDULE, incident); } } }
public override void OnEnter() { PartyModel model = AmbitionApp.GetModel <PartyModel>(); IncidentVO[] incidents = new IncidentVO[model.NumRooms]; IncidentModel story = AmbitionApp.Story; if (model.Incidents != null) { incidents = new IncidentVO[model.NumRooms]; for (int i = model.NumRooms - 1; i >= 0; --i) { incidents[i] = story.GetIncident(model.Incidents[i]); } } else { HashSet <string> characters = new HashSet <string>(); if (model.RequiredIncident != null) { int index = RNG.Generate(model.NumRooms); incidents[index] = story.GetIncident(model.RequiredIncident); } else { List <IncidentVO> result = new List <IncidentVO>(); IncidentVO incident; if (model.Party.SupplementalIncidents != null) { string[] shuffle = RNG.Shuffle(model.Party.SupplementalIncidents); foreach (string incidentID in shuffle) { incident = story.GetIncident(incidentID); if (result.Count < model.NumRooms) { if (FindCharacters(incident, characters)) { result.Add(incident); } } } } if (result.Count < model.NumRooms) { incidents = story.GetIncidents(IncidentType.Party); incidents = RNG.Shuffle(incidents); foreach (IncidentVO rand in incidents) { if (AmbitionApp.CheckIncidentEligible(rand) && (rand.Factions?.Length == 0 || Array.IndexOf(rand.Factions, model.Party.Faction) >= 0) && FindCharacters(rand, characters)) { result.Add(rand); } if (result.Count >= model.NumRooms) { break; } } } while (result.Count < model.NumRooms) { result.Add(null); } incidents = RNG.Shuffle(result); } model.Incidents = new string[model.NumRooms]; for (int i = model.NumRooms - 1; i >= 0; --i) { model.Incidents[i] = incidents[i]?.ID; } } AmbitionApp.SendMessage(PartyMessages.SELECT_INCIDENTS, incidents); string title = AmbitionApp.Localize(PartyConstants.PARTY_NAME + model.Party.ID); if (string.IsNullOrEmpty(title)) { title = PartyConstants.PARTY_REASON + model.Party.Faction.ToString().ToLower() + "." + model.Party.phrases[0]; } AmbitionApp.SendMessage(GameMessages.SHOW_HEADER, title); }