Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GameControler {
- constructor() {
- this.getCoordinates = this.getCoordinates.bind(this)
- this.findCoordinate = this.findCoordinate.bind(this)
- this.getCurrentPath = this.getCurrentPath.bind(this)
- }
- _shipCoordinates() {
- return [
- {id: 1, x: 671 , y: 855 ,entity:1},
- {id: 2, x: 580 , y: 834 , entity:1,obsticle: {bonus: 3}, // daugiklis x2
- {id: 3, x: 494 , y: 784 , entity:1,obsticle: {penalty: -1}, // new game
- {id: 4, x: 547 , y: 707 ,entity:1},
- {id: 5, x: 602 , y: 625 , entity:1,obsticle: {penalty: {test: -1}}}, // testas
- {id: 6, x: 499 , y: 601 , entity:1,obsticle: {bonus: {multiply: 1 }}},, // daugiklis x2
- {id: 7, x: 400 , y: 623, entity:1},
- {id: 8, x: 315 , y: 583 ,entity:1},
- {id: 9, x: 285 , y: 501, entity:1},
- {id: 10, x:207 , y: 434 ,entity:1, obsticle: {penalty: {backstep: -1}}}, // 3 zingsniai atgal
- {id: 11, x: 248 , y: 346 , entity:2},
- {id: 12, x: 281 , y: 256 , entity:2},
- {id: 13, x: 343 ,y: 196 , entity:2},
- {id: 14, x: 436 , y:208 , entity:2},
- {id: 15, x: 540 , y: 216 ,entity:2 , obsticle: {penalty: {backstep: -1}}}, // 3 zingsniai atgal
- {id: 16, x: 630 , y: 193 ,entity:2 , obsticle: {penalty: {newgame: -1}}},
- {id: 17, x: 708 , y: 207 , entity:2 , obsticle: {bonus: {stepfurther: 1 }}}, // 2 zingsniai i prieki ( laimi zaidima )
- {id: 18, x: 751 , y: 275 ,entity:2 , obsticle: {penalty: {test: -1}}}, // testas
- {id: 19, x: 806 , y: 323 , entity:2},
- ]
- }
- getCoordinates(req, res, next){
- const dice = 2
- const activePosition = 3
- const amount = 19
- const coordinates = this._shipCoordinates()
- return res.json(coordinates)
- }
- findCoordinate(req, res, next) {
- const coordinateId = parseInt(req.body.coordinateId) || 0
- const coordinates = this._shipCoordinates()
- const amount = coordinates.length
- let result = {}
- for (let i = 0; i < amount; i++) {
- let coordinate = coordinates[i]
- if (coordinate.id == coordinateId) {
- result = coordinate
- break
- }
- }
- }
- getCurrentPath(){
- const dice = 2
- const activePosition = 3
- const amount = 19
- const pathFinderService = new pathFinderService(dice, activePosition, amount)
- const result = pathFinderService.getPath()
- console.log(dice)
- return res.json(result)
- }
- }
- module.exports = GameControler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement