private void Client_LaunchDuelResultBox(int bps, int exps, bool win, int opponent, RoomConfig config, int roomID)
        {
            DuelResult box = new DuelResult(this, bps, exps, win, opponent, config, roomID);

            box.Topmost = true;
            box.Show();
            Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => box.Activate()));
        }
Example #2
0
        public string GetPlayerBestSequence()
        {
            string sequence        = GetNextSequence();
            var    drawSequence    = string.Empty;
            var    victorySequence = string.Empty;

            while (!string.IsNullOrEmpty(sequence))
            {
                Player.SetUnits(sequence);
                Player.FinalSequence = string.Empty;
                Oponent.SetUnits(Oponent.GenuineSequence); // Resets the stack of units

                DuelResult duelResult = Duel();

                if (duelResult == DuelResult.Victory)
                {
                    victorySequence = Player.FinalSequence;
                    break;
                }

                if (duelResult == DuelResult.Draw && string.IsNullOrEmpty(drawSequence))
                {
                    drawSequence = Player.FinalSequence;
                }

                sequence = GetNextSequence();
            }

            if (!string.IsNullOrEmpty(victorySequence))
            {
                return(string.Concat("+", victorySequence));
            }

            return(!string.IsNullOrEmpty(drawSequence)
                ? string.Concat("=", drawSequence)
                : string.Concat("-", Player.GenuineSequence));
        }
Example #3
0
        /// <summary>
        /// Calculates the battle between <paramref name="yourCreatures"/> and <paramref name="opponentsCreatures"/> and
        /// returns the the result as a <see cref="BattleResult"/>.
        /// </summary>
        public static BattleResult CalculateBattle(List<Creature> yourCreatures, List<Creature> opponentsCreatures)
        {
            if (opponentsCreatures.Count > yourCreatures.Count)
                throw new ArgumentException("You do not have enough creatures!");

            BattleResult battleResult = new BattleResult();

            for (int duelIndex = 0; duelIndex < opponentsCreatures.Count; duelIndex++)
            {
                Creature opponent = new Creature(opponentsCreatures[duelIndex]);
                Creature you = new Creature(yourCreatures[duelIndex]);
                DuelResult duel = new DuelResult();

                AddEnchantmentEffects(you, opponent);
                AddEnchantmentEffects(opponent, you);

                AddItemEffectsBeforeBattle(you, opponent, yourCreatures, opponentsCreatures);
                AddItemEffectsBeforeBattle(opponent, you, opponentsCreatures, yourCreatures);

                while (you.Health > 0 && opponent.Health > 0)
                {
                    int opponentDamage = GetDamage(opponent, you);
                    int yourDamage = GetDamage(you, opponent);

                    you.Health -= opponentDamage;
                    opponent.Health -= yourDamage;

                    AddItemEffectsBeforeTurn(you, opponent);
                    AddItemEffectsBeforeTurn(opponent, you);

                    if (you.Health < 0) you.Health = 0;
                    if (opponent.Health < 0) opponent.Health = 0;

                    duel.Result += String.Format(
                        "Your {0} did {1} damage -> opponent's {2} has {3} health left." + Environment.NewLine +
                        "Opponent's {2} did {4} damage -> your {0} has {5} health left." + Environment.NewLine,
                        you.Name, yourDamage, opponent.Name, opponent.Health, opponentDamage, you.Health);
                }

                if (you.Health == 0 && opponent.Health == 0)
                {
                    string outCome = String.Format("Your {0} killed your opponent's {1} but died in the process.", you.Name, opponent.Name);
                    duel.Result += outCome;
                    duel.ShortResult = outCome;
                    duel.Outcome = DuelOutcome.Dip;
                }
                else if (you.Health > 0)
                {
                    string outCome = String.Format("Your {0} killed your opponent's {1}.", you.Name, opponent.Name);
                    duel.Result += outCome;
                    duel.ShortResult = outCome;
                    duel.Outcome = DuelOutcome.Won;
                }
                else
                {
                    string outCome = String.Format("Your {0} got killed by your opponent's {1}.", you.Name, opponent.Name);
                    duel.Result += outCome;
                    duel.ShortResult = outCome;
                    duel.Outcome = DuelOutcome.Lost;
                }

                battleResult.Add(duel);
            }

            return battleResult;
        }
    public static DuelOutcome GetOutcome(int fistTarget, int secondTarget)
    {
        DuelResult result = Resolve(fistTarget, secondTarget);

        return(new DuelOutcome(fistTarget, secondTarget, result.Remaining, result.FirstSurvives));
    }