diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-07-20 22:30:54 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-07-20 22:30:54 +0000 |
| commit | 96058e330b9a535ec3aecc40cfbd2fa74b791cd8 (patch) | |
| tree | 5afa3a01da6345b4f173e9578e0f7b0219cb9759 /pokebattle/TeamMember.cpp | |
| parent | a44d3c2ebd20e05c7c574cd3a13888fc471067b9 (diff) | |
| download | sigen-96058e330b9a535ec3aecc40cfbd2fa74b791cd8.tar.gz sigen-96058e330b9a535ec3aecc40cfbd2fa74b791cd8.tar.xz sigen-96058e330b9a535ec3aecc40cfbd2fa74b791cd8.zip | |
[FIX] Slimmed up main() for pokemodr
[FIX] Cleaned up initializing TeamMember
[FIX] Hat fixed up
[ADD] Added ActionQueue (thread-safe QQueue)
[FIX] Arena classes fleshed out a bit
[ADD] ATBTimer class added to mediate the ATB counters
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@228 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokebattle/TeamMember.cpp')
| -rw-r--r-- | pokebattle/TeamMember.cpp | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/pokebattle/TeamMember.cpp b/pokebattle/TeamMember.cpp index 98542d0e..3bdee896 100644 --- a/pokebattle/TeamMember.cpp +++ b/pokebattle/TeamMember.cpp @@ -20,6 +20,7 @@ // Pokebattle includes #include "Containment.h" +#include "Player.h" // Pokemod includes #include "../pokemod/Hat.h" @@ -56,6 +57,7 @@ Pokebattle::TeamMember::TeamMember(const int speciesId, const QString& name, con initItems(); initAbilities(); initMoves(); + initNatures(); initStats(); if (species->genderFactor() <= 1) m_gender = species->genderFactor().poll(); @@ -74,7 +76,7 @@ Pokebattle::TeamMember::TeamMember(const int speciesId, const QString& name, con } } -Pokebattle::TeamMember::TeamMember(const Pokemod::MapTrainerTeamMember& teamMember, Containment* containment) : +Pokebattle::TeamMember::TeamMember(const Pokemod::MapTrainerTeamMember* teamMember, Containment* containment) : m_containment(containment) { // TODO: grab information from the class @@ -117,15 +119,16 @@ int Pokebattle::TeamMember::statValue(const int stat, const int exp) const } else statValue += m_dv[stat]; - statValue *= m_level; - statValue /= 100; + statValue *= double(m_level) / pokemod()->rules()->maxLevel(); if (stat == Pokemod::ST_HP) statValue += 10 + m_level; else { statValue += 5; - foreach (int natureId, m_natures) - statValue *= pokemod()->natureById(natureId)->stat(stat); + Pokemod::Fraction multiplier; + foreach (int nature, m_natures) + multiplier *= pokemod()->natureById(nature)->stat(stat); + statValue *= multiplier; } return statValue; } @@ -136,7 +139,6 @@ int Pokebattle::TeamMember::calcExp(int level) const level = m_level; const int square = level * level; const int cube = square * level; - const double p[] = {0.000, 0.008, 0.014}; switch (pokemod()->speciesById(m_species)->growth()) { case Pokemod::Species::Fluctuating: @@ -160,6 +162,8 @@ int Pokebattle::TeamMember::calcExp(int level) const case Pokemod::Species::Fast: return 4 * cube / 5; case Pokemod::Species::Erratic: + { + const double p[] = {0.000, 0.008, 0.014}; if (level <= 50) return cube * ((100 - level) / 50.0); else if (level <= 68) @@ -171,6 +175,7 @@ int Pokebattle::TeamMember::calcExp(int level) const // TODO: better way for further growth? else return 3 * cube / 5; + } default: break; } @@ -321,6 +326,11 @@ void Pokebattle::TeamMember::teachMove(const int move) } } +Pokebattle::TeamMember::Action Pokebattle::TeamMember::requestAction() const +{ + return m_containment->player()->requestAction(this); +} + const Pokemod::Pokemod* Pokebattle::TeamMember::pokemod() const { // TODO: get pokemod @@ -372,8 +382,16 @@ void Pokebattle::TeamMember::initItems() void Pokebattle::TeamMember::initAbilities() { m_abilities.clear(); - while (m_abilities.size()) - m_abilities.append(newAbility()); + const Pokemod::Species* species = pokemod()->speciesById(m_species); + Pokemod::Hat<int> abilityHat; + for (int i = 0; i < species->abilityCount(); ++i) + { + const Pokemod::SpeciesAbility* ability = species->ability(i); + if (!m_abilities.contains(ability->ability())) + abilityHat.add(ability->ability(), ability->weight()); + } + while (m_abilities.size() < pokemod()->rules()->maxAbilities()) + m_abilities.append(abilityHat.takeAndClear()); } void Pokebattle::TeamMember::initMoves() @@ -382,12 +400,25 @@ void Pokebattle::TeamMember::initMoves() m_moves.clear(); for (int i = 0; (i < species->moveCount()) && (m_moves.size() < pokemod()->rules()->maxMoves()); ++i) { - if ((species->move(i)->level() < m_level) && (0 <= species->move(i)->level())) + if (((species->move(i)->level() < m_level) && species->move(i)->level()) || (!m_containment->isMutable() && (species->move(i)->wild() < m_level))) m_moves.append(species->move(i)->move()); } Q_ASSERT(m_moves.size()); } +void Pokebattle::TeamMember::initNatures() +{ + m_natures.clear(); + Pokemod::Hat<int> natureHat; + for (int i = 0; i < pokemod()->natureCount(); ++i) + { + const Pokemod::Nature* nature = pokemod()->nature(i); + natureHat.add(nature->id(), nature->weight()); + } + while (m_natures.size() < pokemod()->rules()->maxNatures()) + m_natures.append(natureHat.takeAndClear()); +} + void Pokebattle::TeamMember::initStats() { if (pokemod()->rules()->specialDVSplit()) @@ -402,16 +433,3 @@ void Pokebattle::TeamMember::initStats() m_dv[Pokemod::ST_HP] = ((m_dv[Pokemod::ST_Attack] & 1) << 3) + ((m_dv[Pokemod::ST_Defense] & 1) << 2) + ((m_dv[Pokemod::ST_Speed] & 1) << 1) + (m_dv[Pokemod::ST_Special] & 1); } } - -int Pokebattle::TeamMember::newAbility() -{ - const Pokemod::Species* species = pokemod()->speciesById(m_species); - Pokemod::Hat<int> abilityHat; - for (int i = 0; i < species->abilityCount(); ++i) - { - const Pokemod::SpeciesAbility* ability = species->ability(i); - if (!m_abilities.contains(ability->ability())) - abilityHat.add(ability->ability(), ability->weight()); - } - return abilityHat.pick(); -} |
