using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Tabletop.Core.Calculators;
using Tabletop.Core.Constants;

namespace Tabletop.Pages.Tools
{
    public partial class Simulation
    {
        public int AttackerFractionId { get; set; }
        public int AttackerId { get; set; }
        public int DefenderFractionId { get; set; }
        public int DefenderId { get; set; }
        public CoverTypes Cover { get; set; }
        public int Quantity { get; set; }
        public double Probability { get; set; }

#nullable disable
        [Inject] public IJSRuntime JSRuntime { get; set; }
#nullable enable

        protected async Task StartSimulation()
        {
            double probability = await Calculation.ProbabilityAsync(AttackerId, DefenderId, Cover);
            probability *= Quantity * 100;
            Probability = Math.Round(probability, 2);
        }
    }
}