コード例 #1
0
        public async Task <JsonResult> Save(string data)
        {
            var skillMatrixViewModel = JsonConvert.DeserializeObject <SkillMatrixViewModel>(data);

            var skillMatrix = new SkillMatrix();

            skillMatrix.OperationId         = skillMatrixViewModel.operationId;
            skillMatrix.OperatorId          = skillMatrixViewModel.operatorId;
            skillMatrix.StandardRft         = skillMatrixViewModel.standardRft;
            skillMatrix.StandardSotInSecond = skillMatrixViewModel.standardSot;
            skillMatrix.RftScore            = skillMatrixViewModel.scoreRft;
            skillMatrix.SotScore            = skillMatrixViewModel.scoreSot;
            skillMatrix.TargetMonth         = skillMatrixViewModel.targetMonth;
            skillMatrix.TargetGrade         = skillMatrixViewModel.targetGrade;
            skillMatrix.UpdatedOn           = DateTime.Now;
            if (skillMatrixViewModel.rowId != -1)
            {
                skillMatrix.Id = skillMatrixViewModel.rowId;
                _context.SkillMatrixs.Update(skillMatrix);
                await _context.SaveChangesAsync();

                return(new JsonResult(skillMatrix.Id));
            }
            else
            {
                _context.SkillMatrixs.Add(skillMatrix);
                await _context.SaveChangesAsync();

                return(new JsonResult(skillMatrix.Id));
            }
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,OperationId,OperatorId,StandardSotInSecond,StandardRft,SotScore,RftScore,UpdatedOn")] SkillMatrix skillMatrix)
        {
            if (id != skillMatrix.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(skillMatrix);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SkillMatrixExists(skillMatrix.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OperationId"] = new SelectList(_context.Operations, "Id", "Name", skillMatrix.OperationId);
            ViewData["OperatorId"]  = new SelectList(_context.Operators, "Id", "Name", skillMatrix.OperatorId);
            return(View(skillMatrix));
        }
コード例 #3
0
        /// <summary>
        /// Creates a skill matrix which can be used to perform complex
        /// calculations based upon magical damage.
        /// </summary>
        /// <param name="source">Source who invokes the skill</param>
        /// <param name="target">Target on who the skill is called</param>
        /// <returns>Magical skillmatrix</returns>
        public SkillMatrix GetMagicalSkillMatrix(Actor source, Actor target)
        {
            SkillMatrix matrix = new SkillMatrix();

            if (source != null)
            {
                matrix.matrix[0, 0] = (int)source._status.MinMAttack;
                matrix.matrix[0, 1] = (int)source._status.MinWMAttack;
                matrix.matrix[0, 2] = (int)source._status.BaseMinMAttack;

                matrix.matrix[1, 0] = (int)source._status.MaxMAttack;
                matrix.matrix[1, 1] = source._status.MaxWMAttack;
                matrix.matrix[1, 2] = (int)source._status.BaseMaxRAttack;

                matrix.matrix[2, 0] = (int)source._status.DefenceMagical;
                matrix.matrix[2, 1] = (int)source._status.BlockrateMagical;
                matrix.matrix[2, 2] = (int)source._status.BaseMCritrate;
                matrix.matrix[2, 3] = (int)source._status.BaseMHitrate;
                matrix.matrix[4, 0] = (int)source._status.BaseMEvasionrate;
                matrix.matrix[4, 1] = source._level;
            }
            if (target != null)
            {
                matrix.matrix[3, 0] = (int)target._status.DefenceMagical;
                matrix.matrix[3, 1] = (int)target._status.BlockrateMagical;
                matrix.matrix[3, 2] = (int)target._status.BasePCritrate;
                matrix.matrix[4, 2] = target._level;
                matrix.matrix[4, 3] = (int)target._status.BasePEvasionrate;
                matrix.matrix[3, 3] = (int)target._status.BasePHitrate;
            }

            return(matrix);
        }
コード例 #4
0
        /// <summary>
        /// Creates a skill matrix which can be used to perform complex
        /// calculations based upon ranged damage.
        /// </summary>
        /// <param name="source">Source who invokes the skill</param>
        /// <param name="target">Target on who the skill is called</param>
        /// <returns>Ranged skillmatrix</returns>
        public SkillMatrix GetRangedSkillMatrix(Actor source, Actor target)
        {
            SkillMatrix matrix = new SkillMatrix();

            if (source != null)
            {
                matrix.matrix[0, 0] = (int)source._status.MinRAttack;
                matrix.matrix[0, 1] = (int)source._status.MinWRAttack;
                matrix.matrix[0, 2] = (int)source._status.BaseMinRAttack;

                matrix.matrix[1, 0] = (int)source._status.MaxRAttack;
                matrix.matrix[1, 1] = (int)source._status.MaxWRAttack;
                matrix.matrix[1, 2] = (int)source._status.BaseMaxRAttack;

                matrix.matrix[2, 0] = (int)source._status.DefenceRanged;
                matrix.matrix[2, 1] = (int)source._status.BlockrateRanged;
                matrix.matrix[2, 2] = (int)source._status.BaseRCritrate;
                matrix.matrix[2, 3] = (int)source._status.BaseRHitrate;
                matrix.matrix[4, 0] = (int)source._status.BaseREvasionrate;
                matrix.matrix[4, 1] = source._level;
            }
            if (target != null)
            {
                matrix.matrix[3, 0] = (int)target._status.DefenceRanged;
                matrix.matrix[3, 1] = (int)target._status.BlockrateRanged;
                matrix.matrix[3, 2] = (int)target._status.BaseRCritrate;
                matrix.matrix[4, 2] = target._level;
                matrix.matrix[4, 3] = (int)target._status.BaseREvasionrate;
                matrix.matrix[3, 3] = (int)target._status.BaseRHitrate;
            }

            return(matrix);
        }
コード例 #5
0
        public async Task <JsonResult> SaveAll(string skillMatrices)
        {
            var error = false;
            var count = 0;
            var skillMatrixViewModels = JsonConvert.DeserializeObject <List <SkillMatrixViewModel> >(skillMatrices);

            foreach (var skillMatrixViewModel in skillMatrixViewModels)
            {
                var skillMatrix = new SkillMatrix();
                skillMatrix.OperationId         = skillMatrixViewModel.operationId;
                skillMatrix.OperatorId          = skillMatrixViewModel.operatorId;
                skillMatrix.StandardRft         = skillMatrixViewModel.standardRft;
                skillMatrix.StandardSotInSecond = skillMatrixViewModel.standardSot;
                skillMatrix.RftScore            = skillMatrixViewModel.scoreRft;
                skillMatrix.SotScore            = skillMatrixViewModel.scoreSot;
                skillMatrix.TargetMonth         = skillMatrixViewModel.targetMonth;
                skillMatrix.TargetGrade         = skillMatrixViewModel.targetGrade;
                skillMatrix.UpdatedOn           = DateTime.Now;

                if (skillMatrixViewModel.rowId != -1)
                {
                    skillMatrix.Id = skillMatrixViewModel.rowId;
                    _context.SkillMatrixs.Update(skillMatrix);
                    try
                    {
                        await _context.SaveChangesAsync();

                        count++;
                    }
                    catch
                    {
                        error = true;
                    }
                }
                else
                {
                    _context.SkillMatrixs.Add(skillMatrix);
                    try
                    {
                        await _context.SaveChangesAsync();

                        count++;
                    }
                    catch
                    {
                        error = true;
                    }
                }
            }
            if (error == false)
            {
                return(new JsonResult(count));
            }
            else
            {
                return(new JsonResult(false));
            }
        }
コード例 #6
0
        /// <summary>
        /// Checks if the skill has missed.
        /// </summary>
        /// <param name="matrix">Skill matrix used to peform the calculation</param>
        /// <returns>True if skill missed</returns>
        public bool IsBlocked(SkillMatrix matrix)
        {
            int Block = Saga.Utils.Generator.Random(0, 1000);

            if (Block + (matrix[2, 3] / 2) < 50 + matrix[3, 1])
            {
                Result      = ResultType.Block;
                this.failed = false;
                return(true);
            }

            return(false);
        }
コード例 #7
0
        /// <summary>
        /// Checks if the skill missed.
        /// </summary>
        /// <param name="matrix">Skill matrix used to peform the calculation</param>
        /// <returns>True if skill missed</returns>
        public bool IsMissed(SkillMatrix matrix)
        {
            int Evasion = Saga.Utils.Generator.Random(500, 1200);

            if ((Evasion + (matrix[2, 3]) / 2) < 50 + matrix[4, 3])
            {
                Result      = ResultType.Miss;
                this.failed = false;
                return(true);
            }

            return(false);
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("Id,OperationId,OperatorId,StandardSotInSecond,StandardRft,SotScore,RftScore,UpdatedOn")] SkillMatrix skillMatrix)
        {
            if (ModelState.IsValid)
            {
                _context.Add(skillMatrix);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OperationId"] = new SelectList(_context.Operations, "Id", "Name", skillMatrix.OperationId);
            ViewData["OperatorId"]  = new SelectList(_context.Operators, "Id", "Name", skillMatrix.OperatorId);
            return(View(skillMatrix));
        }
コード例 #9
0
        /// <summary>
        /// Checks if the skill was a critical hit.
        /// </summary>
        /// <param name="matrix">Skill matrix used to peform the calculation</param>
        /// <returns>True if is critical</returns>
        public bool IsCritical(SkillMatrix matrix)
        {
            int Block = Saga.Utils.Generator.Random(0, 1000);

            if (Block < 80 + matrix[2, 2])
            {
                this.Result = ResultType.Critical;
                this.Damage = (uint)((double)this.Damage * 1.3);
                this.failed = false;
                return(true);
            }

            this.Result = ResultType.Normal;
            return(false);
        }
コード例 #10
0
        /// <summary>
        /// Calculates skill damanged based upon the skill matrix
        /// </summary>
        /// <param name="matrix">Skill matrix used to peform the calculation</param>
        /// <returns>True if is critical</returns>
        public uint GetDamage(SkillMatrix matrix)
        {
            uint Damage = 0;
            int  min    = matrix[0, 0] + matrix[0, 1] + matrix[0, 2] + matrix[0, 3];
            int  max    = matrix[1, 0] + matrix[1, 1] + matrix[1, 2] + matrix[1, 3];
            int  mean   = max;

            for (int i = 0; i < 4; i++)
            {
                double deviations = Math.Abs((double)(Saga.Utils.Generator.Random(min, max) - mean));
                Damage += (uint)Math.Pow(deviations, 2);
            }

            Damage /= 4;
            return((uint)(min + Math.Sqrt((double)Damage)));
        }
コード例 #11
0
 /// <summary>
 /// Calculates new damage with defense reducation substracted from it.
 /// </summary>
 /// <param name="matrix">Skill matrix used to peform the calculation</param>
 /// <param name="damage">Damage</param>
 /// <returns>Damange with reduction</returns>
 public uint GetDefenseReduction(SkillMatrix matrix, uint damage)
 {
     return (uint)(damage - (((double)matrix[3, 0] / (double)1000) * damage));
 }
コード例 #12
0
        public async Task <IActionResult> LoadTable([FromBody] DTParameters dtParameters)
        {
            var searchBy                = dtParameters.Search?.Value;
            var orderCriteria           = string.Empty;
            var orderAscendingDirection = true;

            if (dtParameters.Order != null)
            {
                try
                {
                    orderCriteria           = dtParameters.Columns[dtParameters.Order[0].Column].Data;
                    orderAscendingDirection = dtParameters.Order[0].Dir.ToString().ToLower() == "asc";
                }
                catch (Exception)
                {
                    orderCriteria           = "Id";
                    orderAscendingDirection = true;
                }
            }
            else
            {
                orderCriteria           = "Id";
                orderAscendingDirection = true;
            }

            //here
            var loggedInUser = await _userManager.FindByNameAsync(HttpContext.User.Identity.Name);

            var result = await _context.Operators.Include(o => o.Line).Include(o => o.Section).Where(m => m.Section.FactoryId == loggedInUser.FactoryId).ToListAsync();

            //here
            List <SkillMatrix> skillMatrices = new List <SkillMatrix>();

            //here
            foreach (var item in result)
            {
                SkillMatrix tempSkillMatrix = new SkillMatrix
                {
                    Id             = item.Id,
                    LineLineNumber = item.Line.LineNumber,
                    SectionName    = item.Section.Name,
                    OperatorName   = item.Name,
                    IdCardNumber   = item.IdCardNumber,
                    JoiningDate    = item.JoiningDate,
                    Address        = item.Address,
                    PhoneNumber    = item.PhoneNumber
                };
                skillMatrices.Add(tempSkillMatrix);
            }

            //here
            if (!string.IsNullOrEmpty(searchBy))
            {
                skillMatrices = skillMatrices.Where(r => r.LineLineNumber != null && r.LineLineNumber.ToUpper().Contains(searchBy.ToUpper()) ||
                                                    r.SectionName != null && r.SectionName.ToUpper().Contains(searchBy.ToUpper()) ||
                                                    r.OperatorName != null && r.OperatorName.ToUpper().Contains(searchBy.ToUpper()) ||
                                                    r.IdCardNumber != null && r.IdCardNumber.ToUpper().Contains(searchBy.ToUpper()) ||
                                                    r.JoiningDate != null && r.JoiningDate.ToString("dd-MM-yyyy").Contains(searchBy.ToString()) ||
                                                    r.Address != null && r.Address.ToUpper().Contains(searchBy.ToUpper()) ||
                                                    r.PhoneNumber != null && r.PhoneNumber.ToUpper().Contains(searchBy.ToUpper()))
                                .ToList();
            }

            //here
            skillMatrices = orderAscendingDirection ? skillMatrices.AsQueryable().OrderByDynamic(orderCriteria,
                                                                                                 LinqExtensions.Order.Asc).ToList() : skillMatrices.AsQueryable().OrderByDynamic(orderCriteria,
                                                                                                                                                                                 LinqExtensions.Order.Desc).ToList();

            var filteredResultsCount = result.Count();
            //here
            var totalResultsCount = await _context.Operators.Include(o => o.Line).Include(o => o.Section).Where(m => m.Section.FactoryId == loggedInUser.FactoryId).CountAsync();

            if (dtParameters.Length == -1)
            {
                return(Json(new
                {
                    draw = dtParameters.Draw,
                    recordsTotal = totalResultsCount,
                    recordsFiltered = filteredResultsCount,
                    //here
                    data = skillMatrices
                           .Skip(dtParameters.Start)
                           .ToList()
                }));
            }
            else
            {
                return(Json(new
                {
                    draw = dtParameters.Draw,
                    recordsTotal = totalResultsCount,
                    recordsFiltered = filteredResultsCount,
                    //here
                    data = skillMatrices
                           .Skip(dtParameters.Start)
                           .Take(dtParameters.Length)
                           .ToList()
                }));
            }
        }
コード例 #13
0
        /// <summary>
        /// Checks if the skill missed.
        /// </summary>
        /// <param name="matrix">Skill matrix used to peform the calculation</param>
        /// <returns>True if skill missed</returns>
        public bool IsMissed(SkillMatrix matrix)
        {
            int Evasion = Saga.Utils.Generator.Random(500, 1200);
            if ((Evasion + (matrix[2, 3]) / 2) < 50 + matrix[4, 3])
            {
                Result = ResultType.Miss;
                this.failed = false;
                return true;
            }

            return false;
        }
コード例 #14
0
 /// <summary>
 /// Calculates new damage with defense reducation substracted from it.
 /// </summary>
 /// <param name="matrix">Skill matrix used to peform the calculation</param>
 /// <param name="damage">Damage</param>
 /// <returns>Damange with reduction</returns>
 public uint GetDefenseReduction(SkillMatrix matrix, uint damage)
 {
     return((uint)(damage - (((double)matrix[3, 0] / (double)1000) * damage)));
 }
コード例 #15
0
        /// <summary>
        /// Checks if the skill has missed.
        /// </summary>
        /// <param name="matrix">Skill matrix used to peform the calculation</param>
        /// <returns>True if skill missed</returns>
        public bool IsBlocked(SkillMatrix matrix)
        {
            int Block = Saga.Utils.Generator.Random(0, 1000);
            if (Block + (matrix[2, 3] / 2) < 50 + matrix[3, 1])
            {
                Result = ResultType.Block;
                this.failed = false;
                return true;
            }

            return false;
        }
コード例 #16
0
        /// <summary>
        /// Checks if the skill was a critical hit.
        /// </summary>
        /// <param name="matrix">Skill matrix used to peform the calculation</param>
        /// <returns>True if is critical</returns>
        public bool IsCritical(SkillMatrix matrix)
        {
            int Block = Saga.Utils.Generator.Random(0, 1000);
            if (Block < 80 + matrix[2, 2])
            {
                this.Result = ResultType.Critical;
                this.Damage = (uint)((double)this.Damage * 1.3);
                this.failed = false;
                return true;
            }

            this.Result = ResultType.Normal;
            return false;
        }
コード例 #17
0
        /// <summary>
        /// Creates a skill matrix which can be used to perform complex
        /// calculations based upon physical damage.
        /// </summary>
        /// <param name="source">Source who invokes the skill</param>
        /// <param name="target">Target on who the skill is called</param>
        /// <returns>Physical skillmatrix</returns>
        public SkillMatrix GetPhysicalSkillMatrix(Actor source, Actor target)
        {
            SkillMatrix matrix = new SkillMatrix();
            if (source != null)
            {
                matrix.matrix[0, 0] = (int)source._status.MinPAttack;
                matrix.matrix[0, 1] = (int)source._status.MinWPAttack;
                matrix.matrix[0, 2] = (int)source._status.BaseMinPAttack;

                matrix.matrix[1, 0] = (int)source._status.MaxPAttack;
                matrix.matrix[1, 1] = (int)source._status.MaxWPAttack;
                matrix.matrix[1, 2] = (int)source._status.BaseMaxRAttack;

                matrix.matrix[2, 0] = (int)source._status.DefencePhysical;
                matrix.matrix[2, 1] = (int)source._status.BlockratePhysical;
                matrix.matrix[2, 2] = (int)source._status.BasePCritrate;
                matrix.matrix[2, 3] = (int)source._status.BasePHitrate;
                matrix.matrix[4, 0] = (int)source._status.BasePEvasionrate;
                matrix.matrix[4, 1] = (int)source._level;
            }
            if (target != null)
            {
                matrix.matrix[3, 0] = (int)target._status.DefencePhysical;
                matrix.matrix[3, 1] = (int)target._status.BlockratePhysical;
                matrix.matrix[3, 2] = (int)target._status.BasePCritrate;
                matrix.matrix[4, 2] = (int)target._level;
                matrix.matrix[4, 3] = (int)target._status.BasePEvasionrate;
                matrix.matrix[3, 3] = (int)target._status.BasePHitrate;
            }

            return matrix;
        }
コード例 #18
0
        /// <summary>
        /// Creates a skill matrix which can be used to perform complex
        /// calculations based upon ranged damage.
        /// </summary>
        /// <param name="source">Source who invokes the skill</param>
        /// <param name="target">Target on who the skill is called</param>
        /// <returns>Ranged skillmatrix</returns>
        public SkillMatrix GetRangedSkillMatrix(Actor source, Actor target)
        {
            SkillMatrix matrix = new SkillMatrix();
            if (source != null)
            {
                matrix.matrix[0, 0] = (int)source._status.MinRAttack;
                matrix.matrix[0, 1] = (int)source._status.MinWRAttack;
                matrix.matrix[0, 2] = (int)source._status.BaseMinRAttack;

                matrix.matrix[1, 0] = (int)source._status.MaxRAttack;
                matrix.matrix[1, 1] = (int)source._status.MaxWRAttack;
                matrix.matrix[1, 2] = (int)source._status.BaseMaxRAttack;

                matrix.matrix[2, 0] = (int)source._status.DefenceRanged;
                matrix.matrix[2, 1] = (int)source._status.BlockrateRanged;
                matrix.matrix[2, 2] = (int)source._status.BaseRCritrate;
                matrix.matrix[2, 3] = (int)source._status.BaseRHitrate;
                matrix.matrix[4, 0] = (int)source._status.BaseREvasionrate;
                matrix.matrix[4, 1] = source._level;
            }
            if (target != null)
            {
                matrix.matrix[3, 0] = (int)target._status.DefenceRanged;
                matrix.matrix[3, 1] = (int)target._status.BlockrateRanged;
                matrix.matrix[3, 2] = (int)target._status.BaseRCritrate;
                matrix.matrix[4, 2] = target._level;
                matrix.matrix[4, 3] = (int)target._status.BaseREvasionrate;
                matrix.matrix[3, 3] = (int)target._status.BaseRHitrate;
            }

            return matrix;
        }
コード例 #19
0
 /// <summary>
 /// Gets the capped level difference
 /// </summary>
 /// <param name="matrix">Skill matrix used to peform the calculation</param>
 /// <returns>Level difference</returns>
 public int GetLevelDifference(SkillMatrix matrix)
 {
     return Math.Abs(matrix[4, 2] - matrix[4, 1]);
 }
コード例 #20
0
 /// <summary>
 /// Gets the capped level difference
 /// </summary>
 /// <param name="matrix">Skill matrix used to peform the calculation</param>
 /// <returns>Level difference</returns>
 public int GetCappedLevelDifference(SkillMatrix matrix)
 {
     return(Math.Min(5, Math.Max(0, matrix[4, 2] - matrix[4, 1])));
 }
コード例 #21
0
        /// <summary>
        /// Calculates skill damanged based upon the skill matrix
        /// </summary>
        /// <param name="matrix">Skill matrix used to peform the calculation</param>
        /// <returns>True if is critical</returns>
        public uint GetDamage(SkillMatrix matrix)
        {
            uint Damage = 0;
            int min = matrix[0, 0] + matrix[0, 1] + matrix[0, 2] + matrix[0, 3];
            int max = matrix[1, 0] + matrix[1, 1] + matrix[1, 2] + matrix[1, 3];
            int mean = max;

            for (int i = 0; i < 4; i++)
            {
                double deviations = Math.Abs((double)(Saga.Utils.Generator.Random(min, max) - mean));
                Damage += (uint)Math.Pow(deviations, 2);
            }

            Damage /= 4;
            return (uint)(min + Math.Sqrt((double)Damage));
        }
コード例 #22
0
 /// <summary>
 /// Gets the capped level difference
 /// </summary>
 /// <param name="matrix">Skill matrix used to peform the calculation</param>
 /// <returns>Level difference</returns>
 public int GetCappedLevelDifference(SkillMatrix matrix)
 {
     return Math.Min(5, Math.Max(0, matrix[4, 2] - matrix[4, 1]));
 }
コード例 #23
0
 /// <summary>
 /// Gets the capped level difference
 /// </summary>
 /// <param name="matrix">Skill matrix used to peform the calculation</param>
 /// <returns>Level difference</returns>
 public int GetLevelDifference(SkillMatrix matrix)
 {
     return(Math.Abs(matrix[4, 2] - matrix[4, 1]));
 }