QTfrontend/team.cpp
changeset 13708 3264a26bbf8b
parent 13284 b504131f7405
child 14477 4b678aad50e9
equal deleted inserted replaced
13707:043f694d25d9 13708:3264a26bbf8b
    52     {
    52     {
    53         m_binds.append(BindAction());
    53         m_binds.append(BindAction());
    54         m_binds[i].action = cbinds[i].action;
    54         m_binds[i].action = cbinds[i].action;
    55         m_binds[i].strbind = QString();
    55         m_binds[i].strbind = QString();
    56     }
    56     }
    57     m_rounds = 0;
       
    58     m_wins = 0;
       
    59     m_campaignProgress = 0;
       
    60     m_color = 0;
    57     m_color = 0;
    61 }
    58 }
    62 
    59 
    63 HWTeam::HWTeam(const QStringList& strLst) :
    60 HWTeam::HWTeam(const QStringList& strLst) :
    64     QObject(0)
    61     QObject(0)
    81         m_hedgehogs[i].Hat=strLst[i * 2 + 8];
    78         m_hedgehogs[i].Hat=strLst[i * 2 + 8];
    82 // Somehow claymore managed an empty hat.  Until we figure out how, this should avoid a repeat
    79 // Somehow claymore managed an empty hat.  Until we figure out how, this should avoid a repeat
    83 // Checking net teams is probably pointless, but can't hurt.
    80 // Checking net teams is probably pointless, but can't hurt.
    84         if (m_hedgehogs[i].Hat.isEmpty()) m_hedgehogs[i].Hat = "NoHat";
    81         if (m_hedgehogs[i].Hat.isEmpty()) m_hedgehogs[i].Hat = "NoHat";
    85     }
    82     }
    86     m_rounds = 0;
       
    87     m_wins = 0;
       
    88     m_campaignProgress = 0;
       
    89     m_color = 0;
    83     m_color = 0;
    90 }
    84 }
    91 
    85 
    92 HWTeam::HWTeam() :
    86 HWTeam::HWTeam() :
    93     QObject(0)
    87     QObject(0)
   112     {
   106     {
   113         m_binds.append(BindAction());
   107         m_binds.append(BindAction());
   114         m_binds[i].action = cbinds[i].action;
   108         m_binds[i].action = cbinds[i].action;
   115         m_binds[i].strbind = QString();
   109         m_binds[i].strbind = QString();
   116     }
   110     }
   117     m_rounds = 0;
       
   118     m_wins = 0;
       
   119     m_campaignProgress = 0;
       
   120     m_color = 0;
   111     m_color = 0;
   121 }
   112 }
   122 
   113 
   123 HWTeam::HWTeam(const HWTeam & other) :
   114 HWTeam::HWTeam(const HWTeam & other) :
   124     QObject(0)
   115     QObject(0)
   133     , m_binds(other.m_binds)
   124     , m_binds(other.m_binds)
   134     , m_numHedgehogs(other.m_numHedgehogs)
   125     , m_numHedgehogs(other.m_numHedgehogs)
   135     , m_color(other.m_color)
   126     , m_color(other.m_color)
   136     , m_isNetTeam(other.m_isNetTeam)
   127     , m_isNetTeam(other.m_isNetTeam)
   137     , m_owner(other.m_owner)
   128     , m_owner(other.m_owner)
   138     , m_campaignProgress(other.m_campaignProgress)
       
   139     , m_rounds(other.m_rounds)
       
   140     , m_wins(other.m_wins)
       
   141 //      , AchievementProgress(other.AchievementProgress)
   129 //      , AchievementProgress(other.AchievementProgress)
   142 {
   130 {
   143 
   131 
   144 }
   132 }
   145 
   133 
   158         m_binds = other.m_binds;
   146         m_binds = other.m_binds;
   159         m_numHedgehogs = other.m_numHedgehogs;
   147         m_numHedgehogs = other.m_numHedgehogs;
   160         m_color = other.m_color;
   148         m_color = other.m_color;
   161         m_isNetTeam = other.m_isNetTeam;
   149         m_isNetTeam = other.m_isNetTeam;
   162         m_owner = other.m_owner;
   150         m_owner = other.m_owner;
   163         m_campaignProgress = other.m_campaignProgress;
       
   164         m_rounds = other.m_rounds;
       
   165         m_wins = other.m_wins;
       
   166         m_color = other.m_color;
   151         m_color = other.m_color;
   167     }
   152     }
   168 
   153 
   169     return *this;
   154     return *this;
   170 }
   155 }
   177     m_grave = teamfile.value("Team/Grave", "Statue").toString();
   162     m_grave = teamfile.value("Team/Grave", "Statue").toString();
   178     m_fort = teamfile.value("Team/Fort", "Plane").toString();
   163     m_fort = teamfile.value("Team/Fort", "Plane").toString();
   179     m_voicepack = teamfile.value("Team/Voicepack", "Default").toString();
   164     m_voicepack = teamfile.value("Team/Voicepack", "Default").toString();
   180     m_flag = teamfile.value("Team/Flag", "hedgewars").toString();
   165     m_flag = teamfile.value("Team/Flag", "hedgewars").toString();
   181     m_difficulty = teamfile.value("Team/Difficulty", 0).toInt();
   166     m_difficulty = teamfile.value("Team/Difficulty", 0).toInt();
   182     m_rounds = teamfile.value("Team/Rounds", 0).toInt();
       
   183     m_wins = teamfile.value("Team/Wins", 0).toInt();
       
   184     m_campaignProgress = teamfile.value("Team/CampaignProgress", 0).toInt();
       
   185     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
   167     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
   186     {
   168     {
   187         QString hh = QString("Hedgehog%1/").arg(i);
   169         QString hh = QString("Hedgehog%1/").arg(i);
   188         m_hedgehogs[i].Name = teamfile.value(hh + "Name", QString("Hedgehog %1").arg(i+1)).toString();
   170         m_hedgehogs[i].Name = teamfile.value(hh + "Name", QString("Hedgehog %1").arg(i+1)).toString();
   189         m_hedgehogs[i].Hat = teamfile.value(hh + "Hat", "NoHat").toString();
   171         m_hedgehogs[i].Hat = teamfile.value(hh + "Hat", "NoHat").toString();
   190         m_hedgehogs[i].Rounds = teamfile.value(hh + "Rounds", 0).toInt();
       
   191         m_hedgehogs[i].Kills = teamfile.value(hh + "Kills", 0).toInt();
       
   192         m_hedgehogs[i].Deaths = teamfile.value(hh + "Deaths", 0).toInt();
       
   193         m_hedgehogs[i].Suicides = teamfile.value(hh + "Suicides", 0).toInt();
       
   194     }
   172     }
   195     for(int i = 0; i < BINDS_NUMBER; i++)
   173     for(int i = 0; i < BINDS_NUMBER; i++)
   196         m_binds[i].strbind = teamfile.value(QString("Binds/%1").arg(m_binds[i].action), QString()).toString();
   174         m_binds[i].strbind = teamfile.value(QString("Binds/%1").arg(m_binds[i].action), QString()).toString();
   197     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
   175     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
   198         if(achievements[i][0][0])
   176         if(achievements[i][0][0])
   242     teamfile.setValue("Team/Grave", m_grave);
   220     teamfile.setValue("Team/Grave", m_grave);
   243     teamfile.setValue("Team/Fort", m_fort);
   221     teamfile.setValue("Team/Fort", m_fort);
   244     teamfile.setValue("Team/Voicepack", m_voicepack);
   222     teamfile.setValue("Team/Voicepack", m_voicepack);
   245     teamfile.setValue("Team/Flag", m_flag);
   223     teamfile.setValue("Team/Flag", m_flag);
   246     teamfile.setValue("Team/Difficulty", m_difficulty);
   224     teamfile.setValue("Team/Difficulty", m_difficulty);
   247     teamfile.setValue("Team/Rounds", m_rounds);
       
   248     teamfile.setValue("Team/Wins", m_wins);
       
   249     teamfile.setValue("Team/CampaignProgress", m_campaignProgress);
       
   250 
   225 
   251     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
   226     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
   252     {
   227     {
   253         QString hh = QString("Hedgehog%1/").arg(i);
   228         QString hh = QString("Hedgehog%1/").arg(i);
   254         teamfile.setValue(hh + "Name", m_hedgehogs[i].Name);
   229         teamfile.setValue(hh + "Name", m_hedgehogs[i].Name);
   255         teamfile.setValue(hh + "Hat", m_hedgehogs[i].Hat);
   230         teamfile.setValue(hh + "Hat", m_hedgehogs[i].Hat);
   256         teamfile.setValue(hh + "Rounds", m_hedgehogs[i].Rounds);
       
   257         teamfile.setValue(hh + "Kills", m_hedgehogs[i].Kills);
       
   258         teamfile.setValue(hh + "Deaths", m_hedgehogs[i].Deaths);
       
   259         teamfile.setValue(hh + "Suicides", m_hedgehogs[i].Suicides);
       
   260     }
   231     }
   261     for(int i = 0; i < BINDS_NUMBER; i++)
   232     for(int i = 0; i < BINDS_NUMBER; i++)
   262         teamfile.setValue(QString("Binds/%1").arg(m_binds[i].action), m_binds[i].strbind);
   233         teamfile.setValue(QString("Binds/%1").arg(m_binds[i].action), m_binds[i].strbind);
   263     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
   234     for(int i = 0; i < MAX_ACHIEVEMENTS; i++)
   264         if(achievements[i][0][0])
   235         if(achievements[i][0][0])
   428 QString HWTeam::voicepack() const
   399 QString HWTeam::voicepack() const
   429 {
   400 {
   430     return m_voicepack;
   401     return m_voicepack;
   431 }
   402 }
   432 
   403 
   433 
       
   434 // campaignProgress - getter
       
   435 unsigned int HWTeam::campaignProgress() const
       
   436 {
       
   437     return m_campaignProgress;
       
   438 };
       
   439 
       
   440 // amount of hedgehogs
   404 // amount of hedgehogs
   441 unsigned char HWTeam::numHedgehogs() const
   405 unsigned char HWTeam::numHedgehogs() const
   442 {
   406 {
   443     return m_numHedgehogs;
   407     return m_numHedgehogs;
   444 }
   408 }
   445 void HWTeam::setNumHedgehogs(unsigned char num)
   409 void HWTeam::setNumHedgehogs(unsigned char num)
   446 {
   410 {
   447     m_numHedgehogs = num;
   411     m_numHedgehogs = num;
   448 }
   412 }
   449 
   413 
   450 
       
   451 
       
   452 // rounds+wins - incrementors
       
   453 void HWTeam::incRounds()
       
   454 {
       
   455     m_rounds++;
       
   456 }
       
   457 void HWTeam::incWins()
       
   458 {
       
   459     m_wins++;
       
   460 }
       
   461