private static ITurn ChooseAttack(Neuromon activeNeuromon)
        {
            Console.WriteLine("Choose Attack:");

            var moveIndex = ReadInputUntilValid(input => input <= 4 && input > 0, "Invalid Attack!");

            var move = activeNeuromon.MoveSet[moveIndex - 1];
            return new Attack(move);
        }
        public virtual int CalculateDamage(Move attack, Neuromon target)
        {
            var damage = attack.Damage * 1.0;
            var multipler = 1.0;

            if (attack.Type.IsEffectiveAgainst(target.Type))
            {
                multipler = _effectiveMultipler;
            }
            else if (attack.Type.IsWeakAgainst(target.Type))
            {
                multipler = _weakMultiplier;
            }

            return (int) Math.Floor(damage * multipler);
        }
Exemple #3
0
        private static void RenderAttack(Neuromon attacker, Move move, Neuromon target, int damage)
        {
            var sb = new StringBuilder();

            sb.AppendLine($"{attacker.Name} used {move.Name} and dealt {damage} damage!");

            if (move.Type.IsEffectiveAgainst(target.Type))
            {
                sb.AppendLine("It's super effective!");
            }
            else if (move.Type.IsWeakAgainst(target.Type))
            {
                sb.AppendLine("It wasn't very effective..");
            }

            RenderTurnMade(sb.ToString().Trim());
        }
        private static void SerializeNeuromon(Neuromon neuromon, IList<double> outputArray, ref int index)
        {
            var moves = neuromon.MoveSet.Moves;

            outputArray[index++] = neuromon.Health;
            outputArray[index++] = neuromon.Type.Id;

            for (var i = 0; i < NumberOfMoves; ++i)
            {
                outputArray[index++] = moves[i].Damage;
                outputArray[index++] = moves[i].Type.Id;
            }
        }
        private static RouletteWheel<Move> CreateMoveRouletteWheel(Neuromon neuromon)
        {
            var fitnessProportionateProbabilityCalculator = new FitnessProportionateProbabilityCalculator<Move>(neuromon.MoveSet.Moves);

            var selectionProbabilities = fitnessProportionateProbabilityCalculator.Calculate(m => m.Damage * 1.0);

            return new RouletteWheel<Move>(selectionProbabilities);
        }
        private static int RankNeuromonChoice(Neuromon neuromon, Neuromon opponentNeuromon)
        {
            if (neuromon.Type.IsEffectiveAgainst(opponentNeuromon.Type))
            {
                return EffectiveRank;
            }

            if (!opponentNeuromon.Type.IsEffectiveAgainst(neuromon.Type))
            {
                return NeutralRank;
            }

            return WeakRank;
        }
 private static Dictionary<Neuromon, int> RankNeuromon(IEnumerable<Neuromon> neuromon, Neuromon opponentNeuromon)
 {
     return neuromon.ToDictionary(
         n => n,
         n => RankNeuromonChoice(n, opponentNeuromon)
     );
 }
Exemple #8
0
 private static string FormatNeuromon(Neuromon neuromon)
 {
     return $"Name: {neuromon.Name} | Type: {neuromon.Type.Name} | Health: {neuromon.Health}";
 }
Exemple #9
0
 private void OnNeuromonDefeated(IPlayerState attackingPlayerState, Neuromon attacker, IPlayerState defendingPlayerState, Neuromon defeated)
 {
     PrintWithDelay($"{attackingPlayerState.Name}'s {attacker.Name} defeated {defendingPlayerState.Name}'s {defeated.Name}!\n");
     PrintWithDelay($"{defendingPlayerState.Name} must select a new active Neuromon:\n");
     RenderPlayerState(defendingPlayerState);
     SimulateThinking(defendingPlayerState == _battleSimulator.Player1.State ? _battleSimulator.Player1.Controller : _battleSimulator.Player2.Controller);
 }
Exemple #10
0
 private static void RenderNeuromonChanged(IPlayerState playerState, Neuromon previousNeuromon, Neuromon newNeuromon)
 {
     var output = $"{playerState.Name} switched from {previousNeuromon.Name} to {newNeuromon.Name}!";
     RenderTurnMade(output);
 }