Exemplo n.º 1
0
    protected virtual Action GetMostEffectiveAttack(CharacterController playerCharacter, out float maxPotentialDamage)
    {
        Action bestAttack = null;

        maxPotentialDamage = 0f;

        if (_aiCharacter.Character.Weapon?.Actions == null ||
            _aiCharacter.Character.Weapon.Actions.Count == 0)
        {
            Debug.LogWarning($"Character {_aiCharacter.Character.Name} does not have a weapon with attacks.");
            return(bestAttack);
        }

        foreach (var attack in _aiCharacter.Character.Weapon.Actions)
        {
            if (Vector3.Distance(_aiCharacter.transform.position, playerCharacter.transform.position) < attack.Range)
            {
                var potentialDamage = StatCalculator.CalculateStat(attack, StatType.Damage);
                if (potentialDamage > maxPotentialDamage)
                {
                    maxPotentialDamage = potentialDamage;
                    bestAttack         = attack;
                }
            }
        }

        return(bestAttack);
    }
Exemplo n.º 2
0
        public IActionResult Attack(string mass, string opponentEgo)
        {
            string result         = "";
            int    massInt        = 0;
            int    opponentEgoInt = 0;
            //S
            bool massParseSuccess = int.TryParse(mass, out massInt);
            bool egoParseSuccess  = int.TryParse(opponentEgo, out opponentEgoInt);

            if (massParseSuccess && egoParseSuccess)
            {
                int attackDamage = StatCalculator.Attack(massInt, opponentEgoInt);
                //Ha haaaaaa nice pat
                result = $"You did {attackDamage} damage. ALL ROIGHT";
            }
            else if (massParseSuccess && !egoParseSuccess)
            {
                result = "Ego was not in correct format";
            }
            else if (!massParseSuccess && egoParseSuccess)
            {
                result = "Mass was not in correct format";
            }
            else
            {
                result = "Both mass and ego were not in correct format";
            }


            return(Content(result));
        }
Exemplo n.º 3
0
        public static GameEntity CreateOreBranch(GameContext context, GameEntity vein, Vector2 position)
        {
            var e = context.CreateEntity();

            e.AddSprite("ore_branch");
            e.AddPosition(position);
            var health = StatCalculator.Calculate(BaseBranchHealthPercentage, 1);

            e.AddHealth(health, health);

            e.isOre             = true;
            e.isOreBranch       = true;
            e.isKillable        = true;
            e.isRemovedWhenDead = true;

            e.AddRoomChild(vein.roomChild.id);
            e.AddParent(vein.id.value);
            e.isOnGround = true;

            if (vein.hasBag == false)
            {
                vein.AddBag(new List <int>());
            }

            vein.bag.items.Add(e.id.value);
            return(e);
        }
Exemplo n.º 4
0
    /// <summary>
    /// Effectively passes the turn from the perspective of the battle units.
    /// Their counter values will now reflect the last performed action in-game
    /// </summary>
    private void UpdateCounterValues()
    {
        List <GameCharacter> battleUnits = battleMap.battleUnits_;
        int  index     = 0;
        bool turnFound = false;

        // remember to check isActive
        while (!turnFound)
        {
            for (int i = 0; i < battleUnits.Count; i++)
            {
                if (battleUnits[i].IsActive && battleUnits[i].CounterValue <= 0 && !turnFound)
                {
                    turnFound = true;
                    index     = i;
                }

                battleUnits[i].CounterValue--;
            }
        }

        battleUnits[index].CounterValue = StatCalculator.CalculateCounter(
            battleUnits[index].TickSpeed,
            battleUnits[index].LastSkillRank,
            battleUnits[index].GetStatusEffectByName("HASTE")
            );
    }
Exemplo n.º 5
0
    // ---------------------------------------------------------------------------------------
    /*                                  AGENT ACTION METHODS                                */
    // ---------------------------------------------------------------------------------------

    void Attack(int dir)
    {
        // Calculate damage on target
        const int ATTACK_DMG_CONSTANT = 16;
        GameCharacter target;
        HexTile neighborTile;
        float damageApplied;

        if (BattleMap_.mapTiles.TryGetValue(HexCalculator.GetNeighborAtDir(InGamePosition, dir), out neighborTile))
        {
            target = BattleMap_.mapTiles[HexCalculator.GetNeighborAtDir(InGamePosition, dir)].Occupier;

            if (target != null)
            {
                damageApplied = StatCalculator.PhysicalDmgCalc(GetStatValueByName("STR"), ATTACK_DMG_CONSTANT, target.GetStatValueByName("RES"), GetStatusEffectByName("BRAVERY"), target.GetStatusEffectByName("ARMOR"));
                target.ReceiveDamage(damageApplied);

                if (UnitInPredatorList(target))
                {
                    AddReward(0.2f);
                }
                else if (!UnitInTargetList(target))
                {
                    AddReward(-1f);
                }

                return;
            }
        }

        // Position at dir has no occupier!
        // Position at dir has no tile!
        AddReward(-0.5f);
    }
Exemplo n.º 6
0
    public virtual void Execute(Tile targetTile)
    {
        var areaOfAffect  = StatCalculator.CalculateStat(ActionReference, StatType.AttackAOE);
        var affectedTiles = TileGridController.Instance.GetTilesInRadius(targetTile.GridX, targetTile.GridY, areaOfAffect);

        this.ExecuteAction(affectedTiles);
    }
Exemplo n.º 7
0
        public void CalcValueFromItems_LivingIsNull_ReturnZero()
        {
            StatCalculator statCalc = createStatCalculator();

            int actual = statCalc.CalcValueFromItems(null, eProperty.Constitution);

            Assert.AreEqual(0, actual);
        }
        public void VarianceTest()
        {
            StatCalculator statCalc = new StatCalculator();

            int[] values   = { 1, 2, 3 };
            var   variance = statCalc.Variance(values);

            Assert.AreEqual(0.67, variance);
        }
        public void StandardDTest()
        {
            StatCalculator statCalc = new StatCalculator();

            int[] values = { 1, 2, 3 };
            //dynamic values = statCalc.Squarea(0.67);
            var standDev = statCalc.StandardD(values);

            Assert.AreEqual(SuareRoot.Root(0.67), standDev);
        }
Exemplo n.º 10
0
        public void CalcValue_200ConstitutionDebuff_1()
        {
            var player = NewPlayer();

            player.DebuffCategory[eProperty.Constitution] = 200;

            int actual = StatCalculator.CalcValue(player, eProperty.Constitution);

            Assert.AreEqual(1, actual);
        }
Exemplo n.º 11
0
        public void GetMythicalItemBonusCapIncrease_PlayerWith100MythicalConCap_ReturnCapAt52()
        {
            var player = Create.FakePlayer();

            player.ItemBonus[eProperty.MythicalConCapBonus] = 100;

            int actual = StatCalculator.GetMythicalItemBonusCapIncrease(player, eProperty.Constitution);

            Assert.AreEqual(52, actual);
        }
Exemplo n.º 12
0
        public void CalcValue_NPCWith100Constitution_100()
        {
            var npc = NewNPC();

            npc.Constitution = 100;

            int actual = StatCalculator.CalcValue(npc, eProperty.Constitution);

            Assert.AreEqual(100, actual);
        }
Exemplo n.º 13
0
        public void GetMythicalItemBonusCapIncrease_PlayerWith10MythicalConCap_10()
        {
            var player = NewPlayer();

            player.ItemBonus[eProperty.MythicalConCapBonus] = 10;

            int actual = StatCalculator.GetMythicalItemBonusCapIncrease(player, eProperty.Constitution);

            Assert.AreEqual(10, actual);
        }
Exemplo n.º 14
0
        public void CalcValue_200ConstitutionAbilityBonus_200()
        {
            var player = NewPlayer();

            player.AbilityBonus[eProperty.Constitution] = 200;

            int actual = StatCalculator.CalcValue(player, eProperty.Constitution);

            Assert.AreEqual(200, actual);
        }
Exemplo n.º 15
0
        public void CalcValue_NPCWith100Intelligence_100()
        {
            var npc = NewNPC();

            npc.Intelligence = 100;

            int actual = StatCalculator.CalcValue(npc, eProperty.Intelligence);

            Assert.AreEqual(100, actual);
        }
Exemplo n.º 16
0
        public void CalcValueFromBuffs_GameNPCWith100ConstBaseBuff_100()
        {
            var npc = NewNPC();

            npc.BaseBuffBonusCategory[eProperty.Constitution] = 100;

            int actual = StatCalculator.CalcValueFromBuffs(npc, eProperty.Constitution);

            Assert.AreEqual(100, actual);
        }
Exemplo n.º 17
0
        public void CalcValue_200ConstitutionAbilityBonus_Return200()
        {
            var player = NewFakePlayer();

            player.AbilityBonus[eProperty.Constitution] = 200;
            StatCalculator statCalc = createStatCalculator();

            int actual = statCalc.CalcValue(player, eProperty.Constitution);

            Assert.AreEqual(200, actual);
        }
Exemplo n.º 18
0
        public void GetItemBonusCapIncrease_Level50Player10ConstCap_10()
        {
            var player = NewPlayer();

            player.Level = 50;
            player.ItemBonus[eProperty.ConCapBonus] = 10;

            int actual = StatCalculator.GetItemBonusCapIncrease(player, eProperty.Constitution);

            Assert.AreEqual(10, actual);
        }
Exemplo n.º 19
0
        public void MeanTest()
        {
            StatCalculator statCalc = new StatCalculator();

            int[] values = { 1, 2, 3, 4 };
            //int c = statCalc.Mean(1,4,5,6,2);
            //Assert.AreEqual(6, c);
            var mean = statCalc.Mean(values);

            Assert.AreEqual(2, mean);
        }
Exemplo n.º 20
0
        public void CalcValue_NPCWith100Constitution_Return100()
        {
            var npc = NewFakeNPC();

            npc.Constitution = 100;
            StatCalculator statCalc = createStatCalculator();

            int actual = statCalc.CalcValue(npc, eProperty.Constitution);

            Assert.AreEqual(100, actual);
        }
Exemplo n.º 21
0
        public void CalcValue_NPCWith100Intelligence_Return100()
        {
            var npc = NewFakeNPC();

            npc.Intelligence = 100;
            StatCalculator statCalc = createStatCalculator();

            int actual = statCalc.CalcValue(npc, eProperty.Intelligence);

            Assert.AreEqual(100, actual);
        }
Exemplo n.º 22
0
        public void CalcValue_200ConstitutionDebuff_Return1()
        {
            var player = NewFakePlayer();

            player.DebuffCategory[eProperty.Constitution] = 200;
            StatCalculator statCalc = createStatCalculator();

            int actual = statCalc.CalcValue(player, eProperty.Constitution);

            Assert.AreEqual(1, actual);
        }
Exemplo n.º 23
0
        public void CalcValueFromBuffs_GameNPCWith100ConstBaseBuff_Return100()
        {
            var npc = Create.FakeNPC();

            npc.BaseBuffBonusCategory[eProperty.Constitution] = 100;
            StatCalculator statCalc = createStatCalculator();

            int actual = statCalc.CalcValueFromBuffs(npc, eProperty.Constitution);

            Assert.AreEqual(100, actual);
        }
Exemplo n.º 24
0
        public void CalcValue_200ConAbilityBonusAnd50ConDebuff_200()
        {
            var player = NewPlayer();

            player.AbilityBonus[eProperty.Constitution]   = 200;
            player.DebuffCategory[eProperty.Constitution] = 50;

            int actual = StatCalculator.CalcValue(player, eProperty.Constitution);

            Assert.AreEqual(200 - (50 / 2), actual);
        }
Exemplo n.º 25
0
        public void CalcValue_70ConBaseStatAnd3ConLostOnDeath_67()
        {
            var player = NewPlayer();

            player.Level    = 50;
            player.baseStat = 70;
            player.TotalConstitutionLostAtDeath = 3;

            int actual = StatCalculator.CalcValue(player, eProperty.Constitution);

            Assert.AreEqual(67, actual);
        }
Exemplo n.º 26
0
        public void CalcValue_70ConBuffBonusAnd50ConDebuff_20()
        {
            var player = NewPlayer();

            player.Level = 50;
            player.SpecBuffBonusCategory[eProperty.Constitution] = 70;
            player.DebuffCategory[eProperty.Constitution]        = 50;

            int actual = StatCalculator.CalcValue(player, eProperty.Constitution);

            Assert.AreEqual(20, actual);
        }
Exemplo n.º 27
0
        public void CalcValue_200ConAbilityBonusAnd50ConDebuff_Return200()
        {
            var player = Create.FakePlayer();

            player.AbilityBonus[eProperty.Constitution]   = 200;
            player.DebuffCategory[eProperty.Constitution] = 50;
            StatCalculator statCalc = createStatCalculator();

            int actual = statCalc.CalcValue(player, eProperty.Constitution);

            Assert.AreEqual(200 - (50 / 2), actual);
        }
Exemplo n.º 28
0
        public void CalcValueFromItems_IntelligenceOfLevel50AnimistWith50AcuityFromItems_50()
        {
            var player = NewPlayer();

            player.fakeCharacterClass = new CharacterClassAnimist();
            player.Level = 50;
            player.ItemBonus[eProperty.Acuity] = 50;

            int actual = StatCalculator.CalcValueFromItems(player, eProperty.Intelligence);

            Assert.AreEqual(50, actual);
        }
Exemplo n.º 29
0
        public void CalcValue_GetIntelligenceFromLevel50AnimistWith50Acuity_50()
        {
            var player = NewPlayer();

            player.fakeCharacterClass = new CharacterClassAnimist();
            player.Level = 50;
            player.BaseBuffBonusCategory[(int)eProperty.Acuity] = 50;

            int actual = StatCalculator.CalcValue(player, eProperty.Intelligence);

            Assert.AreEqual(50, actual);
        }
Exemplo n.º 30
0
        public void CalcValueFromItems_Level50Player150ConAnd100MythicalConCap_127()
        {
            var player = NewPlayer();

            player.Level = 50;
            player.ItemBonus[eProperty.MythicalConCapBonus] = 100;
            player.ItemBonus[eProperty.Constitution]        = 150;

            int actual = StatCalculator.CalcValueFromItems(player, eProperty.Constitution);

            Assert.AreEqual(127, actual);
        }