コード例 #1
0
        public static void UpdateEndurance(PlayerSetup.Player player, HubContext context)
        {
            try
            {
                if (player == null)
                {
                    return;
                }

                if (player.MovePoints <= player.MaxMovePoints)
                {
                    var die     = new Helpers();
                    var maxGain = player.Dexterity / 4;

                    if (player.Status == Player.PlayerStatus.Fighting)
                    {
                        maxGain = maxGain / 4;
                    }

                    if (player.Status == Player.PlayerStatus.Sleeping)
                    {
                        maxGain = maxGain * 2;
                    }


                    if (player.Status == Player.PlayerStatus.Resting)
                    {
                        maxGain = (maxGain * 2) / 2;
                    }

                    player.MovePoints += die.dice(1, 1, maxGain);

                    if (player.MovePoints > player.MaxMovePoints)
                    {
                        player.MovePoints = player.MaxMovePoints;
                    }


                    if (player.Type == Player.PlayerTypes.Player)
                    {
                        if (player.HubGuid == null)
                        {
                            return;
                        }

                        context.UpdateStat(player.HubGuid, player.MovePoints, player.MaxMovePoints, "endurance");
                    }

                    Score.ReturnScoreUI(player);
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "Update endurance"
                };

                Save.LogError(log);
            }
        }
コード例 #2
0
        public static void UpdateHp(PlayerSetup.Player player, HubContext context)
        {
            try
            {
                if (player == null)
                {
                    return;
                }

                if (player.HitPoints <= player.MaxHitPoints)
                {
                    var divideBy = 4;
                    var die      = new Helpers();

                    if (Skill.CheckPlayerHasSkill(player, "Fast Healing"))
                    {
                        var chanceOfSuccess = Helpers.Rand(1, 100);

                        var fastHealingSkill = player.Skills.FirstOrDefault(x => x.Name.Equals("Fast Healing"));
                        if (fastHealingSkill != null && fastHealingSkill.Proficiency >= chanceOfSuccess)
                        {
                            divideBy = 2;
                        }
                    }

                    var maxGain = player.Constitution / divideBy;


                    if (player.Status == Player.PlayerStatus.Fighting)
                    {
                        maxGain = maxGain / 4;
                    }

                    if (player.Status == Player.PlayerStatus.Sleeping)
                    {
                        maxGain = maxGain * 2;
                    }


                    if (player.Status == Player.PlayerStatus.Resting)
                    {
                        maxGain = (maxGain * 2) / 2;
                    }


                    player.HitPoints += die.dice(1, 1, maxGain);

                    if (player.HitPoints > player.MaxHitPoints)
                    {
                        player.HitPoints = player.MaxHitPoints;
                    }

                    if (player.Type == Player.PlayerTypes.Player)
                    {
                        if (player.HubGuid == null)
                        {
                            return;
                        }

                        context.UpdateStat(player.HubGuid, player.HitPoints, player.MaxHitPoints, "hp");
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "updateHP"
                };

                Save.LogError(log);
            }
        }