PlayerManager.cpp 437 B

12345678910111213141516171819202122
  1. #include "PlayerManager.h"
  2. #include <cassert>
  3. PlayerManager::PlayerManager(QObject *parent) : QObject(parent)
  4. {
  5. }
  6. Player* PlayerManager::getPlayer(int id) {
  7. assert(unsigned(id) < players_.size());
  8. return &players_[id];
  9. }
  10. int PlayerManager::getPlayersNum() {
  11. return players_.size();
  12. }
  13. void PlayerManager::setPlayersNum(int num) {
  14. players_.resize(num);
  15. for (int i = 0; i < num; i++)
  16. players_[i].init(i);
  17. }