コード例 #1
0
        public IList <Fighter> CalculateBattleResult(byte generation, FightInformation fightInfo)
        {
            byte participated = Convert.ToByte(fightInfo.Team.Count(c => c.HasParticipated));

            if (participated == 0)
            {
                throw new Exception("There can be no fight without participants");
            }

            byte teamCount     = 0;
            byte expShareCount = 0;

            if (generation == 1)
            {
                if (fightInfo.ExpAllActive)
                {
                    teamCount = Convert.ToByte(fightInfo.Team.Count);
                }
            }
            else
            {
                expShareCount = Convert.ToByte(fightInfo.Team.Count(c => c.HoldsExpShare));
            }

            // Loop through all team members
            foreach (Fighter fighter in fightInfo.Team)
            {
                if (fighter.HasParticipated)
                {
                    // Calculate experience that is earned directly through actively defeating the enemy
                    if (generation == 1)
                    {
                        fighter.EarnedExperience = _experienceCalculator.CalculateExperienceForFirstGen(fightInfo.EnemyBaseExperience, fightInfo.EnemyLevel, participated, fightInfo.EnemyIsWild, fighter.TradeState == TradeState.TradedNational, fightInfo.ExpAllActive, 0);
                    }
                    else if (generation == 6)
                    {
                        fighter.EarnedExperience = _experienceCalculator.CalculateExperienceForSixthGen(fightInfo.EnemyBaseExperience, fightInfo.EnemyLevel, fightInfo.EnemyIsWild, fighter.TradeState, fighter.HoldsLuckyEgg, fightInfo.ExpPowerState, fighter.HasAffection, fighter.CouldEvolved, fightInfo.ExpAllActive, true);
                    }
                    else
                    {
                        fighter.EarnedExperience = CalculateExperienceYield(generation, fightInfo.EnemyBaseExperience, fightInfo.EnemyLevel, fighter.Level, participated, fightInfo.EnemyIsWild, fighter.TradeState, fighter.HoldsLuckyEgg, expShareCount, false, fightInfo.ExpPowerState);
                    }
                }

                // if the active fighter also holds Exp.Share he will be given both direct exp from fight and Exp.Share output, so we sum them
                if (fighter.HoldsExpShare && generation > 1)
                {
                    fighter.EarnedExperience += CalculateExperienceYield(generation, fightInfo.EnemyBaseExperience, fightInfo.EnemyLevel, fighter.Level, 1, fightInfo.EnemyIsWild, fighter.TradeState, fighter.HoldsLuckyEgg, expShareCount, true, fightInfo.ExpPowerState);
                }

                // In first gen with activated Exp.All you get half the Exp + the Exp.All output so we calculate both and sum them
                if (teamCount > 0 && generation == 1)
                {
                    fighter.EarnedExperience += _experienceCalculator.CalculateExperienceForFirstGen(fightInfo.EnemyBaseExperience, fightInfo.EnemyLevel, participated, fightInfo.EnemyIsWild, fighter.TradeState == TradeState.TradedNational, fightInfo.ExpAllActive, teamCount);
                }

                // Not sure about this, but all tests seemed to have shown that this is neccessary
                // More tests are needed to evaluate this, maybe Exp Calc is wrong somewhere
                if (generation == 5 && fighter.HasParticipated && fighter.HoldsExpShare && expShareCount > 1)
                {
                    fighter.EarnedExperience = fighter.EarnedExperience - 1;
                }

                if (generation == 6 && fightInfo.ExpAllActive)
                {
                    fighter.EarnedExperience = _experienceCalculator.CalculateExperienceForSixthGen(fightInfo.EnemyBaseExperience, fightInfo.EnemyLevel, fightInfo.EnemyIsWild, fighter.TradeState, fighter.HoldsLuckyEgg, fightInfo.ExpPowerState, fighter.HasAffection, fighter.CouldEvolved, fightInfo.ExpAllActive, false);
                }
            }

            return(fightInfo.Team);
        }
コード例 #2
0
 public int ShouldCalculateExperienceForGen1(ushort baseExperience, byte enemyLevel, byte participatedPokemon, bool isWild, bool isTraded, bool useExpShare, byte teamCount)
 {
     return(_service.CalculateExperienceForFirstGen(baseExperience, enemyLevel, participatedPokemon, isWild, isTraded, useExpShare, teamCount));
 }