Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Spawn point #75

wants to merge 2 commits into from

Conversation

lisasasasa
Copy link
Collaborator

No description provided.

Comment on lines 297 to 300
// {Number} x - Character's x coordinate.
setDefaultValue(playerData, 'x', -1);
// {Number} y - Characetr's y coordinate.
setDefaultValue(playerData, 'y', -1);
Copy link
Collaborator

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.

Comment on lines 169 to 170
firstLocation.x = socket.playerData.x;
firstLocation.y = socket.playerData.y;
Copy link
Collaborator

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.

@@ -174,6 +191,8 @@ class _SingleGameMap {
}

this.dynamicCellSet = {};
this.spawnpointCellSet = [];
this.spawn_point_list = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CamalCase?

* @param {MapCoord} coord - The map coordinate.
* @return {list} spawn point - A list of the spawn point.
*/
getSpawnPoint(coord){
Copy link
Collaborator

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.

}
return this.spawn_point_list;
}
/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant code?

@@ -192,6 +211,9 @@ class _SingleGameMap {
dynamic: false
});
}
if(cellSet.name == "SpawnPoint"){
Copy link
Collaborator

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.

* @param {int} movex , movey
* @return {list} spawn point - A list of the spawn point.
*/
getSpawnPoint(movex, movey){
Copy link
Collaborator

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.

*/
getSpawnPoint(movex, movey){
if(this.spawn_point_list.length == 0){
for(cell in this.spawnpointCellSet){
Copy link
Collaborator

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.

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 */
Copy link
Collaborator

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?

set_location = 1 ;/*set spawn point */
if(set_location != -1){
firstLocation.x = spawn_point[index].x;
firstLocation.y = spawn_point[index].y;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break here?

firstLocation.x = spawn_point[index].x;
firstLocation.y = spawn_point[index].y;
}
index = index + 1;
Copy link
Collaborator

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?)

@john0312
Copy link
Collaborator

Please consider squashing the commits. Also please rebase, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants