var events_c12a15a8_c380_4b28_8144_256cba95f760 = 
{
	"commonEvent": {
		"加点事件": [
			{
				"type": "comment",
				"text": "通过传参，flag:arg1 表示当前应该的加点数值"
			},
			{
				"type": "choices",
				"choices": [
					{
						"text": "攻击+${1*flag:arg1}",
						"action": [
							{
								"type": "setValue",
								"name": "status:atk",
								"operator": "+=",
								"value": "1*flag:arg1"
							}
						]
					},
					{
						"text": "防御+${2*flag:arg1}",
						"action": [
							{
								"type": "setValue",
								"name": "status:def",
								"operator": "+=",
								"value": "2*flag:arg1"
							}
						]
					},
					{
						"text": "生命+${200*flag:arg1}",
						"action": [
							{
								"type": "setValue",
								"name": "status:hp",
								"operator": "+=",
								"value": "200*flag:arg1"
							}
						]
					}
				]
			}
		],
		"游戏说明": [
			{
				"type": "choices",
				"choices": [
					{
						"text": "游戏简介",
						"action": [
							"h5版本是按照flash版复刻，其中部分对话使用的魔塔盛宴的版本。",
							"地图复制：数码宝贝51、641\n部分事件复制：小艾\n默认背景音乐：无；可在切换音乐处设置\n游戏音乐、怪物显伤等开关可以在系统设置里打开和关闭",
							"想要获得更详细的介绍，可以在菜单——游戏信息——游戏主页中进入本塔的评论区，查看置顶评论。",
							{
								"type": "insert",
								"name": "游戏说明"
							}
						]
					},
					{
						"text": "游戏结局",
						"action": [
							{
								"type": "if",
								"condition": "flag:addhp",
								"true": [
									"疯狂加血模式下，本塔有且仅有一个专属结局。",
									{
										"type": "insert",
										"name": "游戏说明"
									}
								],
								"false": [
									"本塔共有四个结局。\n在原版魔塔中，使用下楼器和破墙镐（或下楼器和地震卷轴）可以封印魔王，因此，这个版本如保留下楼器和破墙镐（或下楼器和地震卷轴）击败魔王，即可打出True End，否则为Normal End。",
									"不论是Normal End还是True End，都分为穿墙结局和不穿墙结局，如果从未使用对话穿墙，可以打出不穿墙结局。",
									{
										"type": "insert",
										"name": "游戏说明"
									}
								]
							}
						]
					},
					{
						"text": "对话穿墙",
						"action": [
							"在与老人对话后，或购买商人的物品并再次对话后，可以立即清除，或走一步再清除身边的某一堵墙（不必是暗墙）。",
							"这期间不能瞬移、打怪、开门和使用道具，否则穿墙会失败。",
							{
								"type": "insert",
								"name": "游戏说明"
							}
						]
					},
					{
						"text": "切换音乐",
						"action": [
							{
								"type": "choices",
								"choices": [
									{
										"text": "精灵石 3个小萝莉在一起",
										"action": [
											{
												"type": "setValue",
												"name": "flag:bgm",
												"value": "1"
											},
											{
												"type": "playBgm",
												"name": "xiaoluoli.mp3"
											}
										]
									},
									{
										"text": "精灵石 晚上家里和镇子",
										"action": [
											{
												"type": "setValue",
												"name": "flag:bgm",
												"value": "2"
											},
											{
												"type": "playBgm",
												"name": "wan.mp3"
											}
										]
									},
									{
										"text": "精灵石 黄昏的镇子",
										"action": [
											{
												"type": "setValue",
												"name": "flag:bgm",
												"value": "3"
											},
											{
												"type": "playBgm",
												"name": "huang.mp3"
											}
										]
									},
									{
										"text": "仙境传说-守候永恒的爱",
										"action": [
											{
												"type": "setValue",
												"name": "flag:bgm",
												"value": "4"
											},
											{
												"type": "playBgm",
												"name": "xian.mp3"
											}
										]
									},
									{
										"text": "精灵石 精灵石传说",
										"action": [
											{
												"type": "setValue",
												"name": "flag:bgm",
												"value": "5"
											},
											{
												"type": "playBgm",
												"name": "chuanshuo.mp3"
											}
										]
									},
									{
										"text": "精灵石 ed【神曲】",
										"action": [
											{
												"type": "setValue",
												"name": "flag:bgm",
												"value": "6"
											},
											{
												"type": "playBgm",
												"name": "ed.mp3"
											}
										]
									},
									{
										"text": "精灵石 幸福之花",
										"action": [
											{
												"type": "setValue",
												"name": "flag:bgm",
												"value": "7"
											},
											{
												"type": "playBgm",
												"name": "hua.mp3"
											}
										]
									},
									{
										"text": "精灵石 迷宫",
										"action": [
											{
												"type": "setValue",
												"name": "flag:bgm",
												"value": "8"
											},
											{
												"type": "playBgm",
												"name": "migong.mp3"
											}
										]
									},
									{
										"text": "离开",
										"action": []
									}
								]
							},
							{
								"type": "insert",
								"name": "游戏说明"
							}
						]
					},
					{
						"text": "返回游戏",
						"action": []
					}
				]
			}
		],
		"记事本": [
			{
				"type": "while",
				"condition": "1",
				"data": [
					{
						"type": "previewUI",
						"action": [
							{
								"type": "clearMap"
							},
							{
								"type": "setAttribute",
								"font": "bold 12px Verdana",
								"strokeStyle": [
									255,
									255,
									255,
									1
								],
								"align": "center",
								"baseline": "top"
							}
						]
					},
					{
						"type": "if",
						"condition": "flag:success",
						"true": [
							{
								"type": "comment",
								"text": "绘制三连画布"
							},
							{
								"type": "function",
								"function": "function(){\nlet name = 'uievent',\n\tleft = 0,\n\ttop = 0,\n\twidth = 352,\n\theight = 352;\ncore.fillRoundRect(name, left, top, width, height, 5, [0, 0, 0, 0.5]); //背景颜色\n\n\ncore.setTextAlign(name, 'center');\nlet origin_x = 176, //上面文字起点\n\torigin_y = 12, //上面文字上面起点\n\ttitle = flags.title //标题\ncore.fillText(name, title, origin_x, origin_y, [255, 255, 255, 1], \"bold 15px Verdana\");\ncore.setTextAlign(name, 'left');\n\n//基础数据\nlet box = flags.box || [], //背包物品\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column; //背包列数\nlet box_size = 32, //方框大小\n\tline = 2; //线条粗细\nlet icon_size = box_size - line\nlet prizePool = flags.prizePool, //奖品池\n\tPrizePoolNumber = flags.PrizePoolNumber, //奖品池数量\n\tselect_time = flags.select_time //刷新次数\n\n\n\nlet select_item = core.getFlag(\"select_item\") //选择的物品\n//绘制奖品\norigin_x = 14; //奖品池左侧起点\norigin_y = 46; //奖品池上面起点\ncore.fillRect(name, origin_x, origin_y, box_size * PrizePoolNumber, box_size, [89, 89, 89, 1])\nfor (let i = 0; i < PrizePoolNumber; i++) {\n\tcore.strokeRect(name, origin_x, origin_y, box_size, box_size, [0, 0, 0, 0.5], line)\n\tcore.drawIcon(name, prizePool[i], origin_x + line, origin_y + line, icon_size, icon_size)\n\torigin_x += box_size\n}\n\ncore.setFont(name, \"bold 12px Verdana\");\n//绘制刷新\norigin_x += 8; //刷新按钮左侧起点\ncore.fillRect(name, origin_x, origin_y, 36, 36, [133, 133, 133, 1]);\ncore.fillRect(name, origin_x, origin_y, 32, 4, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x, origin_y, 4, 32, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x + 32, origin_y, 4, 36, [89, 89, 89, 1]);\ncore.fillRect(name, origin_x, origin_y + 32, 36, 4, [89, 89, 89, 1]);\ncore.strokeRect(name, origin_x, origin_y, 36, 36, [0, 0, 0, 1], 2);\ncore.fillText(name, '刷新', origin_x + 3, origin_y + 4, [255, 255, 255, 1])\ncore.fillText(name, select_time + '次', origin_x + 3, origin_y + 18, [255, 255, 255, 1])\n\n//绘制选择的物品\nif (select_item) {\n\torigin_x += 36\n\tlet text = core.material.items[select_item].name;\n\tcore.fillText(name, text, origin_x, origin_y, [255, 255, 255, 1], \"bold 12px Verdana\");\n\torigin_y += 12;\n\tlet config = {\n\t\t\"left\": origin_x,\n\t\t\"top\": origin_y,\n\t\t\"fontSize\": 10,\n\t\t\"maxWidth\": 100\n\t}\n\ttext = core.material.items[select_item].text;\n\tcore.drawTextContent(name, text, config);\n}\n\norigin_x = 14; //背包左侧起点\norigin_y = 94; //背包上面起点\n//绘制背包方框\ncore.fillRect(name, origin_x, origin_y, box_size * box_column, box_size * box_row, [89, 89, 89, 1]); //背包底色\nfor (let i = 0; i <= box_column; i++) {\n\tcore.drawLine(name, origin_x + box_size * i, origin_y, origin_x + box_size * i, origin_y + box_size * box_row, [0, 0, 0, 1], 2); //绘制纵向线条\n}\nfor (let i = 0; i <= box_row; i++) {\n\tcore.drawLine(name, origin_x, origin_y + box_size * i, origin_x + box_size * box_column, origin_y + box_size * i, [0, 0, 0, 1], 2); //绘制横向线条\n}\n//绘制背包物品\nlet i_row = 0,\n\ti_column = 0;\nfor (let i = 0; i < box.length; i++) {\n\tlet item = box[i];\n\tif (item[1] > 0) {\n\t\tfor (let n = 0; n < item[1]; n++) {\n\t\t\tcore.drawIcon(name, item[0], origin_x + i_column * box_size + line, origin_y + i_row * box_size + line, icon_size, icon_size)\n\t\t\ti_column += 1\n\t\t\tif (i_column >= box_column) {\n\t\t\t\ti_column -= box_column;\n\t\t\t\ti_row += 1\n\t\t\t}\n\t\t}\n\t}\n}\nif (select_item) {\n\tlet select_prize = flags.select_prize\n\tif (select_prize) {\n\t\torigin_x = 14; //奖品池左侧起点\n\t\torigin_y = 46; //奖品池上面起点\n\t\tlet prize_index = flags.prize_index\n\t\tcore.strokeRect(name, origin_x + prize_index * box_size, origin_y, box_size, box_size, [255, 255, 0, 1], line);\n\t} else {\n\t\tlet click_X = flags.click_X,\n\t\t\tclick_Y = flags.click_Y;\n\t\tcore.strokeRect(name, origin_x + click_X * box_size, origin_y + click_Y * box_size, box_size, box_size, [255, 255, 0, 1], line);\n\t}\n}\n\ncore.setFont(name, \"bold 12px Verdana\");\n//绘制丢弃\norigin_x = 200; //丢弃按钮左侧起点\norigin_y = 110 + box_row * box_size; //丢弃按钮上面起点\ncore.fillRect(name, origin_x, origin_y, 36, 36, [133, 133, 133, 1]);\ncore.fillRect(name, origin_x, origin_y, 32, 4, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x, origin_y, 4, 32, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x + 32, origin_y, 4, 36, [89, 89, 89, 1]);\ncore.fillRect(name, origin_x, origin_y + 32, 36, 4, [89, 89, 89, 1]);\ncore.strokeRect(name, origin_x, origin_y, 36, 36, [0, 0, 0, 1], 2);\ncore.fillText(name, '丢弃', origin_x + 3, origin_y + 11, [255, 255, 255, 1])\n}"
							},
							{
								"type": "setValue",
								"name": "temp:PrizePoolNumber",
								"value": "flag:PrizePoolNumber"
							},
							{
								"type": "setValue",
								"name": "temp:box_size",
								"value": "32"
							},
							{
								"type": "setValue",
								"name": "temp:origin_x",
								"value": "14"
							},
							{
								"type": "setValue",
								"name": "temp:origin_y",
								"value": "46"
							},
							{
								"type": "setValue",
								"name": "temp:box_row",
								"value": "flag:box_row"
							},
							{
								"type": "setValue",
								"name": "temp:box_column",
								"value": "flag:box_column"
							},
							{
								"type": "wait",
								"forceChild": true,
								"data": [
									{
										"case": "mouse",
										"px": [
											0,
											480
										],
										"py": [
											0,
											480
										],
										"action": [
											{
												"type": "comment",
												"text": "点击三连奖品"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +temp:box_size*temp:PrizePoolNumber)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +temp:box_size))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet prizePool = flags.prizePool, //奖品池\n\tbox_size = 32, //方框大小\n\tline = 2, //线条粗细\n\torigin_x = 14, //奖品池左侧起点\n\torigin_y = 46, //奖品池上面起点\n\tprize_index = flags.prize_index //上次点击的位置\n\n\n//计算点击的位置\nlet index = parseInt((flags.px - origin_x) / box_size);\nindex = Math.floor(index);\nlet select_item = prizePool[index]\nif (select_item) {\n\tflags.select_prize = true\n\tflags.prize_index = index\n\tflags.select_item = select_item\n\tflags.title = \"请选择三连奖品\"\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n}\n\nif (prize_index === index) {\n\tcore.getItem(select_item, 1)\n\tcore.setFlag(\"select_prize\", null);\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"select_item\", null);\n\tcore.setFlag(\"success\", false);\n\tflags.title = \"请选择你的物品\"\n}\n}"
													}
												]
											},
											{
												"type": "comment",
												"text": "刷新三连"
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "22 +temp:box_size*temp:PrizePoolNumber"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "46"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +36)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +  36))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet select_time = flags.select_time //刷新次数\nif (select_time > 0) {\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"select_item\", null);\n\n\tlet randomPool = flags.randomPool\n\n\tlet prizePool = [], //奖品池\n\t\tPrizePoolNumber = flags.PrizePoolNumber //三连奖品数量\n\tfor (let i = 0; i < PrizePoolNumber; i++) { //随机从随机池里面添加N个物品进入奖品池\n\t\tlet rand = core.rand(randomPool.length)\n\t\tlet item = randomPool[rand]\n\t\tprizePool.push(item)\n\t}\n\tflags.prizePool = prizePool\n\tflags.select_time -= 1 //挑选刷新次数-1\n\tflags.success = true //成功三连\n\tflags.title = \"请选择三连奖品\"\n} else {\n\tlet text = core.material.items[select_item].name;\n\tflags.title = \"你没有刷新次数\"\n}\n}"
													}
												]
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "14"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "94"
											},
											{
												"type": "comment",
												"text": "点击背包"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +temp:box_size*temp:box_column)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +temp:box_size*temp:box_row))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet box = flags.box || [], //背包物品\n\tbox_number = flags.box_number,\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column, //背包列数\n\tbox_size = 32, //方框大小\n\tline = 2, //线条粗细\n\torigin_x = 14, //背包左侧起点\n\torigin_y = 94, //背包上面起点\n\tclick_X = flags.click_X, //上次点击的位置X\n\tclick_Y = flags.click_Y; //上次点击的位置Y\n\n\n//计算点击的位置\nlet Xoffset = parseInt((flags.px - origin_x) / box_size);\nXoffset = Math.floor(Xoffset);\nlet Yoffset = parseInt((flags.py - origin_y) / box_size);\nYoffset = Math.floor(Yoffset);\nlet index = Yoffset * box_column + Xoffset\nif (box_number > index) {\n\tlet select_item\n\tfor (let i = 0; i < box.length; i++) {\n\t\tlet item = box[i];\n\t\tif (item[1] > 0) {\n\t\t\tif (index < item[1]) {\n\t\t\t\tselect_item = item[0];\n\t\t\t\ti = 999;\n\t\t\t} else {\n\t\t\t\tindex -= item[1]\n\t\t\t}\n\t\t}\n\t}\n\tif (Xoffset === click_X && Yoffset === click_Y) { //点击相同位置，则使用道具\n\t\tlet cls = core.material.items[select_item].cls;\n\t\tlet select_item_index = flags.box_index[select_item]\n\t\tif (cls === \"equips\") {\n\t\t\tlet type = core.getEquipTypeById(select_item)\n\t\t\tlet equip = core.getEquip(type)\n\t\t\tif (equip) { //将卸下来的装备重新加入物品池\n\t\t\t\tlet equip_index = flags.box_index[equip]\n\t\t\t\tflags.box[equip_index][1] += 1;\n\t\t\t\tflags.box_number += 1;\n\t\t\t}\n\t\t\tcore.loadEquip(select_item) //装载装备\n\t\t\tif (type === 0) {\n\t\t\t\tcore.setFlag('nowWeapon', select_item);\n\t\t\t} else {\n\t\t\t\tcore.setFlag('nowShield', select_item);\n\t\t\t}\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\tif (cls === \"tools\") {\n\t\t\tcore.useItem(select_item, true)\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\tcore.setFlag(\"click_X\", null);\n\t\tcore.setFlag(\"click_Y\", null);\n\t\tcore.setFlag(\"select_item\", null);\n\t} else {\n\t\tcore.setFlag(\"click_X\", Xoffset);\n\t\tcore.setFlag(\"click_Y\", Yoffset);\n\t\tcore.setFlag(\"select_item\", select_item);\n\t}\n\tcore.setFlag(\"select_prize\", false);\n}\nflags.title = \"请选择三连奖品\"\ncore.setFlag(\"prize_index\", null);\n}"
													}
												]
											},
											{
												"type": "comment",
												"text": "点击丢弃"
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "200"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "110 + temp:box_size*temp:box_row"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +36)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +  36))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet select_item = core.getFlag(\"select_item\"),\n\tprize_index = flags.prize_index\nif (select_item && prize_index == null) {\n\tlet index = flags.box_index[select_item]\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"select_item\", null);\n\tcore.removeItem(select_item, 1)\n\tflags.box[index][1] -= 1;\n\tflags.box_number -= 1;\n} else {\n\tcore.setFlag(\"select_prize\", null);\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"select_item\", null);\n\tcore.setFlag(\"success\", false);\n\tflags.title = \"请选择你的物品\"\n}\n}"
													}
												]
											}
										]
									}
								]
							}
						],
						"false": [
							{
								"type": "comment",
								"text": "绘制合成画布"
							},
							{
								"type": "function",
								"function": "function(){\nlet name = 'uievent',\n\tleft = 0,\n\ttop = 0,\n\twidth = 352,\n\theight = 352;\ncore.fillRoundRect(name, left, top, width, height, 5, [0, 0, 0, 0.5]); //背景颜色\n\ncore.setTextAlign(name, 'center');\nlet origin_x = 176, //上面文字左侧起点\n\torigin_y = 12, //上面文字上面起点\n\ttitle = flags.title\ncore.fillText(name, title, origin_x, origin_y, [255, 255, 255, 1], \"bold 15px Verdana\");\ncore.setTextAlign(name, 'left');\n\n//基础数据\nlet box = flags.box || [], //背包物品\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column; //背包列数\nlet box_size = 32, //方框大小\n\tline = 2; //线条粗细\nlet icon_size = box_size - line\n\n\nlet select_item = core.getFlag(\"select_item\"), //选择的物品\n\tproduct\n//绘制选择的物品\norigin_x = 14; //选择的物品，左侧起点\norigin_y = 46; //选择的物品，上面起点\ncore.fillRect(name, origin_x, origin_y, box_size, box_size, [89, 89, 89, 1])\ncore.strokeRect(name, origin_x, origin_y, box_size, box_size, [0, 0, 0, 0.5], line)\nif (select_item) {\n\tcore.drawIcon(name, select_item, origin_x, origin_y, icon_size, icon_size);\n\torigin_x += 36\n\tlet text = core.material.items[select_item].name;\n\tcore.fillText(name, text, origin_x, origin_y, [255, 255, 255, 1], \"bold 12px Verdana\");\n\torigin_y += 12;\n\tlet config = {\n\t\t\"left\": origin_x,\n\t\t\"top\": origin_y,\n\t\t\"fontSize\": 10,\n\t\t\"maxWidth\": 100\n\t}\n\ttext = core.material.items[select_item].text;\n\tcore.drawTextContent(name, text, config);\n\n\tproduct = flags.update[select_item]\n}\n\n\n//箭头\norigin_x = 160; //三连产品框左侧起点\norigin_y = 46; //三连产品框上面起点\ncore.drawIcon(name, \"arrowRight\", origin_x, origin_y, icon_size, icon_size);\n\n//绘制三连物品\norigin_x = 208; //三连产品框左侧起点\norigin_y = 46; //三连产品框上面起点\ncore.fillRect(name, origin_x, origin_y, box_size, box_size, [89, 89, 89, 1])\ncore.strokeRect(name, origin_x, origin_y, box_size, box_size, [0, 0, 0, 0.5], line)\nif (product) {\n\tcore.drawIcon(name, product, origin_x, origin_y, icon_size, icon_size);\n\torigin_x += 36\n\tlet text = core.material.items[product].name;\n\tcore.fillText(name, text, origin_x, origin_y, [255, 255, 255, 1], \"bold 12px Verdana\");\n\torigin_y += 12;\n\tlet config = {\n\t\t\"left\": origin_x,\n\t\t\"top\": origin_y,\n\t\t\"fontSize\": 10,\n\t\t\"maxWidth\": 100\n\t}\n\ttext = core.material.items[product].text;\n\tcore.drawTextContent(name, text, config);\n}\n\n\norigin_x = 14; //背包左侧起点\norigin_y = 94; //背包上面起点\n//绘制背包方框\ncore.fillRect(name, origin_x, origin_y, box_size * box_column, box_size * box_row, [89, 89, 89, 1]); //背包底色\nfor (let i = 0; i <= box_column; i++) {\n\tcore.drawLine(name, origin_x + box_size * i, origin_y, origin_x + box_size * i, origin_y + box_size * box_row, [0, 0, 0, 1], 2); //绘制纵向线条\n}\nfor (let i = 0; i <= box_row; i++) {\n\tcore.drawLine(name, origin_x, origin_y + box_size * i, origin_x + box_size * box_column, origin_y + box_size * i, [0, 0, 0, 1], 2); //绘制横向线条\n}\n//绘制背包物品\nlet i_row = 0,\n\ti_column = 0;\nfor (let i = 0; i < box.length; i++) {\n\tlet item = box[i];\n\tif (item[1] > 0) {\n\t\tfor (let n = 0; n < item[1]; n++) {\n\t\t\tcore.drawIcon(name, item[0], origin_x + i_column * box_size + line, origin_y + i_row * box_size + line, icon_size, icon_size)\n\t\t\ti_column += 1\n\t\t\tif (i_column >= box_column) {\n\t\t\t\ti_column -= box_column;\n\t\t\t\ti_row += 1\n\t\t\t}\n\t\t}\n\t}\n}\nif (select_item) {\n\tlet click_X = flags.click_X,\n\t\tclick_Y = flags.click_Y;\n\tcore.strokeRect(name, origin_x + click_X * box_size, origin_y + click_Y * box_size, box_size, box_size, [255, 255, 0, 1], line);\n}\n\ncore.setFont(name, \"bold 12px Verdana\");\n//绘制丢弃\norigin_x = 200; //丢弃按钮左侧起点\norigin_y = 110 + box_row * box_size; //丢弃按钮上面起点\ncore.fillRect(name, origin_x, origin_y, 36, 36, [133, 133, 133, 1]);\ncore.fillRect(name, origin_x, origin_y, 32, 4, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x, origin_y, 4, 32, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x + 32, origin_y, 4, 36, [89, 89, 89, 1]);\ncore.fillRect(name, origin_x, origin_y + 32, 36, 4, [89, 89, 89, 1]);\ncore.strokeRect(name, origin_x, origin_y, 36, 36, [0, 0, 0, 1], 2);\ncore.fillText(name, '丢弃', origin_x + 3, origin_y + 11, [255, 255, 255, 1])\n\n\n//绘制离开\norigin_x = 300; //离开按钮左侧起点\norigin_y = 300; //离开按钮上面起点\ncore.fillRect(name, origin_x, origin_y, 36, 36, [133, 133, 133, 1]);\ncore.fillRect(name, origin_x, origin_y, 32, 4, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x, origin_y, 4, 32, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x + 32, origin_y, 4, 36, [89, 89, 89, 1]);\ncore.fillRect(name, origin_x, origin_y + 32, 36, 4, [89, 89, 89, 1]);\ncore.strokeRect(name, origin_x, origin_y, 36, 36, [0, 0, 0, 1], 2);\ncore.fillText(name, '离开', origin_x + 3, origin_y + 11, [255, 255, 255, 1])\n}"
							},
							{
								"type": "setValue",
								"name": "temp:number",
								"value": "flag:box_number"
							},
							{
								"type": "setValue",
								"name": "temp:box_size",
								"value": "32"
							},
							{
								"type": "setValue",
								"name": "temp:origin_x",
								"value": "14"
							},
							{
								"type": "setValue",
								"name": "temp:origin_y",
								"value": "94"
							},
							{
								"type": "setValue",
								"name": "temp:box_row",
								"value": "flag:box_row"
							},
							{
								"type": "setValue",
								"name": "temp:box_column",
								"value": "flag:box_column"
							},
							{
								"type": "wait",
								"forceChild": true,
								"data": [
									{
										"case": "mouse",
										"px": [
											0,
											480
										],
										"py": [
											0,
											480
										],
										"action": [
											{
												"type": "comment",
												"text": "点击背包"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +temp:box_size*temp:box_column)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +temp:box_size*temp:box_row))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet box = flags.box || [], //背包物品\n\tbox_number = flags.box_number,\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column, //背包列数\n\tbox_size = 32, //方框大小\n\tline = 2, //线条粗细\n\torigin_x = 14, //背包左侧起点\n\torigin_y = 94, //背包上面起点\n\tclick_X = flags.click_X, //上次点击的位置X\n\tclick_Y = flags.click_Y; //上次点击的位置Y\n\n\n//计算点击的位置\nlet Xoffset = parseInt((flags.px - origin_x) / box_size);\nXoffset = Math.floor(Xoffset);\nlet Yoffset = parseInt((flags.py - origin_y) / box_size);\nYoffset = Math.floor(Yoffset);\nlet index = Yoffset * box_column + Xoffset\nif (box_number > index) {\n\tlet select_item\n\tfor (let i = 0; i < box.length; i++) {\n\t\tlet item = box[i];\n\t\tif (item[1] > 0) {\n\t\t\tif (index < item[1]) {\n\t\t\t\tselect_item = item[0];\n\t\t\t\ti = 999;\n\t\t\t} else {\n\t\t\t\tindex -= item[1]\n\t\t\t}\n\t\t}\n\t}\n\tif (Xoffset === click_X && Yoffset === click_Y) { //点击相同位置，则使用道具\n\t\tlet cls = core.material.items[select_item].cls;\n\t\tlet select_item_index = flags.box_index[select_item]\n\t\tif (cls === \"equips\") {\n\t\t\tlet type = core.getEquipTypeById(select_item)\n\t\t\tlet equip = core.getEquip(type)\n\t\t\tif (equip) { //将卸下来的装备重新加入物品池\n\t\t\t\tlet equip_index = flags.box_index[equip]\n\t\t\t\tflags.box[equip_index][1] += 1;\n\t\t\t\tflags.box_number += 1;\n\t\t\t}\n\t\t\tcore.loadEquip(select_item) //装载装备\n\t\t\tif (type === 0) {\n\t\t\t\tcore.setFlag('nowWeapon', select_item);\n\t\t\t} else {\n\t\t\t\tcore.setFlag('nowShield', select_item);\n\t\t\t}\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\tif (cls === \"tools\") {\n\t\t\tcore.useItem(select_item, true)\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\tcore.setFlag(\"click_X\", null);\n\t\tcore.setFlag(\"click_Y\", null);\n\t\tcore.setFlag(\"select_item\", null);\n\t} else {\n\t\tcore.setFlag(\"click_X\", Xoffset);\n\t\tcore.setFlag(\"click_Y\", Yoffset);\n\t\tcore.setFlag(\"select_item\", select_item);\n\t}\n\tflags.title = \"请选择你的物品\"\n}\n}"
													}
												]
											},
											{
												"type": "comment",
												"text": "点击合成框"
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "208"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "46"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x + temp:box_size)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y + temp:box_size))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet select_item = core.getFlag(\"select_item\"),\n\tproduct\nif (select_item) product = flags.update[select_item];\nif (product) {\n\tlet index = flags.box_index[select_item],\n\t\tcls = core.material.items[select_item].cls; //选择物品的类型\n\tlet need_number = 3; //三连需求数量\n\tif (cls === \"equips\") {\n\t\tlet type = core.getEquipTypeById(select_item) //装备类型\n\t\tlet equip = core.getEquip(type) //当前装备\n\t\tif (equip === select_item) need_number -= 1\n\t}\n\tif (flags.box[index][1] >= need_number) {\n\t\tcore.setFlag(\"click_X\", null);\n\t\tcore.setFlag(\"click_Y\", null);\n\t\tcore.setFlag(\"select_item\", null);\n\n\t\tflags.box[index][1] -= need_number;\n\t\tflags.box_number -= need_number;\n\t\tif (need_number === 2) {\n\t\t\tlet type = core.getEquipTypeById(select_item) //装备类型\n\t\t\tcore.unloadEquip(type)\n\t\t\tif (type === 0) {\n\t\t\t\tcore.setFlag('nowWeapon', null);\n\t\t\t} else {\n\t\t\t\tcore.setFlag('nowShield', null);\n\t\t\t}\n\t\t}\n\t\tcore.removeItem(select_item, 3)\n\t\tcore.getItem(product, 1)\n\n\t\tif (need_number === 2) {\n\t\t\tlet type = core.getEquipTypeById(product), //装备类型\n\t\t\t\tproduct_index = flags.box_index[product];\n\t\t\tcore.loadEquip(product) //装载装备\n\t\t\tif (type === 0) {\n\t\t\t\tcore.setFlag('nowWeapon', product);\n\t\t\t} else {\n\t\t\t\tcore.setFlag('nowShield', product);\n\t\t\t}\n\t\t\tflags.box[product_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\t//构建随机池，构建奖品\n\t\tlet level = core.material.items[product].level; //三连奖品等级\n\t\tif (!level) return null\n\t\tlet randomPool = [], //随机池\n\t\t\tluck = flags.luck + flags.temp_luck //幸运值\n\t\tflags.temp_luck = 0\n\t\tfor (let i = 0; i < flags.level[level].length; i++) {\n\t\t\tlet item = flags.level[level][i],\n\t\t\t\tweight = flags.weight[level][item] + luck //所有物品权重增加幸运值数值\n\t\t\tfor (let j = 0; j < weight; j++) {\n\t\t\t\trandomPool.push(item) //随机池里面增加三连奖品等级的物品\n\t\t\t}\n\t\t}\n\t\trandomPool.sort(() => 0.5 - core.rand()); //打乱随机池\n\n\t\tlet prizePool = [], //奖品池\n\t\t\tPrizePoolNumber = flags.PrizePoolNumber //三连奖品数量\n\t\tfor (let i = 0; i < PrizePoolNumber; i++) { //随机从随机池里面添加N个物品进入奖品池\n\t\t\tlet rand = core.rand(randomPool.length)\n\t\t\tlet item = randomPool[rand]\n\t\t\tprizePool.push(item)\n\t\t}\n\t\tflags.randomPool = randomPool\n\t\tflags.prizePool = prizePool\n\t\tflags.select_time = flags.refresh //挑选刷新次数\n\t\tflags.success = true //成功三连\n\t\tflags.title = \"请选择三连奖品\"\n\t} else {\n\t\tlet text = core.material.items[select_item].name;\n\t\tflags.title = text + \"不足三个\"\n\t}\n} else {\n\tlet text = core.material.items[select_item].name;\n\tflags.title = text + \"不能继续合成\"\n}\n}"
													}
												]
											},
											{
												"type": "comment",
												"text": "点击丢弃"
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "200"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "110 + temp:box_size*temp:box_row"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +36)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +  36))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet select_item = core.getFlag(\"select_item\")\nif (select_item) {\n\tlet index = flags.box_index[select_item]\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"select_item\", null);\n\tcore.removeItem(select_item, 1)\n\tflags.box[index][1] -= 1;\n\tflags.box_number -= 1;\n}\n}"
													}
												]
											},
											{
												"type": "comment",
												"text": "点击离开"
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "300"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "300"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +36)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +  36))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "break",
														"n": 1
													}
												]
											}
										]
									}
								]
							}
						]
					},
					{
						"type": "waitAsync"
					}
				]
			},
			{
				"type": "drawSelector",
				"code": 1
			},
			{
				"type": "function",
				"function": "function(){\ncore.deleteCanvas('uievent');\ncore.clearUI();\ncore.clearMap('uievent');\ncore.setFlag(\"click_X\", null);\ncore.setFlag(\"click_Y\", null);\ncore.setFlag(\"select_item\", null);\ncore.setFlag(\"success\", null);\ncore.setFlag(\"randomPool\", null);\ncore.setFlag(\"prizePool\", null);\ncore.setFlag(\"title\", null);\ncore.setFlag(\"select_time\", null);\ncore.setFlag(\"prize_index\", null);\n}"
			}
		],
		"物品超量": [
			{
				"type": "setValue",
				"name": "flag:title",
				"value": "\"请选择一个物品使用或者三连\""
			},
			{
				"type": "while",
				"condition": "1",
				"data": [
					{
						"type": "previewUI",
						"action": [
							{
								"type": "clearMap"
							},
							{
								"type": "setAttribute",
								"font": "bold 12px Verdana",
								"strokeStyle": [
									255,
									255,
									255,
									1
								],
								"align": "center",
								"baseline": "top"
							}
						]
					},
					{
						"type": "if",
						"condition": "flag:success",
						"true": [
							{
								"type": "comment",
								"text": "绘制三连画布"
							},
							{
								"type": "function",
								"function": "function(){\nlet name = 'uievent',\n\tleft = 0,\n\ttop = 0,\n\twidth = 352,\n\theight = 352;\ncore.fillRoundRect(name, left, top, width, height, 5, [0, 0, 0, 0.5]); //背景颜色\n\n\ncore.setTextAlign(name, 'center');\nlet origin_x = 176, //上面文字起点\n\torigin_y = 12, //上面文字上面起点\n\ttitle = flags.title //标题\ncore.fillText(name, title, origin_x, origin_y, [255, 255, 255, 1], \"bold 15px Verdana\");\ncore.setTextAlign(name, 'left');\n\n//基础数据\nlet box = flags.box || [], //背包物品\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column; //背包列数\nlet box_size = 32, //方框大小\n\tline = 2; //线条粗细\nlet icon_size = box_size - line\nlet prizePool = flags.prizePool, //奖品池\n\tPrizePoolNumber = flags.PrizePoolNumber, //奖品池数量\n\tselect_time = flags.select_time //刷新次数\n\n\n\nlet select_item = core.getFlag(\"select_item\") //选择的物品\n//绘制奖品\norigin_x = 14; //奖品池左侧起点\norigin_y = 46; //奖品池上面起点\ncore.fillRect(name, origin_x, origin_y, box_size * PrizePoolNumber, box_size, [89, 89, 89, 1])\nfor (let i = 0; i < PrizePoolNumber; i++) {\n\tcore.strokeRect(name, origin_x, origin_y, box_size, box_size, [0, 0, 0, 0.5], line)\n\tcore.drawIcon(name, prizePool[i], origin_x + line, origin_y + line, icon_size, icon_size)\n\torigin_x += box_size\n}\n\ncore.setFont(name, \"bold 12px Verdana\");\n//绘制刷新\norigin_x += 8; //刷新按钮左侧起点\ncore.fillRect(name, origin_x, origin_y, 36, 36, [133, 133, 133, 1]);\ncore.fillRect(name, origin_x, origin_y, 32, 4, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x, origin_y, 4, 32, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x + 32, origin_y, 4, 36, [89, 89, 89, 1]);\ncore.fillRect(name, origin_x, origin_y + 32, 36, 4, [89, 89, 89, 1]);\ncore.strokeRect(name, origin_x, origin_y, 36, 36, [0, 0, 0, 1], 2);\ncore.fillText(name, '刷新', origin_x + 3, origin_y + 4, [255, 255, 255, 1])\ncore.fillText(name, select_time + '次', origin_x + 3, origin_y + 18, [255, 255, 255, 1])\n\n//绘制选择的物品\nif (select_item) {\n\torigin_x += 36\n\tlet text = core.material.items[select_item].name;\n\tcore.fillText(name, text, origin_x, origin_y, [255, 255, 255, 1], \"bold 12px Verdana\");\n\torigin_y += 12;\n\tlet config = {\n\t\t\"left\": origin_x,\n\t\t\"top\": origin_y,\n\t\t\"fontSize\": 10,\n\t\t\"maxWidth\": 100\n\t}\n\ttext = core.material.items[select_item].text;\n\tcore.drawTextContent(name, text, config);\n}\n\norigin_x = 14; //背包左侧起点\norigin_y = 94; //背包上面起点\n//绘制背包方框\ncore.fillRect(name, origin_x, origin_y, box_size * box_column, box_size * box_row, [89, 89, 89, 1]); //背包底色\nfor (let i = 0; i <= box_column; i++) {\n\tcore.drawLine(name, origin_x + box_size * i, origin_y, origin_x + box_size * i, origin_y + box_size * box_row, [0, 0, 0, 1], 2); //绘制纵向线条\n}\nfor (let i = 0; i <= box_row; i++) {\n\tcore.drawLine(name, origin_x, origin_y + box_size * i, origin_x + box_size * box_column, origin_y + box_size * i, [0, 0, 0, 1], 2); //绘制横向线条\n}\n//绘制背包物品\nlet i_row = 0,\n\ti_column = 0;\nfor (let i = 0; i < box.length; i++) {\n\tlet item = box[i];\n\tif (item[1] > 0) {\n\t\tfor (let n = 0; n < item[1]; n++) {\n\t\t\tcore.drawIcon(name, item[0], origin_x + i_column * box_size + line, origin_y + i_row * box_size + line, icon_size, icon_size)\n\t\t\ti_column += 1\n\t\t\tif (i_column >= box_column) {\n\t\t\t\ti_column -= box_column;\n\t\t\t\ti_row += 1\n\t\t\t}\n\t\t}\n\t}\n}\nif (select_item) {\n\tlet select_prize = flags.select_prize\n\tif (select_prize) {\n\t\torigin_x = 14; //奖品池左侧起点\n\t\torigin_y = 46; //奖品池上面起点\n\t\tlet prize_index = flags.prize_index\n\t\tcore.strokeRect(name, origin_x + prize_index * box_size, origin_y, box_size, box_size, [255, 255, 0, 1], line);\n\t} else {\n\t\tlet click_X = flags.click_X,\n\t\t\tclick_Y = flags.click_Y;\n\t\tcore.strokeRect(name, origin_x + click_X * box_size, origin_y + click_Y * box_size, box_size, box_size, [255, 255, 0, 1], line);\n\t}\n}\n\ncore.setFont(name, \"bold 12px Verdana\");\n//绘制丢弃\norigin_x = 200; //丢弃按钮左侧起点\norigin_y = 110 + box_row * box_size; //丢弃按钮上面起点\ncore.fillRect(name, origin_x, origin_y, 36, 36, [133, 133, 133, 1]);\ncore.fillRect(name, origin_x, origin_y, 32, 4, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x, origin_y, 4, 32, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x + 32, origin_y, 4, 36, [89, 89, 89, 1]);\ncore.fillRect(name, origin_x, origin_y + 32, 36, 4, [89, 89, 89, 1]);\ncore.strokeRect(name, origin_x, origin_y, 36, 36, [0, 0, 0, 1], 2);\ncore.fillText(name, '丢弃', origin_x + 3, origin_y + 11, [255, 255, 255, 1])\n}"
							},
							{
								"type": "setValue",
								"name": "temp:PrizePoolNumber",
								"value": "flag:PrizePoolNumber"
							},
							{
								"type": "setValue",
								"name": "temp:box_size",
								"value": "32"
							},
							{
								"type": "setValue",
								"name": "temp:origin_x",
								"value": "14"
							},
							{
								"type": "setValue",
								"name": "temp:origin_y",
								"value": "46"
							},
							{
								"type": "setValue",
								"name": "temp:box_row",
								"value": "flag:box_row"
							},
							{
								"type": "setValue",
								"name": "temp:box_column",
								"value": "flag:box_column"
							},
							{
								"type": "wait",
								"forceChild": true,
								"data": [
									{
										"case": "mouse",
										"px": [
											0,
											480
										],
										"py": [
											0,
											480
										],
										"action": [
											{
												"type": "comment",
												"text": "点击三连奖品"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +temp:box_size*temp:PrizePoolNumber)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +temp:box_size))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet prizePool = flags.prizePool, //奖品池\n\tbox_size = 32, //方框大小\n\tline = 2, //线条粗细\n\torigin_x = 14, //奖品池左侧起点\n\torigin_y = 46, //奖品池上面起点\n\tprize_index = flags.prize_index //上次点击的位置\n\n\n//计算点击的位置\nlet index = parseInt((flags.px - origin_x) / box_size);\nindex = Math.floor(index);\nlet select_item = prizePool[index]\nif (select_item) {\n\tflags.select_prize = true\n\tflags.prize_index = index\n\tflags.select_item = select_item\n\tflags.title = \"请选择三连奖品\"\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n}\n\nif (prize_index === index) {\n\tflags.can_quit = true\n\tcore.getItem(select_item, 1)\n\tcore.setFlag(\"select_prize\", null);\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"select_item\", null);\n\tcore.setFlag(\"success\", false);\n}\n}"
													}
												]
											},
											{
												"type": "comment",
												"text": "刷新三连"
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "22 +temp:box_size*temp:PrizePoolNumber"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "46"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +36)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +  36))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet select_time = flags.select_time //刷新次数\nif (select_time > 0) {\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"select_item\", null);\n\n\tlet randomPool = flags.randomPool\n\n\tlet prizePool = [], //奖品池\n\t\tPrizePoolNumber = flags.PrizePoolNumber //三连奖品数量\n\tfor (let i = 0; i < PrizePoolNumber; i++) { //随机从随机池里面添加N个物品进入奖品池\n\t\tlet rand = core.rand(randomPool.length)\n\t\tlet item = randomPool[rand]\n\t\tprizePool.push(item)\n\t}\n\tflags.prizePool = prizePool\n\tflags.select_time -= 1 //挑选刷新次数-1\n\tflags.success = true //成功三连\n\tflags.title = \"请选择三连奖品\"\n} else {\n\tlet text = core.material.items[select_item].name;\n\tflags.title = \"你没有刷新次数\"\n}\n}"
													}
												]
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "14"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "94"
											},
											{
												"type": "comment",
												"text": "点击背包"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +temp:box_size*temp:box_column)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +temp:box_size*temp:box_row))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet box = flags.box || [], //背包物品\n\tbox_number = flags.box_number,\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column, //背包列数\n\tbox_size = 32, //方框大小\n\tline = 2, //线条粗细\n\torigin_x = 14, //背包左侧起点\n\torigin_y = 94, //背包上面起点\n\tclick_X = flags.click_X, //上次点击的位置X\n\tclick_Y = flags.click_Y; //上次点击的位置Y\n\n\n//计算点击的位置\nlet Xoffset = parseInt((flags.px - origin_x) / box_size);\nXoffset = Math.floor(Xoffset);\nlet Yoffset = parseInt((flags.py - origin_y) / box_size);\nYoffset = Math.floor(Yoffset);\nlet index = Yoffset * box_column + Xoffset\nif (box_number > index) {\n\tlet select_item\n\tfor (let i = 0; i < box.length; i++) {\n\t\tlet item = box[i];\n\t\tif (item[1] > 0) {\n\t\t\tif (index < item[1]) {\n\t\t\t\tselect_item = item[0];\n\t\t\t\ti = 999;\n\t\t\t} else {\n\t\t\t\tindex -= item[1]\n\t\t\t}\n\t\t}\n\t}\n\tif (Xoffset === click_X && Yoffset === click_Y) { //点击相同位置，则使用道具\n\t\tlet cls = core.material.items[select_item].cls;\n\t\tlet select_item_index = flags.box_index[select_item]\n\t\tif (cls === \"equips\") {\n\t\t\tlet type = core.getEquipTypeById(select_item)\n\t\t\tlet equip = core.getEquip(type)\n\t\t\tif (equip) { //将卸下来的装备重新加入物品池\n\t\t\t\tlet equip_index = flags.box_index[equip]\n\t\t\t\tflags.box[equip_index][1] += 1;\n\t\t\t\tflags.box_number += 1;\n\t\t\t}\n\t\t\tcore.loadEquip(select_item) //装载装备\n\t\t\tif (type === 0) {\n\t\t\t\tcore.setFlag('nowWeapon', select_item);\n\t\t\t} else {\n\t\t\t\tcore.setFlag('nowShield', select_item);\n\t\t\t}\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\tif (cls === \"tools\") {\n\t\t\tcore.useItem(select_item, true)\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\tcore.setFlag(\"click_X\", null);\n\t\tcore.setFlag(\"click_Y\", null);\n\t\tcore.setFlag(\"select_item\", null);\n\t} else {\n\t\tcore.setFlag(\"click_X\", Xoffset);\n\t\tcore.setFlag(\"click_Y\", Yoffset);\n\t\tcore.setFlag(\"select_item\", select_item);\n\t}\n\tcore.setFlag(\"select_prize\", false);\n}\nflags.title = \"请选择三连奖品\"\ncore.setFlag(\"prize_index\", null);\n}"
													}
												]
											},
											{
												"type": "comment",
												"text": "点击丢弃"
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "200"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "110 + temp:box_size*temp:box_row"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +36)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +  36))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet select_item = core.getFlag(\"select_item\"),\n\tprize_index = flags.prize_index\nif (select_item && prize_index == null) {\n\tlet index = flags.box_index[select_item]\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"select_item\", null);\n\tcore.removeItem(select_item, 1)\n\tflags.box[index][1] -= 1;\n\tflags.box_number -= 1;\n} else {\n\tcore.setFlag(\"select_prize\", null);\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"select_item\", null);\n\tcore.setFlag(\"success\", false);\n\tflags.can_quit = true\n}\n}"
													}
												]
											}
										]
									}
								]
							}
						],
						"false": [
							{
								"type": "comment",
								"text": "绘制画布"
							},
							{
								"type": "function",
								"function": "function(){\nlet name = 'uievent',\n\tleft = 0,\n\ttop = 0,\n\twidth = 352,\n\theight = 352;\ncore.fillRoundRect(name, left, top, width, height, 5, [0, 0, 0, 0.5]); //背景颜色\n\n\ncore.setTextAlign(name, 'center');\nlet origin_x = 176, //上面文字起点\n\torigin_y = 12, //上面文字上面起点\n\ttitle = flags.title //标题\ncore.fillText(name, title, origin_x, origin_y, [255, 255, 255, 1], \"bold 15px Verdana\");\ncore.setTextAlign(name, 'left');\n\n//基础数据\nlet box = flags.box || [], //背包物品\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column; //背包列数\nlet box_size = 32, //方框大小\n\tline = 2; //线条粗细\nlet icon_size = box_size - line\nlet select_prize = flags.select_prize\n\n\nlet select_item = flags.select_item, //选择的物品\n\tget_item = flags.get_item; //获得的物品\nlet product = flags.update[select_item]\n\n//绘制选择的物品\norigin_x = 14; //选择的物品，左侧起点\norigin_y = 46; //选择的物品，上面起点\ncore.fillRect(name, origin_x, origin_y, box_size, box_size, [89, 89, 89, 1])\ncore.strokeRect(name, origin_x, origin_y, box_size, box_size, [0, 0, 0, 0.5], line)\nif (select_item) {\n\tcore.drawIcon(name, select_item, origin_x, origin_y, icon_size, icon_size);\n\torigin_x += 36\n\tlet text = core.material.items[select_item].name;\n\tcore.fillText(name, text, origin_x, origin_y, [255, 255, 255, 1], \"bold 12px Verdana\");\n\torigin_y += 12;\n\tlet config = {\n\t\t\"left\": origin_x,\n\t\t\"top\": origin_y,\n\t\t\"fontSize\": 10,\n\t\t\"maxWidth\": 100\n\t}\n\ttext = core.material.items[select_item].text;\n\tcore.drawTextContent(name, text, config);\n\n\tproduct = flags.update[select_item]\n}\n\n//箭头\norigin_x = 160; //三连产品框左侧起点\norigin_y = 46; //三连产品框上面起点\ncore.drawIcon(name, \"arrowRight\", origin_x, origin_y, icon_size, icon_size);\n\n//绘制三连物品\norigin_x = 208; //三连产品框左侧起点\norigin_y = 46; //三连产品框上面起点\ncore.fillRect(name, origin_x, origin_y, box_size, box_size, [89, 89, 89, 1])\ncore.strokeRect(name, origin_x, origin_y, box_size, box_size, [0, 0, 0, 0.5], line)\nif (product) {\n\tcore.drawIcon(name, product, origin_x, origin_y, icon_size, icon_size);\n\torigin_x += 36\n\tlet text = core.material.items[product].name;\n\tcore.fillText(name, text, origin_x, origin_y, [255, 255, 255, 1], \"bold 12px Verdana\");\n\torigin_y += 12;\n\tlet config = {\n\t\t\"left\": origin_x,\n\t\t\"top\": origin_y,\n\t\t\"fontSize\": 10,\n\t\t\"maxWidth\": 100\n\t}\n\ttext = core.material.items[product].text;\n\tcore.drawTextContent(name, text, config);\n}\norigin_x = 14; //背包左侧起点\norigin_y = 94; //背包上面起点\n//绘制背包方框\ncore.fillRect(name, origin_x, origin_y, box_size * box_column, box_size * box_row, [89, 89, 89, 1]); //背包底色\nfor (let i = 0; i <= box_column; i++) {\n\tcore.drawLine(name, origin_x + box_size * i, origin_y, origin_x + box_size * i, origin_y + box_size * box_row, [0, 0, 0, 1], 2); //绘制纵向线条\n}\nfor (let i = 0; i <= box_row; i++) {\n\tcore.drawLine(name, origin_x, origin_y + box_size * i, origin_x + box_size * box_column, origin_y + box_size * i, [0, 0, 0, 1], 2); //绘制横向线条\n}\n//绘制背包物品\nlet i_row = 0,\n\ti_column = 0;\nfor (let i = 0; i < box.length; i++) {\n\tlet item = box[i];\n\tif (item[1] > 0) {\n\t\tfor (let n = 0; n < item[1]; n++) {\n\t\t\tcore.drawIcon(name, item[0], origin_x + i_column * box_size + line, origin_y + i_row * box_size + line, icon_size, icon_size)\n\t\t\ti_column += 1\n\t\t\tif (i_column >= box_column) {\n\t\t\t\ti_column -= box_column;\n\t\t\t\ti_row += 1\n\t\t\t}\n\t\t}\n\t}\n}\n\n//绘制获得的物品\norigin_x = 14; //获得的物品左侧起点\norigin_y = 110 + box_row * box_size; //获得的物品上面起点\ncore.fillRect(name, origin_x, origin_y, box_size, box_size, [89, 89, 89, 1])\ncore.strokeRect(name, origin_x, origin_y, box_size, box_size, [0, 255, 255, 1], line)\ncore.drawIcon(name, get_item, origin_x + line, origin_y + line, icon_size, icon_size)\n\norigin_x += 48\nlet text = core.material.items[get_item].name;\ncore.fillText(name, text, origin_x, origin_y, [255, 255, 255, 1], \"bold 12px Verdana\");\norigin_y += 12;\nlet config = {\n\t\"left\": origin_x,\n\t\"top\": origin_y,\n\t\"fontSize\": 10,\n\t\"maxWidth\": 100\n}\ntext = core.material.items[get_item].text;\ncore.drawTextContent(name, text, config);\n\n//绘制边框\nif (select_prize) {\n\torigin_x = 14; //奖品池左侧起点\n\torigin_y = 110 + box_row * box_size; //奖品池上面起点\n\tcore.strokeRect(name, origin_x, origin_y, box_size, box_size, [255, 255, 0, 1], line);\n} else {\n\tif (select_item) {\n\t\torigin_x = 14; //背包左侧起点\n\t\torigin_y = 94; //背包上面起点\n\t\tlet click_X = flags.click_X,\n\t\t\tclick_Y = flags.click_Y;\n\t\tcore.strokeRect(name, origin_x + click_X * box_size, origin_y + click_Y * box_size, box_size, box_size, [255, 255, 0, 1], line);\n\t}\n}\n\ncore.setFont(name, \"bold 12px Verdana\");\n//绘制丢弃\norigin_x = 200; //丢弃按钮左侧起点\norigin_y = 110 + box_row * box_size; //丢弃按钮上面起点\ncore.fillRect(name, origin_x, origin_y, 36, 36, [133, 133, 133, 1]);\ncore.fillRect(name, origin_x, origin_y, 32, 4, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x, origin_y, 4, 32, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x + 32, origin_y, 4, 36, [89, 89, 89, 1]);\ncore.fillRect(name, origin_x, origin_y + 32, 36, 4, [89, 89, 89, 1]);\ncore.strokeRect(name, origin_x, origin_y, 36, 36, [0, 0, 0, 1], 2);\ncore.fillText(name, '丢弃', origin_x + 3, origin_y + 11, [255, 255, 255, 1])\n}"
							},
							{
								"type": "setValue",
								"name": "temp:PrizePoolNumber",
								"value": "flag:PrizePoolNumber"
							},
							{
								"type": "setValue",
								"name": "temp:box_size",
								"value": "32"
							},
							{
								"type": "setValue",
								"name": "temp:origin_x",
								"value": "14"
							},
							{
								"type": "setValue",
								"name": "temp:origin_y",
								"value": "94"
							},
							{
								"type": "setValue",
								"name": "temp:box_row",
								"value": "flag:box_row"
							},
							{
								"type": "setValue",
								"name": "temp:box_column",
								"value": "flag:box_column"
							},
							{
								"type": "wait",
								"forceChild": true,
								"data": [
									{
										"case": "mouse",
										"px": [
											0,
											480
										],
										"py": [
											0,
											480
										],
										"action": [
											{
												"type": "comment",
												"text": "点击背包"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +temp:box_size*temp:box_column)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +temp:box_size*temp:box_row))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet box = flags.box || [], //背包物品\n\tbox_number = flags.box_number,\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column, //背包列数\n\tbox_size = 32, //方框大小\n\tline = 2, //线条粗细\n\torigin_x = 14, //背包左侧起点\n\torigin_y = 94, //背包上面起点\n\tclick_X = flags.click_X, //上次点击的位置X\n\tclick_Y = flags.click_Y; //上次点击的位置Y\n\n\n//计算点击的位置\nlet Xoffset = parseInt((flags.px - origin_x) / box_size);\nXoffset = Math.floor(Xoffset);\nlet Yoffset = parseInt((flags.py - origin_y) / box_size);\nYoffset = Math.floor(Yoffset);\nlet index = Yoffset * box_column + Xoffset\nif (box_number > index) {\n\tlet select_item\n\tfor (let i = 0; i < box.length; i++) {\n\t\tlet item = box[i];\n\t\tif (item[1] > 0) {\n\t\t\tif (index < item[1]) {\n\t\t\t\tselect_item = item[0];\n\t\t\t\ti = 999;\n\t\t\t} else {\n\t\t\t\tindex -= item[1]\n\t\t\t}\n\t\t}\n\t}\n\tif (Xoffset === click_X && Yoffset === click_Y) { //点击相同位置，则使用道具\n\t\tlet cls = core.material.items[select_item].cls;\n\t\tlet select_item_index = flags.box_index[select_item]\n\t\tif (cls === \"equips\") {\n\t\t\tlet type = core.getEquipTypeById(select_item)\n\t\t\tlet equip = core.getEquip(type)\n\t\t\tif (equip) { //将卸下来的装备重新加入物品池\n\t\t\t\tlet equip_index = flags.box_index[equip]\n\t\t\t\tflags.box[equip_index][1] += 1;\n\t\t\t\tflags.box_number += 1;\n\t\t\t} else {\n\t\t\t\tflags.can_quit = true;\n\t\t\t\tlet get_item = flags.get_item;\n\t\t\t\tlet get_item_index = flags.box_index[get_item]\n\t\t\t\tflags.box[get_item_index][1] += 1;\n\t\t\t\tflags.box_number += 1;\n\t\t\t}\n\t\t\tcore.loadEquip(select_item) //装载装备\n\t\t\tif (type === 0) {\n\t\t\t\tcore.setFlag('nowWeapon', select_item);\n\t\t\t} else {\n\t\t\t\tcore.setFlag('nowShield', select_item);\n\t\t\t}\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\tif (cls === \"tools\") {\n\t\t\tcore.useItem(select_item, true)\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\n\t\t\tflags.can_quit = true;\n\t\t\tlet get_item = flags.get_item;\n\t\t\tlet get_item_index = flags.box_index[get_item]\n\t\t\tflags.box[get_item_index][1] += 1;\n\t\t\tflags.box_number += 1;\n\t\t}\n\t\tcore.setFlag(\"click_X\", null);\n\t\tcore.setFlag(\"click_Y\", null);\n\t\tcore.setFlag(\"select_item\", null);\n\t} else {\n\t\tcore.setFlag(\"click_X\", Xoffset);\n\t\tcore.setFlag(\"click_Y\", Yoffset);\n\t\tcore.setFlag(\"select_item\", select_item);\n\t}\n\tcore.setFlag(\"select_prize\", false);\n}\n}"
													}
												]
											},
											{
												"type": "comment",
												"text": "点击合成框"
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "208"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "46"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x + temp:box_size)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y + temp:box_size))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet select_item = flags.select_item,\n\tget_item = flags.get_item,\n\tproduct\nif (select_item) product = flags.update[select_item];\nif (product) {\n\tlet index = flags.box_index[select_item],\n\t\tcls = core.material.items[select_item].cls, //选择物品的类型\n\t\tneed_number = 3, //三连需求数量\n\t\tequip\n\tif (get_item === select_item) need_number -= 1\n\tif (cls === \"equips\") {\n\t\tlet type = core.getEquipTypeById(select_item) //装备类型\n\t\tequip = core.getEquip(type) //当前装备\n\t\tif (equip === select_item) need_number -= 1\n\t}\n\tif (flags.box[index][1] >= need_number) {\n\t\tcore.setFlag(\"click_X\", null);\n\t\tcore.setFlag(\"click_Y\", null);\n\t\tcore.setFlag(\"select_item\", null);\n\n\t\tflags.box[index][1] -= need_number;\n\t\tflags.box_number -= need_number;\n\t\tif (equip === select_item) {\n\t\t\tlet type = core.getEquipTypeById(select_item) //装备类型\n\t\t\tcore.unloadEquip(type)\n\t\t\tif (type === 0) {\n\t\t\t\tcore.setFlag('nowWeapon', null);\n\t\t\t} else {\n\t\t\t\tcore.setFlag('nowShield', null);\n\t\t\t}\n\t\t}\n\t\tcore.removeItem(select_item, need_number + 1)\n\t\tcore.getItem(product, 1)\n\n\t\tif (equip === select_item) {\n\t\t\tlet type = core.getEquipTypeById(product), //装备类型\n\t\t\t\tproduct_index = flags.box_index[product];\n\t\t\tcore.loadEquip(product) //装载装备\n\t\t\tif (type === 0) {\n\t\t\t\tcore.setFlag('nowWeapon', product);\n\t\t\t} else {\n\t\t\t\tcore.setFlag('nowShield', product);\n\t\t\t}\n\t\t\tflags.box[product_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\t//构建随机池，构建奖品\n\t\tlet level = core.material.items[product].level; //三连奖品等级\n\t\tif (!level) return null\n\t\tlet randomPool = [], //随机池\n\t\t\tluck = flags.luck + flags.temp_luck //幸运值\n\t\tflags.temp_luck = 0\n\t\tfor (let i = 0; i < flags.level[level].length; i++) {\n\t\t\tlet item = flags.level[level][i],\n\t\t\t\tweight = flags.weight[level][item] + luck //所有物品权重增加幸运值数值\n\t\t\tfor (let j = 0; j < weight; j++) {\n\t\t\t\trandomPool.push(item) //随机池里面增加三连奖品等级的物品\n\t\t\t}\n\t\t}\n\t\trandomPool.sort(() => 0.5 - core.rand()); //打乱随机池\n\n\t\tlet prizePool = [], //奖品池\n\t\t\tPrizePoolNumber = flags.PrizePoolNumber //三连奖品数量\n\t\tfor (let i = 0; i < PrizePoolNumber; i++) { //随机从随机池里面添加N个物品进入奖品池\n\t\t\tlet rand = core.rand(randomPool.length)\n\t\t\tlet item = randomPool[rand]\n\t\t\tprizePool.push(item)\n\t\t}\n\t\tflags.randomPool = randomPool\n\t\tflags.prizePool = prizePool\n\t\tflags.select_time = flags.refresh //挑选刷新次数\n\t\tflags.success = true //成功三连\n\t\tflags.title = \"请选择三连奖品\"\n\t\tif (get_item !== select_item) {\n\t\t\tlet get_item_index = flags.box_index[get_item]\n\t\t\tflags.box[get_item_index][1] += 1;\n\t\t\tflags.box_number += 1;\n\t\t}\n\t} else {\n\t\tlet text = core.material.items[select_item].name;\n\t\tflags.title = text + \"不足三个\"\n\t}\n} else {\n\tlet text = core.material.items[select_item].name;\n\tflags.title = text + \"不能继续合成\"\n}\n}"
													}
												]
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "14"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "110 + temp:box_size*temp:box_row"
											},
											{
												"type": "comment",
												"text": "点击获得的物品"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +temp:box_size)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +temp:box_size))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet select_prize = flags.select_prize,\n\tselect_item = flags.get_item\ncore.setFlag(\"click_X\", null);\ncore.setFlag(\"click_Y\", null);\ncore.setFlag(\"select_item\", null);\n\nif (select_prize) {\n\tlet cls = core.material.items[select_item].cls;\n\tlet select_item_index = flags.box_index[select_item]\n\tif (cls === \"equips\") {\n\t\tlet type = core.getEquipTypeById(select_item)\n\t\tlet equip = core.getEquip(type)\n\t\tif (equip) { //将卸下来的装备重新加入物品池\n\t\t\tlet equip_index = flags.box_index[equip]\n\t\t\tflags.get_item = equip;\n\t\t} else {\n\t\t\tflags.can_quit = true;\n\t\t}\n\t\tcore.loadEquip(select_item) //装载装备\n\t\tif (type === 0) {\n\t\t\tcore.setFlag('nowWeapon', select_item);\n\t\t} else {\n\t\t\tcore.setFlag('nowShield', select_item);\n\t\t}\n\t}\n\tif (cls === \"tools\") {\n\t\tcore.useItem(select_item, true)\n\t\tflags.can_quit = true;\n\t}\n} else {\n\tflags.select_item = select_item\n\tflags.select_prize = true\n}\n}"
													}
												]
											},
											{
												"type": "comment",
												"text": "点击丢弃"
											},
											{
												"type": "setValue",
												"name": "temp:origin_x",
												"value": "200"
											},
											{
												"type": "setValue",
												"name": "temp:origin_y",
												"value": "110 + temp:box_size*temp:box_row"
											},
											{
												"type": "if",
												"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +36)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +  36))))",
												"true": [
													{
														"type": "playSound",
														"name": "确定"
													},
													{
														"type": "function",
														"function": "function(){\nlet select_prize = flags.select_prize,\n\tselect_item = flags.select_item\n\nif (select_item) {\n\tif (select_prize) {\n\t\tcore.removeItem(select_item, 1)\n\t\tcore.setFlag(\"select_item\", null);\n\t\tcore.setFlag(\"get_item\", null);\n\t} else {\n\t\tlet index = flags.box_index[select_item]\n\t\tcore.setFlag(\"click_X\", null);\n\t\tcore.setFlag(\"click_Y\", null);\n\t\tcore.setFlag(\"select_item\", null);\n\t\tcore.removeItem(select_item, 1)\n\t\tflags.box[index][1] -= 1;\n\t\tflags.box_number -= 1;\n\n\t\tlet get_item = flags.get_item\n\t\tlet get_item_index = flags.box_index[get_item]\n\t\tflags.box[get_item_index][1] += 1;\n\t\tflags.box_number += 1;\n\t}\n}\nflags.can_quit = true;\n}"
													}
												]
											}
										]
									}
								]
							}
						]
					},
					{
						"type": "if",
						"condition": "flag:can_quit",
						"true": [
							{
								"type": "break",
								"n": 1
							}
						]
					},
					{
						"type": "waitAsync"
					}
				]
			},
			{
				"type": "drawSelector",
				"code": 1
			},
			{
				"type": "function",
				"function": "function(){\ncore.deleteCanvas('uievent');\ncore.clearUI();\ncore.clearMap('uievent');\ncore.setFlag(\"click_X\", null);\ncore.setFlag(\"click_Y\", null);\ncore.setFlag(\"select_item\", null);\ncore.setFlag(\"title\", null);\ncore.setFlag(\"select_time\", null);\ncore.setFlag(\"can_quit\", null);\ncore.setFlag(\"get_item\", null);\ncore.setFlag(\"success\", null);\ncore.setFlag(\"randomPool\", null);\ncore.setFlag(\"prizePool\", null);\ncore.setFlag(\"prize_index\", null);\n}"
			}
		],
		"击杀怪物": [
			{
				"type": "function",
				"function": "function(){\nlet floor = flags.floor,\n\trandomPool = [], //随机池\n\tluck = flags.luck + flags.temp_luck //幸运值\nflags.temp_luck = 0\n//构建随机池，构建奖品\nfor (let i = 1; i <= floor; i++) { //i，物品等级\n\tif (flags.level[i]) {\n\t\tfor (let j = 0; j < flags.level[i].length; j++) { //物品池\n\t\t\tlet item = flags.level[i][j],\n\t\t\t\tweight = flags.weight[i][item]\n\t\t\tweight *= (floor - i + 1) //物品等级越低，权重越大\n\t\t\tweight += luck //物品权重增加幸运等级\n\t\t\tfor (let k = 0; k < weight; k++) {\n\t\t\t\trandomPool.push(item) //随机池里面增加三连奖品等级的物品\n\t\t\t}\n\t\t}\n\t}\n}\nrandomPool.sort(() => 0.5 - core.rand()); //打乱随机池\n\nlet prizePool = [], //奖品池\n\tPrizePoolNumber = flags.PrizePoolNumber //三连奖品数量\nfor (let i = 0; i < PrizePoolNumber; i++) { //随机从随机池里面添加N个物品进入奖品池\n\tlet rand = core.rand(randomPool.length)\n\tlet item = randomPool[rand]\n\tprizePool.push(item)\n}\nflags.randomPool = randomPool\nflags.prizePool = prizePool\nflags.select_time = flags.refresh //挑选刷新次数\nflags.title = \"请选择奖品\"\n}"
			},
			{
				"type": "while",
				"condition": "1",
				"data": [
					{
						"type": "previewUI",
						"action": [
							{
								"type": "clearMap"
							},
							{
								"type": "setAttribute",
								"font": "bold 12px Verdana",
								"strokeStyle": [
									255,
									255,
									255,
									1
								],
								"align": "center",
								"baseline": "top"
							}
						]
					},
					{
						"type": "comment",
						"text": "绘制三连画布"
					},
					{
						"type": "function",
						"function": "function(){\nlet name = 'uievent',\n\tleft = 0,\n\ttop = 0,\n\twidth = 352,\n\theight = 352;\ncore.fillRoundRect(name, left, top, width, height, 5, [0, 0, 0, 0.5]); //背景颜色\n\ncore.setTextAlign(name, 'center');\nlet origin_x = 176, //上面文字起点\n\torigin_y = 12, //上面文字上面起点\n\ttitle = flags.title //标题\ncore.fillText(name, title, origin_x, origin_y, [255, 255, 255, 1], \"bold 15px Verdana\");\ncore.setTextAlign(name, 'left');\n\n//基础数据\nlet box = flags.box || [], //背包物品\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column; //背包列数\nlet box_size = 32, //方框大小\n\tline = 2; //线条粗细\nlet icon_size = box_size - line\nlet prizePool = flags.prizePool, //奖品池\n\tPrizePoolNumber = flags.PrizePoolNumber, //奖品池数量\n\tselect_time = flags.select_time //刷新次数\n\n\nlet select_item = core.getFlag(\"select_item\") //选择的物品\n//绘制奖品\norigin_x = 14; //奖品池左侧起点\norigin_y = 46; //奖品池上面起点\ncore.fillRect(name, origin_x, origin_y, box_size * PrizePoolNumber, box_size, [89, 89, 89, 1])\nfor (let i = 0; i < PrizePoolNumber; i++) {\n\tcore.strokeRect(name, origin_x, origin_y, box_size, box_size, [0, 0, 0, 0.5], line)\n\tcore.drawIcon(name, prizePool[i], origin_x + line, origin_y + line, icon_size, icon_size)\n\torigin_x += box_size\n}\n\ncore.setFont(name, \"bold 12px Verdana\");\n//绘制刷新\norigin_x += 8; //刷新按钮左侧起点\ncore.fillRect(name, origin_x, origin_y, 36, 36, [133, 133, 133, 1]);\ncore.fillRect(name, origin_x, origin_y, 32, 4, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x, origin_y, 4, 32, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x + 32, origin_y, 4, 36, [89, 89, 89, 1]);\ncore.fillRect(name, origin_x, origin_y + 32, 36, 4, [89, 89, 89, 1]);\ncore.strokeRect(name, origin_x, origin_y, 36, 36, [0, 0, 0, 1], 2);\ncore.fillText(name, '刷新', origin_x + 3, origin_y + 4, [255, 255, 255, 1])\ncore.fillText(name, select_time + '次', origin_x + 3, origin_y + 18, [255, 255, 255, 1])\n\n//绘制选择的物品\nif (select_item) {\n\torigin_x += 36\n\tlet text = core.material.items[select_item].name;\n\tcore.fillText(name, text, origin_x, origin_y, [255, 255, 255, 1], \"bold 12px Verdana\");\n\torigin_y += 12;\n\tlet config = {\n\t\t\"left\": origin_x,\n\t\t\"top\": origin_y,\n\t\t\"fontSize\": 10,\n\t\t\"maxWidth\": 100\n\t}\n\ttext = core.material.items[select_item].text;\n\tcore.drawTextContent(name, text, config);\n}\n\norigin_x = 14; //背包左侧起点\norigin_y = 94; //背包上面起点\n//绘制背包方框\ncore.fillRect(name, origin_x, origin_y, box_size * box_column, box_size * box_row, [89, 89, 89, 1]); //背包底色\nfor (let i = 0; i <= box_column; i++) {\n\tcore.drawLine(name, origin_x + box_size * i, origin_y, origin_x + box_size * i, origin_y + box_size * box_row, [0, 0, 0, 1], 2); //绘制纵向线条\n}\nfor (let i = 0; i <= box_row; i++) {\n\tcore.drawLine(name, origin_x, origin_y + box_size * i, origin_x + box_size * box_column, origin_y + box_size * i, [0, 0, 0, 1], 2); //绘制横向线条\n}\n//绘制背包物品\nlet i_row = 0,\n\ti_column = 0;\nfor (let i = 0; i < box.length; i++) {\n\tlet item = box[i];\n\tif (item[1] > 0) {\n\t\tfor (let n = 0; n < item[1]; n++) {\n\t\t\tcore.drawIcon(name, item[0], origin_x + i_column * box_size + line, origin_y + i_row * box_size + line, icon_size, icon_size)\n\t\t\ti_column += 1\n\t\t\tif (i_column >= box_column) {\n\t\t\t\ti_column -= box_column;\n\t\t\t\ti_row += 1\n\t\t\t}\n\t\t}\n\t}\n}\nif (select_item) {\n\tlet select_prize = flags.select_prize\n\tif (select_prize) {\n\t\torigin_x = 14; //奖品池左侧起点\n\t\torigin_y = 46; //奖品池上面起点\n\t\tlet prize_index = flags.prize_index\n\t\tcore.strokeRect(name, origin_x + prize_index * box_size, origin_y, box_size, box_size, [255, 255, 0, 1], line);\n\t} else {\n\t\tlet click_X = flags.click_X,\n\t\t\tclick_Y = flags.click_Y;\n\t\tcore.strokeRect(name, origin_x + click_X * box_size, origin_y + click_Y * box_size, box_size, box_size, [255, 255, 0, 1], line);\n\t}\n}\n\ncore.setFont(name, \"bold 12px Verdana\");\n//绘制丢弃\norigin_x = 200; //丢弃按钮左侧起点\norigin_y = 110 + box_row * box_size; //丢弃按钮上面起点\ncore.fillRect(name, origin_x, origin_y, 36, 36, [133, 133, 133, 1]);\ncore.fillRect(name, origin_x, origin_y, 32, 4, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x, origin_y, 4, 32, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x + 32, origin_y, 4, 36, [89, 89, 89, 1]);\ncore.fillRect(name, origin_x, origin_y + 32, 36, 4, [89, 89, 89, 1]);\ncore.strokeRect(name, origin_x, origin_y, 36, 36, [0, 0, 0, 1], 2);\ncore.fillText(name, '丢弃', origin_x + 3, origin_y + 11, [255, 255, 255, 1])\n}"
					},
					{
						"type": "setValue",
						"name": "temp:PrizePoolNumber",
						"value": "flag:PrizePoolNumber"
					},
					{
						"type": "setValue",
						"name": "temp:box_size",
						"value": "32"
					},
					{
						"type": "setValue",
						"name": "temp:origin_x",
						"value": "14"
					},
					{
						"type": "setValue",
						"name": "temp:origin_y",
						"value": "46"
					},
					{
						"type": "setValue",
						"name": "temp:box_row",
						"value": "flag:box_row"
					},
					{
						"type": "setValue",
						"name": "temp:box_column",
						"value": "flag:box_column"
					},
					{
						"type": "wait",
						"forceChild": true,
						"data": [
							{
								"case": "mouse",
								"px": [
									0,
									480
								],
								"py": [
									0,
									480
								],
								"action": [
									{
										"type": "comment",
										"text": "点击奖品"
									},
									{
										"type": "if",
										"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +temp:box_size*temp:PrizePoolNumber)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +temp:box_size))))",
										"true": [
											{
												"type": "playSound",
												"name": "确定"
											},
											{
												"type": "function",
												"function": "function(){\nlet prizePool = flags.prizePool, //奖品池\n\tbox_size = 32, //方框大小\n\tline = 2, //线条粗细\n\torigin_x = 14, //奖品池左侧起点\n\torigin_y = 46, //奖品池上面起点\n\tprize_index = flags.prize_index //上次点击的位置\n\n\n//计算点击的位置\nlet index = parseInt((flags.px - origin_x) / box_size);\nindex = Math.floor(index);\nlet select_item = prizePool[index]\nif (select_item) {\n\tflags.select_prize = true\n\tflags.prize_index = index\n\tflags.select_item = select_item\n\tflags.title = \"请选择奖品\"\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n}\n\nif (prize_index === index) {\n\tcore.setFlag(\"select_prize\", null);\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"can_quit\", true);\n}\n}"
											}
										]
									},
									{
										"type": "comment",
										"text": "刷新"
									},
									{
										"type": "setValue",
										"name": "temp:origin_x",
										"value": "22 +temp:box_size*temp:PrizePoolNumber"
									},
									{
										"type": "setValue",
										"name": "temp:origin_y",
										"value": "46"
									},
									{
										"type": "if",
										"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +36)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +  36))))",
										"true": [
											{
												"type": "playSound",
												"name": "确定"
											},
											{
												"type": "function",
												"function": "function(){\nlet select_time = flags.select_time //刷新次数\nif (select_time > 0) {\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"select_item\", null);\n\n\tlet randomPool = flags.randomPool\n\n\tlet prizePool = [], //奖品池\n\t\tPrizePoolNumber = flags.PrizePoolNumber //三连奖品数量\n\tfor (let i = 0; i < PrizePoolNumber; i++) { //随机从随机池里面添加N个物品进入奖品池\n\t\tlet rand = core.rand(randomPool.length)\n\t\tlet item = randomPool[rand]\n\t\tprizePool.push(item)\n\t}\n\tflags.prizePool = prizePool\n\tflags.select_time -= 1 //挑选刷新次数-1\n\tflags.success = true //成功三连\n\tflags.title = \"请选择三连奖品\"\n} else {\n\tlet text = core.material.items[select_item].name;\n\tflags.title = \"你没有刷新次数\"\n}\n}"
											}
										]
									},
									{
										"type": "setValue",
										"name": "temp:origin_x",
										"value": "14"
									},
									{
										"type": "setValue",
										"name": "temp:origin_y",
										"value": "94"
									},
									{
										"type": "comment",
										"text": "点击背包"
									},
									{
										"type": "if",
										"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +temp:box_size*temp:box_column)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +temp:box_size*temp:box_row))))",
										"true": [
											{
												"type": "playSound",
												"name": "确定"
											},
											{
												"type": "function",
												"function": "function(){\nlet box = flags.box || [], //背包物品\n\tbox_number = flags.box_number,\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column, //背包列数\n\tbox_size = 32, //方框大小\n\tline = 2, //线条粗细\n\torigin_x = 14, //背包左侧起点\n\torigin_y = 94, //背包上面起点\n\tclick_X = flags.click_X, //上次点击的位置X\n\tclick_Y = flags.click_Y; //上次点击的位置Y\n\n\n//计算点击的位置\nlet Xoffset = parseInt((flags.px - origin_x) / box_size);\nXoffset = Math.floor(Xoffset);\nlet Yoffset = parseInt((flags.py - origin_y) / box_size);\nYoffset = Math.floor(Yoffset);\nlet index = Yoffset * box_column + Xoffset\nif (box_number > index) {\n\tlet select_item\n\tfor (let i = 0; i < box.length; i++) {\n\t\tlet item = box[i];\n\t\tif (item[1] > 0) {\n\t\t\tif (index < item[1]) {\n\t\t\t\tselect_item = item[0];\n\t\t\t\ti = 999;\n\t\t\t} else {\n\t\t\t\tindex -= item[1]\n\t\t\t}\n\t\t}\n\t}\n\tif (Xoffset === click_X && Yoffset === click_Y) { //点击相同位置，\n\t\tlet cls = core.material.items[select_item].cls;\n\t\tlet select_item_index = flags.box_index[select_item]\n\t\tif (cls === \"equips\") {\n\t\t\tlet type = core.getEquipTypeById(select_item)\n\t\t\tlet equip = core.getEquip(type)\n\t\t\tif (equip) { //将卸下来的装备重新加入物品池\n\t\t\t\tlet equip_index = flags.box_index[equip]\n\t\t\t\tflags.box[equip_index][1] += 1;\n\t\t\t\tflags.box_number += 1;\n\t\t\t}\n\t\t\tcore.loadEquip(select_item) //装载装备\n\t\t\tif (type === 0) {\n\t\t\t\tcore.setFlag('nowWeapon', select_item);\n\t\t\t} else {\n\t\t\t\tcore.setFlag('nowShield', select_item);\n\t\t\t}\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\tif (cls === \"tools\") {\n\t\t\tcore.useItem(select_item, true)\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\tcore.setFlag(\"click_X\", null);\n\t\tcore.setFlag(\"click_Y\", null);\n\t\tcore.setFlag(\"select_item\", null);\n\t} else {\n\t\tcore.setFlag(\"click_X\", Xoffset);\n\t\tcore.setFlag(\"click_Y\", Yoffset);\n\t\tcore.setFlag(\"select_item\", select_item);\n\t}\n\tcore.setFlag(\"select_prize\", false);\n}\nflags.title = \"请选择奖品\"\ncore.setFlag(\"prize_index\", null);\n}"
											}
										]
									},
									{
										"type": "comment",
										"text": "点击丢弃"
									},
									{
										"type": "setValue",
										"name": "temp:origin_x",
										"value": "200"
									},
									{
										"type": "setValue",
										"name": "temp:origin_y",
										"value": "110 + temp:box_size*temp:box_row"
									},
									{
										"type": "if",
										"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +36)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +  36))))",
										"true": [
											{
												"type": "playSound",
												"name": "确定"
											},
											{
												"type": "function",
												"function": "function(){\nlet select_item = core.getFlag(\"select_item\"),\n\tprize_index = flags.prize_index\nif (select_item && prize_index == null) {\n\tlet index = flags.box_index[select_item]\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"select_item\", null);\n\tcore.removeItem(select_item, 1)\n\tflags.box[index][1] -= 1;\n\tflags.box_number -= 1;\n} else {\n\tcore.setFlag(\"select_prize\", null);\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"select_item\", null);\n\tcore.setFlag(\"success\", false);\n\tflags.can_quit = true\n}\n}"
											}
										]
									}
								]
							}
						]
					},
					{
						"type": "if",
						"condition": "flag:can_quit",
						"true": [
							{
								"type": "break",
								"n": 1
							}
						]
					},
					{
						"type": "waitAsync"
					}
				]
			},
			{
				"type": "drawSelector",
				"code": 1
			},
			{
				"type": "function",
				"function": "function(){\nlet select_item = flags.select_item\ncore.deleteCanvas('uievent');\ncore.clearUI();\ncore.clearMap('uievent');\ncore.setFlag(\"click_X\", null);\ncore.setFlag(\"click_Y\", null);\ncore.setFlag(\"select_item\", null);\ncore.setFlag(\"success\", null);\ncore.setFlag(\"randomPool\", null);\ncore.setFlag(\"prizePool\", null);\ncore.setFlag(\"title\", null);\ncore.setFlag(\"select_time\", null);\ncore.setFlag(\"prize_index\", null);\ncore.setFlag(\"can_quit\", null);\nif (select_item) {\n\tcore.getItem(select_item, 1)\n}\n}"
			}
		],
		"福袋": [
			{
				"type": "while",
				"condition": "1",
				"data": [
					{
						"type": "previewUI",
						"action": [
							{
								"type": "clearMap"
							},
							{
								"type": "setAttribute",
								"font": "bold 12px Verdana",
								"strokeStyle": [
									255,
									255,
									255,
									1
								],
								"align": "center",
								"baseline": "top"
							}
						]
					},
					{
						"type": "comment",
						"text": "绘制三连画布"
					},
					{
						"type": "function",
						"function": "function(){\nlet name = 'uievent',\n\tleft = 0,\n\ttop = 0,\n\twidth = 352,\n\theight = 352;\ncore.fillRoundRect(name, left, top, width, height, 5, [0, 0, 0, 0.5]); //背景颜色\n\ncore.setTextAlign(name, 'center');\nlet origin_x = 176, //上面文字起点\n\torigin_y = 12, //上面文字上面起点\n\ttitle = flags.title //标题\ncore.fillText(name, title, origin_x, origin_y, [255, 255, 255, 1], \"bold 15px Verdana\");\ncore.setTextAlign(name, 'left');\n\n//基础数据\nlet box = flags.box || [], //背包物品\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column; //背包列数\nlet box_size = 32, //方框大小\n\tline = 2; //线条粗细\nlet icon_size = box_size - line\nlet prizePool = flags.prizePool, //奖品池\n\tPrizePoolNumber = flags.PrizePoolNumber, //奖品池数量\n\tselect_time = flags.select_time //刷新次数\n\n\nlet select_item = core.getFlag(\"select_item\") //选择的物品\n//绘制奖品\norigin_x = 14; //奖品池左侧起点\norigin_y = 46; //奖品池上面起点\ncore.fillRect(name, origin_x, origin_y, box_size * PrizePoolNumber, box_size, [89, 89, 89, 1])\nfor (let i = 0; i < PrizePoolNumber; i++) {\n\tcore.strokeRect(name, origin_x, origin_y, box_size, box_size, [0, 0, 0, 0.5], line)\n\tcore.drawIcon(name, prizePool[i], origin_x + line, origin_y + line, icon_size, icon_size)\n\torigin_x += box_size\n}\n\ncore.setFont(name, \"bold 12px Verdana\");\n//绘制刷新\norigin_x += 8; //刷新按钮左侧起点\ncore.fillRect(name, origin_x, origin_y, 36, 36, [133, 133, 133, 1]);\ncore.fillRect(name, origin_x, origin_y, 32, 4, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x, origin_y, 4, 32, [161, 161, 161, 1]);\ncore.fillRect(name, origin_x + 32, origin_y, 4, 36, [89, 89, 89, 1]);\ncore.fillRect(name, origin_x, origin_y + 32, 36, 4, [89, 89, 89, 1]);\ncore.strokeRect(name, origin_x, origin_y, 36, 36, [0, 0, 0, 1], 2);\ncore.fillText(name, '刷新', origin_x + 3, origin_y + 4, [255, 255, 255, 1])\ncore.fillText(name, select_time + '次', origin_x + 3, origin_y + 18, [255, 255, 255, 1])\n\n//绘制选择的物品\nif (select_item) {\n\torigin_x += 36\n\tlet text = core.material.items[select_item].name;\n\tcore.fillText(name, text, origin_x, origin_y, [255, 255, 255, 1], \"bold 12px Verdana\");\n\torigin_y += 12;\n\tlet config = {\n\t\t\"left\": origin_x,\n\t\t\"top\": origin_y,\n\t\t\"fontSize\": 10,\n\t\t\"maxWidth\": 100\n\t}\n\ttext = core.material.items[select_item].text;\n\tcore.drawTextContent(name, text, config);\n}\n\norigin_x = 14; //背包左侧起点\norigin_y = 94; //背包上面起点\n//绘制背包方框\ncore.fillRect(name, origin_x, origin_y, box_size * box_column, box_size * box_row, [89, 89, 89, 1]); //背包底色\nfor (let i = 0; i <= box_column; i++) {\n\tcore.drawLine(name, origin_x + box_size * i, origin_y, origin_x + box_size * i, origin_y + box_size * box_row, [0, 0, 0, 1], 2); //绘制纵向线条\n}\nfor (let i = 0; i <= box_row; i++) {\n\tcore.drawLine(name, origin_x, origin_y + box_size * i, origin_x + box_size * box_column, origin_y + box_size * i, [0, 0, 0, 1], 2); //绘制横向线条\n}\n//绘制背包物品\nlet i_row = 0,\n\ti_column = 0;\nfor (let i = 0; i < box.length; i++) {\n\tlet item = box[i];\n\tif (item[1] > 0) {\n\t\tfor (let n = 0; n < item[1]; n++) {\n\t\t\tcore.drawIcon(name, item[0], origin_x + i_column * box_size + line, origin_y + i_row * box_size + line, icon_size, icon_size)\n\t\t\ti_column += 1\n\t\t\tif (i_column >= box_column) {\n\t\t\t\ti_column -= box_column;\n\t\t\t\ti_row += 1\n\t\t\t}\n\t\t}\n\t}\n}\nif (select_item) {\n\tlet select_prize = flags.select_prize\n\tif (select_prize) {\n\t\torigin_x = 14; //奖品池左侧起点\n\t\torigin_y = 46; //奖品池上面起点\n\t\tlet prize_index = flags.prize_index\n\t\tcore.strokeRect(name, origin_x + prize_index * box_size, origin_y, box_size, box_size, [255, 255, 0, 1], line);\n\t} else {\n\t\tlet click_X = flags.click_X,\n\t\t\tclick_Y = flags.click_Y;\n\t\tcore.strokeRect(name, origin_x + click_X * box_size, origin_y + click_Y * box_size, box_size, box_size, [255, 255, 0, 1], line);\n\t}\n}\n}"
					},
					{
						"type": "setValue",
						"name": "temp:PrizePoolNumber",
						"value": "flag:PrizePoolNumber"
					},
					{
						"type": "setValue",
						"name": "temp:box_size",
						"value": "32"
					},
					{
						"type": "setValue",
						"name": "temp:origin_x",
						"value": "14"
					},
					{
						"type": "setValue",
						"name": "temp:origin_y",
						"value": "46"
					},
					{
						"type": "setValue",
						"name": "temp:box_row",
						"value": "flag:box_row"
					},
					{
						"type": "setValue",
						"name": "temp:box_column",
						"value": "flag:box_column"
					},
					{
						"type": "wait",
						"forceChild": true,
						"data": [
							{
								"case": "mouse",
								"px": [
									0,
									480
								],
								"py": [
									0,
									480
								],
								"action": [
									{
										"type": "comment",
										"text": "点击奖品"
									},
									{
										"type": "if",
										"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +temp:box_size*temp:PrizePoolNumber)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +temp:box_size))))",
										"true": [
											{
												"type": "playSound",
												"name": "确定"
											},
											{
												"type": "function",
												"function": "function(){\nlet prizePool = flags.prizePool, //奖品池\n\tbox_size = 32, //方框大小\n\tline = 2, //线条粗细\n\torigin_x = 14, //奖品池左侧起点\n\torigin_y = 46, //奖品池上面起点\n\tprize_index = flags.prize_index //上次点击的位置\n\n\n//计算点击的位置\nlet index = parseInt((flags.px - origin_x) / box_size);\nindex = Math.floor(index);\nlet select_item = prizePool[index]\nif (select_item) {\n\tflags.select_prize = true\n\tflags.prize_index = index\n\tflags.select_item = select_item\n\tflags.title = \"请选择奖品\"\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n}\n\nif (prize_index === index) {\n\tcore.setFlag(\"select_prize\", null);\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"can_quit\", true);\n}\n}"
											}
										]
									},
									{
										"type": "comment",
										"text": "刷新"
									},
									{
										"type": "setValue",
										"name": "temp:origin_x",
										"value": "22 +temp:box_size*temp:PrizePoolNumber"
									},
									{
										"type": "setValue",
										"name": "temp:origin_y",
										"value": "46"
									},
									{
										"type": "if",
										"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +36)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +  36))))",
										"true": [
											{
												"type": "playSound",
												"name": "确定"
											},
											{
												"type": "function",
												"function": "function(){\nlet select_time = flags.select_time //刷新次数\nif (select_time > 0) {\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"select_item\", null);\n\n\tlet randomPool = flags.randomPool\n\n\tlet prizePool = [], //奖品池\n\t\tPrizePoolNumber = flags.PrizePoolNumber //三连奖品数量\n\tfor (let i = 0; i < PrizePoolNumber; i++) { //随机从随机池里面添加N个物品进入奖品池\n\t\tlet rand = core.rand(randomPool.length)\n\t\tlet item = randomPool[rand]\n\t\tprizePool.push(item)\n\t}\n\tflags.prizePool = prizePool\n\tflags.select_time -= 1 //挑选刷新次数-1\n\tflags.success = true //成功三连\n\tflags.title = \"请选择三连奖品\"\n} else {\n\tlet text = core.material.items[select_item].name;\n\tflags.title = \"你没有刷新次数\"\n}\n}"
											}
										]
									},
									{
										"type": "setValue",
										"name": "temp:origin_x",
										"value": "14"
									},
									{
										"type": "setValue",
										"name": "temp:origin_y",
										"value": "94"
									},
									{
										"type": "comment",
										"text": "点击背包"
									},
									{
										"type": "if",
										"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +temp:box_size*temp:box_column)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +temp:box_size*temp:box_row))))",
										"true": [
											{
												"type": "playSound",
												"name": "确定"
											},
											{
												"type": "function",
												"function": "function(){\nlet box = flags.box || [], //背包物品\n\tbox_number = flags.box_number,\n\tbox_row = flags.box_row, //背包行数\n\tbox_column = flags.box_column, //背包列数\n\tbox_size = 32, //方框大小\n\tline = 2, //线条粗细\n\torigin_x = 14, //背包左侧起点\n\torigin_y = 94, //背包上面起点\n\tclick_X = flags.click_X, //上次点击的位置X\n\tclick_Y = flags.click_Y; //上次点击的位置Y\n\n\n//计算点击的位置\nlet Xoffset = parseInt((flags.px - origin_x) / box_size);\nXoffset = Math.floor(Xoffset);\nlet Yoffset = parseInt((flags.py - origin_y) / box_size);\nYoffset = Math.floor(Yoffset);\nlet index = Yoffset * box_column + Xoffset\nif (box_number > index) {\n\tlet select_item\n\tfor (let i = 0; i < box.length; i++) {\n\t\tlet item = box[i];\n\t\tif (item[1] > 0) {\n\t\t\tif (index < item[1]) {\n\t\t\t\tselect_item = item[0];\n\t\t\t\ti = 999;\n\t\t\t} else {\n\t\t\t\tindex -= item[1]\n\t\t\t}\n\t\t}\n\t}\n\tif (Xoffset === click_X && Yoffset === click_Y) { //点击相同位置，则使用道具\n\t\tlet cls = core.material.items[select_item].cls;\n\t\tlet select_item_index = flags.box_index[select_item]\n\t\tif (cls === \"equips\") {\n\t\t\tlet type = core.getEquipTypeById(select_item)\n\t\t\tlet equip = core.getEquip(type)\n\t\t\tif (equip) { //将卸下来的装备重新加入物品池\n\t\t\t\tlet equip_index = flags.box_index[equip]\n\t\t\t\tflags.box[equip_index][1] += 1;\n\t\t\t\tflags.box_number += 1;\n\t\t\t}\n\t\t\tcore.loadEquip(select_item) //装载装备\n\t\t\tif (type === 0) {\n\t\t\t\tcore.setFlag('nowWeapon', select_item);\n\t\t\t} else {\n\t\t\t\tcore.setFlag('nowShield', select_item);\n\t\t\t}\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\tif (cls === \"tools\") {\n\t\t\tcore.useItem(select_item, true)\n\t\t\tflags.box[select_item_index][1] -= 1;\n\t\t\tflags.box_number -= 1;\n\t\t}\n\t\tcore.setFlag(\"click_X\", null);\n\t\tcore.setFlag(\"click_Y\", null);\n\t\tcore.setFlag(\"select_item\", null);\n\t} else {\n\t\tcore.setFlag(\"click_X\", Xoffset);\n\t\tcore.setFlag(\"click_Y\", Yoffset);\n\t\tcore.setFlag(\"select_item\", select_item);\n\t}\n\tcore.setFlag(\"select_prize\", false);\n}\nflags.title = \"请选择奖品\"\ncore.setFlag(\"prize_index\", null);\n}"
											}
										]
									},
									{
										"type": "comment",
										"text": "点击丢弃"
									},
									{
										"type": "setValue",
										"name": "temp:origin_x",
										"value": "300"
									},
									{
										"type": "setValue",
										"name": "temp:origin_y",
										"value": "110 + temp:box_size*temp:box_row"
									},
									{
										"type": "if",
										"condition": "((flags.px>=temp:origin_x)&&((flags.  px<=temp:origin_x +36)&&((flags.py>=temp:origin_y)&&(flags.py<=temp:origin_y +  36))))",
										"true": [
											{
												"type": "playSound",
												"name": "确定"
											},
											{
												"type": "function",
												"function": "function(){\nlet select_item = core.getFlag(\"select_item\"),\n\tprize_index = flags.prize_index\nif (select_item && prize_index == null) {\n\tlet index = flags.box_index[select_item]\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"select_item\", null);\n\tcore.removeItem(select_item, 1)\n\tflags.box[index][1] -= 1;\n\tflags.box_number -= 1;\n} else {\n\tcore.setFlag(\"select_prize\", null);\n\tcore.setFlag(\"click_X\", null);\n\tcore.setFlag(\"click_Y\", null);\n\tcore.setFlag(\"prize_index\", null);\n\tcore.setFlag(\"select_item\", null);\n\tcore.setFlag(\"success\", false);\n\tflags.can_quit = true\n}\n}"
											}
										]
									}
								]
							}
						]
					},
					{
						"type": "if",
						"condition": "flag:can_quit",
						"true": [
							{
								"type": "break",
								"n": 1
							}
						]
					},
					{
						"type": "waitAsync"
					}
				]
			},
			{
				"type": "drawSelector",
				"code": 1
			},
			{
				"type": "function",
				"function": "function(){\nlet select_item = flags.select_item\ncore.deleteCanvas('uievent');\ncore.clearUI();\ncore.clearMap('uievent');\ncore.setFlag(\"click_X\", null);\ncore.setFlag(\"click_Y\", null);\ncore.setFlag(\"select_item\", null);\ncore.setFlag(\"success\", null);\ncore.setFlag(\"randomPool\", null);\ncore.setFlag(\"prizePool\", null);\ncore.setFlag(\"title\", null);\ncore.setFlag(\"select_time\", null);\ncore.setFlag(\"prize_index\", null);\ncore.setFlag(\"can_quit\", null);\nif (select_item) {\n\tcore.getItem(select_item, 1)\n}\n}"
			}
		]
	}
}