Esempio n. 1
0
        public void DyeList()
        {
            Dyes = new Dictionary <int, Dye>();
            {
                try
                {
                    var sheet = MainWindow.Realm.GameData.GetSheet <SaintCoinach.Xiv.Stain>();
                    foreach (var Parse in sheet)
                    {
                        Dye dye = new Dye();
                        dye.Index = Parse.Key;
                        dye.Name  = Parse.Name;
                        if (Parse.Key == 0)
                        {
                            dye.Name = "None";
                        }
                        Dyes.Add(Parse.Key, dye);
                        //     Console.WriteLine($"{Parse.Key} {Parse.Name}");
                    }
                }
                catch (Exception e)
                {
                    Dyes = null;

                    throw;
                }
            }
        }
 public void Execute()
 {
     userService.LogOut();
     Dye.Fail();
     Console.WriteLine("LogOut");
     Console.ResetColor();
 }
Esempio n. 3
0
        public TestVM TestCreate()
        {
            var testVM = testHelper.TestFullData();

            if (validator.Validate(testVM).IsValid)
            {
                var mappedTest = mapper.Map <TestVM, Test>(testVM);
                testService.AddTest(mappedTest);

                Dye.Succsess();
                Console.WriteLine("You have successfully created test");
                Console.ResetColor();

                return(testVM);
            }
            else
            {
                Dye.Fail();
                Console.WriteLine(validator.Validate(testVM));
                Console.ResetColor();
                TestCreate();

                return(null);
            }
        }
Esempio n. 4
0
 public ItemColor(Dye color1, Dye color2, Dye color3, Dye color4)
 {
     _color1 = color1;
                 _color2 = color2;
                 _color3 = color3;
                 _color4 = color4;
 }
Esempio n. 5
0
        public void DyeList()
        {
            Dyes = new Dictionary <int, Dye>();
            {
                try
                {
                    var sheet = MainWindow.Realm.GameData.GetSheet <SaintCoinach.Xiv.Stain>();
                    foreach (var Parse in sheet)
                    {
                        Dye dye = new Dye
                        {
                            Index = Parse.Key,
                            Name  = Parse.Name
                        };
                        if (Parse.Key == 0)
                        {
                            dye.Name = "None";
                        }
                        Dyes.Add(Parse.Key, dye);
                    }
                }
                catch (Exception)
                {
                    Dyes = null;

                    //throw;
                }
            }
        }
        public bool AddCourseToUserProgress(CourseVM courseVM)
        {
            var mappedCourse = mapper.Map <CourseVM, Course>(courseVM);

            if (mappedCourse == null)
            {
                Dye.Fail();
                Console.WriteLine("Unknown course Id");
                Console.ResetColor();
                return(false);
            }
            if (userService.AddCourseToProgress(mappedCourse))
            {
                Dye.Succsess();
                Console.WriteLine("Course passing started!");
                Console.ResetColor();
                return(true);
            }
            else
            {
                Dye.Inform();
                Console.WriteLine("You have passed this course early");
                Console.ResetColor();
                return(false);
            }
        }
Esempio n. 7
0
 public ItemColor(Dye color1, Dye color2, Dye color3, Dye color4)
 {
     _color1 = color1;
     _color2 = color2;
     _color3 = color3;
     _color4 = color4;
 }
Esempio n. 8
0
        public string AddDyeToBunny(string bunnyName, int power)
        {
            var dye   = new Dye(power);
            var bunny = bunnies.FindByName(bunnyName);

            if (bunny == null)
            {
                throw new InvalidOperationException(ExceptionMessages.InexistentBunny);
            }
            return(string.Format(OutputMessages.DyeAdded, power, bunnyName));
        }
Esempio n. 9
0
        public string AddDyeToBunny(string bunnyName, int power)
        {
            Dye dye = new Dye(power);

            if (bunnies.FindByName(bunnyName) == null)
            {
                throw new InvalidOperationException("The bunny you want to add a dye to doesn't exist!");
            }

            bunnies.FindByName(bunnyName).AddDye(dye);

            return($"Successfully added dye with power {dye.Power} to bunny {bunnyName}!");
        }
Esempio n. 10
0
        public string AddDyeToBunny(string bunnyName, int power) //ok?
        {
            IBunny bunny = bunnies.FindByName(bunnyName);

            if (bunny == null)
            {
                throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentBunny));
            }
            Dye dye = new Dye(power);

            bunny.AddDye(dye);
            return($"Successfully added dye with power {power} to bunny {bunnyName}!");
        }
Esempio n. 11
0
        public static Dye GetRecord(string dyeCode)
        {
            TableElement        te       = new TableElement("DyeCode", dyeCode);
            List <TableElement> elements = m_db.GetRecord(te);

            if (elements == null)
            {
                return(null);
            }
            Dye dye = new Dye(elements);

            return(dye);
        }
Esempio n. 12
0
        public string AddDyeToBunny(string bunnyName, int power)
        {
            IBunny currentBunny = bunnies.FindByName(bunnyName);

            if (currentBunny == null)
            {
                throw new InvalidOperationException(ExceptionMessages.InexistentBunny);
            }
            IDye currentDye = new Dye(power);

            currentBunny.AddDye(currentDye);
            return($"{String.Format(OutputMessages.DyeAdded, power, bunnyName)}");
        }
Esempio n. 13
0
        public string AddDyeToBunny(string bunnyName, int power)
        {
            IDye   dye   = new Dye(power);
            IBunny bunny = bunnies.FindByName(bunnyName);

            if (bunny == null)
            {
                throw new InvalidOperationException(Utilities.Messages.ExceptionMessages.InexistentBunny);
            }

            bunny.AddDye(dye);
            return(string.Format(Utilities.Messages.OutputMessages.DyeAdded, power, bunnyName));
        }
Esempio n. 14
0
        public QuestionVM QuestionData(int variant)
        {
            QuestionVM questionVM = new QuestionVM();

            Console.WriteLine("Enter question");
            questionVM.Name    = Console.ReadLine();
            questionVM.Answers = new List <AnswerVM>();

            bool infinity = true;

            while (infinity)
            {
                Console.WriteLine("1 - Add answer\n2 - Finish adding answers");
                switch (Console.ReadLine())
                {
                case "1":
                    Dye.Succsess();
                    Console.WriteLine(questionVM.Name);
                    Console.ResetColor();
                    var answer = answerHelper.AnswerData(variant++);
                    if (questionVM.Answers.Count(x => x.IsTrue == true) == 1 && answer.IsTrue == true)
                    {
                        Dye.Fail();
                        Console.WriteLine(new Exception("True answer alredy exist!"));
                        Console.ResetColor();
                        break;
                    }
                    Dye.Succsess();
                    Console.WriteLine("Answer added");
                    Console.ResetColor();

                    //Вставить маппинг ответов
                    questionVM.Answers.Add(answer);
                    break;

                case "2":
                    if (questionVM.Answers.Any(x => x.IsTrue == true) && questionVM.Answers.Count() >= 2 && questionVM.Answers.Count() <= 6)
                    {
                        return(questionVM);
                    }
                    Dye.Fail();
                    Console.WriteLine(new Exception("Atleast 1 answer must be true. Min. 2 answers. Max. 6 answers"));
                    Console.ResetColor();
                    break;

                default:
                    continue;
                }
            }
            return(null);
        }
Esempio n. 15
0
        public string AddDyeToBunny(string bunnyName, int power)
        {
            IBunny bunny = this.bunnies.FindByName(bunnyName);

            if (bunny == null)
            {
                throw new InvalidOperationException(ExceptionMessages.InexistentBunny);
            }

            IDye dye = new Dye(power);

            bunny.Dyes.Add(dye);
            return($"Successfully added dye with power {dye.Power} to bunny {bunny.Name}!");
        }
Esempio n. 16
0
        public string AddDyeToBunny(string bunnyName, int power)
        {
            var bunny = this.bunnyRepository.FindByName(bunnyName);

            if (bunny is null)
            {
                throw new InvalidOperationException(ExceptionMessages.InexistentBunny);
            }

            var dye = new Dye(power);

            bunny.AddDye(dye);

            return(string.Format(OutputMessages.DyeAdded, power, bunnyName));
        }
Esempio n. 17
0
        public void DyeList()
        {
            Dyes = new Dictionary <int, Dye>();
            {
                try
                {
                    using (TextFieldParser parser = new TextFieldParser(new StringReader(Resources.stain_exh_en)))
                    {
                        parser.TextFieldType = FieldType.Delimited;
                        parser.SetDelimiters(",");
                        int rowCount = 0;
                        parser.ReadFields();
                        while (!parser.EndOfData)
                        {
                            rowCount++;
                            Dye dye = new Dye();
                            //Processing row
                            string[] fields = parser.ReadFields();
                            int      fCount = 0;
                            dye.Index = int.Parse(fields[0]);

                            foreach (string field in fields)
                            {
                                fCount++;

                                if (fCount == 4)
                                {
                                    dye.Name = field;
                                }
                            }

                            //Console.WriteLine($"{rowCount} - {dye.Name}");
                            Dyes.Add(dye.Index, dye);
                        }

                        //Console.WriteLine($"{rowCount} Dyes read");
                    }
                }

                catch (Exception exc)
                {
                    Dyes = null;
#if DEBUG
                    throw exc;
#endif
                }
            }
        }
        public string AddDyeToBunny(string bunnyName, int power)
        {
            var currentBunny = this.bunnies.FindByName(bunnyName);

            if (currentBunny == null)
            {
                throw new InvalidOperationException(ExceptionMessages.InexistentBunny);
            }

            IDye dye = new Dye(power);

            currentBunny.AddDye(dye);

            var result = String.Format(OutputMessages.DyeAdded, power, bunnyName);

            return(result);
        }
Esempio n. 19
0
        public string AddDyeToBunny(string bunnyName, int power)
        {
            string message       = string.Empty;
            var    searchedBunny = bunnyRepository.FirstOrDefault(b => b.Name == bunnyName);

            if (searchedBunny == null)
            {
                throw new InvalidOperationException(ExceptionMessages.InexistentBunny);
            }
            else
            {
                var dye = new Dye(power);
                searchedBunny.AddDye(dye);
                message = string.Format(OutputMessages.DyeAdded, power, bunnyName);
            }
            return(message);
        }
        public void Execute()
        {
            Console.Clear();
            var(login, password) = UserHelper.UserLoginData();

            if (userService.LogIn(login, password))
            {
                Dye.Succsess();
                Console.WriteLine("Authorized");
                Console.ResetColor();
            }
            else
            {
                Dye.Fail();
                Console.WriteLine(new Exception("Something went wrong, try again"));
                Console.ResetColor();
            }
        }
        public void Execute()
        {
            Console.Clear();
            var userVM = UserHelper.UserFullData();

            if (validator.Validate(userVM).IsValid)
            {
                userService.Register(mapper.Map <UserVM, User>(userVM));
                Dye.Succsess();
                Console.WriteLine("You have successfully registered and authorized");
                Console.ResetColor();
            }
            else
            {
                Dye.Fail();
                Console.WriteLine(validator.Validate(userVM));
                Console.ResetColor();
            }
        }
        public QuestionVM QuestionCreate()
        {
            var questionVM = questionHelper.QuestionData(answerLetter);

            if (validator.Validate(questionVM).IsValid)
            {
                Dye.Succsess();
                Console.WriteLine("You have successfully created question");
                Console.ResetColor();
                return(questionVM);
            }
            else
            {
                Dye.Fail();
                Console.WriteLine(validator.Validate(questionVM));
                Console.ResetColor();
                QuestionCreate();
                return(null);
            }
        }
        public VideoMaterialVM VideoCreate()
        {
            var videoVM = materialHelper.VideoFullData();

            if (validations.Validate(videoVM).IsValid&& videoValidator.Validate(videoVM).IsValid)
            {
                var mappedVideo = mapper.Map <VideoMaterialVM, VideoMaterial>(videoVM);
                videoMaterialService.AddVideoMaterial(mappedVideo);
                Dye.Succsess();
                Console.WriteLine("You have add video");
                Console.ResetColor();
                return(videoVM);
            }
            else
            {
                Dye.Fail();
                Console.WriteLine(videoValidator.Validate(videoVM) + " " + " " + validations.Validate(videoVM));
                Console.ResetColor();
                VideoCreate();
                return(null);
            }
        }
        public void UserPassCourse(CourseVM courseVM)
        {
            int rightAnswers = 0;

            //нужен джоин thenInclude answers()
            var test = testController.GetTestById(courseVM.Test.Id);

            Console.WriteLine(string.Join(". ", courseVM.Name, courseVM.Description));

            foreach (var question in test.Questions)
            {
                Dye.Succsess();
                Console.WriteLine(question.Name);
                Console.ResetColor();
                Console.WriteLine("Choose the variant");
                foreach (var answers in question.Answers)
                {
                    Console.WriteLine(answers.Name);
                }
                var userVariatnt = Console.ReadLine().Trim().Split("")[0];
                testController.AnswersCounting(question, userVariatnt, ref rightAnswers);
            }

            var mappedCourse = mapper.Map <CourseVM, Course>(courseVM);

            if (userService.IsCoursePassed(mappedCourse, rightAnswers))
            {
                Dye.Succsess();
                Console.WriteLine($"Test - passed. Right answers {rightAnswers}/{courseVM.Test.Questions.Count()} CONGRATULATIONS!!!");
                Console.ResetColor();
            }
            else
            {
                Dye.Fail();
                Console.WriteLine("Learn materials hard, and try again");
                Console.ResetColor();
            }
        }
Esempio n. 25
0
        public ArticleMaterialVM ArticleCreate()
        {
            var articleVM = materialHelper.ArticleFullData();

            if (validations.Validate(articleVM).IsValid&& acticleValidator.Validate(articleVM).IsValid)
            {
                var mappedArticle = mapper.Map <ArticleMaterialVM, ArticleMaterial>(articleVM);
                articleMaterialService.AddArticleMaterial(mappedArticle);

                Dye.Succsess();
                Console.WriteLine("You have add article");
                Console.ResetColor();
                return(articleVM);
            }
            else
            {
                Dye.Fail();
                Console.WriteLine(acticleValidator.Validate(articleVM) + " " + " " + validations.Validate(articleVM));
                Console.ResetColor();
                ArticleCreate();
                return(null);
            }
        }
        public void CourseCreate()
        {
            var courseVM = courseHelper.CourseFullData();

            if (validator.Validate(courseVM).IsValid&& courseVM.Skills.Count >= 1 && courseVM.Materials.Count >= 1)
            {
                var mappedCourse = mapper.Map <CourseVM, Course>(courseVM);
                courseService.AddCourse(mappedCourse);

                courseVM.Id = mappedCourse.Id;

                Dye.Succsess();
                Console.WriteLine("You have successfully created course");
                Console.ResetColor();
            }
            else
            {
                Dye.Fail();
                Console.WriteLine(validator.Validate(courseVM));
                Console.WriteLine(new Exception("Course is not added, try again."));
                Console.ResetColor();
            }
        }
        public SkillVM SkillCreate()
        {
            var skillVM = SkillHelper.SkillFullData();

            if (validator.Validate(skillVM).IsValid)
            {
                var mappedSkill = mapper.Map <SkillVM, Skill>(skillVM);
                skillService.AddSkill(mappedSkill);

                Dye.Succsess();
                Console.WriteLine("Skill has successfully added");
                Console.ResetColor();
                return(skillVM);
            }
            else
            {
                Dye.Fail();
                Console.WriteLine(validator.Validate(skillVM));
                Console.ResetColor();
                SkillCreate();
                return(null);
            }
        }
        public TestVM TestFullData()
        {
            TestVM testVM = new TestVM();

            Console.WriteLine("Enter test Name");
            testVM.Name      = Console.ReadLine();
            testVM.Questions = new List <QuestionVM>();
            bool infinity = true;

            while (infinity)
            {
                Console.WriteLine("1 - Add question\n2 - Finish adding questions");
                switch (Console.ReadLine())
                {
                case "1":
                    Console.Clear();
                    var question = questionController.QuestionCreate();
                    //Вставить маппинг вопросов
                    testVM.Questions.Add(question);
                    break;

                case "2":
                    if (testVM.Questions.Count() >= 0)
                    {
                        return(testVM);
                    }
                    Dye.Fail();
                    Console.WriteLine("Count of questions must be greater than 3");
                    Console.ResetColor();
                    break;

                default:
                    continue;
                }
            }
            return(null);
        }
        public BookMaterialVM BookCreate()
        {
            var bookVM = materialHelper.BookFullData();

            if (validations.Validate(bookVM).IsValid&& bookValidator.Validate(bookVM).IsValid)
            {
                var mappedBook = mapper.Map <BookMaterialVM, BookMaterial>(bookVM);
                bookMaterialService.AddBookMaterial(mappedBook);

                Dye.Succsess();
                Console.WriteLine("You have add book");
                Console.ResetColor();

                return(bookVM);
            }
            else
            {
                Dye.Fail();
                Console.WriteLine(bookValidator.Validate(bookVM) + " " + " " + validations.Validate(bookVM));
                Console.ResetColor();

                return(null);
            }
        }
Esempio n. 30
0
	public static void Deserialize(byte[] serialized, out Dye dye)
	{
		Item item;
		Deserialize(serialized, out item);
		dye = (Dye)item;
	}
Esempio n. 31
0
 public My(string msg)
 {
     foo = new Dye(msg);
 }
Esempio n. 32
0
	public static byte[] Serialize(Dye dye)
	{
		return Serialize((Item)dye);
	}
Esempio n. 33
0
 public ItemColor(Dye color1)
 {
     _color1 = color1;
 }
Esempio n. 34
0
File: My.cs Progetto: selfexam/waf
	public My(string msg) {
		foo = new Dye(msg);
	}
Esempio n. 35
0
        protected override void UpdateAttribute(string name, dynamic value)
        {
            AttributeList.Add(name);
            switch (name)
            {
            case "position":
                DroppedItem.Transformation.Position = new Position(float.Parse(value.x.ToString()), float.Parse(value.y.ToString()), short.Parse(value.plane.ToString()));
                break;

            case "item":
                if (!Enum.TryParse(value.type.ToString(), out ItemType type))
                {
                    // not fully specified!
                    Debugging.Debug.Error("Received invalid ItemType '{0}'", value.type);
                    AttributeList.RemoveAt(AttributeList.Count - 1);
                    break;
                }
                if (!Enum.TryParse(value.model.ToString(), out ItemModel model))
                {
                    // not fully specified!
                    Debugging.Debug.Error("Received invalid ItemModel '{0}'", value.model);
                    AttributeList.RemoveAt(AttributeList.Count - 1);
                    break;
                }
                string    item_name = value.name.ToString();
                ItemFlags flags     = 0;
                foreach (object flag_string in value.flags)
                {
                    if (Enum.TryParse(flag_string.ToString(), out ItemFlags flag))
                    {
                        flags |= flag;
                    }
                }

                List <ItemStat> itemStats = new List <ItemStat>();
                foreach (object stat_string in value.stats)
                {
                    string[] stat_string_parts = stat_string.ToString().Split(':');
                    bool     success           = true;
                    success &= Enum.TryParse(stat_string_parts[0], out ItemStatIdentifier statId);
                    success &= byte.TryParse(stat_string_parts[1], out var p1);
                    success &= byte.TryParse(stat_string_parts[2], out var p2);
                    if (success)
                    {
                        itemStats.Add(new ItemStat(statId, p1, p2));
                    }
                }

                Dye[] colors = new Dye[4];
                int   i      = 0;
                foreach (object color in value.color)
                {
                    if (Enum.TryParse(color.ToString(), out Dye dye))
                    {
                        colors[i++] = dye;
                    }
                }
                ItemColor itemColor = new ItemColor(colors[0], colors[1], colors[2], colors[3]);

                Item             = new Item(type, (uint)model, item_name, flags, itemColor, itemStats);
                DroppedItem.Item = Item;
                break;
            }
            if (FullySpecified)
            {
                Game.Zone.AddAgent(DroppedItem);
            }
        }