Beispiel #1
0
        public void Start()
        {
            try
            {
                Deal();                          // deal the initial hands

                TrumpCard = gameDeck.DrawFrom(); //take the trump card

                SetFirstAttacker();
                while (true)
                {
                    try
                    {
                        do
                        {
                            Attack();
                            Defend();
                        } while (AttackingPlayer.CanAttackAgain(AttackRanks));

                        AttackersLose();
                    }
                    catch (CannotDefendException Cde)
                    {
                        DefenderLoses();
                    }
                }
            }
            catch (OutOfCardsException Ooce)
            {
                //game once deck is gone

                throw new NotImplementedException("The game has no end yet");
            }
        }
Beispiel #2
0
        private void Move()
        {
            if (ActiveCard.Card != null)
            {
                if (ActivePlayer == AttackingPlayer)
                {
                    AttackingPlayer.Attack();
                    ActivePlayer = DefendingPlayer;
                }
                else
                {
                    DefendingPlayer.Defend();
                    if (AttackingPlayer.hand.cards.Count == 0 && deck.cards.Count == 0)
                    {
                        if (DefendingPlayer.hand.cards.Count == 0)
                        {
                            MessageBox.Show("draw");
                        }
                        else
                        {
                            MessageBox.Show(AttackingPlayer.Name + "won");
                        }
                    }

                    if (DefendingPlayer.isDefended == true)
                    {
                        ActivePlayer = AttackingPlayer;
                        DefendingPlayer.isDefended = false;
                    }
                }
            }
        }
Beispiel #3
0
    public AttackerStyle GetStyle(AttackingPlayer player)
    {
        switch (player)
        {
        case AttackingPlayer.one:
            return(p1);

        case AttackingPlayer.two:
            return(p2);

        case AttackingPlayer.none:
        default:
            return(defaultStyle);
        }
    }
Beispiel #4
0
    //  Calculate the hit chance
    private void CalculateHitChance()
    {
        Debug.Log($"HIT CHANCE VS {CacheManager.SetupTab.CurrentSubBoss.name}");

        //  create player from data to feed into boss attack method
        AttackingPlayer attPl = new AttackingPlayer(new Weapon(model.AttackStyle, model.WeaponAccTier),
                                                    model.BoostedCombatLevel(),
                                                    model.AccuracyModifier,
                                                    model.AffinityModifier);

        //  feed in and get value
        double val = CacheManager.SetupTab.CurrentSubBoss.HitChance(in attPl) + model.HitChanceModifier.Modifier;

        //  display as percentage to 2 decimal points
        view.SetHitChanceText(val.ToString("N2") + "%");
    }
        private void Fight()
        {
            var selectedAttackerArmiesCount = SelectAttackerArmiesByStrategy();
            var selectedDefenderArmiesCount = SelectDefenderArmiesByStrategy();

            var attackerDice = Enumerable.Range(0, selectedAttackerArmiesCount)
                               .Select(i => ThrowDice())
                               .Select(i => new Dice(i))
                               .ToList();

            var defenderDice = Enumerable.Range(0, selectedDefenderArmiesCount)
                               .Select(i => ThrowDice())
                               .Select(i => new Dice(i))
                               .ToList();

            var fight       = new Fight(attackerDice, defenderDice);
            var fightResult = fight.GetFightResult();

            AttackingPlayer.DecreaseArmy(fightResult.AttackerLoses);
            DefendingPlayer.DecreaseArmy(fightResult.DefenderLoses);
        }
Beispiel #6
0
    void Start()
    {
        realtimeView = GetComponent <RealtimeView>();
        _brokenWrapper.SetActive(false);

        _shardsLocalRotation = _shards[0].localRotation;
        GetBrokenLocalPositions();

        ShowRegularHead();

        if (!_isDummy)
        {
            int ownerID = realtimeView.ownerID;
            player = ownerID == 0 ? AttackingPlayer.one : AttackingPlayer.two;

            if (realtimeView.isOwnedLocally)
            {
                _eyes.SetActive(false);
            }
        }
    }
Beispiel #7
0
    private void SetupDummy()
    {
        player = AttackingPlayer.none;

        var realtimeViews = GetComponentsInChildren <RealtimeView>();

        foreach (var rtv in realtimeViews)
        {
            rtv.enabled = false;
        }

        var realtimeTransforms = GetComponentsInChildren <RealtimeTransform>();

        foreach (var rtt in realtimeTransforms)
        {
            rtt.enabled = false;
        }

        GetComponent <RealtimeAvatar>().enabled = false;
        GetComponentInChildren <RealtimeAvatarVoice>().enabled = false;
    }
Beispiel #8
0
 protected virtual void OnAttackingPlayer(Creature attackingCreature, Duelist defendingPlayer)
 {
     AttackingPlayer?.Invoke(this, attackingCreature, defendingPlayer);
 }
Beispiel #9
0
 /// <summary>
 /// This is the method that is called when it is time for a player to attack
 /// </summary>
 private void Attack()
 {
     Console.WriteLine("{0} is attacking {1}", AttackingPlayer.Name, DefendingPlayer.Name);
     Attacks.Add(new AttackPair(AttackingPlayer.Attack(trump, AttackRanks)));
 }