-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spawn point #75
Spawn point #75
Conversation
common/rpc-directory/directory.mjs
Outdated
// {Number} x - Character's x coordinate. | ||
setDefaultValue(playerData, 'x', -1); | ||
// {Number} y - Characetr's y coordinate. | ||
setDefaultValue(playerData, 'y', -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, character's coordinate is stored in playerData.mapCoord
You should not add x and y like this.
services/gateway/gateway-service.mjs
Outdated
firstLocation.x = socket.playerData.x; | ||
firstLocation.y = socket.playerData.y; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use playerData.mapCoord.x
and player.mapCoord.y
.
common/maplib/map.mjs
Outdated
@@ -174,6 +191,8 @@ class _SingleGameMap { | |||
} | |||
|
|||
this.dynamicCellSet = {}; | |||
this.spawnpointCellSet = []; | |||
this.spawn_point_list = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CamalCase?
common/maplib/map.mjs
Outdated
* @param {MapCoord} coord - The map coordinate. | ||
* @return {list} spawn point - A list of the spawn point. | ||
*/ | ||
getSpawnPoint(coord){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is coord for? The list of spawn points should be unrelated to a coordinate. i.e. The list of spawn point should always be the same, there shouldn't be a coord input parameter that could change the list of spawn points.
Note that a coordinate is denoted by (world, x, y), whereby (x,y) could be the same for different world.
common/maplib/map.mjs
Outdated
} | ||
return this.spawn_point_list; | ||
} | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant code?
common/maplib/map.mjs
Outdated
@@ -192,6 +211,9 @@ class _SingleGameMap { | |||
dynamic: false | |||
}); | |||
} | |||
if(cellSet.name == "SpawnPoint"){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider creating a hash table style map from cellSet name to the cellSet in this.gameMap.cellSet.
This would eliminate the need to store the SpawnPoint cellset's .cells in this.spawnpointCellSet. You can directly grab the cellSet's .cell in getSpawnPoint() through the map.
common/maplib/map.mjs
Outdated
* @param {int} movex , movey | ||
* @return {list} spawn point - A list of the spawn point. | ||
*/ | ||
getSpawnPoint(movex, movey){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a more generic function, i.e. getCellsInStaticCellSet(), returning a list of MapCoord.
common/maplib/map.mjs
Outdated
*/ | ||
getSpawnPoint(movex, movey){ | ||
if(this.spawn_point_list.length == 0){ | ||
for(cell in this.spawnpointCellSet){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider const cell in ...
Ditto below.
services/gateway/gateway-service.mjs
Outdated
let spawn_point = this.gameMap.getSpawnPoint(firstLocation.mapCoord); | ||
spawn_point.sort(() => Math.random() - 0.5); | ||
while(set_location == -1 && index < spawn_point.length){ | ||
set_location = 1 ;/*set spawn point */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the function call to take the location and call that function here?
services/gateway/gateway-service.mjs
Outdated
set_location = 1 ;/*set spawn point */ | ||
if(set_location != -1){ | ||
firstLocation.x = spawn_point[index].x; | ||
firstLocation.y = spawn_point[index].y; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break here?
services/gateway/gateway-service.mjs
Outdated
firstLocation.x = spawn_point[index].x; | ||
firstLocation.y = spawn_point[index].y; | ||
} | ||
index = index + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error handling if no location is found? (i.e. disconnect the player or just let it wait?)
Please consider squashing the commits. Also please rebase, thank you. |
No description provided.