QTfrontend/team.cpp
changeset 6616 f77bb02b669f
parent 6225 505643d4c23d
child 6700 e04da46ee43c
equal deleted inserted replaced
6615:65602f1ef0f8 6616:f77bb02b669f
    81     m_campaignProgress = 0;
    81     m_campaignProgress = 0;
    82 }
    82 }
    83 
    83 
    84 HWTeam::HWTeam() :
    84 HWTeam::HWTeam() :
    85     QObject(0)
    85     QObject(0)
    86   , m_difficulty(0)
    86     , m_difficulty(0)
    87   , m_numHedgehogs(4)
    87     , m_numHedgehogs(4)
    88   , m_isNetTeam(false)
    88     , m_isNetTeam(false)
    89 {
    89 {
    90     m_name = QString("Team");
    90     m_name = QString("Team");
    91     for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
    91     for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
    92     {
    92     {
    93         m_hedgehogs[i].Name.sprintf("hedgehog %d", i);
    93         m_hedgehogs[i].Name.sprintf("hedgehog %d", i);
   108     m_wins = 0;
   108     m_wins = 0;
   109     m_campaignProgress = 0;
   109     m_campaignProgress = 0;
   110 }
   110 }
   111 
   111 
   112 HWTeam::HWTeam(const HWTeam & other) :
   112 HWTeam::HWTeam(const HWTeam & other) :
   113         QObject(0)
   113     QObject(0)
   114         , OldTeamName(other.OldTeamName)
   114     , OldTeamName(other.OldTeamName)
   115         , m_name(other.m_name)
   115     , m_name(other.m_name)
   116         , m_grave(other.m_grave)
   116     , m_grave(other.m_grave)
   117         , m_fort(other.m_fort)
   117     , m_fort(other.m_fort)
   118         , m_flag(other.m_flag)
   118     , m_flag(other.m_flag)
   119         , m_voicepack(other.m_voicepack)
   119     , m_voicepack(other.m_voicepack)
   120         , m_hedgehogs(other.m_hedgehogs)
   120     , m_hedgehogs(other.m_hedgehogs)
   121         , m_difficulty(other.m_difficulty)
   121     , m_difficulty(other.m_difficulty)
   122         , m_binds(other.m_binds)
   122     , m_binds(other.m_binds)
   123         , m_numHedgehogs(other.m_numHedgehogs)
   123     , m_numHedgehogs(other.m_numHedgehogs)
   124         , m_color(other.m_color)
   124     , m_color(other.m_color)
   125         , m_isNetTeam(other.m_isNetTeam)
   125     , m_isNetTeam(other.m_isNetTeam)
   126         , m_owner(other.m_owner)
   126     , m_owner(other.m_owner)
   127         , m_campaignProgress(other.m_campaignProgress)
   127     , m_campaignProgress(other.m_campaignProgress)
   128         , m_rounds(other.m_rounds)
   128     , m_rounds(other.m_rounds)
   129         , m_wins(other.m_wins)
   129     , m_wins(other.m_wins)
   130 //      , AchievementProgress(other.AchievementProgress)
   130 //      , AchievementProgress(other.AchievementProgress)
   131 {
   131 {
   132 
   132 
   133 }
   133 }
   134 
   134 
   264             if(!m_binds[i].strbind.isEmpty())
   264             if(!m_binds[i].strbind.isEmpty())
   265                 sl.push_back(QString("ebind " + m_binds[i].strbind + " " + m_binds[i].action));
   265                 sl.push_back(QString("ebind " + m_binds[i].strbind + " " + m_binds[i].action));
   266 
   266 
   267     for (int t = 0; t < m_numHedgehogs; t++)
   267     for (int t = 0; t < m_numHedgehogs; t++)
   268     {
   268     {
   269       sl.push_back(QString("eaddhh %1 %2 %3")
   269         sl.push_back(QString("eaddhh %1 %2 %3")
   270                .arg(QString::number(m_difficulty),
   270                      .arg(QString::number(m_difficulty),
   271                 QString::number(InitHealth),
   271                           QString::number(InitHealth),
   272                 m_hedgehogs[t].Name));
   272                           m_hedgehogs[t].Name));
   273       sl.push_back(QString("ehat %1")
   273         sl.push_back(QString("ehat %1")
   274                .arg(m_hedgehogs[t].Hat));
   274                      .arg(m_hedgehogs[t].Hat));
   275     }
   275     }
   276     return sl;
   276     return sl;
   277 }
   277 }
   278 
   278 
   279 bool HWTeam::isNetTeam() const
   279 bool HWTeam::isNetTeam() const
   280 {
   280 {
   281   return m_isNetTeam;
   281     return m_isNetTeam;
   282 }
   282 }
   283 
   283 
   284 
   284 
   285 bool HWTeam::operator==(const HWTeam& t1) const {
   285 bool HWTeam::operator==(const HWTeam& t1) const
   286   return m_name==t1.m_name;
   286 {
   287 }
   287     return m_name==t1.m_name;
   288 
   288 }
   289 bool HWTeam::operator<(const HWTeam& t1) const {
   289 
   290   return m_name<t1.m_name; // if names are equal - test if it is net team
   290 bool HWTeam::operator<(const HWTeam& t1) const
       
   291 {
       
   292     return m_name<t1.m_name; // if names are equal - test if it is net team
   291 }
   293 }
   292 
   294 
   293 
   295 
   294 //// Methods for member inspection+modification ////
   296 //// Methods for member inspection+modification ////
   295 
   297 
   296 
   298 
   297 // name
   299 // name
   298 QString HWTeam::name() const { return m_name; }
   300 QString HWTeam::name() const
   299    void HWTeam::setName(const QString & name) { m_name = name; }
   301 {
       
   302     return m_name;
       
   303 }
       
   304 void HWTeam::setName(const QString & name)
       
   305 {
       
   306     m_name = name;
       
   307 }
   300 
   308 
   301 // single hedgehog
   309 // single hedgehog
   302 const HWHog & HWTeam::hedgehog(unsigned int idx) const { return m_hedgehogs[idx]; }
   310 const HWHog & HWTeam::hedgehog(unsigned int idx) const
   303          void HWTeam::setHedgehog(unsigned int idx, HWHog hh) { m_hedgehogs[idx] = hh; }
   311 {
       
   312     return m_hedgehogs[idx];
       
   313 }
       
   314 void HWTeam::setHedgehog(unsigned int idx, HWHog hh)
       
   315 {
       
   316     m_hedgehogs[idx] = hh;
       
   317 }
   304 
   318 
   305 // owner
   319 // owner
   306 QString HWTeam::owner() const { return m_owner; }
   320 QString HWTeam::owner() const
       
   321 {
       
   322     return m_owner;
       
   323 }
   307 
   324 
   308 
   325 
   309 
   326 
   310 // difficulty
   327 // difficulty
   311 unsigned int HWTeam::difficulty() const { return m_difficulty; }
   328 unsigned int HWTeam::difficulty() const
   312         void HWTeam::setDifficulty(unsigned int level) { m_difficulty = level; }
   329 {
       
   330     return m_difficulty;
       
   331 }
       
   332 void HWTeam::setDifficulty(unsigned int level)
       
   333 {
       
   334     m_difficulty = level;
       
   335 }
   313 
   336 
   314 // color
   337 // color
   315 QColor HWTeam::color() const { return m_color; }
   338 QColor HWTeam::color() const
   316   void HWTeam::setColor(const QColor & color) { m_color = color; }
   339 {
       
   340     return m_color;
       
   341 }
       
   342 void HWTeam::setColor(const QColor & color)
       
   343 {
       
   344     m_color = color;
       
   345 }
   317 
   346 
   318 
   347 
   319 // binds
   348 // binds
   320 QString HWTeam::keyBind(unsigned int idx) const { return m_binds[idx].strbind; }
   349 QString HWTeam::keyBind(unsigned int idx) const
   321    void HWTeam::bindKey(unsigned int idx, const QString & key) { m_binds[idx].strbind = key; }
   350 {
       
   351     return m_binds[idx].strbind;
       
   352 }
       
   353 void HWTeam::bindKey(unsigned int idx, const QString & key)
       
   354 {
       
   355     m_binds[idx].strbind = key;
       
   356 }
   322 
   357 
   323 // flag
   358 // flag
   324 void    HWTeam::setFlag(const QString & flag) { m_flag = flag; }
   359 void    HWTeam::setFlag(const QString & flag)
   325 QString HWTeam::flag() const { return m_flag; }
   360 {
       
   361     m_flag = flag;
       
   362 }
       
   363 QString HWTeam::flag() const
       
   364 {
       
   365     return m_flag;
       
   366 }
   326 
   367 
   327 // fort
   368 // fort
   328 void    HWTeam::setFort(const QString & fort) { m_fort = fort; }
   369 void    HWTeam::setFort(const QString & fort)
   329 QString HWTeam::fort() const { return m_fort; }
   370 {
       
   371     m_fort = fort;
       
   372 }
       
   373 QString HWTeam::fort() const
       
   374 {
       
   375     return m_fort;
       
   376 }
   330 
   377 
   331 // grave
   378 // grave
   332 void HWTeam::setGrave(const QString & grave) { m_grave = grave; }
   379 void HWTeam::setGrave(const QString & grave)
   333 QString HWTeam::grave() const { return m_grave; }
   380 {
       
   381     m_grave = grave;
       
   382 }
       
   383 QString HWTeam::grave() const
       
   384 {
       
   385     return m_grave;
       
   386 }
   334 
   387 
   335 // voicepack - getter/setter
   388 // voicepack - getter/setter
   336 void HWTeam::setVoicepack(const QString & voicepack) { m_voicepack = voicepack; }
   389 void HWTeam::setVoicepack(const QString & voicepack)
   337 QString HWTeam::voicepack() const { return m_voicepack; }
   390 {
       
   391     m_voicepack = voicepack;
       
   392 }
       
   393 QString HWTeam::voicepack() const
       
   394 {
       
   395     return m_voicepack;
       
   396 }
   338 
   397 
   339 
   398 
   340 // campaignProgress - getter
   399 // campaignProgress - getter
   341 unsigned int HWTeam::campaignProgress() const { return m_campaignProgress; };
   400 unsigned int HWTeam::campaignProgress() const
       
   401 {
       
   402     return m_campaignProgress;
       
   403 };
   342 
   404 
   343 // amount of hedgehogs
   405 // amount of hedgehogs
   344 unsigned char HWTeam::numHedgehogs() const { return m_numHedgehogs; }
   406 unsigned char HWTeam::numHedgehogs() const
   345          void HWTeam::setNumHedgehogs(unsigned char num) { m_numHedgehogs = num; }
   407 {
       
   408     return m_numHedgehogs;
       
   409 }
       
   410 void HWTeam::setNumHedgehogs(unsigned char num)
       
   411 {
       
   412     m_numHedgehogs = num;
       
   413 }
   346 
   414 
   347 
   415 
   348 
   416 
   349 // rounds+wins - incrementors
   417 // rounds+wins - incrementors
   350 void HWTeam::incRounds() { m_rounds++; }
   418 void HWTeam::incRounds()
   351 void HWTeam::incWins() { m_wins++; }
   419 {
   352 
   420     m_rounds++;
       
   421 }
       
   422 void HWTeam::incWins()
       
   423 {
       
   424     m_wins++;
       
   425 }
       
   426