-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPalette.js
40 lines (34 loc) · 909 Bytes
/
Palette.js
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
31
32
33
34
35
36
37
38
39
40
/*
*/
if (ps.flags.SHOW_LOGS) console.log("Creating the Palette.");
ps.Palette = function () {
let that = this;
that.init = function () {
// stores Polyomino objects
that.polyominoes = new HashMap();
}
/*
Adds a given Polyomino to the Palette
*/
that.add = function (polyomino) {
that.polyominoes.set(ps.hashPolyomino(polyomino), polyomino);
}
/*
Removes a Polyomino from the Palette given a hashcode of a Polyomino
*/
that.remove = function (hash) {
that.polyominoes.remove(hash);
}
/*
Returns a String of ASCII Polyominoes that resembles the contents of the Palette
*/
that.toString = function () {
let temp = "The contents of the Palette:\n";
that.polyominoes.forEach(function (polyomino, hash) {
temp += polyomino.toString() + "\n";
});
return temp;
}
// init
that.init();
}