server for my chess game
Diffstat (limited to 'src/infos.js')
-rw-r--r--src/infos.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/infos.js b/src/infos.js
new file mode 100644
index 0000000..0e2e129
--- /dev/null
+++ b/src/infos.js
@@ -0,0 +1,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;
+ }
+}