Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.79 KB | None | 0 0
  1.  
  2. Tampermonkey®
  3. v4.8.41 by Jan Biniok
  4.  
  5. ROZBUDOWANE KTO TU JEST :D
  6. by Adi Wilk
  7. 1
  8. // ==UserScript==
  9. 2
  10. // @name ROZBUDOWANE KTO TU JEST :D
  11. 3
  12. // @version 2019
  13. 4
  14. // @description kto tu jest z podstawowymi funkcjami
  15. 5
  16. // @author Adi Wilk
  17. 6
  18. // @match http://*.margonem.pl/
  19. 7
  20. // @grant none
  21. 8
  22. // ==/UserScript==
  23. 9
  24. 10
  25. (function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;c<g.length;c++)a(g[c]);return a}return b})()({1:[function(a,b){function c(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=w(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function d(a){return void 0===a._maxListeners?c.defaultMaxListeners:a._maxListeners}function e(a,b,c){if(b)a.call(c);else for(var d=a.length,e=u(a,d),f=0;f<d;++f)e[f].call(c)}function f(a,b,c,d){if(b)a.call(c,d);else for(var e=a.length,f=u(a,e),g=0;g<e;++g)f[g].call(c,d)}function g(b,c,d,e,f){if(c)b.call(d,e,f);else for(var g=b.length,h=u(b,g),i=0;i<g;++i)h[i].call(d,e,f)}function h(b,c,d,e,f,g){if(c)b.call(d,e,f,g);else for(var h=b.length,i=u(b,h),a=0;a<h;++a)i[a].call(d,e,f,g)}function j(a,b,c,d){if(b)a.apply(c,d);else for(var e=a.length,f=u(a,e),g=0;g<e;++g)f[g].apply(c,d)}function k(b,c,e,f){var g,h,j;if("function"!=typeof e)throw new TypeError("\"listener\" argument must be a function");if(h=b._events,h?(h.newListener&&(b.emit("newListener",c,e.listener?e.listener:e),h=b._events),j=h[c]):(h=b._events=w(null),b._eventsCount=0),!j)j=h[c]=e,++b._eventsCount;else if("function"==typeof j?j=h[c]=f?[e,j]:[j,e]:f?j.unshift(e):j.push(e),!j.warned&&(g=d(b))&&0<g&&j.length>g){j.warned=!0;var k=new Error("Possible EventEmitter memory leak detected. "+j.length+" \""+(c+"\" listeners added. Use emitter.setMaxListeners() to increase limit."));k.name="MaxListenersExceededWarning",k.emitter=b,k.type=c,k.count=j.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",k.name,k.message)}return b}function l(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var a=Array(arguments.length),b=0;b<a.length;++b)a[b]=arguments[b];this.listener.apply(this.target,a);}}function m(a,b,c){var d={fired:!1,wrapFn:void 0,target:a,type:b,listener:c},e=y.call(l,d);return e.listener=c,d.wrapFn=e,e}function n(a,b,c){var d=a._events;if(!d)return[];var e=d[b];return e?"function"==typeof e?c?[e.listener||e]:[e]:c?v(e):u(e,e.length):[]}function p(a){var b=this._events;if(b){var c=b[a];if("function"==typeof c)return 1;if(c)return c.length}return 0}function q(a,b){for(var c=b,d=c+1,e=a.length;d<e;c+=1,d+=1)a[c]=a[d];a.pop()}function u(a,b){for(var c=Array(b),d=0;d<b;++d)c[d]=a[d];return c}function v(a){for(var b=Array(a.length),c=0;c<b.length;++c)b[c]=a[c].listener||a[c];return b}var w=Object.create||function(a){var b=function(){};return b.prototype=a,new b},x=Object.keys||function(a){var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return c},y=Function.prototype.bind||function(a){var b=this;return function(){return b.apply(a,arguments)}};b.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0;var z,A=10;try{var B={};Object.defineProperty&&Object.defineProperty(B,"x",{value:0}),z=0===B.x}catch(a){z=!1}z?Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return A},set:function(a){if("number"!=typeof a||0>a||a!==a)throw new TypeError("\"defaultMaxListeners\" must be a positive number");A=a}}):c.defaultMaxListeners=A,c.prototype.setMaxListeners=function(a){if("number"!=typeof a||0>a||isNaN(a))throw new TypeError("\"n\" argument must be a positive number");return this._maxListeners=a,this},c.prototype.getMaxListeners=function(){return d(this)},c.prototype.emit=function(b){var c,d,k,m,p,q,v="error"===b;if(q=this._events)v=v&&null==q.error;else if(!v)return!1;if(v){if(1<arguments.length&&(c=arguments[1]),c instanceof Error)throw c;var w=new Error("Unhandled \"error\" event. ("+c+")");throw w.context=c,w}if(!(d=q[b]))return!1;var l="function"==typeof d;switch(k=arguments.length){case 1:e(d,l,this);break;case 2:f(d,l,this,arguments[1]);break;case 3:g(d,l,this,arguments[1],arguments[2]);break;case 4:h(d,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(m=Array(k-1),p=1;p<k;p++)m[p-1]=arguments[p];j(d,l,this,m);}return!0},c.prototype.addListener=function(a,b){return k(this,a,b,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(a,b){return k(this,a,b,!0)},c.prototype.once=function(a,b){if("function"!=typeof b)throw new TypeError("\"listener\" argument must be a function");return this.on(a,m(this,a,b)),this},c.prototype.prependOnceListener=function(a,b){if("function"!=typeof b)throw new TypeError("\"listener\" argument must be a function");return this.prependListener(a,m(this,a,b)),this},c.prototype.removeListener=function(a,b){var c,d,e,f,g;if("function"!=typeof b)throw new TypeError("\"listener\" argument must be a function");if(!(d=this._events))return this;if(!(c=d[a]))return this;if(c===b||c.listener===b)0==--this._eventsCount?this._events=w(null):(delete d[a],d.removeListener&&this.emit("removeListener",a,c.listener||b));else if("function"!=typeof c){for(e=-1,f=c.length-1;0<=f;f--)if(c[f]===b||c[f].listener===b){g=c[f].listener,e=f;break}if(0>e)return this;0===e?c.shift():q(c,e),1===c.length&&(d[a]=c[0]),d.removeListener&&this.emit("removeListener",a,g||b)}return this},c.prototype.removeAllListeners=function(a){var b,c,d;if(!(c=this._events))return this;if(!c.removeListener)return 0===arguments.length?(this._events=w(null),this._eventsCount=0):c[a]&&(0==--this._eventsCount?this._events=w(null):delete c[a]),this;if(0===arguments.length){var e,f=x(c);for(d=0;d<f.length;++d)"removeListener"!==(e=f[d])&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events=w(null),this._eventsCount=0,this}if("function"==typeof(b=c[a]))this.removeListener(a,b);else if(b)for(d=b.length-1;0<=d;d--)this.removeListener(a,b[d]);return this},c.prototype.listeners=function(a){return n(this,a,!0)},c.prototype.rawListeners=function(a){return n(this,a,!1)},c.listenerCount=function(a,b){return"function"==typeof a.listenerCount?a.listenerCount(b):p.call(a,b)},c.prototype.listenerCount=p,c.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}],2:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=a("../core/Emmiter"),e=function(){function a(){this.div=document.createElement("div"),this.isActivated=!1,this.itemName=null===localStorage.getItem("adi-kto-tu-jest-itemName")?"Zw\xF3j teleportacji na Kwieciste Przej\u015Bcie":JSON.parse(localStorage.getItem("adi-kto-tu-jest-itemName")),this.init()}return a.prototype.getDiv=function(){return this.div},a.prototype.teleport=function(){var b=this,c=window.g,e=c.dead,f=c.battle;if(!0===e)return window.message("Nie \u017Cyjesz g\u0142upku...");if(!0===this.isActivated)return this.isActivated=!1,window.message("Ucieczka wy\u0142\u0105czona"),void d.default.removeListener(d.EVENTS_NAMES.BATTLE_CLOSE,this.listener);var g=this.findTeleportId();void 0===g?window.message("Nie posiadasz: "+this.itemName):(this.isActivated=!0,this.listener=function(){return window._g("moveitem&id="+g+"&st=1",function(){b.isActivated=!1})},[0,!1].includes(f)?window.message("Nie jeste\u015B w trakcie walki."):(window.message("Trwa walka, teleport zostanie u\u017Cyty po niej"),d.default.once(d.EVENTS_NAMES.BATTLE_CLOSE,this.listener)))},a.prototype.findTeleportId=function(){var a=this,b=Object.values(window.g.item).find(function(b){var c=b.name,d=b.loc;return c===a.itemName&&"g"===d});if(void 0!==b){var c=b.id;return parseInt(c,10)}},a.prototype.init=function(){this.div.classList.add("adi-kto-tu-jest-escape"),this.div.textContent="UCIECZKA",this.div.dataset.escape="escape",this.div.setAttribute("tip","Kliknij, aby uciec po walce")},a}();c.default=e},{"../core/Emmiter":6}],3:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d;!function(a){a.box="adi-kto-tu-jest-player",a.nick="nick",a.attack="attack"}(d||(d={}));var e;!function(a){a.GREEN="green",a.RED="red",a.LIGHTBLUE="lightblue",a.NONE="default"}(e||(e={}));var f=function(){function a(b){var c=b.id,d=b.nick,e=b.lvl,f=b.prof,g=b.relation;this.div=document.createElement("div"),this.id=parseInt(c,10),this.nick=d,this.lvl=e,this.prof=f,this.relation=g,this.init()}return a.prototype.getDiv=function(){return this.div},a.prototype.remove=function(){this.div.remove()},a.prototype.getColor=function(a){return"cl"===a||"cl-fr"===a?e.LIGHTBLUE:"en"===a||"cl-en"===a?e.RED:"fr"===a?e.GREEN:e.NONE},a.prototype.createNick=function(){var a=document.createElement("span");return a.textContent=this.nick,a.dataset.nick=this.nick,a.setAttribute("tip","Kliknij, aby napisa\u0107 do gracza"),a.classList.add(this.getColor(this.relation)),a.classList.add(d.nick),a},a.prototype.createLvl=function(){var a=document.createElement("span");return a.textContent=""+this.lvl+this.prof,a},a.prototype.createAttack=function(){var a=document.createElement("span");return a.textContent="[ATAKUJ]",a.dataset.playerId=this.id.toString(),a.classList.add(d.attack),a},a.prototype.init=function(){var a=this.createNick(),b=this.createLvl(),c=this.createAttack();this.div.appendChild(a),this.div.appendChild(b),this.div.appendChild(c),this.div.classList.add(d.box),this.div.dataset.id=this.id.toString()},a}();c.default=f},{}],4:[function(a,b,c){"use strict";var d=this&&this.__awaiter||function(b,d,f,g){return new(f||(f=Promise))(function(h,a){function i(b){try{c(g.next(b))}catch(b){a(b)}}function j(b){try{c(g.throw(b))}catch(b){a(b)}}function c(a){a.done?h(a.value):new f(function(b){b(a.value)}).then(i,j)}c((g=g.apply(b,d||[])).next())})},f=this&&this.__generator||function(b,d){function e(a){return function(b){return f([a,b])}}function f(a){if(g)throw new TypeError("Generator is already executing.");for(;m;)try{if(g=1,h&&(j=2&a[0]?h.return:a[0]?h.throw||((j=h.return)&&j.call(h),0):h.next)&&!(j=j.call(h,a[1])).done)return j;switch(h=0,j&&(a=[2&a[0],j.value]),a[0]){case 0:case 1:j=a;break;case 4:return m.label++,{value:a[1],done:!1};case 5:m.label++,h=a[1],a=[0];continue;case 7:a=m.ops.pop(),m.trys.pop();continue;default:if(j=m.trys,!(j=0<j.length&&j[j.length-1])&&(6===a[0]||2===a[0])){m=0;continue}if(3===a[0]&&(!j||a[1]>j[0]&&a[1]<j[3])){m.label=a[1];break}if(6===a[0]&&m.label<j[1]){m.label=j[1],j=a;break}if(j&&m.label<j[2]){m.label=j[2],m.ops.push(a);break}j[2]&&m.ops.pop(),m.trys.pop();continue;}a=d.call(b,m)}catch(b){a=[6,b],h=0}finally{g=j=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}var g,h,j,k,m={label:0,sent:function(){if(1&j[0])throw j[1];return j[1]},trys:[],ops:[]};return k={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(k[Symbol.iterator]=function(){return this}),k},g=this;Object.defineProperty(c,"__esModule",{value:!0});var h=a("../core/AttackPlayer"),i=a("../core/Emmiter"),j=a("../store/Players"),k=a("./Escape"),l=a("./Player"),m=document.createElement("div"),p=new k.default;m.classList.add("adi-wilk-kto-tu-jest-box"),m.appendChild(p.getDiv()),i.default.on(i.EVENTS_NAMES.NEW_PLAYER,function(b){var c=b[0],d=b[1],e=Object.assign(d,{id:c}),f=new l.default(e);j.default.addPlayer(f),m.appendChild(f.getDiv())}),i.default.on(i.EVENTS_NAMES.REMOVE_PLAYER,function(a){var b=a[0];j.default.removeById(b)}),m.addEventListener("click",function(b){return d(g,void 0,void 0,function(){var c,d,e,g,j;return f(this,function(a){switch(a.label){case 0:return null===(c=b.target)?[3,3]:(d=c.dataset,e=d.nick,g=d.playerId,j=d.escape,void 0!==e&&window.chatTo(e),void 0===g?[3,2]:2===window.map.pvp?(window.message("Rozpocz\u0119to po\u015Bcig za graczem: "+window.g.other[+g].nick),[4,h.default.attack(+g)]):[2,window.message("Nie jeste\u015B na czerwonej mapie")]);case 1:a.sent(),a.label=2;case 2:void 0!==j&&p.teleport(),a.label=3;case 3:return[2];}})})}),document.querySelector("#nick").addEventListener("click",function(){window.message("Anulowano atak"),i.default.emit("ROAD_END")}),c.default=m},{"../core/AttackPlayer":5,"../core/Emmiter":6,"../store/Players":13,"./Escape":2,"./Player":3}],5:[function(a,b,c){"use strict";var d=this&&this.__awaiter||function(b,c,d,f){return new(d||(d=Promise))(function(g,a){function h(b){try{j(f.next(b))}catch(b){a(b)}}function i(b){try{j(f.throw(b))}catch(b){a(b)}}function j(a){a.done?g(a.value):new d(function(b){b(a.value)}).then(h,i)}j((f=f.apply(b,c||[])).next())})},f=this&&this.__generator||function(b,c){function d(a){return function(b){return f([a,b])}}function f(a){if(e)throw new TypeError("Generator is already executing.");for(;k;)try{if(e=1,g&&(h=2&a[0]?g.return:a[0]?g.throw||((h=g.return)&&h.call(g),0):g.next)&&!(h=h.call(g,a[1])).done)return h;switch(g=0,h&&(a=[2&a[0],h.value]),a[0]){case 0:case 1:h=a;break;case 4:return k.label++,{value:a[1],done:!1};case 5:k.label++,g=a[1],a=[0];continue;case 7:a=k.ops.pop(),k.trys.pop();continue;default:if(h=k.trys,!(h=0<h.length&&h[h.length-1])&&(6===a[0]||2===a[0])){k=0;continue}if(3===a[0]&&(!h||a[1]>h[0]&&a[1]<h[3])){k.label=a[1];break}if(6===a[0]&&k.label<h[1]){k.label=h[1],h=a;break}if(h&&k.label<h[2]){k.label=h[2],k.ops.push(a);break}h[2]&&k.ops.pop(),k.trys.pop();continue;}a=c.call(b,k)}catch(b){a=[6,b],g=0}finally{e=h=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}var e,g,h,j,k={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]};return j={next:d(0),throw:d(1),return:d(2)},"function"==typeof Symbol&&(j[Symbol.iterator]=function(){return this}),j};Object.defineProperty(c,"__esModule",{value:!0});var g=a("./Emmiter"),h=a("./pathFinder"),i=function(){function a(){}return a.attack=function(a){return d(this,void 0,void 0,function(){return f(this,function(b){switch(b.label){case 0:return[0,!1].includes(window.g.battle)?(g.default.emit("ROAD_END"),[4,h.default.killEnemy(a)]):(window.message("Aktualnie trwa walka."),[2]);case 1:return b.sent(),[2];}})})},a}();c.default=i},{"./Emmiter":6,"./pathFinder":9}],6:[function(a,b,c){"use strict";var d=this&&this.__extends||function(){var a=function(b,c){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])})(b,c)};return function(b,c){function d(){this.constructor=b}a(b,c),b.prototype=null===c?Object.create(c):(d.prototype=c.prototype,new d)}}();Object.defineProperty(c,"__esModule",{value:!0});var f,g=a("events"),h=a("../store/PlayersInBattle");!function(a){a.BATTLE_CLOSE="battle_close",a.BATTLE_END="battle_end",a.NEW_PLAYER="new_player",a.REMOVE_PLAYER="remove_player",a.NEW_POSITION="new_position",a.OTHER_BATTLE_END="other_battle_end",a.OTHER_IN_BATTLE="other_in_battle"}(f=c.EVENTS_NAMES||(c.EVENTS_NAMES={}));var i=function(a){function b(){var b=a.call(this)||this;return b.initListeners(),b.init(),b}return d(b,a),b.prototype.initListeners=function(){this.on(f.BATTLE_END,function(){window._g("fight&a=quit")})},b.prototype.init=function(){var b=this,c=window.parseInput;window.parseInput=function(d){for(var e=[],g=1;g<arguments.length;g++)e[g-1]=arguments[g];if(d.hasOwnProperty("f")&&(d.f.hasOwnProperty("init")&&d.f.hasOwnProperty("w")&&Object.keys(d.f.w).forEach(function(a){b.emit(f.OTHER_IN_BATTLE,+a)}),1===d.f.close&&-1===d.f.move&&0===d.f.current&&b.emit(f.BATTLE_CLOSE),-1!==d.f.move||0!==d.f.current||d.f.hasOwnProperty("close")||b.emit(f.BATTLE_END)),d.hasOwnProperty("other")&&void 0!==d.other){var j=d.other;Object.entries(j).forEach(function(a){var c=a[0],d=a[1];if(void 0===window.g.other[+c])b.emit(f.NEW_PLAYER,[+c,d]);else if([1,!0].includes(d.del))b.emit(f.REMOVE_PLAYER,[+c,window.g.other[+c]]);else{var e=d.x,g=d.y;b.emit(f.NEW_POSITION,[+c,{x:e,y:g}])}})}if(d.hasOwnProperty("emo")&&d.emo.forEach(function(a){var b=a.name,c=a.source_id;"battle"===b&&h.default.addPlayer(c),"noemo"===b&&h.default.isInBattle(c)&&h.default.removePlayer(c)}),d.hasOwnProperty("alert")){var i=d.alert;["Walki pvp mo\u017Cliwe s\u0105 tylko w wyznaczonych miejscach!","Przeciwnik nie zgadza si\u0119 na walk\u0119!"].includes(i)&&(delete d.alert,window.message(i),b.emit("ROAD_END")),i.includes("zbyt daleko")&&(delete d.alert,window.message(i))}return c.apply(void 0,[d].concat(e))}},b}(g.EventEmitter);c.default=new i},{"../store/PlayersInBattle":14,events:1}],7:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=a("./Point"),e=function(){function a(a,b,c,d,f,e){void 0===e&&(e={}),this.openSet=[],this.closedSet=[],this.width=b,this.height=c,this.collisions=this.parseCollisions(a,b,c),this.additionalCollisions=e,this.start=this.collisions[d.x][d.y],this.end=this.collisions[f.x][f.y],this.start.g=0,this.start.beginning=!0,this.start.f=this.heuristic(this.start,this.end),this.end.target=!0,this.end.g=0,this.openSet.push(this.start),this.addNeighbours()}return a.prototype.anotherFindPath=function(){for(;0<this.openSet.length;){var a=this.getLowestF(),b=this.openSet[a];if(b===this.end)return this.reconstructPath();this.openSet.splice(a,1),this.closedSet.push(b);for(var c,d=0,f=b.neighbours;d<f.length;d++)if(c=f[d],!this.closedSet.includes(c)){var g=b.g+1,h=!1;this.end!==this.collisions[c.x][c.y]&&(this.openSet.includes(c)||c.collision||this.additionalCollisions[c.x+256*c.y])?g<c.g&&!c.collision&&(h=!0):(this.openSet.push(c),c.h=this.heuristic(c,this.end),h=!0),h&&(c.previous=b,c.g=g,c.f=c.g+c.h)}}return[]},a.prototype.parseCollisions=function(a,b,c){for(var f=Array(b),g=0;g<b;g++){f[g]=Array(c);for(var i=0;i<c;i++)f[g][i]=new d.default(g,i,"1"===a.charAt(g+i*b))}return f},a.prototype.heuristic=function(a,b){return Math.abs(a.x-b.x)+Math.abs(a.y-b.y)},a.prototype.addNeighbours=function(){for(var a=0;a<this.width;a++)for(var b=0;b<this.height;b++)this.collisions[a][b].neighbours=this.getPointNeighbours(this.collisions[a][b])},a.prototype.getPointNeighbours=function(a){var b=[],c=a.x,d=a.y;return d<this.height-1&&b.push(this.collisions[c][d+1]),c<this.width-1&&b.push(this.collisions[c+1][d]),0<d&&b.push(this.collisions[c][d-1]),0<c&&b.push(this.collisions[c-1][d]),b},a.prototype.getLowestF=function(){for(var a=0,b=0;b<this.openSet.length;b++)this.openSet[b].f<this.openSet[a].f&&(a=b);return a},a.prototype.reconstructPath=function(){for(var a=[],b=this.end;b!==this.start;)a.push(b),b=b.previous;return a},a}();c.default=e},{"./Point":8}],8:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=function(){function a(a,b,c){this.g=1e7,this.f=1e7,this.beginning=!1,this.target=!1,this.neighbours=[],this.x=a,this.y=b,this.collision=c}return a}();c.default=d},{}],9:[function(a,b,c){"use strict";var d=this&&this.__awaiter||function(b,c,a,d){return new(a||(a=Promise))(function(e,f){function g(a){try{i(d.next(a))}catch(a){f(a)}}function h(a){try{i(d.throw(a))}catch(a){f(a)}}function i(b){b.done?e(b.value):new a(function(a){a(b.value)}).then(g,h)}i((d=d.apply(b,c||[])).next())})},f=this&&this.__generator||function(b,c){function d(a){return function(b){return f([a,b])}}function f(a){if(e)throw new TypeError("Generator is already executing.");for(;k;)try{if(e=1,g&&(h=2&a[0]?g.return:a[0]?g.throw||((h=g.return)&&h.call(g),0):g.next)&&!(h=h.call(g,a[1])).done)return h;switch(g=0,h&&(a=[2&a[0],h.value]),a[0]){case 0:case 1:h=a;break;case 4:return k.label++,{value:a[1],done:!1};case 5:k.label++,g=a[1],a=[0];continue;case 7:a=k.ops.pop(),k.trys.pop();continue;default:if(h=k.trys,!(h=0<h.length&&h[h.length-1])&&(6===a[0]||2===a[0])){k=0;continue}if(3===a[0]&&(!h||a[1]>h[0]&&a[1]<h[3])){k.label=a[1];break}if(6===a[0]&&k.label<h[1]){k.label=h[1],h=a;break}if(h&&k.label<h[2]){k.label=h[2],k.ops.push(a);break}h[2]&&k.ops.pop(),k.trys.pop();continue;}a=c.call(b,k)}catch(b){a=[6,b],g=0}finally{e=h=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}var e,g,h,j,k={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]};return j={next:d(0),throw:d(1),return:d(2)},"function"==typeof Symbol&&(j[Symbol.iterator]=function(){return this}),j};Object.defineProperty(c,"__esModule",{value:!0});var g=a("../../helpers"),h=a("../Emmiter"),j=a("./AStar"),k=a("../../store/PlayersInBattle"),l=function(){function a(){}return a.getWay=function(b,c){return d(this,void 0,void 0,function(){var d,e,g,h,k,l,m;return f(this,function(){return d=window.map,e=d.x,g=d.y,h=d.col,k=window.hero,l=k.x,m=k.y,[2,new j.default(h,e,g,{x:l,y:m},{x:b,y:c},window.g.npccol).anotherFindPath()]})})},a.start=function(){var a=this;return new Promise(function(b){return d(a,void 0,void 0,function(){var a,c,e=this;return f(this,function(j){switch(j.label){case 0:return a=!1,c=window,[4,this.getWay(this.targetX,this.targetY)];case 1:c.road=j.sent(),h.default.on("CHANGE_ROAD",function(){return d(e,void 0,void 0,function(){var a;return f(this,function(b){switch(b.label){case 0:return a=window,[4,this.getWay(this.targetX,this.targetY)];case 1:return a.road=b.sent(),[2];}})})}),h.default.on("ROAD_END",function(){h.default.emit("CLEAR_ALL_BATTLE_EMMITERS"),window.road=[],a=!0,b(!0)}),j.label=2;case 2:return a?[3,6]:this.isGoodDistanceToTarget(this.targetX,this.targetY)?(h.default.emit("NEAR_TO_ENEMY"),[4,g.Sleep(500)]):[3,4];case 3:j.sent(),j.label=4;case 4:return 2>=window.road.length&&!this.isGoodDistanceToTarget(this.targetX,this.targetY)&&h.default.emit("CHANGE_ROAD"),[4,g.Sleep(100)];case 5:return j.sent(),[3,2];case 6:return[2];}})})})},a.killEnemy=function(b){var a=this;return new Promise(function(g){return d(a,void 0,void 0,function(){var j,m,p,q,r,t,v,w,x,c=this;return f(this,function(a){switch(a.label){case 0:return void 0===(j=window.g.other[b])?[3,2]:(m=j.x,p=j.y,this.targetX=m,this.targetY=p,q=function(a){a[0]===b&&(h.default.emit("ROAD_END"),g(!1))},h.default.on(h.EVENTS_NAMES.REMOVE_PLAYER,q),r=function(a){var g=a[0],j=a[1];return d(c,void 0,void 0,function(){var a,c;return f(this,function(){return g===b&&(a=j.x,c=j.y,this.targetX=a,this.targetY=c,h.default.emit("CHANGE_ROAD")),[2]})})},h.default.on(h.EVENTS_NAMES.NEW_POSITION,r),t=function(a){a===b&&window._g("fight&a=attack&id="+b)},h.default.on(h.EVENTS_NAMES.OTHER_BATTLE_END,t),v=function(){return d(c,void 0,void 0,function(){return f(this,function(){return k.default.isInBattle(b)||window._g("fight&a=attack&id="+b),[2]})})},h.default.on("NEAR_TO_ENEMY",v),w=function(a){a===b&&(h.default.emit("ROAD_END"),g(!0))},h.default.on(h.EVENTS_NAMES.OTHER_IN_BATTLE,w),h.default.on("CLEAR_ALL_BATTLE_EMMITERS",function(){h.default.removeAllListeners("ROAD_END"),h.default.removeAllListeners("CHANGE_ROAD"),h.default.removeListener(h.EVENTS_NAMES.REMOVE_PLAYER,q),h.default.removeListener(h.EVENTS_NAMES.NEW_POSITION,r),h.default.removeListener(h.EVENTS_NAMES.OTHER_BATTLE_END,t),h.default.removeListener(h.EVENTS_NAMES.OTHER_IN_BATTLE,w),h.default.removeListener("NEAR_TO_ENEMY",v)}),[4,this.start()]);case 1:return x=a.sent(),g(x),[3,3];case 2:g(!1),a.label=3;case 3:return[2];}})})})},a.isGoodDistanceToTarget=function(a,b){var c=window.hero;return 2>=Math.abs(a-c.x)&&2>=Math.abs(b-c.y)},a}();c.default=l},{"../../helpers":11,"../../store/PlayersInBattle":14,"../Emmiter":6,"./AStar":7}],10:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=document.createElement("style");d.appendChild(document.createTextNode("\n .co\u015B tam {\n height: 100%;\n }\n")),c.default=d},{}],11:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0}),c.Sleep=function(a){return new Promise(function(b){return setTimeout(b,a)})}},{}],12:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0}),console.log("Addon started");var d=a("./components"),e=a("./css");document.body.appendChild(d.default),document.head.appendChild(e.default)},{"./components":4,"./css":10}],13:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=function(){function a(){}return a.addPlayer=function(a){return this.players.push(a),this},a.removeById=function(a){var b=this.players.find(function(b){return b.id===a});return void 0!==b&&(this.players=this.players.filter(function(a){return a.id!==b.id}),b.remove(),!0)},a.players=[],a}();c.default=d},{}],14:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=a("../core/Emmiter"),e=function(){function a(){}return a.isInBattle=function(a){return this.playerIds.includes(a)},a.addPlayer=function(a){this.playerIds.push(a)},a.removePlayer=function(a){d.default.emit(d.EVENTS_NAMES.OTHER_BATTLE_END,a),this.playerIds=this.playerIds.filter(function(b){return b!==a})},a.playerIds=[],a}();c.default=e},{"../core/Emmiter":6}]},{},[12]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement