E
E
Egorian2018-09-06 20:32:51
JavaScript
Egorian, 2018-09-06 20:32:51

What can be done to protect the code?

I'm making a game on pixijs+socketio. And there was a problem that the game is very vulnerable.
First, I will give the most vulnerable places in the code, and then I will explain.

# создание игрока и как я его перемещаю по карте
class Player{
constructor(){...}
move(x,y){
player.setTransform(x,y)
}
}
##########################
##########################
$("#move").on("click",function(){
                self.player.move(transformpos.x,transformpos.y)
               # эта функция выделяет создает поле радиусом 3х3 на карте(пошаговая игра) по которому игрок может передвигаться
               # притом функция создает  
               #кликабельные( rectangle.on("mousedown",function(){...... self.player.move()    } ) ) квадраты, 
               #при нажатии на которые игрок перемещается к нему
                actionzones= calcualteAviableZones("move",zone,3,map); 
            }
#########################
## отправка данных о перемещении игрока
$("#apply").on("click",function(){
             self.socket.emit('playerMovement', { 
                  x:self.player.circle.transform.position.x,
                  y: self.player.circle.transform.position.y,
                  prevPos:self.player.prevPos
                 });
                }
        });

With a utility like Resource Override, the client can change the code. What measures can be taken to make the code safer?
And now I can not single out the main actions to achieve the goal.
It would be possible to transfer the zone calculation to the server, but you still need to create clickable squares where self.player.move() will be, and Resource Override can be applied again.
The most important problem seems to me to be the movement of the player, but when the player moves anywhere, the client can get this data. Then you need to implement the movement using the server or how?
I know that maybe I'm asking about elementary things, but I'm doing a project of this kind for the first time

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question