custom_edited

custom_edited library to use

目前为 2016-03-27 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/18325/115899/custom_edited.js

  1. doLog = function() {
  2. };
  3. log("Logging killed.", "initialize");
  4.  
  5. animatedCoins.init = function(b, a, e, g) {
  6. if (isWeb()) {
  7. var c,
  8. d,
  9. f,
  10. h,
  11. k = { images: ["/images/animations/coin_flip.png"], animations: { all: [0, 32] }, frames: { regX: 0, height: 60, count: 33, regY: 0, width: 61 } },
  12. m = {
  13. images: ["/images/animations/coin_sparkle.png"],
  14. animations: { all: { frames: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] } },
  15. frames: [
  16. [0, 0, 128, 128, 0, 0, 0], [128, 0, 128, 128, 0, 0, 0], [256, 0, 128, 128, 0, 0, 0], [384, 0, 128, 128, 0, 0, 0], [512, 0, 128, 128, 0, 0, 0], [640, 0, 128, 128, 0, 0, 0], [768, 0, 128, 128, 0, 0, 0], [896, 0, 128, 128, 0, 0, 0], [0, 128, 128, 128, 0, 0, 0],
  17. [128, 128, 128, 128, 0, 0, 0], [256, 128, 128, 128, 0, 0, 0], [384, 128, 128, 128, 0, 0, 0], [512, 128, 128, 128, 0, 0, 0], [640, 128, 128, 128, 0, 0, 0], [768, 128, 128, 128, 0, 0, 0]
  18. ]
  19. },
  20. l,
  21. n,
  22. p = false;
  23.  
  24. //EXTENDER :: Modification, seriously?
  25. // bugfix: b.offset is undefined (offset from button to silver visually)
  26. if (null === b || void 0 === b || b.length == 0) {
  27. return;
  28. } else if (null === a || void 0 === a) {
  29. return;
  30. } else {
  31. if (null === e || void 0 === e)
  32. e = [
  33. 0,
  34. 0
  35. ];
  36. if (null === g || void 0 === g) g = [0, 0];
  37. d = $("<canvas>").attr({ id: "animatedCoins", "class": "coinCanvasAnimation", width: "130", height: "120" }).prependTo($("body"));
  38. c = d[0];
  39. h = $("<canvas>").attr({ id: "animatedCoinsSparkle", "class": "coinCanvasAnimation", width: "130", height: "120" }).prependTo($("body"));
  40. f = h[0];
  41. c = new createjs.Stage(c);
  42. f = new createjs.Stage(f);
  43. null === b.offset() ? (h.remove(), d.remove(), console.warn("animatedCoins: startingElement.offset() is null. Exiting script.")) : null === a.offset() ? (h.remove(), d.remove(),
  44. console.warn("animatedCoins: endingElement.offset() is null. Exiting script.")) : (d.offset({ left: b.offset().left + e[0], top: b.offset().top + e[1] }), h.offset({ left: b.offset().left + e[0], top: b.offset().top + e[1] }), e = new createjs.SpriteSheet(k), m = new createjs.SpriteSheet(m), l = new createjs.Sprite(e), l.x = 30, l.y = 25, n = new createjs.Sprite(m), l.on("animationend", function(c, f) {
  45. c.visible = false;
  46. doLog("animation end");
  47. null === b.offset() ? (h.remove(), d.remove(), console.error("animatedCoins: startingElement.offset() is null")) :
  48. null === a.offset() ? (h.remove(), d.remove(), console.error("animatedCoins: endingElement.offset() is null")) : (h.offset({ left: a.offset().left + g[0], top: a.offset().top + g[1] }), n.visible = true, n.gotoAndPlay("all"), l.stop(), p = true);
  49. }), n.on("animationend", function(a, b) {
  50. n.visible = false;
  51. p && (n.stop(), d.fadeOut(500, function(a) { d.remove(); }), h.remove());
  52. }), l.gotoAndPlay("all"), n.gotoAndPlay("all"), f.addChild(n), c.addChild(l), createjs.Ticker.setFPS(30), createjs.Ticker.addEventListener("tick", c), createjs.Ticker.addEventListener("tick",
  53. f), $(d).animate({ left: a.offset().left + g[0], top: a.offset().top + g[1] }, 1E3));
  54. }
  55. }
  56. };
  57. log("Animated coins fixed.", "initialize");
  58.  
  59. doInstantSpeedUp = function doInstantSpeedUp(c, a, callback) {
  60. var b = buildingById(c),
  61. d = getCurrentSpeedUpType(b.producing_archetype_id, b.recipe_symbol);
  62.  
  63. // EXTENDER :: Modification
  64. if (instantSpeedCost(b.build_remaining, d) > 0) {
  65. console.log('EXTENDER :: The instant speed up costs money. Exiting...');
  66. return false;
  67. }
  68.  
  69. if (false == hasGold(instantSpeedCost(b.build_remaining, d), function() {
  70. doInstantSpeedUp(c, true, callback);
  71. }, a) && true != a) return false;
  72. playSound("coins");
  73. return speedBuild(-1, c, callback);
  74. };
  75. log("Instant speed up returns if gold is required.", "initialize");
  76.  
  77. doFinishProduction = function doFinishProduction(b, callback) {
  78. var a = buildingByItemId(b), c = itemFromId(a.producing_archetype_id);
  79. userContext.lastFinish = a.symbol;
  80. doLog("doFinishProduction: building_id=" + b + " symbol=" + a.symbol + " producing=" + c.symbol);
  81. "Upgrade" !== c.slot && (analytics.track("Production Finish", { building_symbol: a.symbol, item_symbol: c.symbol, item_category: c.slot }), analytics.wizardtrack("Production Finish", { building_symbol: a.symbol, item_symbol: c.symbol, item_category: c.slot }));
  82. var d = "finish-" + b;
  83. userLock(d) && (playSound("build"),
  84. isWeb() && $("#collect_" + a.symbol).html(""), $.ajax({
  85. url: "/play/finish_production/" + b,
  86. dataType: "JSON",
  87. success: function(a) {
  88. //console.debug("Logging server response for doFinishProduction: ", a);
  89.  
  90. doLog("doFinishProduction: succeess ");
  91. freeLock(d);
  92. var c = buildingByItemId(b, a.building);
  93. userContext.playerData.character = a.character;
  94. userContext.playerData.user.money = a.user.money;
  95. userContext.playerData.stat.onboarding = a.stat.onboarding;
  96. userContext.playerData.stat.num_items_produced = a.stat.num_items_produced;
  97. userContext.playerData.stat.produced_stone = a.stat.produced_stone;
  98. userContext.playerData.stat.building_upgrades_finished =
  99. a.stat.building_upgrades_finished;
  100. c.producing_archetype_id = null;
  101. c.modifier = null;
  102. c.recipe_symbol = null;
  103. var f = extractItemBySymbol(playerInventory, c.symbol);
  104. f.effective_upgrade_level = a.building.effective_upgrade_level;
  105. f.producing_archetype_id = null;
  106. f.modifier = null;
  107. f.recipe_symbol = null;
  108.  
  109. // EXTENDER :: Modification, execute current code ONLY if there's a produced item returned!
  110. if (a.produced_item) {
  111. if (userContext.intCurrentRecipeIndex = null,
  112. doLog("doFinishProduction: data.produced_item.id=" + a.produced_item.id + " quantity=" + a.produced_item.quantity),
  113. insertInventoryFromItem(playerInventory, a.produced_item),
  114. theNewItem = extractItemById(playerInventory, a.produced_item.id), 1 == a.is_loot) {
  115. 0 < a.enhanced_loot_roll
  116. ? dialogAlert({
  117. style: "alert",
  118. text: "The result of your production (enhanced) is: " + a.produced_full_name,
  119. items: [theNewItem],
  120. heading: "You have produced...",
  121. button1: "Okay"
  122. }) : dialogAlert({
  123. style: "alert",
  124. text: "The result of your production is: " + a.produced_full_name,
  125. items: [theNewItem],
  126. heading: "You have produced...",
  127. button1: "Okay"
  128. });
  129. } else if (0 < a.affix_chance) {
  130. var m;
  131. m = "" + ("You have a " + a.affix_chance_from_stats +
  132. "% chance to produce a superior-quality item from your talents, equipment and buildings.");
  133. a.bonus_item_name && (m += " Your " + a.bonus_item_name + " adds another +" + a.affix_chance_from_bonus + "% chance to produce a superior-quality item from your talents, equipment and buildings.");
  134. m = a.affix_roll1 <= a.affix_chance && a.affix_roll2 <= a.affix_chance ? m + "<p/>Critical Success! You obtained a superb result!" : a.affix_roll1 > a.affix_chance && a.affix_roll2 > a.affix_chance ? m + "<p/>You obtained a normal result." : m + "<p/>Success! You obtained a good result.";
  135. dialogAlert({ style: "alert", text: m, items: [theNewItem], heading: a.produced_full_name, button1: "Okay" });
  136. }
  137.  
  138. userContext.newBldgOrUpgrade = true;
  139. var q;
  140.  
  141. "Upgrade" != theNewItem.slot ?
  142. (userContext.newProducedItem = theNewItem, isWeb()
  143. && $("#collect_" + f.symbol).html(renderUpgradeCollect(f)),
  144. isWeb() && $("#build_panel_action_" + f.id).html(renderBuildPanelAction(f)),
  145. isWeb() && $("#speed_button_" + f.id).hide())
  146. : q = theNewItem.symbol;
  147.  
  148. isWeb() ? (renderBuildingInventory(userContext.playerData),
  149. renderBuildingsOnScreen(userContext.playerData))
  150. : (f = null, f = null == q
  151. ? { symbol: c.symbol, status: "idle" }
  152. : { symbol: c.symbol, status: "idle", upgrade: q },
  153. iosSignal("finish_production", "update", f),
  154. isAndroid()
  155. && mobileCooldownDataSignal([{ mode: "building", symbol: c.symbol }]),
  156. refreshActiveBuildingPanel(),
  157. $("#building_tab_prod, .buildingupgradetree").fadeTo("slow", "1"));
  158.  
  159. uiEvent("do_finish_production");
  160. uiEvent("building_panel_" + userContext.activeBuildingPanel);
  161. a.produced_item && ("stacks_of_coins" == a.produced_item.symbol ? retrievePlayerData(!0, function (a) {
  162. userContext.playerData.quests = a.quests;
  163. reRenderQuestActionItems()
  164. }) : "stacks_of_coins" == a.produced_item.symbol && (userContext.playerData.stat.ftpe_decorative_blade = 1));
  165.  
  166. "Upgrade" == theNewItem.slot && (buildingUpgradePanel(c.symbol), userContext.playerData.stat[c.symbol + "_upgrades_finished"] = void 0 == userContext.playerData.stat[c.symbol + "_upgrades_finished"] ? 1 : userContext.playerData.stat[c.symbol +
  167. "_upgrades_finished"] + 1);
  168. updatePlayerInfo(userContext.playerData);
  169. updateAllStatus();
  170. } else {
  171.  
  172. // EXTENDER :: Modification ...
  173. console.debug("This building is still producing! Building: ", a.building);
  174. }
  175.  
  176. if (typeof callback == "function") {
  177. //console.debug("Calling callback... ");
  178. callback(a); // pass response
  179. }
  180. }
  181. }));
  182. };
  183. log("Finish production and call callback if any. Fix bug.", "initialize");