public static string CreateNewAccount(Bank bank, string id, int startMoney = 0)
 {
     string[] allIds = FinancialDataSupplier.AccountsIDs(bank);
     bank.AllAccounts.Add(new FinancialAccount(DataChecks.EnsureUnique(allIds, id), startMoney));
     OnNewAccountCreated?.Invoke(bank.AllAccounts[bank.AllAccounts.Count - 1].accountID);
     return(bank.AllAccounts[bank.AllAccounts.Count - 1].accountID);
 }
        private void runToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataChecks f = new DataChecks();

            f.MdiParent   = this;
            f.WindowState = FormWindowState.Maximized;
            f.Show();
        }
Exemplo n.º 3
0
        public void AddNewItemType(string typeName)
        {
            if (allItems.Count > 0)
            {
                typeName = DataChecks.EnsureUnique(allItemTypeNames(), typeName);
            }

            ItemType itemType = new ItemType(typeName);
        }
Exemplo n.º 4
0
    public void CreateNewSkillNodeFromInputField()
    {
        if (NameInput.text == null || NameInput.text == "")
        {
            return;
        }
        string inputText = DataChecks.EnsureUnique(gameManager.skillTree.GetAllSkillNames(), NameInput.text);

        Dictionary <string, float> effectors = new Dictionary <string, float>();

        effectors.Add("Test effector 1", .1f);
        effectors.Add("Test effector 2", .2f);

        string description = "No Description";

        Skill skill = new Skill(inputText, description, effectors);

        gameManager.skillTree.AddSkill(skill);
        OnNewSkillCreated?.Invoke(inputText);
    }
Exemplo n.º 5
0
    public static int GetHiarchyLevelOfSkill(List <Skill> skills, string skillName)
    {
        int level      = 0;
        int skillIndex = skills.FindIndex(x => x.Name == skillName);

        Skill skillToCheck = skills[skillIndex];

        if (skillToCheck.RequiredSkills.Any())
        {
            int highestLevel = 1;
            for (int i = 0; i < skillToCheck.RequiredSkills.Length; i++)
            {
                int reqSkill = skillToCheck.RequiredSkills[i];

                int highestLevelOfRequirement = DataChecks.GetMax(GetHiarchyLevelOfSkill(skills, skills[reqSkill].Name) + 1, highestLevel);
                highestLevel = DataChecks.GetMax(highestLevel, highestLevelOfRequirement);
            }
        }
        return(level);
    }
Exemplo n.º 6
0
        public int GetHiarchyLevelOfSkill(int skillIndex)
        {
            int level = 0;


            Skill skillToCheck = tree[skillIndex];

            if (skillToCheck.RequiredSkills != null && skillToCheck.RequiredSkills.Length > 0)
            {
                int highestLevel = 1;
                for (int i = 0; i < skillToCheck.RequiredSkills.Length; i++)
                {
                    int reqSkill = skillToCheck.RequiredSkills[i];

                    int highestLevelOfRequirement = DataChecks.GetMax(GetHiarchyLevelOfSkill(tree[reqSkill].Name) + 1, highestLevel);
                    highestLevel = DataChecks.GetMax(highestLevel, highestLevelOfRequirement);
                }
                level = DataChecks.GetMax(level, highestLevel);
            }
            return(level);
        }
Exemplo n.º 7
0
        public IHttpActionResult CreateBook(PostBook book)
        {
            Author author = DataChecks.CheckAuthor(book);
            Genre  genre  = DataChecks.CheckGenre(book);

            // The null value of DateTime is 0001, 01, 01.
            if (book.DueBackDate == new DateTime(0001, 01, 01))
            {
                book.DueBackDate = new DateTime(1990, 01, 01);
            }

            var newBook = new Book
            {
                Title         = book.BookTitle,
                YearPublished = book.YearPublished,
                Condition     = book.Condition,

                // Get Author name.
                AuthorID = author.ID,

                // Get Genre.
                GenreID = genre.ID,

                ISBN         = book.ISBN,
                IsCheckedOut = book.IsCheckedOut,
                DueBackDate  = book.DueBackDate
            };

            var db = new LibraryContext();

            db.Books.Add(newBook);
            db.SaveChanges();
            // Tack properties on to the newBook and then return.
            newBook.Author = author;
            newBook.Genre  = genre;
            return(Ok(newBook));
        }