<commit_before>
var Room = function( sync_settings ) {
	this.rooms = {};
	this.sockets = {};
	sync = sync_settings;
  // this.allianceCount = 0;
  // this.rebelCount = 0;
};

Room.prototype = Object.create({});

Room.prototype.init = function( socket, room, playerData ) {
  console.log(playerData);
  this.rooms[room] = {};
  this.rooms[room].gamestate = {};
  this.rooms[room].playerList = {};
  // if ( <= ) {
  //   playerData.team = 'alliance';
    this.rooms[room].playerList[playerData.name] = playerData;
  //   this.teamToggle = false;
  // } else {
  //   playerData.team = 'rebel';
  //   this.rooms[room].playerList[playerData.name] = playerData;
  //   this.teamToggle = true;
  // }
  this.sockets[socket.id] = {name: playerData.name, socket: socket.id, ship: playerData.ship, room: room};
};

Room.prototype.add = function( socket, room, playerData) {
  this.sockets[socket.id] = {name: playerData.name, room: room, ship: playerData.ship};
  this.rooms[room].playerList[playerData.name] = playerData;
};


module.exports = Room;
//write a test for init.
//write a test for sync;<commit_msg>added teamlogic to rooms if teammode is on. currently teammode is hardcoded in<commit_after>
var Room = function( sync_settings ) {
	this.rooms = {};
	this.sockets = {};
	sync = sync_settings;
};

Room.prototype = Object.create({});

Room.prototype.init = function( socket, room, playerData ) {
  // make a room with a playerlist and the
  // 'gamestate' of all player positions:
  var roomProperties = {
    gamestate: {},
    playerList: {},
    teamMode: true,
  };

  if (roomProperties.teamMode === true){ // team mode currently DNE
    // make the first player alliance
    playerData.team = 'alliance';
    // extend the rooms so that they
    // account for teams balance
    roomProperties.allianceCount = 1;
    roomProperties.rebelCount = 0;
  }

  roomProperties.playerList[playerData.name] = playerData;

  this.rooms[room] = roomProperties;
  this.sockets[socket.id] = {
    name: playerData.name,
    team: playerData.team,
    socket: socket.id,
    ship: playerData.ship,
    room: room
  };
};

Room.prototype.add = function( socket, room, playerData) {
  var roomData = this.rooms[room];
  if (roomData.teamMode === true){ // team mode currently DNE
    playerData.team = ( roomData.allianceCount < roomData.rebelCount ) ? 'alliance' : 'rebel';
    roomData[playerData.team]++;
  }

  roomData.playerList[playerData.name] = playerData;
  this.sockets[socket.id] = {
    name: playerData.name,
    team: playerData.team,
    socket: socket.id,
    ship: playerData.ship,
    room: roomData
  };
};


module.exports = Room;
//write a test for init.
//write a test for sync;
{'fraction_non_alphanumeric': 0.1469387755102041, 'fraction_numerical': 0.001484230055658627, 'mean_word_length': 3.3695299837925448, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '306626', 'n_tokens_mistral': 900, 'n_tokens_neox': 887, 'n_words': 208}