MCPcopy Create free account
hub / github.com/candybox2/candybox2.github.io / move

Method move

code/main/QuestEntity.ts:327–355  ·  view source on GitHub ↗
(pos: Pos, force: boolean = false)

Source from the content-addressed store, hash-verified

325 }
326
327 public move(pos: Pos, force: boolean = false): boolean{
328 // BUGS
329 if(Bugs.getQuestBugLevel() >= 3 || (Bugs.getQuestBugLevel() >= 2 && Random.oneChanceOutOf(3)) || (Bugs.getQuestBugLevel() >= 1 && Random.oneChanceOutOf(5))){
330 pos.x += Random.between(1, 3) - 2;
331 pos.y += Random.between(1, 3) - 2;
332 }
333
334 // If we're not a turtle or this isn't a pure horizontal movement (turtles only care about horizontal movement)
335 if(this.turtle == false || pos.y != 0)
336 return this.setGlobalPosition(this.globalPosition.plus(pos), force);
337 // Else, we're a turtle
338 else{
339 // We check the duration
340 if(this.turtleDuration > 0){
341 this.turtleDuration -= 1;
342 }
343 else this.stopTurtle();
344 // If the movement is >= 2
345 if(this.turtleLastMovement >= 2){
346 this.turtleLastMovement = 0; // We reset the movement
347 return this.setGlobalPosition(this.globalPosition.plus(pos), force); // We move
348 }
349 // Else, we increase the movement
350 else{
351 this.turtleLastMovement += 1;
352 return false;
353 }
354 }
355 }
356
357 public moveWormsLike(pos: Pos): boolean{
358 // If we can move normally

Callers 4

forceMovingMethod · 0.95
moveWormsLikeMethod · 0.95
handleGravityMethod · 0.95
handleMovementMethod · 0.95

Calls 3

setGlobalPositionMethod · 0.95
stopTurtleMethod · 0.95
plusMethod · 0.80

Tested by

no test coverage detected