(name)
| 1085 | |
| 1086 | class Direction { |
| 1087 | constructor (name) { |
| 1088 | this.name = name // 'up', 'down', 'left', 'right' |
| 1089 | if (this.name === 'up') { |
| 1090 | this.vector = new Vector(0, 1) |
| 1091 | } else if (this.name === 'down') { |
| 1092 | this.vector = new Vector(0, -1) |
| 1093 | } else if (this.name === 'left') { |
| 1094 | this.vector = new Vector(-1, 0) |
| 1095 | } else if (this.name === 'right') { |
| 1096 | this.vector = new Vector(1, 0) |
| 1097 | } else { |
| 1098 | const randomDirection = new Direction(_.sample(directionNames)) |
| 1099 | this.name = randomDirection.name |
| 1100 | this.vector = randomDirection.vector |
| 1101 | } |
| 1102 | } |
| 1103 | |
| 1104 | is (direction) { |
| 1105 | return this.name === direction.name |
nothing calls this directly
no outgoing calls
no test coverage detected