\\n ");\n\n var createTalent = function createTalent(_ref) {\n var grade = _ref.grade,\n name = _ref.name,\n description = _ref.description;\n return $("
"));\n };\n\n talentPage.find(\'#random\').click(function () {\n talentPage.find(\'#random\').hide();\n var ul = talentPage.find(\'#talents\');\n\n app_classPrivateFieldGet(_this2, _life).talentRandom().forEach(function (talent) {\n var li = createTalent(talent);\n ul.append(li);\n li.click(function () {\n if (li.hasClass(\'selected\')) {\n li.removeClass(\'selected\');\n\n app_classPrivateFieldGet(_this2, _talentSelected).delete(talent);\n\n if (app_classPrivateFieldGet(_this2, _talentSelected).size < 3) {\n talentPage.find(\'#next\').text(\'请选择3个\');\n }\n } else {\n if (app_classPrivateFieldGet(_this2, _talentSelected).size == 3) {\n _this2.hint(\'只能选3个天赋\');\n\n return;\n }\n\n var exclusive = app_classPrivateFieldGet(_this2, _life).exclusive(Array.from(app_classPrivateFieldGet(_this2, _talentSelected)).map(function (_ref2) {\n var id = _ref2.id;\n return id;\n }), talent.id);\n\n if (exclusive != null) {\n var _iterator = app_createForOfIteratorHelper(app_classPrivateFieldGet(_this2, _talentSelected)),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var _step$value = _step.value,\n name = _step$value.name,\n id = _step$value.id;\n\n if (id == exclusive) {\n _this2.hint("\\u4E0E\\u5DF2\\u9009\\u62E9\\u7684\\u5929\\u8D4B\\u3010".concat(name, "\\u3011\\u51B2\\u7A81"));\n\n return;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n return;\n }\n\n li.addClass(\'selected\');\n\n app_classPrivateFieldGet(_this2, _talentSelected).add(talent);\n\n if (app_classPrivateFieldGet(_this2, _talentSelected).size == 3) {\n talentPage.find(\'#next\').text(\'开始新人生\');\n }\n }\n });\n });\n\n talentPage.find(\'#next\').show();\n });\n talentPage.find(\'#next\').click(function () {\n if (app_classPrivateFieldGet(_this2, _talentSelected).size != 3) {\n _this2.hint(\'请选择3个天赋\');\n\n return;\n }\n\n talentPage.find(\'#next\').hide();\n\n app_classPrivateFieldSet(_this2, _totalMax, 20 + app_classPrivateFieldGet(_this2, _life).getTalentAllocationAddition(Array.from(app_classPrivateFieldGet(_this2, _talentSelected)).map(function (_ref3) {\n var id = _ref3.id;\n return id;\n })));\n\n _this2.switch(\'property\');\n }); // Property\n // hint of extension tobermory.es6-string-html\n\n var propertyPage = $(\n /*html*/\n "\\n
\\n
\\n
\\u8C03\\u6574\\u521D\\u59CB\\u5C5E\\u6027
\\n
\\u53EF\\u7528\\u5C5E\\u6027\\u70B9\\uFF1A0
\\n
\\n
\\n
\\n
\\n \\n \\n
\\n
\\n ");\n\n propertyPage.mounted = function () {\n propertyPage.find(\'#talentSelectedView\').append("
\\u5DF2\\u9009\\u5929\\u8D4B
" + Array.from(app_classPrivateFieldGet(_this2, _talentSelected)).map(function (_ref4) {\n var name = _ref4.name,\n description = _ref4.description;\n return "
".concat(name, "(").concat(description, ")
");\n }).join(\'\'));\n };\n\n var groups = {};\n\n var total = function total() {\n var t = 0;\n\n for (var type in groups) {\n t += groups[type].get();\n }\n\n return t;\n };\n\n var freshTotal = function freshTotal() {\n propertyPage.find(\'#total\').text("\\u53EF\\u7528\\u5C5E\\u6027\\u70B9\\uFF1A".concat(app_classPrivateFieldGet(_this2, _totalMax) - total()));\n };\n\n var getBtnGroups = function getBtnGroups(name, min, max) {\n var group = $("
".concat(name, "
"));\n var btnSub = $("");\n var inputBox = $("");\n var btnAdd = $("");\n group.append(btnSub);\n group.append(inputBox);\n group.append(btnAdd);\n\n var limit = function limit(v) {\n v = Number(v) || 0;\n v = Math.round(v);\n return v < min ? min : v > max ? max : v;\n };\n\n var get = function get() {\n return Number(inputBox.val());\n };\n\n var set = function set(v) {\n inputBox.val(limit(v));\n freshTotal();\n };\n\n btnAdd.click(function () {\n if (total() >= app_classPrivateFieldGet(_this2, _totalMax)) {\n _this2.hint(\'没有可分配的点数了\');\n\n return;\n }\n\n set(get() + 1);\n });\n btnSub.click(function () {\n return set(get() - 1);\n });\n inputBox.on(\'input\', function () {\n var t = total();\n var val = get();\n\n if (t > app_classPrivateFieldGet(_this2, _totalMax)) {\n val -= t - app_classPrivateFieldGet(_this2, _totalMax);\n }\n\n val = limit(val);\n\n if (val != inputBox.val()) {\n set(val);\n }\n\n freshTotal();\n });\n return {\n group: group,\n get: get,\n set: set\n };\n };\n\n groups.CHR = getBtnGroups("颜值", 0, 10); // 颜值 charm CHR\n\n groups.INT = getBtnGroups("智力", 0, 10); // 智力 intelligence INT\n\n groups.STR = getBtnGroups("体质", 0, 10); // 体质 strength STR\n\n groups.MNY = getBtnGroups("家境", 0, 10); // 家境 money MNY\n\n var ul = propertyPage.find(\'#propertyAllocation\');\n\n for (var type in groups) {\n ul.append(groups[type].group);\n }\n\n propertyPage.find(\'#random\').click(function () {\n var t = app_classPrivateFieldGet(_this2, _totalMax);\n\n var arr = [10, 10, 10, 10];\n\n while (t > 0) {\n var sub = Math.round(Math.random() * (Math.min(t, 10) - 1)) + 1;\n\n while (true) {\n var select = Math.floor(Math.random() * 4) % 4;\n if (arr[select] - sub < 0) continue;\n arr[select] -= sub;\n t -= sub;\n break;\n }\n }\n\n groups.CHR.set(10 - arr[0]);\n groups.INT.set(10 - arr[1]);\n groups.STR.set(10 - arr[2]);\n groups.MNY.set(10 - arr[3]);\n });\n propertyPage.find(\'#start\').click(function () {\n if (total() < app_classPrivateFieldGet(_this2, _totalMax)) {\n _this2.hint("\\u4F60\\u8FD8\\u6709".concat(app_classPrivateFieldGet(_this2, _totalMax) - total(), "\\u5C5E\\u6027\\u70B9\\u6CA1\\u6709\\u5206\\u914D\\u5B8C"));\n\n return;\n } else if (total() > app_classPrivateFieldGet(_this2, _totalMax)) {\n _this2.hint("\\u4F60\\u591A\\u4F7F\\u7528\\u4E86".concat(total() - app_classPrivateFieldGet(_this2, _totalMax), "\\u5C5E\\u6027\\u70B9"));\n\n return;\n }\n\n app_classPrivateFieldGet(_this2, _life).restart({\n CHR: groups.CHR.get(),\n INT: groups.INT.get(),\n STR: groups.STR.get(),\n MNY: groups.MNY.get(),\n SPR: 5,\n TLT: Array.from(app_classPrivateFieldGet(_this2, _talentSelected)).map(function (_ref5) {\n var id = _ref5.id;\n return id;\n })\n });\n\n _this2.switch(\'trajectory\');\n\n app_classPrivateFieldGet(_this2, _pages).trajectory.born(); // $(document).keydown(function(event){\n // if(event.which == 32 || event.which == 13){\n // $(\'#lifeTrajectory\').click();\n // }\n // })\n\n }); // Trajectory\n\n var trajectoryPage = $("\\n
\\n
\\n
\\n
\\n \\n \\n
\\n
\\n \\n
\\n
\\n ");\n trajectoryPage.find(\'#lifeTrajectory\').click(function () {\n if (app_classPrivateFieldGet(_this2, _isEnd)) return;\n\n var trajectory = app_classPrivateFieldGet(_this2, _life).next();\n\n var age = trajectory.age,\n content = trajectory.content,\n isEnd = trajectory.isEnd;\n var li = $("
".concat(age, "\\u5C81\\uFF1A").concat(content.map(function (_ref6) {\n var type = _ref6.type,\n description = _ref6.description,\n grade = _ref6.grade,\n name = _ref6.name,\n postEvent = _ref6.postEvent;\n\n switch (type) {\n case \'TLT\':\n return "\\u5929\\u8D4B\\u3010".concat(name, "\\u3011\\u53D1\\u52A8\\uFF1A").concat(description);\n\n case \'EVT\':\n return description + (postEvent ? " ".concat(postEvent) : \'\');\n }\n }).join(\' \'), "
"));\n li.appendTo(\'#lifeTrajectory\');\n $("#lifeTrajectory").scrollTop($("#lifeTrajectory")[0].scrollHeight);\n\n if (isEnd) {\n $(document).unbind("keydown");\n\n app_classPrivateFieldSet(_this2, _isEnd, true);\n\n trajectoryPage.find(\'#summary\').show();\n trajectoryPage.find(\'#domToImage\').show();\n } else {\n // 如未死亡,更新数值\n // Update properties if not die yet\n var property = app_classPrivateFieldGet(_this2, _life).getLastRecord();\n\n $("#lifeProperty").html("\\n
\\u989C\\u503C".concat(property.CHR, "
\\n
\\u667A\\u529B").concat(property.INT, "\\n
\\u4F53\\u8D28").concat(property.STR, "\\n
\\u5BB6\\u5883").concat(property.MNY, "\\n
\\u5FEB\\u4E50").concat(property.SPR, "\\n "));\n }\n }); // html2canvas\n\n trajectoryPage.find(\'#domToImage\').click(function () {\n $("#lifeTrajectory").addClass("deleteFixed");\n var ua = navigator.userAgent.toLowerCase();\n domtoimage.toJpeg(document.getElementById(\'lifeTrajectory\')).then(function (dataUrl) {\n var link = document.createElement(\'a\');\n link.download = \'我的人生回放.jpeg\';\n link.href = dataUrl;\n link.click();\n $("#lifeTrajectory").removeClass("deleteFixed"); // 微信内置浏览器,显示图片,需要用户单独保存\n\n if (ua.match(/MicroMessenger/i) == "micromessenger") {\n $(\'#endImage\').attr(\'src\', dataUrl);\n }\n });\n });\n trajectoryPage.find(\'#summary\').click(function () {\n _this2.switch(\'summary\');\n }); // Summary\n\n var summaryPage = $("\\n