Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. class GameControler {
  2. constructor() {
  3. this.getCoordinates = this.getCoordinates.bind(this)
  4. this.findCoordinate = this.findCoordinate.bind(this)
  5. this.getCurrentPath = this.getCurrentPath.bind(this)
  6.  
  7.  
  8. }
  9.  
  10. _shipCoordinates() {
  11. return [
  12.  
  13. {id: 1, x: 671 , y: 855 ,entity:1},
  14. {id: 2, x: 580 , y: 834 , entity:1,obsticle: {bonus: 3}, // daugiklis x2
  15. {id: 3, x: 494 , y: 784 , entity:1,obsticle: {penalty: -1}, // new game
  16. {id: 4, x: 547 , y: 707 ,entity:1},
  17. {id: 5, x: 602 , y: 625 , entity:1,obsticle: {penalty: {test: -1}}}, // testas
  18. {id: 6, x: 499 , y: 601 , entity:1,obsticle: {bonus: {multiply: 1 }}},, // daugiklis x2
  19. {id: 7, x: 400 , y: 623, entity:1},
  20. {id: 8, x: 315 , y: 583 ,entity:1},
  21. {id: 9, x: 285 , y: 501, entity:1},
  22. {id: 10, x:207 , y: 434 ,entity:1, obsticle: {penalty: {backstep: -1}}}, // 3 zingsniai atgal
  23. {id: 11, x: 248 , y: 346 , entity:2},
  24. {id: 12, x: 281 , y: 256 , entity:2},
  25. {id: 13, x: 343 ,y: 196 , entity:2},
  26. {id: 14, x: 436 , y:208 , entity:2},
  27. {id: 15, x: 540 , y: 216 ,entity:2 , obsticle: {penalty: {backstep: -1}}}, // 3 zingsniai atgal
  28. {id: 16, x: 630 , y: 193 ,entity:2 , obsticle: {penalty: {newgame: -1}}},
  29. {id: 17, x: 708 , y: 207 , entity:2 , obsticle: {bonus: {stepfurther: 1 }}}, // 2 zingsniai i prieki ( laimi zaidima )
  30. {id: 18, x: 751 , y: 275 ,entity:2 , obsticle: {penalty: {test: -1}}}, // testas
  31. {id: 19, x: 806 , y: 323 , entity:2},
  32.  
  33. ]
  34. }
  35. getCoordinates(req, res, next){
  36. const dice = 2
  37. const activePosition = 3
  38. const amount = 19
  39. const coordinates = this._shipCoordinates()
  40. return res.json(coordinates)
  41. }
  42.  
  43.  
  44. findCoordinate(req, res, next) {
  45. const coordinateId = parseInt(req.body.coordinateId) || 0
  46. const coordinates = this._shipCoordinates()
  47. const amount = coordinates.length
  48. let result = {}
  49. for (let i = 0; i < amount; i++) {
  50. let coordinate = coordinates[i]
  51. if (coordinate.id == coordinateId) {
  52. result = coordinate
  53. break
  54. }
  55. }
  56. }
  57.  
  58. getCurrentPath(){
  59. const dice = 2
  60. const activePosition = 3
  61. const amount = 19
  62.  
  63. const pathFinderService = new pathFinderService(dice, activePosition, amount)
  64. const result = pathFinderService.getPath()
  65. console.log(dice)
  66. return res.json(result)
  67.  
  68. }
  69.  
  70. }
  71.  
  72. module.exports = GameControler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement