Guest User

Untitled

a guest
Sep 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. Update Progress:
  2.  
  3. public void updateProgress(MapleMap next, MapleMap from) {
  4. if (MapleRace.getMinutesUntilBegin() < 0) { // if they try to start early, wat
  5. if (next.getId() != map.getLeft()) //at this point, this is basically saying if it isnt the first map of the race
  6. racer.getCharacter().changeMap(from);
  7. return;
  8. }
  9. //a check if they reach the end of a list
  10. synchronized(this) { //order is crucial here, multi-threaded "photo finish" moment.
  11. if (next.getId() == racing_track.get((stage - 1)).get(racing_track.get((stage - 1)).size()).getLeft()) {
  12. if (MapleRace.STAGES_USE > stage) { //if they have more to go
  13. ++stage;
  14. MapleRace.announce("Racer #" + racer.getRacingId() + " has moved on to stage " + stage + " of the Great Maple Race!");
  15. racer.getCharacter().changeMap(ChannelServer.getInstance(1).getMapFactory().getMap(racing_track.get((stage - 1)).get(0).getLeft()));
  16. } else {
  17. MapleRace.announce("Racer #" + racer.getRacingId() + " has won the Great Maple Race!!! Please give him/her a huge congratulations!");
  18. racer.award();
  19. MapleRace.end();
  20. }
  21. }
  22. }
  23.  
  24. Pair<Integer, Integer> update = new Pair<>(next.getId(), (point + 1));
  25. if (racing_track.get((stage - 1)).contains(update)) { //checks for valid global coordinate
  26. ++point;
  27. this.map = update;
  28. MapleRace.announce("Racer #" + racer.getRacingId() + " has progressed to " + next.getMapName() + " (point " + point + ")");
  29.  
  30. } else {
  31. client.MapleCharacter c = racer.getCharacter();
  32.  
  33. c.dropMessage(6, "You're going the wrong way!!! Follow the map! Head east!");
  34. int sendBack = racing_track.get((stage - 1)).contains(new Pair<>(from.getId(), point)) ? map.getLeft() : racing_track.get(0).get(0).getLeft();
  35.  
  36. this.map = new Pair<>(sendBack, 1);
  37. c.changeMap(ChannelServer.getInstance(1).getMapFactory().getMap(sendBack)); // previous map or beginning
  38. }
  39. }
  40.  
  41. ________________
  42.  
  43.  
  44. Change map:
  45.  
  46. private void changeMapInternal(final MapleMap to, final Point pos, byte[] warpPacket, final MaplePortal pto) {
  47. if (to == null || MapleRace.getMinutesUntilBegin() < 0 && MapleRace.getMinutesUntilBegin() > -2 && getRacerIdentity() != null) {
  48. return;
  49. }
  50. final int nowmapid = map.getId();
  51. if (eventInstance != null) {
  52. eventInstance.changedMap(this, to.getId());
  53. }
  54. final boolean pyramid = pyramidSubway != null;
  55. if (map.getId() == nowmapid) {
  56. client.getSession().write(warpPacket);
  57. final boolean shouldChange = !isClone() && client.getChannelServer().getPlayerStorage().getCharacterById(getId()) != null;
  58. final boolean shouldState = map.getId() == to.getId();
  59. if (shouldChange && shouldState) {
  60. to.setCheckStates(false);
  61. }
  62. map.removePlayer(this);
  63. if (shouldChange) {
  64. map = to;
  65. setPosition(pos);
  66. to.addPlayer(this);
  67. stats.relocHeal(this);
  68. if (shouldState) {
  69. to.setCheckStates(true);
  70. }
  71. }
  72. }
  73. if (this.getRacingId() > -1 && this.getRacerIdentity() != null) {
  74. getRacerIdentity().getProgress().updateProgress(to, map);
  75. }
  76. if (pyramid && pyramidSubway != null) { //checks if they had pyramid before AND after changing
  77. pyramidSubway.onChangeMap(this, to.getId());
  78. }
  79. }
Add Comment
Please, Sign In to add comment