Advertisement
Guest User

Simple defense & damage reduction system (C# Shell App Paste)

a guest
Oct 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6.  
  7. namespace CSharp_Shell
  8. {
  9.  
  10.     public static class Program
  11.     {
  12.         public static void Main()
  13.         {
  14.             try {
  15.             Console.Write("Halfway threshold:  ");
  16.             int thres = ReadInt();
  17.    
  18.             while(true)
  19.             {
  20.                 Console.WriteLine("\n\n---INPUT----");
  21.                 Console.Write("Defense:  ");
  22.                 int def   = ReadInt();
  23.            
  24.                 Console.Write("Damage:   ");
  25.                 int inDmg   = ReadInt();
  26.            
  27.                 Console.WriteLine("\n---OUTPUT---");
  28.                 float reduc = 1 - def / (float)(def + thres);
  29.                 string inPercent = (reduc * 100).ToString() + "%";
  30.                 Console.Write($"Reduct:   {inPercent}\n");
  31.            
  32.                 int outDmg  = (int)(inDmg * reduc);
  33.                 Console.Write($"Damage:   {outDmg}\n");
  34.            } } catch (Exception e) {
  35.                 Console.WriteLine("Hey idiot, " + e.Message.ToLower());
  36.                 System.Threading.Thread.Sleep(2500);
  37.                 Console.Clear();
  38.            }
  39.            Main();
  40.         }
  41.        
  42.         private static int ReadInt() => int.Parse(Console.ReadLine());
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement