add new objectives if entries does not match existing ones
This commit is contained in:
		
							parent
							
								
									6dda7cfde4
								
							
						
					
					
						commit
						068a2102b9
					
				@ -34,6 +34,7 @@ namespace EliteBGS.BGS {
 | 
				
			|||||||
                e.Is(Events.MissionAccepted) ||
 | 
					                e.Is(Events.MissionAccepted) ||
 | 
				
			||||||
                e.Is(Events.Docked) ||
 | 
					                e.Is(Events.Docked) ||
 | 
				
			||||||
                e.Is(Events.FSDJump) ||
 | 
					                e.Is(Events.FSDJump) ||
 | 
				
			||||||
 | 
					                e.Is(Events.Location) ||
 | 
				
			||||||
                e.Is(Events.MultiSellExplorationData) ||
 | 
					                e.Is(Events.MultiSellExplorationData) ||
 | 
				
			||||||
                e.Is(Events.SellMicroResources) ||
 | 
					                e.Is(Events.SellMicroResources) ||
 | 
				
			||||||
                e.Is(Events.RedeemVoucher) ||
 | 
					                e.Is(Events.RedeemVoucher) ||
 | 
				
			||||||
@ -73,6 +74,18 @@ namespace EliteBGS.BGS {
 | 
				
			|||||||
                     */
 | 
					                     */
 | 
				
			||||||
                    current_system = (e as FSDJumpEntry).StarSystem;
 | 
					                    current_system = (e as FSDJumpEntry).StarSystem;
 | 
				
			||||||
                    controlling_faction = (e as FSDJumpEntry).SystemFaction;
 | 
					                    controlling_faction = (e as FSDJumpEntry).SystemFaction;
 | 
				
			||||||
 | 
					                } else if (e.Is(Events.Location)) {
 | 
				
			||||||
 | 
					                    /* Get current system, faction name and station from Location message
 | 
				
			||||||
 | 
					                     */
 | 
				
			||||||
 | 
					                    LocationEntry location = e as LocationEntry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    current_system = location.StarSystem;
 | 
				
			||||||
 | 
					                    if (!string.IsNullOrEmpty(location.SystemFaction)) {
 | 
				
			||||||
 | 
					                        controlling_faction = location.SystemFaction;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (!string.IsNullOrEmpty(location.StationName)) {
 | 
				
			||||||
 | 
					                        current_station = location.StationName;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                } else if (e.Is(Events.MissionCompleted)) {
 | 
					                } else if (e.Is(Events.MissionCompleted)) {
 | 
				
			||||||
                    var completed = e as MissionCompletedEntry;
 | 
					                    var completed = e as MissionCompletedEntry;
 | 
				
			||||||
                    entry = new MissionCompleted(completed) { System = current_system, Station = current_station };
 | 
					                    entry = new MissionCompleted(completed) { System = current_system, Station = current_station };
 | 
				
			||||||
@ -145,20 +158,24 @@ namespace EliteBGS.BGS {
 | 
				
			|||||||
                    .Where(x => x.Matches(entry) > 0)
 | 
					                    .Where(x => x.Matches(entry) > 0)
 | 
				
			||||||
                    .OrderBy(x => x.Matches(entry))
 | 
					                    .OrderBy(x => x.Matches(entry))
 | 
				
			||||||
                    ;
 | 
					                    ;
 | 
				
			||||||
                if (matches == null || matches.Count() <= 0) {
 | 
					 | 
				
			||||||
                    continue;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                /* Then select the one that matches the most.
 | 
					                Objective objective = null;
 | 
				
			||||||
                 */
 | 
					                if (matches != null && matches.Count() > 0) {
 | 
				
			||||||
                var objective = matches
 | 
					                    /* Then select the one that matches the most.
 | 
				
			||||||
                    .OrderBy(x => x.Matches(entry))
 | 
					                     */
 | 
				
			||||||
                    .Reverse()
 | 
					                    objective = matches
 | 
				
			||||||
                    .First()
 | 
					                        .OrderBy(x => x.Matches(entry))
 | 
				
			||||||
                    ;
 | 
					                        .Reverse()
 | 
				
			||||||
 | 
					                        .First()
 | 
				
			||||||
                if (objective == null) {
 | 
					                        ;
 | 
				
			||||||
                    continue;
 | 
					                } else {
 | 
				
			||||||
 | 
					                    /* create a new objective if we don't have one */
 | 
				
			||||||
 | 
					                    objective = new Objective() {
 | 
				
			||||||
 | 
					                        Station = entry.Station,
 | 
				
			||||||
 | 
					                        Faction = entry.Faction,
 | 
				
			||||||
 | 
					                        System = entry.System,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    objectives.Add(objective);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                LogEntry existing = null;
 | 
					                LogEntry existing = null;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user