Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Nether_Realms
- {
- class Program
- {
- static void Main(string[] args)
- {
- string patternOne = @"([-|+]?[0-9\.]*[0-9])";
- string patternTwo = @"([A-Za-z]+)";
- string input = Console.ReadLine();
- string[] tokens = input
- .Split(new char[] { ' ', ',', '\t', '\n' },
- StringSplitOptions.RemoveEmptyEntries);
- List<string> demons = new List<string>();
- foreach (var entry in tokens)
- {
- demons.Add(entry);
- }
- double damage = 0.0;
- double health = 0.0;
- foreach (var demon in demons)
- {
- MatchCollection nums = Regex.Matches(demon, patternOne);
- MatchCollection letters = Regex.Matches(demon, patternTwo);
- List<double> numStore = new List<double>();
- foreach (Match num in nums)
- {
- if (num.Success)
- {
- double converted = double.Parse(num.Value);
- numStore.Add(converted);
- }
- }
- foreach (var num in numStore)
- {
- damage += num;
- }
- if (demon.Contains('*'))
- {
- int count = input.Count(c => c == '*');
- damage *= count * 2;
- if (demon.Contains('/'))
- {
- damage /= 2;
- }
- }
- string concat = string.Empty;
- foreach (Match letter in letters)
- {
- if (letter.Success)
- {
- concat += letter.Value.ToString();
- }
- }
- for (int i = 0; i < concat.Length; i++)
- {
- health += concat[i];
- }
- }
- foreach (var demon in demons)
- {
- Console.WriteLine("{0} - {1} health, {2:F2} damage", demon, health, damage);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement