コード例 #1
0
        private static string RestoreTimeLeft(CharacterMotherClass player, bool isHP)
        {
            double restores = RestorePerSeconds(player.stats.GetDEX(), isHP);
            double totalSeconds;

            if (isHP)
            {
                long   mhp  = player.Health();
                double hpps = mhp * restores;
                totalSeconds = (mhp - player.health) / hpps;
            }
            else
            {
                int    shp  = player.Stamina();
                double spps = shp * restores;
                totalSeconds = (shp - player.stamina) / spps;
            }

            double vagueMinutes = totalSeconds / 60.00;
            double hours        = Math.Floor(vagueMinutes / 60);
            double minutes      = Math.Floor(vagueMinutes - (hours * 60));

            return((hours > 0 ? $"{hours}h " : "") +
                   (minutes > 0 ? $"{minutes}m " : "") +
                   $"{Math.Floor(totalSeconds - (Math.Floor(vagueMinutes) * 60))}s ");
        }
コード例 #2
0
        private static EmbedFieldBuilder RestRecover(CharacterMotherClass character, double totalSeconds)
        {
            long maxHealth  = character.Health();
            int  maxStamina = character.Stamina();

            int dex = character.stats.GetDEX();

            double hpps       = RestorePerSeconds(dex, true);
            long   hpRestored = Math.Min(maxHealth - character.health,
                                         NumbersM.FloorParse <long>(maxHealth * hpps * totalSeconds));

            character.health += hpRestored;

            double spps       = RestorePerSeconds(dex, false);
            int    spRestored = Math.Min(maxStamina - character.stamina,
                                         NumbersM.FloorParse <int>(maxStamina * spps * totalSeconds));

            character.stamina += spRestored;

            return(DUtils.NewField(character.name,
                                   $"Restored {hpRestored} Health and {spRestored} Stamina", true));
        }