playermanager.cpp 428 B

1234567891011121314151617181920212223
  1. #include "playermanager.h"
  2. #include <cassert>
  3. PlayerManager::PlayerManager(QObject *parent) : QObject(parent)
  4. {
  5. }
  6. Player* PlayerManager::getPlayer(int id) {
  7. assert(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. }