server for my chess game
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { flip_int } from "./utils.js";

export class Infos {
  constructor(hosterIndex, hosterName, hosterCountry) {
    this.hosterIndex = hosterIndex;
    this.names = ["Anonymous", "Anonymous"];
    this.names[hosterIndex] = hosterName;
    this.countrys = ["rainbow", "rainbow"];
    this.countrys[hosterIndex] = hosterCountry;
  }
  get(index) {
    return {
      name: this.names[index],
      country: this.countrys[index],
    };
  }

  get_all() {
    return { w: this.get(0), b: this.get(1) };
  }

  get joinerIndex() {
    return flip_int(this.hosterIndex);
  }

  add(name, country) {
    this.names[this.joinerIndex] = name;
    this.countrys[this.joinerIndex] = country;
  }
}