MCPcopy Create free account
hub / github.com/codecombat/codecombat / constructor

Method constructor

app/lib/level-generation.js:1087–1102  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

1085
1086class 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected