Skip to content

Commit

Permalink
Standardize on QVector as the main container for various consts.
Browse files Browse the repository at this point in the history
  • Loading branch information
szreder committed Jul 19, 2014
1 parent f9d3f39 commit aa965ed
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/BTCommon/Rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ This file is part of BTech Project.

BTech::GameVersion Rules::version;
QString Rules::description;
QList <BTech::GamePhase> Rules::allowedPhases;

void Rules::setVersion(const BTech::GameVersion newVersion)
{
Expand All @@ -44,7 +43,7 @@ QString Rules::getDescription()
return description;
}

QList <BTech::GamePhase> Rules::getAllowedPhases()
QVector <BTech::GamePhase> Rules::getAllowedPhases()
{
return BTech::versionToPhaseList[getVersion()];
}
3 changes: 1 addition & 2 deletions src/BTCommon/Rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Q_OBJECT;
static BTech::GameVersion getVersion();
static void setDescription(const QString &description);
static QString getDescription();
static QList <BTech::GamePhase> getAllowedPhases();
static QVector <BTech::GamePhase> getAllowedPhases();

private:
Rules() = delete;
Expand All @@ -48,7 +48,6 @@ Q_OBJECT;

static BTech::GameVersion version;
static QString description;
static QList <BTech::GamePhase> allowedPhases;
};

#endif // RULES_H
6 changes: 3 additions & 3 deletions src/BTCommon/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const BiHash <BTech::GameVersion, QString> BTech::gameVersionStringChange {
{GameVersion::AdvancedBattleDroids, Strings::AdvancedBattleDroids},
};

const QHash <BTech::GameVersion, QList <BTech::GamePhase> > BTech::versionToPhaseList {
const QHash <BTech::GameVersion, QVector <BTech::GamePhase> > BTech::versionToPhaseList {
{GameVersion::BasicBattleDroids,
{GamePhase::Initiative, GamePhase::Movement, GamePhase::Combat, GamePhase::End}
},
Expand Down Expand Up @@ -322,9 +322,9 @@ QString BTech::General::bashColorString(const QString &string, const QColor& col
{Qt::yellow, "33m"},
{Qt::blue, "34m"},
};

static const QString pref = QString("\e[");

if (colorBashValue.contains(color))
return pref + colorBashValue[color] + string + pref + colorBashValue[Qt::white];
else
Expand Down
18 changes: 9 additions & 9 deletions src/BTCommon/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace BTech {
End = 7
};

static const QList <GamePhase> phases {
static const QVector <GamePhase> phases {
GamePhase::Initiative,
GamePhase::Movement,
GamePhase::Reaction,
Expand All @@ -65,14 +65,14 @@ namespace BTech {
AdvancedBattleDroids,
};

static const QList <GameVersion> gameVersions {
static const QVector <GameVersion> gameVersions {
GameVersion::BasicBattleDroids,
GameVersion::AdvancedBattleDroids
};

extern const BiHash <GameVersion, QString> gameVersionStringChange;

extern const QHash <GameVersion, QList <GamePhase> > versionToPhaseList;
extern const QHash <GameVersion, QVector <GamePhase> > versionToPhaseList;

QDataStream & operator << (QDataStream &out, const GameVersion &rules);
QDataStream & operator >> (QDataStream &in, GameVersion &rules);
Expand Down Expand Up @@ -160,20 +160,20 @@ namespace BTech {
OutOfRange = 4
};

static const std::array <Range, 5> ranges {
static const QVector <Range> ranges {
Range::Contact,
Range::Short,
Range::Medium,
Range::Long,
Range::OutOfRange,
};
static const std::array <Range, 4> attackRanges {
static const QVector <Range> attackRanges {
Range::Contact,
Range::Short,
Range::Medium,
Range::Long,
};
static const std::array <Range, 3> shootRanges {
static const QVector <Range> shootRanges {
Range::Short,
Range::Medium,
Range::Long,
Expand Down Expand Up @@ -240,7 +240,7 @@ namespace BTech {
TurnLeft,
};

const QList <MovementAction> movementActions = {
const QVector <MovementAction> movementActions = {
MovementAction::Idle,
MovementAction::Walk,
MovementAction::Run,
Expand All @@ -265,7 +265,7 @@ namespace BTech {
Charge
};

const QList <CombatAction> combatActions = {
const QVector <CombatAction> combatActions = {
CombatAction::Idle,
CombatAction::SimpleAttack,
CombatAction::WeaponAttack,
Expand All @@ -291,7 +291,7 @@ namespace BTech {
*/
namespace General {
QString indexString(const QString &string, const QList <QString> &existing);

QString bashColorString(const QString &string, const QColor &color);

// world timer
Expand Down
2 changes: 1 addition & 1 deletion src/BTCommon/WeaponBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int WeaponBase::getRangeModifier(int distance) const

int WeaponBase::getRangeModifier(BTech::Range range) const
{
return rangeModifier[toUnderlying(range)];
return rangeModifier[range];
}

BTech::Range WeaponBase::distanceToRange(int distance) const
Expand Down
4 changes: 2 additions & 2 deletions src/BTCommon/WeaponBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class WeaponBase

BTech::WeaponType type;

static const std::array <int, BTech::ranges.size()> rangeModifier;
static const QHash <BTech::Range, int> rangeModifier;
int minRange;
QHash <BTech::Range, int> maxRange;

Expand Down Expand Up @@ -142,7 +142,7 @@ namespace BTech {

extern const QHash <Modifier, QString> modifierStringChange;

static const std::array <Modifier, 7> modifiers {
static const QVector <Modifier> modifiers {
Modifier::Base,
Modifier::Range,
Modifier::Direction,
Expand Down

0 comments on commit aa965ed

Please sign in to comment.