You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

51 lines
944 B

  1. define([
  2. 'js/system/events'
  3. ], function(
  4. events
  5. ) {
  6. return {
  7. type: 'trade',
  8. itemList: null,
  9. action: 'buy',
  10. init: function(blueprint) {
  11. },
  12. extend: function(blueprint) {
  13. var redraw = false;
  14. if (blueprint.buyList) {
  15. this.itemList = blueprint.buyList;
  16. redraw = true;
  17. this.action = 'buy';
  18. if (blueprint.buyList.buyback)
  19. this.action = 'buyback';
  20. delete blueprint.buyList;
  21. }
  22. else if (blueprint.sellList) {
  23. this.itemList = blueprint.sellList;
  24. redraw = true;
  25. this.action = 'sell';
  26. delete blueprint.sellList;
  27. }
  28. if (blueprint.removeItems) {
  29. this.itemList.items.spliceWhere(function(b) {
  30. return (blueprint.removeItems.indexOf(b.id) > -1);
  31. });
  32. redraw = true;
  33. delete blueprint.removeItems;
  34. }
  35. for (var p in blueprint) {
  36. this[p] = blueprint[p];
  37. }
  38. if (redraw)
  39. events.emit('onGetTradeList', this.itemList, this.action);
  40. }
  41. };
  42. });