Example #1
0
        private void ExecuteCommand(Command command)
        {
            switch (command.Action)
            {
            case ActionName.Attack:
                AttackOutcome attackOutcome = _warriorClient.Attack(command.Strength);
                WarriorLogger.AttackLogging(attackOutcome, command.Strength);
                break;

            case ActionName.Defend:
                DefenseOutcome defenseOutcome = _warriorClient.Defend(command.Time);
                WarriorLogger.DefenceLogging(defenseOutcome);
                break;

            case ActionName.Rest:
                RestOutcome restOutcome = _warriorClient.Rest(command.Time);
                WarriorLogger.RestLogging(restOutcome);
                break;

            case ActionName.Check:
                WarriorState warriorState = _warriorClient.Check();
                WarriorLogger.CheckLogging(warriorState);
                break;
            }
        }
Example #2
0
        public double Trigger(EnchantmentParameters ep)
        {
            Character charAttacker = getCharByAccessString(ep, attacker.ToString());
            Character charDefender = getCharByAccessString(ep, defender.ToString());

            if (charAttacker.enchantmentLayersDeep > 0)
            {
                return(0);
            }
            charAttacker.enchantmentLayersDeep++;
            double?an = attackValue.Calculate(ep);
            double?dn = defenceValue.Calculate(ep);

            if (an != null && dn != null)
            {
                double a = (double)an;
                double d = (double)dn;

                Weapon save = charAttacker.CombatStuff.CombatWeapon;

                string selectedWepforcalc = EnchantmentUtilities.checkForVariable(selectedWeap, this);
                charAttacker.CombatStuff.CombatWeapon = Utilities.GetWeaponByName(selectedWepforcalc);

                AttackOutcome outcome = CombatScripts.RunCombat(charAttacker, charDefender, a, d, null);
                CombatScripts.applyAttackOutcome(outcome);

                charAttacker.CombatStuff.CombatWeapon = save;
            }
            charAttacker.enchantmentLayersDeep--;
            return(0.0);
        }
Example #3
0
 public DamageOutcome(Damage damageToDeal, DamageDealt damageDealt, AttackOutcome outcome, bool killedTarget)
 {
     DamageToDeal  = damageToDeal;
     DamageDealt   = damageDealt;
     AttackOutcome = outcome;
     KilledTarget  = killedTarget;
 }
Example #4
0
        public static void AttackLogging(AttackOutcome outcome, Strength strength)
        {
            switch (outcome)
            {
            case AttackOutcome.Success:
                Logger.Info("Your " + strength + " attack was " + outcome);
                break;

            case AttackOutcome.Interrupted:
                Logger.Info("Your " + strength + " attack was interrupted");
                break;

            case AttackOutcome.WrongData:
                WrongAttackData();
                break;

            case AttackOutcome.Reflected:
                Logger.Info("Your " + strength + " attack was reflected with a shield");
                break;

            case AttackOutcome.Defended:
                Logger.Info("Your " + strength + " attack was blocked with shield");
                break;

            case AttackOutcome.BattleNotStarted:
                BattleNotStarted();
                break;
            }
        }
Example #5
0
 public AttackHappened(string roomId, AttackOutcome outcome, string planetName, Guid attackerUserId,
                       Guid?defenderUserId)
 {
     RoomId         = roomId;
     Outcome        = outcome;
     PlanetName     = planetName;
     AttackerUserId = attackerUserId;
     DefenderUserId = defenderUserId;
     Timestamp      = DateTime.UtcNow;
 }
Example #6
0
        public Dictionary <TerritoryIDType, TerritoryStanding> GetTerritoryStandingsAfterAllMoves()
        {
            if (standingCache != null)
            {
                return(standingCache);
            }
            Dictionary <TerritoryIDType, TerritoryStanding> beginStandings = GameState.CurrentTurn().LatestTurnStanding.Territories;
            Dictionary <TerritoryIDType, TerritoryStanding> endStandings   = new Dictionary <TerritoryIDType, TerritoryStanding>();

            // init
            foreach (TerritoryIDType territoryId in beginStandings.Keys)
            {
                endStandings.Add(territoryId, beginStandings[territoryId].Clone());
            }
            // handle deployments
            foreach (GameOrderDeploy deployMove in DeployMoves)
            {
                endStandings[deployMove.DeployOn].NumArmies = new Armies(endStandings[deployMove.DeployOn].NumArmies.ArmiesOrZero + deployMove.NumArmies);
            }
            // handle attack and transfer moves
            foreach (GameOrderAttackTransfer attackTransferMove in AttackMoves)
            {
                int attackingArmies = attackTransferMove.NumArmies.ArmiesOrZero;
                if (endStandings[attackTransferMove.To].OwnerPlayerID == GameState.MyPlayerId)
                {
                    // if transfer remove armies from start and add armies to too
                    endStandings[attackTransferMove.From].NumArmies        = new Armies(endStandings[attackTransferMove.From].NumArmies.ArmiesOrZero - attackingArmies);
                    endStandings[attackTransferMove.To].NumArmies          = new Armies(endStandings[attackTransferMove.To].NumArmies.ArmiesOrZero + attackingArmies);
                    endStandings[attackTransferMove.To].ArmiesMarkedAsUsed = new Armies(endStandings[attackTransferMove.To].ArmiesMarkedAsUsed.ArmiesOrZero + attackingArmies);
                }
                else
                {
                    // if attack the result needs to get calculated
                    TerritoryStanding from          = endStandings[attackTransferMove.From];
                    TerritoryStanding to            = endStandings[attackTransferMove.To];
                    AttackOutcome     attackOutcome = new AttackOutcome(from.NumArmies.ArmiesOrZero, attackingArmies, to.NumArmies.ArmiesOrZero);
                    from.NumArmies = new Armies(attackOutcome.RemainingArmiesAttackingTerritory);
                    if (attackOutcome.IsTerritoryTaken)
                    {
                        to.OwnerPlayerID = GameState.MyPlayerId;
                        to.NumArmies     = new Armies(attackOutcome.NewArmiesDefendingTerritoryAttacker);
                    }
                    else
                    {
                        to.NumArmies = new Armies(attackOutcome.RemainingArmiesDefendingTerritoryDefender);
                    }
                }
            }
            standingCache = endStandings;
            return(endStandings);
        }
Example #7
0
    public bool Attack(Pawn other)
    {
        bool pawnDied = false;

        if (m_swordHp > 0.0f)
        {
            AttackOutcome outcome = other.TakeDmg(m_dmg);
            m_swordHp -= m_dmg;
            if (m_swordHp <= 0.0f)
            {
                if (armyId == GameBoard.PLAYER_ARMY_ID)
                {
                    FindObjectOfType <AdvancementManager>().NewBrokenSword(transform.position);
                }

                m_swordHp    = 0.0f;
                m_isInCombat = false;
                m_tileRemoveCallback(this);
                if ((outcome == AttackOutcome.None) || ((outcome == AttackOutcome.Repair) && other.m_isInCombat))
                {
                    m_assignToTileCallback(other, m_tilePositionX, m_tilePositionY, m_subTilePositionX, m_subTilePositionY);
                    other.m_isMovingToFreePlace = true;
                }
                else if (outcome == AttackOutcome.Death)
                {
                    m_killCallback?.Invoke(other.gameObject);
                }

                if (!(armyId == GameBoard.PLAYER_ARMY_ID && m_armyManager.AskForRepair(this)))
                {
                    m_killCallback?.Invoke(gameObject, false);
                }
                return(true);
            }

            if ((outcome == AttackOutcome.Death) || ((outcome == AttackOutcome.Repair) && !other.m_isInCombat))
            {
                m_isMovingToFreePlace = true;
                m_assignToTileCallback(this, other.m_tilePositionX, other.m_tilePositionY, other.m_subTilePositionX, other.m_subTilePositionY);
                if (outcome == AttackOutcome.Death)
                {
                    m_killCallback?.Invoke(other.gameObject, false);
                }
                m_isInCombat = false;
                pawnDied     = true;
            }
        }
        return(pawnDied);
    }
Example #8
0
 public CellOutcome(AttackOutcome attackOutcome, int posX, int posY)
 {
     this.attackOutcome = attackOutcome;
     this.posX          = posX;
     this.posY          = posY;
 }
Example #9
0
 public DamageOutcome(Damage damageToDeal, DamageDealt damageDealt, AttackOutcome outcome)
 {
     DamageToDeal  = damageToDeal;
     DamageDealt   = damageDealt;
     AttackOutcome = outcome;
 }
Example #10
0
 public DamageOutcome(Damage damageToDeal, AttackOutcome outcome)
 {
     DamageToDeal  = damageToDeal;
     AttackOutcome = outcome;
 }