예제 #1
0
        public ActionResult EditCombos(string id, AddEditCombosViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IFightingArtCombination obj = authedUser.GameAccount.Config.Combos.FirstOrDefault(combo => combo.Name.Equals(id));
            string message;

            if (obj == null)
            {
                message = "That does not exist";
                return(RedirectToAction("Combos", new { Message = message }));
            }

            obj.Name             = vModel.DataObject.Name;
            obj.Arts             = vModel.DataObject.Arts;
            obj.FightingStances  = vModel.DataObject.FightingStances;
            obj.IsSystem         = vModel.DataObject.IsSystem;
            obj.SituationalUsage = vModel.DataObject.SituationalUsage;

            if (authedUser.GameAccount.Config.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - EditCombos[" + obj.Name.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Edit Successful.";
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return(RedirectToAction("Combos", new { Message = message }));
        }
예제 #2
0
        public ActionResult EditCombos(string id)
        {
            AddEditCombosViewModel vModel = new AddEditCombosViewModel
            {
                AuthedUser = UserManager.FindById(User.Identity.GetUserId())
            };

            IFightingArtCombination obj = vModel.AuthedUser.GameAccount.Config.Combos.FirstOrDefault(combo => combo.Name.Equals(id));

            if (obj == null)
            {
                string message = "That does not exist";
                return(RedirectToAction("Combos", new { Message = message }));
            }

            vModel.DataObject = obj;

            return(View("EditCombos", vModel));
        }
예제 #3
0
        public ActionResult RemoveCombo(string ID, string authorize)
        {
            string message;

            if (string.IsNullOrWhiteSpace(authorize) || !ID.ToString().Equals(authorize))
            {
                message = "You must check the proper authorize radio button first.";
            }
            else
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                IFightingArtCombination obj = authedUser.GameAccount.Config.Combos.FirstOrDefault(combo => combo.Name.Equals(ID));

                if (obj == null)
                {
                    message = "That does not exist";
                }
                else
                {
                    authedUser.GameAccount.Config.Combos = authedUser.GameAccount.Config.Combos.Where(combo => !combo.Name.Equals(ID));

                    if (authedUser.GameAccount.Config.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                    {
                        LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveUIModule[" + ID.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                        message = "Delete Successful.";
                    }
                    else
                    {
                        message = "Error; Removal failed.";
                    }
                }
            }

            return(RedirectToAction("UIModules", new { Message = message }));
        }
예제 #4
0
        /// <summary>
        /// Execute an attack round
        /// </summary>
        /// <param name="actor">the person attacking</param>
        /// <param name="target">the person defending</param>
        public static bool ExecuteRound(IMobile actor, IMobile target)
        {
            //Stagger clearance comes before ending a fight
            if (actor.Stagger > 0)
            {
                actor.Stagger -= 1;
                //Send a ui update
                actor.WriteTo(null);
                return(true);
            }

            if (!actor.IsFighting())
            {
                return(false);
            }

            if (actor == target)
            {
                target = null;
            }

            IFightingArt attack = actor.LastAttack;

            var rand = new Random();

            //If we lack an attack or we're on the tail end of the attack just find a new one and start it
            if (attack == null || !actor.Executing)
            {
                IFightingArtCombination myCombo = actor.LastCombo;
                if (myCombo == null)
                {
                    var   weights  = GetUsageWeights(actor, target);
                    ulong distance = 0;

                    if (target != null)
                    {
                        distance = 1;
                    }

                    var validCombos = actor.Combos.Where(combo => combo.IsValid(actor, target, distance));

                    if (validCombos.Count() == 0)
                    {
                        myCombo = actor.Combos.OrderByDescending(combo => weights[combo.SituationalUsage] * rand.NextDouble()).FirstOrDefault();
                    }
                    else
                    {
                        myCombo = validCombos.OrderByDescending(combo => weights[combo.SituationalUsage] * rand.NextDouble()).FirstOrDefault();
                    }
                }

                //uhh k we need to use a fake combo logic to get a random attack
                if (myCombo == null)
                {
                    var attacks = TemplateCache.GetAll <IFightingArt>(true);

                    attack = attacks.Where(atk => atk.IsValid(actor, target, (ulong)Math.Abs(actor.Balance))).OrderBy(atk => Guid.NewGuid()).FirstOrDefault();
                }
                else
                {
                    attack = myCombo.GetNext(actor.LastAttack);
                }

                if (attack == null)
                {
                    //we have no valid attacks, so we're tired
                    actor.Stagger += 10;
                    actor.Sleep(1); //recover stamina
                    actor.WriteTo(null);
                    return(true);
                }

                actor.Stagger    = attack.Setup;
                actor.Sturdy     = attack.Armor;
                actor.LastCombo  = myCombo;
                actor.LastAttack = attack;
                actor.Executing  = true;

                if (actor.Stagger > 0)
                {
                    actor.Stagger -= 1;

                    //Send a ui update
                    actor.WriteTo(null);
                    return(true);
                }
                //else we just run right into the combo if there's no setup
            }

            //execute the attack
            actor.Executing = false;

            //basics
            actor.Stagger    = attack.Recovery;
            actor.LastAttack = attack;
            actor.LastCombo  = null;
            actor.Balance    = attack.DistanceChange;

            //numbers damage
            if (attack.Health.Actor > 0)
            {
                actor.Harm(attack.Health.Actor);
            }

            if (attack.Stamina.Actor > 0)
            {
                actor.Exhaust(attack.Stamina.Actor);
            }

            Tuple <string, string, string> messaging = null;

            if (target != null)
            {
                target.Balance = -1 * attack.DistanceChange;

                var targetReadiness = ReadinessState.Offensive; //attacking is default
                var targetDirection = AnatomyAim.Mid;           //mid is default

                if (target.LastAttack != null)
                {
                    targetReadiness = target.LastAttack.Readiness;
                    targetDirection = target.LastAttack.Aim;
                }

                //TODO: for now we're just doing flat chances for avoidance states since we have no stats to base anything on
                var    avoided         = false;
                var    blocked         = false;
                double impact          = attack.Impact;
                double damage          = attack.Health.Victim;
                double staminaDrain    = attack.Stamina.Victim;
                var    aimDifferential = Math.Abs(attack.Aim - targetDirection);

                //no blocking if it's not an attack
                if (attack.Readiness != ReadinessState.Offensive || attack.Health.Victim > 0)
                {
                    switch (targetReadiness)
                    {
                    case ReadinessState.Circle:     //circle is dodge essentially
                        avoided = rand.Next(0, 100) <= Math.Max(1, Math.Abs(target.Balance)) / (Math.Max(1, aimDifferential + target.Stagger) * 4) * 100;
                        break;

                    case ReadinessState.Block:
                        blocked = rand.Next(0, 100) <= Math.Max(1, Math.Abs(target.Balance)) / (Math.Max(1, aimDifferential + target.Stagger) * 2) * 100;

                        if (blocked)
                        {
                            impact       *= .25;
                            damage       *= .50;
                            staminaDrain *= .50;
                        }
                        ;
                        break;

                    case ReadinessState.Deflect:
                        blocked = rand.Next(0, 100) <= Math.Max(1, Math.Abs(target.Balance)) / (Math.Max(1, aimDifferential + target.Stagger) * 2) * 100;

                        if (blocked)
                        {
                            impact       *= .50;
                            damage       *= .25;
                            staminaDrain *= .25;
                        }
                        break;

                    case ReadinessState.Redirect:
                        avoided = rand.Next(0, 100) <= Math.Max(1, Math.Abs(target.Balance)) / (Math.Max(1, aimDifferential + target.Stagger) * 20) * 100;
                        break;

                    case ReadinessState.Offensive:
                        //Clash mechanics, only works if the target is mid-execution
                        if (target.LastAttack != null && aimDifferential == 0 && target.Executing)
                        {
                            var impactDifference = target.LastAttack.Impact + target.LastAttack.Armor - attack.Impact;

                            if (impactDifference > 0)
                            {
                                blocked       = true;
                                impact        = 0;
                                damage       /= impactDifference;
                                staminaDrain *= .75;
                            }
                        }
                        break;
                    }
                }

                messaging = GetOutputStrings(attack, target, avoided || blocked, targetReadiness);

                if (!avoided)
                {
                    var victStagger = target.Sturdy - (int)Math.Truncate(impact);

                    //Affect the victim, sturdy/armor absorbs stagger impact and the remainder gets added to victim stagger
                    target.Sturdy   = Math.Max(0, victStagger);
                    target.Stagger += Math.Abs(Math.Min(0, victStagger));

                    if (damage > 0)
                    {
                        target.Harm((int)Math.Truncate(damage));
                    }

                    if (staminaDrain > 0)
                    {
                        target.Exhaust((int)Math.Truncate(staminaDrain));
                    }

                    //affect qualities
                    if (attack.QualityValue != 0 && !string.IsNullOrWhiteSpace(attack.ResultQuality))
                    {
                        target.SetQuality(attack.QualityValue, attack.ResultQuality, attack.AdditiveQuality);
                    }
                }
            }
            else
            {
                messaging = GetOutputStrings(attack, target, false, ReadinessState.Offensive);
            }

            var msg = new Message(new LexicalParagraph(messaging.Item1))
            {
                ToTarget = new LexicalParagraph[] { new LexicalParagraph(messaging.Item2) },
                ToOrigin = new LexicalParagraph[] { new LexicalParagraph(messaging.Item3) }
            };


            msg.ExecuteMessaging(actor, null, target, actor.CurrentLocation.CurrentContainer, null, true);

            return(true);
        }