-
Notifications
You must be signed in to change notification settings - Fork 61
/
MoveHistory.js
38 lines (33 loc) · 904 Bytes
/
MoveHistory.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
class MoveHistory{
constructor() {
this.moveHistoryList=[];
}
addDirectionalMove(x,y){
if(x === -1){
this.moveHistoryList.push("LEFT");
}else if(x === 1){
this.moveHistoryList.push("RIGHT");
}else if(y === 1){
this.moveHistoryList.push("DOWN");
}else{
print(`ERROR BRO WHAT THE FUCK IS: ${x}, ${y}`);
}
}
addRotationMove(){
this.moveHistoryList.push("ROTATE");
}
addHoldMove(addToTail = true){
if(addToTail){
this.moveHistoryList.push("HOLD");
}else{
this.moveHistoryList.unshift("HOLD");
}
}
clone(){
let clone = new MoveHistory();
for(let i = 0 ; i < this.moveHistoryList.length;i++){
clone.moveHistoryList.push(""+ this.moveHistoryList[i]);
}
return clone;
}
}