public NpcProfile GenerateOne()
        {
            var npc = NPC.TransformTo(Npc.Generate(MilitaryUnits.GetServiceBranch()));

            _mongo.InsertOne(npc, new InsertOneOptions {
                BypassDocumentValidation = false
            });
            return(npc);
        }
Beispiel #2
0
        public IEnumerable <NPC> Create(InsiderThreatGenerationConfiguration config, CancellationToken ct)
        {
            var createdNPCs = new List <NPC>();

            foreach (var enclave in config.Enclaves)
            {
                foreach (var team in enclave.Teams)
                {
                    for (var i = 0; i < team.Npcs.Number; i++)
                    {
                        var branch = team.Npcs.Configuration.Branch ?? MilitaryUnits.GetServiceBranch();
                        var npc    = NPC.TransformTo(Npc.Generate(branch));
                        npc.Team     = team.Name;
                        npc.Campaign = config.Campaign;
                        npc.Enclave  = enclave.Name;
                        createdNPCs.Add(npc);
                    }
                }
            }

            foreach (var npc in createdNPCs)
            {
                foreach (var job in npc.Employment.EmploymentRecords)
                {
                    //get same company departments and highest ranked in that department

                    var managerList = createdNPCs.Where(x => x.Id != npc.Id &&
                                                        x.Employment.EmploymentRecords.Any(
                                                            x => x.Company == job.Company &&
                                                            x.Department == job.Department &&
                                                            x.Level >= job.Level));

                    if (managerList.Any())
                    {
                        var manager = managerList.RandomElement();
                        job.Manager = manager.Id;
                    }
                }
            }

            _mongo.InsertMany(createdNPCs, new InsertManyOptions {
                IsOrdered = false
            }, ct);
            return(createdNPCs);
        }
Beispiel #3
0
 public NpcTests()
 {
     this._npc = Npc.Generate(MilitaryUnits.GetServiceBranch());
 }