Exemplo n.º 1
0
        public MediaFolderVM(IWpfAppManager mediaManager)
        {
            this.mediaManager = mediaManager;
            Items             = new ObservableCollection <MediaItem>();
            folder            = mediaManager.GetMediaFolder("Get Media Folder From Disk");

            this.SearchCommand = new RelayCommand(o => {
                IEnumerable <MediaItem> items = mediaManager.SearchForItems(SearchName, folder);
                Items.Clear();
                foreach (MediaItem item in items)
                {
                    Items.Add(item);
                }
            });

            this.ClearCommand = new RelayCommand(o => {
                Items.Clear();
                SearchName = "";

                FillListView();
            });

            this.RandGenItemCommand = new RelayCommand(o => {
                MediaItem genItem = mediaManager.CreateItem(NameGenerator.GenerateName(4), NameGenerator.GenerateName(8), NameGenerator.GenerateName(16), DateTime.Now);
                Items.Add(genItem);
            });

            this.RandGenLogCommand = new RelayCommand(o => {
                MediaLog genLog = mediaManager.CreateItemLog(NameGenerator.GenerateName(45), CurrentItem);
            });

            InitListView();
        }
Exemplo n.º 2
0
        public static string GeneratePermadeathSaveName()
        {
            string fileName = NameGenerator.GenerateName(Faction.OfPlayer.def.factionNameMaker);

            fileName = GenFile.SanitizedFileName(fileName);
            return(NewPermadeathSaveNameWithAppendedNumberIfNecessary(fileName));
        }
Exemplo n.º 3
0
    public void GenerateEquipmentStats()
    {
        //Roll to see how rare the equipment is
        float rarityRoll = Random.Range(0, 1.0f);

        //Determine the equipment's rarity
        //Common:		50%
        //Uncommon:		30%
        //Rare:			20%
        if ((1 - rarityRoll) <= 0.20f)
        {
            armorRarity = Rarity.Rare;
        }
        else if ((1 - rarityRoll) <= 0.30f)
        {
            armorRarity = Rarity.Uncommon;
        }
        else
        {
            armorRarity = Rarity.Common;
        }

        //Determine number of gem slots
        //Common:		0
        //Uncommon:		1-3
        //Rare:			3-5
        if (armorRarity == Rarity.Common)
        {
            armorGemSlots = 0;
        }
        else if (armorRarity == Rarity.Uncommon)
        {
            armorGemSlots = Random.Range(1, 4);
        }
        else if (armorRarity == Rarity.Rare)
        {
            armorGemSlots = Random.Range(3, 6);
        }

        //Determine if any gem slots will have a gem in it
        //For each gem slot, there is a 10% chance to have a gem in it
        //JPS: Scale this to factor in rarity of the gem, which isn't implemented yet.
        //	   Currently any gem has an equal chance of taking up a gem slot.
        for (int i = 0; i < armorGemSlots; i++)
        {
            float gemRoll = Random.Range(0, 1.0f);
            if ((1 - gemRoll) <= 0.10f)
            {
                attachedGems.Add((Gems)Random.Range(0, (int)Gems.NumberOfTypes));
            }
        }

        //Calculate enchantment percents for each gem equipped
        CalculateEnchantmentPercents();

        DetermineDefenseStats();

        //Generate the name of the armor given the randomly generated values above
        armorName = NameGenerator.GenerateName(this);
    }
Exemplo n.º 4
0
        public static void NamesFromRulepack()
        {
            IEnumerable <RulePackDef> first = DefDatabase <FactionDef> .AllDefsListForReading.Select((FactionDef f) => f.factionNameMaker);

            IEnumerable <RulePackDef> second = DefDatabase <FactionDef> .AllDefsListForReading.Select((FactionDef f) => f.settlementNameMaker);

            IEnumerable <RulePackDef> second2 = DefDatabase <FactionDef> .AllDefsListForReading.Select((FactionDef f) => f.playerInitialSettlementNameMaker);

            IEnumerable <RulePackDef> second3 = DefDatabase <FactionDef> .AllDefsListForReading.Select((FactionDef f) => f.pawnNameMaker);

            IOrderedEnumerable <RulePackDef> orderedEnumerable = from d in (from d in Enumerable.Concat(second: DefDatabase <RulePackDef> .AllDefsListForReading.Where((RulePackDef d) => d.defName.Contains("Namer")), first: first.Concat(second).Concat(second2).Concat(second3))
                                                                            where d != null
                                                                            select d).Distinct()
                                                                 orderby d.defName
                                                                 select d;
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (RulePackDef item2 in orderedEnumerable)
            {
                RulePackDef     localNamer = item2;
                FloatMenuOption item       = new FloatMenuOption(localNamer.defName, delegate
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine("Testing RulePack " + localNamer.defName + " as a name generator:");
                    for (int i = 0; i < 200; i++)
                    {
                        string testPawnNameSymbol = (i % 2 == 0) ? "Smithee" : null;
                        stringBuilder.AppendLine(NameGenerator.GenerateName(localNamer, null, appendNumberIfNameUsed: false, localNamer.FirstRuleKeyword, testPawnNameSymbol));
                    }
                    Log.Message(stringBuilder.ToString());
                });
                list.Add(item);
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Exemplo n.º 5
0
        private static string GenerateName()
        {
            GrammarRequest req = default(GrammarRequest);

            req.Rules.AddRange(QuestGen.QuestNameRulesReadOnly);
            foreach (KeyValuePair <string, string> item in QuestGen.QuestNameConstantsReadOnly)
            {
                req.Constants.Add(item.Key, item.Value);
            }
            QuestGenUtility.AddSlateVars(ref req);
            Predicate <string> predicate = (string x) => !Find.QuestManager.QuestsListForReading.Any((Quest y) => y.name == x);

            if (QuestGen.Root.nameMustBeUnique)
            {
                return(NameGenerator.GenerateName(req, predicate, appendNumberIfNameUsed: false, "questName"));
            }
            string text = null;
            int    i;

            for (i = 0; i < 20; i++)
            {
                text = NameGenerator.GenerateName(req, null, appendNumberIfNameUsed: false, "questName");
                if (predicate(text) || QuestGen.Root.defaultHidden)
                {
                    break;
                }
            }
            if (i == 20)
            {
                Log.Warning(string.Concat("Generated duplicate quest name. QuestScriptDef: ", QuestGen.Root, ". Quest name: ", text));
            }
            return(text);
        }
Exemplo n.º 6
0
 public static Name GeneratePawnName(Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
 {
     if (style == NameStyle.Full)
     {
         RulePackDef nameGenerator = pawn.RaceProps.GetNameGenerator(pawn.gender);
         if (nameGenerator != null)
         {
             string name = NameGenerator.GenerateName(nameGenerator, (string x) => !new NameSingle(x, false).UsedThisGame, false);
             return(new NameSingle(name, false));
         }
         if (pawn.Faction != null && pawn.Faction.def.pawnNameMaker != null)
         {
             string rawName = NameGenerator.GenerateName(pawn.Faction.def.pawnNameMaker, delegate(string x)
             {
                 NameTriple nameTriple4 = NameTriple.FromString(x);
                 nameTriple4.ResolveMissingPieces(forcedLastName);
                 return(!nameTriple4.UsedThisGame);
             }, false);
             NameTriple nameTriple = NameTriple.FromString(rawName);
             nameTriple.CapitalizeNick();
             nameTriple.ResolveMissingPieces(forcedLastName);
             return(nameTriple);
         }
         if (pawn.RaceProps.nameCategory != PawnNameCategory.NoName)
         {
             if (Rand.Value < 0.5f)
             {
                 NameTriple nameTriple2 = TryGetRandomUnusedSolidName(pawn.gender, forcedLastName);
                 if (nameTriple2 != null)
                 {
                     return(nameTriple2);
                 }
             }
             return(GeneratePawnName_Shuffled(pawn, forcedLastName));
         }
         Log.Error("No name making method for " + pawn);
         NameTriple nameTriple3 = NameTriple.FromString(pawn.def.label);
         nameTriple3.ResolveMissingPieces(null);
         return(nameTriple3);
     }
     else
     {
         if (style == NameStyle.Numeric)
         {
             int    num = 1;
             string text;
             while (true)
             {
                 text = pawn.KindLabel + " " + num.ToString();
                 if (!NameUseChecker.NameSingleIsUsed(text))
                 {
                     break;
                 }
                 num++;
             }
             return(new NameSingle(text, true));
         }
         throw new InvalidOperationException();
     }
 }
Exemplo n.º 7
0
        public static string GeneratePermadeathSaveName()
        {
            string text = NameGenerator.GenerateName(Faction.OfPlayer.def.factionNameMaker, null, false, null, null);

            text = GenFile.SanitizedFileName(text);
            return(PermadeathModeUtility.NewPermadeathSaveNameWithAppendedNumberIfNecessary(text, null));
        }
Exemplo n.º 8
0
 public void SetUp()
 {
     classUnderTest = new NameGenerator();
     existingNames  = NameGenerator.AllNames.Skip(1);
     expectedName   = NameGenerator.AllNames.First();
     generatedName  = classUnderTest.GenerateName(existingNames);
 }
Exemplo n.º 9
0
    public void AddPriest()
    {
        bool gender = (Roll.d2() == 1);

        string name = NameGenerator.GenerateName(gender);

        members.Add(new Priest(name));
    }
Exemplo n.º 10
0
    public void AddWarrior()
    {
        bool gender = (Roll.d2() == 1);

        string name = NameGenerator.GenerateName(gender);

        members.Add(new Warrior(name));
    }
Exemplo n.º 11
0
    IEnumerator Auth()
    {
        yield return(new WaitUntil(() => UDPConnection.init));

        string playerName = NameGenerator.GenerateName(4, 10);

        UDPConnection.Send(new AuthMessage(playerName));
    }
Exemplo n.º 12
0
 public Dialog_NamePlayerFaction()
 {
     nameGenerator         = (() => NameGenerator.GenerateName(Faction.OfPlayer.def.factionNameMaker, IsValidName));
     curName               = nameGenerator();
     nameMessageKey        = "NamePlayerFactionMessage";
     gainedNameMessageKey  = "PlayerFactionGainsName";
     invalidNameMessageKey = "PlayerFactionNameIsInvalid";
 }
Exemplo n.º 13
0
        public void NameGeneratorTest()
        {
            var ng = new NameGenerator();
            HashSet <string> names = new HashSet <string>();
            string           name2 = ng.GenerateName("car7");

            names.Add(name2);
            for (int i = 0; i < 100; i++)
            {
                string name = ng.GenerateName("car");
                Assert.DoesNotContain(name, names);
                names.Add(name);
            }

            name2 = ng.GenerateName("car9");
            Assert.DoesNotContain(name2, names);
        }
Exemplo n.º 14
0
 public Moon(int uniqueID, World world, int newTicks)
 {
     this.uniqueID    = uniqueID;
     name             = NameGenerator.GenerateName(RulePackDefOf.NamerWorld, (x => x != (hostPlanet?.info?.name ?? "") && x.Count() < 9), false);
     hostPlanet       = world;
     ticksInCycle     = newTicks;
     ticksLeftInCycle = ticksInCycle;
     //Log.Message("New moon: " + name + " initialized. " + ticksInCycle + " ticks per cycle.");
 }
Exemplo n.º 15
0
        /// <summary>
        /// Creates a cutebold name.
        /// </summary>
        /// <param name="nameMaker">The given name rules.</param>
        /// <param name="forcedLastName">The forced last name.</param>
        /// <returns>Returns a new cutebold name.</returns>
        private static NameTriple CuteboldNameResolver(RulePackDef nameMaker, string forcedLastName)
        {
            NameTriple name = NameTriple.FromString(NameGenerator.GenerateName(nameMaker, null, false, null, null));

            name.CapitalizeNick();
            name.ResolveMissingPieces(forcedLastName);

            return(name);
        }
Exemplo n.º 16
0
 public override void Initialize(CompProperties pro)
 {
     name = NameGenerator.GenerateName(RulePackDef.Named("EngravedName"));
     key  = "";
     for (int i = 0; i < 16; ++i)
     {
         key += random_hex_byte();
     }
 }
Exemplo n.º 17
0
        private void DrawAllianceMainPage(Rect inRect)
        {
            Rect rect1 = inRect;

            rect1.width  = 500;
            rect1.height = 530;
            Rect rect2 = rect1;

            rect2.x += 500;

            Text.Anchor = TextAnchor.UpperCenter;
            Widgets.Label(rect1, "DrawAllianceMainPage_AllianceTitle".Translate());
            Widgets.Label(rect2, "DrawAllianceMainPage_CoalitionTitle".Translate());
            Text.Anchor = TextAnchor.UpperLeft;

            Rect scrollVertRectFact = new Rect(0, 30, rect1.x, commAllianceSliderLength);
            int  y = 60;

            Widgets.BeginScrollView(rect1, ref factionListSlider, scrollVertRectFact, false);
            for (int i = 0; i < alliances.Count; i++)
            {
                Alliance alliance = alliances[i];

                DrawAllianceCard(rect1, ref y, alliance);
            }
            Widgets.EndScrollView();

            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;
            Rect bottomButton = new Rect(inRect.x + 125, 530, 250, 40);

            if (DrawCustomButton(bottomButton, "DrawAllianceMainPage_AllianceCreateButton".Translate(), Color.white))
            {
                if (globalFactionManager.PlayerAlliance == null)
                {
                    Alliance alliance = Alliance.MakeAlliance(NameGenerator.GenerateName(RulePackDefOfLocal.NamerSettlementOutlander), Faction.OfPlayer, AllianceGoalDefOfLocal.CommonGoal);

                    globalFactionManager.AddAlliance(alliance);
                }
                else
                {
                    Messages.Message("Alliance_PlayerAlreadyHaveOne".Translate(), MessageTypeDefOf.NeutralEvent);
                }
            }
            bottomButton.x += 500;
            if (DrawCustomButton(bottomButton, "DrawAllianceMainPage_CoalitioneCreateButton".Translate(), Color.white))
            {
            }
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Small;

            GUI.color    = MenuSectionBGBorderColor;
            rect1.height = 556;
            Widgets.DrawBox(rect1);
            GUI.color = Color.white;
        }
Exemplo n.º 18
0
        public FormAddNewProfessor()
        {
            InitializeComponent();

            _config = new ConfigurationBuilder()
                      .SetBasePath(Directory.GetCurrentDirectory())
                      .AddJsonFile("appsettings.json").Build();

            textBoxName.Text = NameGenerator.GenerateName(12);
        }
Exemplo n.º 19
0
 public Leader(int seed)
 {
     System.Random random = new System.Random(seed);
     name         = NameGenerator.GenerateName(random, 3, 7, 2);
     popularity   = (float)random.NextDouble() * 2 - 1;
     rage         = (float)random.NextDouble() * 2 - 1;
     intelligence = (float)random.NextDouble() * 2 - 1;
     vicious      = (float)random.NextDouble() * 2 - 1;
     religious    = (float)random.NextDouble() * 2 - 1;
     scientific   = (float)random.NextDouble() * 2 - 1;
 }
Exemplo n.º 20
0
 // ******************** Private Methods ********************
 private static NewProfessorRequest GenerateNewProfessor()
 {
     return(new NewProfessorRequest()
     {
         Name = NameGenerator.GenerateName(12),
         Doj = Timestamp.FromDateTime(DateTime.Now.AddYears(-1 * RandomNumberGenerator.GetRandomValue(1, 10)).ToUniversalTime()),
         Teaches = "CSharp, Java",
         Salary = 1234.56,
         IsPhd = true
     });
 }
Exemplo n.º 21
0
 public Leader(Leader parent, int seed)
 {
     System.Random random = new System.Random(seed);
     name         = NameGenerator.GenerateName(random, 3, 7, 2, parent.name[0].ToString());
     popularity   = GetVariation(random, parent.popularity);
     rage         = GetVariation(random, parent.rage);
     intelligence = GetVariation(random, parent.intelligence);
     vicious      = GetVariation(random, parent.vicious);
     religious    = GetVariation(random, parent.religious);
     scientific   = GetVariation(random, parent.scientific);
 }
        public FormAddNewProfessor()
        {
            InitializeComponent();

            _config = new ConfigurationBuilder()
                      .SetBasePath(Directory.GetCurrentDirectory())
                      .AddJsonFile("appsettings.json").Build();

            textBoxName.Text = NameGenerator.GenerateName(12);

            _client = CollegeServiceClientHelper.GetCollegeServiceClient(_config["RPCService:ServiceUrl"]);
        }
Exemplo n.º 23
0
    private void HandleUpload(string imageUrl)
    {
        qrCodeRenderer.onQrCodeDisplayed.AddListener(() =>
        {
            finalizePanel.SetActive(true);

            // Persist character data
            characterStore.SetCharacter(imageUrl, nameGenerator.GenerateName());
        });

        // Display a QR code for the imgur link
        qrCodeRenderer.DisplayQrCode(imageUrl);
    }
        public void WhenAProduct_IsCreated()
        {
            var productsRepository = new ProductsRepository();
            var currencyGenerator  = new CurrencyGenerator();
            var product            = new Product
            {
                Name  = NameGenerator.GenerateName(),
                Price = currencyGenerator.GenerateAmount()
            };
            var results = productsRepository.Add(product).Result;

            Console.WriteLine(results);
        }
Exemplo n.º 25
0
 void Update()
 {
     if (Input.GetButtonDown("Fire2"))
     {
         string nameGot;
         do
         {
             nameGot = nameGen.GenerateName();
         } while (nameGot.Length < 4);
         nameGot          = char.ToUpper(nameGot[0]) + nameGot.Substring(1);
         displayText.text = nameGot + '\n' + storyGen.GenerateStory();
     }
 }
Exemplo n.º 26
0
        private Faction GenerateFaction()
        {
            if (newFaction != null && newFaction.leader != null)
            {
                Find.WorldPawns.RemoveAndDiscardPawnViaGC(newFaction.leader);
            }

            Faction    faction = new Faction();
            FactionDef facDef  = null;

            if (selectedFaction == null)
            {
                selectedFaction = avaliableFactions.RandomElement();
            }
            facDef      = selectedFaction;
            faction.def = facDef;
            faction.colorFromSpectrum = FactionGenerator.NewRandomColorFromSpectrum(faction);
            if (!facDef.isPlayer)
            {
                if (facDef.fixedName != null)
                {
                    faction.Name = facDef.fixedName;
                }
                else
                {
                    faction.Name = NameGenerator.GenerateName(facDef.factionNameMaker, from fac in Find.FactionManager.AllFactionsVisible
                                                              select fac.Name);
                }
            }
            faction.centralMelanin = Rand.Value;
            foreach (Faction item in Find.FactionManager.AllFactions)
            {
                faction.TryMakeInitialRelationsWith(item);
            }

            Pawn p = PawnGenerator.GeneratePawn(PawnKindDefOf.AncientSoldier);

            leaderName = p.Name.ToStringFull;

            FieldInfo relations = typeof(Faction).GetField("relations", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            newFactionRelation     = relations.GetValue(faction) as List <FactionRelation>;
            newFactionGoodwillBuff = new string[newFactionRelation.Count];

            for (int i = 0; i < newFactionRelation.Count; i++)
            {
                newFactionGoodwillBuff[i] = newFactionRelation[i].goodwill.ToString();
            }

            return(faction);
        }
Exemplo n.º 27
0
        public static World GenerateWorld(float planetCoverage, string seedString, OverallRainfall overallRainfall, OverallTemperature overallTemperature)
        {
            DeepProfiler.Start("GenerateWorld");
            Rand.PushState();
            int seedFromSeedString = WorldGenerator.GetSeedFromSeedString(seedString);

            Rand.Seed = seedFromSeedString;
            World creatingWorld;

            try
            {
                Current.CreatingWorld = new World();
                Current.CreatingWorld.info.seedString         = seedString;
                Current.CreatingWorld.info.planetCoverage     = planetCoverage;
                Current.CreatingWorld.info.overallRainfall    = overallRainfall;
                Current.CreatingWorld.info.overallTemperature = overallTemperature;
                Current.CreatingWorld.info.name = NameGenerator.GenerateName(RulePackDefOf.NamerWorld, null, false, null, null);
                WorldGenerator.tmpGenSteps.Clear();
                WorldGenerator.tmpGenSteps.AddRange(WorldGenerator.GenStepsInOrder);
                for (int i = 0; i < WorldGenerator.tmpGenSteps.Count; i++)
                {
                    DeepProfiler.Start("WorldGenStep - " + WorldGenerator.tmpGenSteps[i]);
                    try
                    {
                        Rand.Seed = Gen.HashCombineInt(seedFromSeedString, WorldGenerator.GetSeedPart(WorldGenerator.tmpGenSteps, i));
                        WorldGenerator.tmpGenSteps[i].worldGenStep.GenerateFresh(seedString);
                    }
                    catch (Exception arg)
                    {
                        Log.Error("Error in WorldGenStep: " + arg, false);
                    }
                    finally
                    {
                        DeepProfiler.End();
                    }
                }
                Rand.Seed = seedFromSeedString;
                Current.CreatingWorld.grid.StandardizeTileData();
                Current.CreatingWorld.FinalizeInit();
                Find.Scenario.PostWorldGenerate();
                creatingWorld = Current.CreatingWorld;
            }
            finally
            {
                Rand.PopState();
                DeepProfiler.End();
                Current.CreatingWorld = null;
            }
            return(creatingWorld);
        }
Exemplo n.º 28
0
        public void CheckGender(Gender gender)
        {
            // Act
            var generatedName = unitToTest.GenerateName(gender);
            var hero          = new Hero(generatedName);

            // Assert
            Assert.True(hero.Gender.Equals(gender));
        }
Exemplo n.º 29
0
        public void GenerateName(Faction faction)
        {
            if (newFaction == null)
            {
                return;
            }

            if (faction.def.factionNameMaker == null)
            {
                Faction f = (from fac in Find.FactionManager.AllFactionsVisible where fac.def.factionNameMaker != null select fac).RandomElement();
                faction = f;
            }

            faction.Name = NameGenerator.GenerateName(faction.def.factionNameMaker, from fac in Find.FactionManager.AllFactionsVisible
                                                      select fac.Name);
        }
Exemplo n.º 30
0
 private void InitiateShipProperties()
 {
     DropShipUtility.currentShipTracker.AllWorldShips.Add(this);
     this.ShipNick       = NameGenerator.GenerateName(RulePackDef.Named("NamerShipGeneric"));
     this.compShipCached = this.TryGetComp <CompShip>();
     if (this.compShip == null)
     {
         Log.Error("DropShip is missing " + nameof(CompProperties_Ship) + "/n Defaulting.");
         this.compShipCached = new CompShip();
         this.drawTickOffset = compShip.sProps.TicksToImpact;
     }
     if (this.installedTurrets.Count == 0)
     {
         this.InitiateInstalledTurrets();
     }
 }