Пример #1
0
        public void ProfessionInitialize()
        {
            _professionRepository = new ProfessionRepository(new Core.Base.Data.SqlServer.Factory.BaseContextFactory <HCRGUniversity.Core.Data.SqlServer.HCRGUniversityDBContext>());

            _organizationRepository = new OrganizationRepository(new Core.Base.Data.SqlServer.Factory.BaseContextFactory <HCRGUniversity.Core.Data.SqlServer.HCRGUniversityDBContext>());
            _professionBL           = new ProfessionImpl(_professionRepository, _organizationRepository);
        }
Пример #2
0
        // Get the total amount of a specific needed mat in all steps
        public static int GetTotalNeededMat(IProfession profession, Item itemToSearch)
        {
            int amount = 0;

            foreach (Step s in profession.AllSteps)
            {
                int pickFromVirtualBag = 0;

                // If it's the current step make sure we mitigate to match amount goal
                if (s == profession.CurrentStep && s.Type == Step.StepType.CraftToLevel && s.EstimatedAmountOfCrafts != 0)
                {
                    s.EstimatedAmountOfCrafts = s.GetRemainingProfessionLevels();
                }
                else if (s == profession.CurrentStep && s.Type == Step.StepType.CraftAll)
                {
                    pickFromVirtualBag = PickFromVirtualBag(s.ItemoCraft, s.EstimatedAmountOfCrafts);
                }

                // We search the targetted mat in the current step item or its children
                Item.Mat searchedMat = s.ItemoCraft.Materials.Find(i => i.Item.ItemId == itemToSearch.ItemId || i.Item.Materials.Exists(it => it.Item.ItemId == itemToSearch.ItemId));
                if (searchedMat.Item != null)
                {
                    if (ToolBox.GetProfessionLevel(profession.Name) < s.LevelToReach || s.ItemoCraft.IsAPrerequisiteItem)
                    {
                        amount += GetMaterialAmountInItem(s.ItemoCraft, itemToSearch, s.EstimatedAmountOfCrafts - pickFromVirtualBag);
                    }
                }
            }
            virtualBag.Clear();
            return(amount);
        }
        private static void FillStrings(IProfession prof)
        {
            string profNameS      = null;
            string farmsNeededS   = null;
            string currentstepS   = null;
            string requiredLevelS = null;

            if (prof != null)
            {
                profNameS = prof.Name.ToString();

                if (prof.CurrentStep != null)
                {
                    // Requires player action
                    if (prof.CurrentStep.ItemoCraft.UserMustBuyManually)
                    {
                        farmsNeededS = $"WARNING: You need tu buy {prof.CurrentStep.ItemoCraft.Name} to proceed";
                    }
                    else if (prof.ItemToFarm != null && prof.AmountOfItemToFarm > 0)
                    {
                        farmsNeededS = $"{prof.AmountOfItemToFarm} {prof.ItemToFarm.Name} required";
                    }

                    // Current step (craft all)
                    if (prof.CurrentStep.Type == Step.StepType.CraftAll)
                    {
                        currentstepS = $"Craft all {prof.CurrentStep.ItemoCraft.Name} x {prof.CurrentStep.EstimatedAmountOfCrafts}";
                    }
                    else if (prof.CurrentStep.Type == Step.StepType.CraftToLevel)
                    {
                        currentstepS = $"Craft {prof.CurrentStep.ItemoCraft.Name} until lvl {prof.CurrentStep.LevelToReach}";
                    }

                    // Minimum level required not met
                    if (!prof.MyCharLevelIsHighEnough())
                    {
                        requiredLevelS = $"You must be at least level {prof.MinimumCharLevel} to progress";
                    }

                    if (prof == Main.primaryProfession)
                    {
                        professionNameStringPrim = profNameS;
                        farmsNeededStringPrim    = farmsNeededS;
                        currentStepStringPrim    = currentstepS;
                        requiredLevelStringPrim  = requiredLevelS;
                    }
                    else if (prof == Main.secondaryProfession)
                    {
                        professionNameStringSecond = profNameS;
                        farmsNeededStringSecond    = farmsNeededS;
                        currentStepStringSecond    = currentstepS;
                        requiredLevelStringSecond  = requiredLevelS;
                    }
                }
                else
                {
                    currentstepS = "No progression is currently possible";
                }
            }
        }
 public EducationService(IEducation education, IProfession profession, IEducationProfession educationProfession, IEducationFormat educationFormat, IEducationFormatAvailable educationFormatAvailable, IEducationCredential educationCredential)
 {
     _education                = education;
     _profession               = profession;
     _educationProfession      = educationProfession;
     _educationFormat          = educationFormat;
     _educationFormatAvailable = educationFormatAvailable;
     _educationCredential      = educationCredential;
 }
Пример #5
0
 public Player(UnitPostion location, Map map, IProfession profession) : base(location, map)
 {
     Name          = "Player";
     Profession    = profession;
     MaximumHealth = 150;
     CurrentHealth = 150;
     this.Effects.AddEffect(profession);
     Representation = new Symbol('@', Color4.LimeGreen);
     //BaseAtack += 5;
 }
 public SkillTemplate(string buildFile, IProfession emptyProfession)
     : this(
         buildFile,
         emptyProfession,
         emptyProfession,
         Enumerable.Empty <ISkill>().ToList(),
         Enumerable.Empty <AttributeValue>(),
         string.Empty)
 {
     isValid = false;
 }
Пример #7
0
        // Surcharge pour la recherche par ID
        public static int GetTotalNeededMat(IProfession profession, int itemToSearchId)
        {
            Item item = ItemDB.GetItemFromId(itemToSearchId);

            if (item == null)
            {
                return(0);
            }
            else
            {
                return(GetTotalNeededMat(profession, item));
            }
        }
Пример #8
0
    // Craft to level
    public Step(IProfession profession, int minlevel, int levelToReach, Item itemoCraft, int estimatedAmountOfCrafts = 0)
    {
        Minlevel                = minlevel;
        LevelToReach            = levelToReach;
        ItemoCraft              = itemoCraft;
        StepProfession          = profession;
        EstimatedAmountOfCrafts = (estimatedAmountOfCrafts + WholesomeProfessionsSettings.CurrentSetting.ServerRate - 1) / WholesomeProfessionsSettings.CurrentSetting.ServerRate;

        if (estimatedAmountOfCrafts == 0)
        {
            Type = StepType.ListPreCraft;
        }
        else
        {
            Type = StepType.CraftToLevel;
        }
    }
    public static bool RecipeIsKnown(string recipeName, IProfession profession)
    {
        SpellManager.CastSpellByNameLUA(profession.Name.ToString());
        bool recipeIsKnown = Lua.LuaDoString <bool> (@"
                                    tradeskillName, currentLevel, maxLevel, skillLineModifier = GetTradeSkillLine();
                                    tradeItemCount = GetNumTradeSkills()
                                    for i = 1, tradeItemCount do
                                            tradeItemName, tradeItemType, _, _ = GetTradeSkillInfo(i)
                                            if tradeItemName == """ + recipeName + @""" then
                                                return true;
                                            end
                                    end");

        Thread.Sleep(300);
        SpellManager.CastSpellByNameLUA(profession.Name.ToString());
        profession.HasCheckedIfWeKnowRecipeFlag = true;
        return(recipeIsKnown);
    }
        public SkillTemplate(string buildFile,
                             IProfession primaryProfession,
                             IProfession secondaryProfession,
                             IList <ISkill> skills,
                             IEnumerable <AttributeValue> attributes,
                             string templateCode)
        {
            if (string.IsNullOrEmpty(buildFile))
            {
                throw new ArgumentNullException("buildFile");
            }

            if (primaryProfession == null)
            {
                throw new ArgumentNullException("primaryProfession");
            }

            if (secondaryProfession == null)
            {
                throw new ArgumentNullException("secondaryProfession");
            }

            if (skills == null)
            {
                throw new ArgumentNullException("skills");
            }

            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            this.buildFile           = buildFile;
            this.primaryProfession   = primaryProfession;
            this.secondaryProfession = secondaryProfession;
            this.skills       = skills;
            this.attributes   = attributes;
            this.templateCode = templateCode;
            isValid           = true;
        }
Пример #11
0
        // Search if a base item should be farmed (ex : Linen Cloth)
        public static void CalculateFarmAmountFor(IProfession profession, Item itemToCraft)
        {
            foreach (Item.Mat mat in itemToCraft.Materials)
            {
                if (mat.Item.CanBeFarmed)
                {
                    int amountOfItemsToFarm = GetTotalNeededMat(profession, mat.Item);
                    if (amountOfItemsToFarm > 0)
                    {
                        profession.ItemToFarm         = mat.Item;
                        profession.AmountOfItemToFarm = amountOfItemsToFarm;
                        Logger.LogDebug($"Found item that needs to be farmed for {itemToCraft.Name} : {profession.AmountOfItemToFarm} {mat.Item.Name}");
                        return;
                    }
                }
                //Recursion
                CalculateFarmAmountFor(profession, mat.Item);
            }
            profession.ItemToFarm         = null;
            profession.AmountOfItemToFarm = 0;

            return;
        }
Пример #12
0
 public bool Equals(IProfession other)
 {
     return(other.Name == Name);
 }
Пример #13
0
 // Craft all
 public Step(IProfession profession, Item itemoCraft, int estimatedAmountOfCrafts)
 {
     ItemoCraft = itemoCraft;
     EstimatedAmountOfCrafts = estimatedAmountOfCrafts;
     Type = StepType.CraftAll;
 }
Пример #14
0
 private void SetProfessions()
 {
     primaryProfession         = new Tailoring();
     amountProfessionsSelected = 1;
 }
Пример #15
0
        public static Character GenerateRandomCharacterWithSeed(int pointTotal, int randomSeed)
        {
            Random random = new Random(randomSeed);

            Character   character  = new Character();
            IProfession profession = professions.PickRandom(random);

            character.Profession = profession;
            int remainingPoints = pointTotal;

            // randomize the primary/secondary attributes
            List <KeyValuePair <AttributeType, float> > attrWeights =
                new List <KeyValuePair <AttributeType, float> >(profession.PrimaryAttributeWeights.ToList());

            attrWeights.AddRange(profession.SecondaryAttributeWeights.ToList());

            var attrWeightsShuffled = from a in attrWeights
                                      orderby random.Next()
                                      select a;

            foreach ((AttributeType type, float weight) in attrWeightsShuffled)
            {
                CharacterAttribute attr = type.GetCharacterAttribute(character);

                // update secondary attributes since they are based on primaries
                if (attr is SecondaryAttribute)
                {
                    (attr as SecondaryAttribute).Recalculate(character);
                }

                // do a little randomization for flavor so we occasionally get something
                // different from the template
                Normal normalDist    = new Normal(weight, 0.03, random);
                int    pointsToSpend = (int)Math.Floor(normalDist.Sample() * pointTotal);

                attr.SpendPoints(pointsToSpend, out int extra);
                remainingPoints -= (pointsToSpend - extra);
            }

            // buy mandatory traits
            foreach (Trait t in profession.MandatoryTraits)
            {
                Trait toAdd = t; // copies since Traits are value-typed
                toAdd.Level     += 1;
                remainingPoints -= toAdd.PointValue;
                character.Traits.Add(toAdd);
            }

            // randomize the advantages
            List <KeyValuePair <Trait, float> > traitWeights =
                new List <KeyValuePair <Trait, float> >(profession.AdvantageWeights.ToList());

            traitWeights.AddRange(profession.DisadvantageWeights.ToList());

            var traitWeightsShuffled = from t in traitWeights
                                       orderby random.Next()
                                       select t;

            foreach ((Trait t, float weight) in traitWeightsShuffled)
            {
                Normal normalDist    = new Normal(weight, 0.015, random);
                int    pointsToSpend = (int)Math.Floor(normalDist.Sample() * pointTotal);
                if (pointsToSpend >= t.PointValue)
                {
                    Trait toAdd = t;//copy the trait before we modify it
                    // buy one level
                    toAdd.Level     += 1;
                    remainingPoints -= t.PointValue;
                    pointsToSpend   -= t.PointValue;
                    // if it's a leveled trait, buy multiple levels
                    if (t.Leveled)
                    {
                        while (pointsToSpend >= t.PointValue)
                        {
                            toAdd.Level     += 1;
                            remainingPoints -= t.PointValue;
                            pointsToSpend   -= t.PointValue;
                        }
                    }
                    toAdd.PointValue = t.PointValue * toAdd.Level;
                    character.Traits.Add(toAdd);
                }
            }

            // randomize the skills
            List <KeyValuePair <FantasyGameSkill, float> > skillWeights = new List <KeyValuePair <FantasyGameSkill, float> >(profession.SkillWeights.ToList());
            var skillsShuffled = from skill in skillWeights
                                 orderby random.Next()
                                 select skill;

            foreach ((FantasyGameSkill skill, float weight) in skillsShuffled)
            {
                Normal normalDist    = new Normal(weight, 0.004, random);
                int    pointsToSpend = (int)Math.Floor(normalDist.Sample() * pointTotal);
                // skip negative or 0 point value skills
                if (pointsToSpend < 1)
                {
                    continue;
                }

                FantasyGameSkill mySkill = new FantasyGameSkill(skill.BaseAttribute, skill.Difficulty)
                {
                    Name        = skill.Name,
                    Description = skill.Description,
                };
                // don't attempt to spend more points than we have left
                if (pointsToSpend > remainingPoints)
                {
                    pointsToSpend = remainingPoints;
                }

                mySkill.SpendPoints(pointsToSpend, out int extra);
                remainingPoints -= (pointsToSpend - extra);

                character.Skills.Add(mySkill);

                if (remainingPoints == 0)
                {
                    // stop here if we've spent exactly as many as we can
                    break;
                }
            }

            // what to do with leftover points?
            if (remainingPoints > 0)
            {
                // improve low skills
                var lowSkills = from s in character.Skills
                                where s.PointsSpent < (skillWeights.Find(m => m.Key.Name == s.Name).Value *pointTotal * 1.02f)
                                orderby(random.Next())  // shuffle list
                                select s;
                foreach (FantasyGameSkill skill in lowSkills)
                {
                    if (remainingPoints >= 4)
                    {
                        skill.SpendPoints(4, out int uselessPoints);
                        remainingPoints -= (4 - uselessPoints);
                    }
                    else
                    {
                        break;
                    }
                }

                var professionAdv = from s in traitWeights
                                    where s.Key.PointValue > 0 && s.Key.PointValue <= remainingPoints
                                    where character.Traits.Find(m => m.Name == s.Key.Name).Name == "" //find missing trait
                                    orderby(random.Next())
                                    select s.Key;
                foreach (Trait t in professionAdv)
                {
                    if (remainingPoints >= t.PointValue)
                    {
                        Trait toAdd = t; // copy the trait before we modify it
                                         // buy one level
                        toAdd.Level     += 1;
                        remainingPoints -= t.PointValue;
                        // if it's a leveled trait, buy multiple levels
                        if (t.Leveled)
                        {
                            // buy up to 3 levels
                            int i = 0;
                            while (remainingPoints >= t.PointValue && i++ < 3)
                            {
                                toAdd.Level     += 1;
                                remainingPoints -= t.PointValue;
                            }
                        }
                        toAdd.PointValue = t.PointValue * toAdd.Level;
                        character.Traits.Add(toAdd);
                    }
                }
            }


            var    genderNormal = new Normal(random);
            var    sample       = genderNormal.Sample();
            Normal heightNormal;

            if (sample > 0.01)
            {
                character.Gender = "Male";
                heightNormal     = new Normal(70, 3, random);
            }
            else if (sample < -0.011)
            {
                character.Gender = "Female";
                heightNormal     = new Normal(64, 3, random);
            }
            else
            {
                character.Gender = "Nonbinary";
                heightNormal     = new Normal(67.5, 3, random);
            }

            character.Height          = (int)Math.Round(heightNormal.Sample());
            character.RemainingPoints = remainingPoints;
            return(character);
        }