mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 04:19:30 +08:00
商店
This commit is contained in:
parent
5f48eef6af
commit
e471648e52
@ -1,128 +1,127 @@
|
||||
main.floors.MT32 = {
|
||||
floorId: 'MT32',
|
||||
title: '冰封雪原',
|
||||
name: '冰封雪原',
|
||||
width: 15,
|
||||
height: 15,
|
||||
canFlyTo: true,
|
||||
canFlyFrom: true,
|
||||
canUseQuickShop: true,
|
||||
cannotViewMap: false,
|
||||
images: [],
|
||||
ratio: 8,
|
||||
defaultGround: 'T580',
|
||||
bgm: 'winter.mp3',
|
||||
firstArrive: [
|
||||
main.floors.MT32=
|
||||
{
|
||||
"floorId": "MT32",
|
||||
"title": "冰封雪原",
|
||||
"name": "冰封雪原",
|
||||
"width": 15,
|
||||
"height": 15,
|
||||
"canFlyTo": true,
|
||||
"canFlyFrom": true,
|
||||
"canUseQuickShop": true,
|
||||
"cannotViewMap": false,
|
||||
"images": [],
|
||||
"ratio": 8,
|
||||
"defaultGround": "T580",
|
||||
"bgm": "winter.mp3",
|
||||
"firstArrive": [
|
||||
{
|
||||
type: 'function',
|
||||
function: "function(){\ncore.removeMaps('MT17', 'MT21', true)\n}"
|
||||
"type": "function",
|
||||
"function": "function(){\ncore.removeMaps('MT17', 'MT21', true)\n}"
|
||||
}
|
||||
],
|
||||
eachArrive: [],
|
||||
parallelDo: '',
|
||||
events: {
|
||||
'0,7': [
|
||||
"eachArrive": [],
|
||||
"parallelDo": "",
|
||||
"events": {
|
||||
"0,7": [
|
||||
{
|
||||
type: 'if',
|
||||
condition: '(flag:inWinter2===true)',
|
||||
true: ['\t[低级智人]\b[up,hero]没必要回去了'],
|
||||
false: [
|
||||
"type": "if",
|
||||
"condition": "(flag:inWinter2===true)",
|
||||
"true": [
|
||||
"\t[低级智人]\b[up,hero]没必要回去了"
|
||||
],
|
||||
"false": [
|
||||
{
|
||||
type: 'changeFloor',
|
||||
floorId: 'MT31',
|
||||
loc: [14, 7]
|
||||
"type": "changeFloor",
|
||||
"floorId": "MT31",
|
||||
"loc": [
|
||||
14,
|
||||
7
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
'1,6': ['宝石血瓶的加成已提升至8倍'],
|
||||
'1,8': [
|
||||
'衣服是个装备,记得穿上',
|
||||
'光环会在地图上显示,如果不想要可以在背包里面的系统设置里面关闭',
|
||||
'每张地图会保证极昼怪的数量与永夜怪的数量相同',
|
||||
'注意打过永夜怪或者极昼怪之后或者有光环的时候,怪物标记可能与当前地图不符,因为标记怪物是标记的某一类怪物而不是某一点的怪物',
|
||||
'怪物手册显示的怪物是不经过光环加成的怪物,而定点查看则是经过各种加成的怪物。你可以将鼠标移动到怪物上,按下e或c使用定点查看功能'
|
||||
"1,6": [
|
||||
"宝石血瓶的加成已提升至8倍"
|
||||
],
|
||||
"1,8": [
|
||||
"衣服是个装备,记得穿上",
|
||||
"光环会在地图上显示,如果不想要可以在背包里面的系统设置里面关闭",
|
||||
"注意打过永夜怪或者极昼怪之后或者有光环的时候,怪物标记可能与当前地图不符,因为标记怪物是标记的某一类怪物而不是某一点的怪物",
|
||||
"怪物手册显示的怪物是不经过光环加成的怪物,而定点查看则是经过各种加成的怪物。你可以将鼠标移动到怪物上,按下e或c使用定点查看功能"
|
||||
]
|
||||
},
|
||||
changeFloor: {
|
||||
'14,6': {
|
||||
floorId: 'MT33',
|
||||
loc: [0, 6]
|
||||
"changeFloor": {
|
||||
"14,6": {
|
||||
"floorId": "MT33",
|
||||
"loc": [
|
||||
0,
|
||||
6
|
||||
]
|
||||
}
|
||||
},
|
||||
beforeBattle: {},
|
||||
afterBattle: {},
|
||||
afterGetItem: {},
|
||||
afterOpenDoor: {},
|
||||
autoEvent: {},
|
||||
cannotMove: {},
|
||||
cannotMoveIn: {},
|
||||
map: [
|
||||
[
|
||||
147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
|
||||
147, 147
|
||||
],
|
||||
[147, 0, 482, 441, 274, 0, 28, 147, 34, 0, 603, 0, 0, 0, 147],
|
||||
[147, 595, 147, 147, 147, 32, 0, 590, 0, 34, 587, 0, 147, 147, 147],
|
||||
[147, 0, 403, 0, 147, 602, 587, 586, 587, 587, 587, 21, 147, 381, 147],
|
||||
[147, 28, 33, 27, 492, 34, 34, 586, 34, 390, 588, 0, 592, 34, 147],
|
||||
[
|
||||
147, 147, 494, 147, 147, 585, 492, 585, 595, 588, 588, 590, 147,
|
||||
492, 147
|
||||
],
|
||||
[147, 129, 0, 21, 147, 32, 0, 602, 0, 586, 0, 0, 34, 0, 94],
|
||||
[92, 0, 589, 0, 492, 0, 32, 584, 27, 590, 0, 587, 0, 28, 147],
|
||||
[147, 129, 0, 22, 147, 590, 492, 584, 29, 586, 587, 587, 492, 147, 147],
|
||||
[147, 147, 494, 147, 147, 0, 0, 603, 0, 586, 0, 32, 32, 0, 147],
|
||||
[
|
||||
147, 27, 33, 28, 147, 147, 147, 147, 494, 585, 585, 585, 584, 602,
|
||||
147
|
||||
],
|
||||
[147, 0, 403, 0, 492, 34, 34, 147, 0, 0, 381, 381, 0, 0, 147],
|
||||
[
|
||||
147, 595, 147, 147, 147, 603, 147, 147, 147, 147, 274, 147, 147,
|
||||
590, 147
|
||||
],
|
||||
[147, 0, 21, 27, 0, 0, 0, 0, 28, 33, 0, 492, 0, 0, 147],
|
||||
[
|
||||
147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
|
||||
147, 147
|
||||
]
|
||||
],
|
||||
bgmap: [
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 145, 145, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 145, 145, 145, 145, 145],
|
||||
[145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 0, 145, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 145, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 0],
|
||||
[0, 145, 0, 0, 0, 0, 0, 0, 0, 0, 145, 145, 145, 145, 0],
|
||||
[0, 145, 0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 0, 0, 0],
|
||||
[0, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
],
|
||||
fgmap: [],
|
||||
bg2map: [
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 146, 146, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 146, 146, 146, 0, 0, 0, 0, 146, 146, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 146, 146, 146, 0, 0, 0, 582, 0, 0, 0, 0, 146, 146, 0],
|
||||
[0, 146, 146, 146, 0, 0, 0, 0, 0, 0, 0, 0, 146, 146, 0],
|
||||
[0, 146, 146, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 581, 581, 582, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 146, 146, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 146, 146, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
],
|
||||
fg2map: []
|
||||
};
|
||||
"beforeBattle": {},
|
||||
"afterBattle": {},
|
||||
"afterGetItem": {},
|
||||
"afterOpenDoor": {},
|
||||
"autoEvent": {},
|
||||
"cannotMove": {},
|
||||
"cannotMoveIn": {},
|
||||
"map": [
|
||||
[147,147,147,147,147,147,147,147,147,147,147,147,147,147,147],
|
||||
[147, 0,482,441,274, 0, 28,147, 34, 0,603, 0, 0, 0,147],
|
||||
[147,595,147,147,147, 32, 0,590, 0, 34,587, 0,147,147,147],
|
||||
[147, 0,403, 0,147,602,587,586,587,587,587, 21,147,381,147],
|
||||
[147, 28, 33, 27,492, 34, 34,586, 34,390,588, 0,592, 34,147],
|
||||
[147,147,494,147,147,585,492,585,595,588,588,590,147,492,147],
|
||||
[147,129, 0, 21,147, 32, 0,602, 0,586, 0, 0, 34, 0, 94],
|
||||
[ 92, 0,589, 0,492, 0, 32,584, 27,590, 0,587, 0, 28,147],
|
||||
[147,129, 0, 22,147,590,492,584, 29,586,587,587,492,147,147],
|
||||
[147,147,494,147,147, 0, 0,603, 0,586, 0, 32, 32, 0,147],
|
||||
[147, 27, 33, 28,147,147,147,147,494,585,585,585,584,602,147],
|
||||
[147, 0,403, 0,492, 34, 34,147, 0, 0,381,381, 0, 0,147],
|
||||
[147,595,147,147,147,603,147,147,147,147,274,147,147,590,147],
|
||||
[147, 0, 21, 27, 0, 0, 0, 0, 28, 33, 0,492, 0, 0,147],
|
||||
[147,147,147,147,147,147,147,147,147,147,147,147,147,147,147]
|
||||
],
|
||||
"bgmap": [
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0,145,145, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0,145, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0,145, 0,145,145,145,145,145],
|
||||
[145,145,145,145,145,145,145,145,145,145,145, 0,145, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,145, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,145,145, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,145, 0],
|
||||
[ 0,145, 0, 0, 0, 0, 0, 0, 0, 0,145,145,145,145, 0],
|
||||
[ 0,145, 0, 0, 0, 0, 0, 0, 0, 0,145, 0, 0, 0, 0],
|
||||
[ 0,145,145,145,145,145,145,145,145,145,145, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
],
|
||||
"fgmap": [
|
||||
|
||||
],
|
||||
"bg2map": [
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0,146,146,146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0,146,146,146, 0, 0, 0, 0,146,146, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0,146,146,146, 0, 0, 0,582, 0, 0, 0, 0,146,146, 0],
|
||||
[ 0,146,146,146, 0, 0, 0, 0, 0, 0, 0, 0,146,146, 0],
|
||||
[ 0,146,146,146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0,581,581,582, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0,146,146,146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0,146,146,146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
],
|
||||
"fg2map": [
|
||||
|
||||
]
|
||||
}
|
@ -1122,29 +1122,19 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
return damageInfo;
|
||||
}
|
||||
|
||||
if (toMap.length <= 1) {
|
||||
// 单个与多个分开计算,有助于提高性能表现
|
||||
const dirDamage = [];
|
||||
for (const dir of toMap) {
|
||||
damage = Infinity;
|
||||
damageInfo = null;
|
||||
autoSkill();
|
||||
if (damageInfo) {
|
||||
return Object.assign(damageInfo, {
|
||||
dir: [toMap[0]?.[0] ?? 'none', damage]
|
||||
});
|
||||
} else return null;
|
||||
} else {
|
||||
const dirDamage = [];
|
||||
for (const dir of toMap) {
|
||||
damage = Infinity;
|
||||
damageInfo = null;
|
||||
autoSkill();
|
||||
dirDamage.push([dir, damage]);
|
||||
if (damage < dirMinDamage) {
|
||||
dirMinDamage = damage;
|
||||
dirDamageInfo = damageInfo;
|
||||
}
|
||||
if (dirDamageInfo) {
|
||||
return Object.assign(dirDamageInfo, { dir: dirDamage });
|
||||
} else return null;
|
||||
dirDamage.push([dir, damage]);
|
||||
if (damage < dirMinDamage) {
|
||||
dirMinDamage = damage;
|
||||
dirDamageInfo = damageInfo;
|
||||
}
|
||||
if (dirDamageInfo) {
|
||||
return Object.assign(dirDamageInfo, { dir: dirDamage });
|
||||
} else return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -160,9 +160,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"itemEffectTip": ",攻击+10"
|
||||
},
|
||||
"sword2": {
|
||||
"cls": "items",
|
||||
"cls": "equips",
|
||||
"name": "铁剑",
|
||||
"text": "真的是一把很普通的银剑,哦不,铁剑",
|
||||
"text": "真的是一把很普通的银剑,哦不,铁剑。攻击+180,额外攻击+50",
|
||||
"equip": {
|
||||
"type": 0,
|
||||
"animate": "sword",
|
||||
@ -246,17 +246,16 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"itemEffectTip": ",防御+10"
|
||||
},
|
||||
"shield2": {
|
||||
"cls": "items",
|
||||
"name": "银盾",
|
||||
"text": "一个真的很普通的铁盾,这次没错了,就是铁盾!",
|
||||
"cls": "equips",
|
||||
"name": "铁盾",
|
||||
"text": "一个真的很普通的铁盾,这次没错了,就是铁盾!防御+120,生命回复+30",
|
||||
"equip": {
|
||||
"type": 1,
|
||||
"value": {
|
||||
"hpmax": 30,
|
||||
"def": 120
|
||||
},
|
||||
"percentage": {
|
||||
"hpmax": 30
|
||||
}
|
||||
"percentage": {}
|
||||
},
|
||||
"itemEffect": "core.status.hero.def += 20",
|
||||
"itemEffectTip": ",防御+20"
|
||||
@ -1349,7 +1348,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"cls": "equips",
|
||||
"name": "寒冰护符",
|
||||
"canUseItemEffect": "true",
|
||||
"text": "与寒冰没有任何关系,但是为什么叫寒冰护符呢?攻击和额外攻击各增加5%",
|
||||
"text": "!!html<span style=\"color: gold\">饰品</span>。与寒冰没有任何关系,但是为什么叫寒冰护符呢?攻击和额外攻击各增加5%",
|
||||
"equip": {
|
||||
"type": 0,
|
||||
"value": {},
|
||||
|
@ -384,7 +384,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = {
|
||||
|
||||
/// 是否访问过某个快捷商店
|
||||
this.isShopVisited = function (id) {
|
||||
if (!core.hasFlag('__shops__')) core.setFlag('__shops__', {});
|
||||
flags.__shops__ ??= {};
|
||||
var shops = core.getFlag('__shops__');
|
||||
if (!shops[id]) shops[id] = {};
|
||||
return shops[id].visited;
|
||||
@ -864,431 +864,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = {
|
||||
};
|
||||
},
|
||||
itemShop: function () {
|
||||
// 道具商店相关的插件
|
||||
// 可在全塔属性-全局商店中使用「道具商店」事件块进行编辑(如果找不到可以在入口方块中找)
|
||||
|
||||
var shopId = null; // 当前商店ID
|
||||
var type = 0; // 当前正在选中的类型,0买入1卖出
|
||||
var selectItem = 0; // 当前正在选中的道具
|
||||
var selectCount = 0; // 当前已经选中的数量
|
||||
var page = 0;
|
||||
var totalPage = 0;
|
||||
var totalMoney = 0;
|
||||
var list = [];
|
||||
var shopInfo = null; // 商店信息
|
||||
var choices = []; // 商店选项
|
||||
var use = 'money';
|
||||
var useText = '金币';
|
||||
|
||||
var bigFont = core.ui._buildFont(20, false),
|
||||
middleFont = core.ui._buildFont(18, false);
|
||||
|
||||
this._drawItemShop = function () {
|
||||
// 绘制道具商店
|
||||
|
||||
// Step 1: 背景和固定的几个文字
|
||||
core.ui._createUIEvent();
|
||||
core.clearMap('ui');
|
||||
core.ui.clearUIEventSelector();
|
||||
core.setTextAlign('ui', 'left');
|
||||
core.setTextBaseline('ui', 'top');
|
||||
core.fillRect('ui', 0, 0, 480, 480, 'black');
|
||||
core.drawWindowSkin('winskin.png', 'ui', 0, 0, 480, 64);
|
||||
core.drawWindowSkin('winskin.png', 'ui', 0, 64, 360, 64);
|
||||
core.drawWindowSkin('winskin.png', 'ui', 0, 128, 360, 352);
|
||||
core.drawWindowSkin('winskin.png', 'ui', 360, 64, 120, 64);
|
||||
core.drawWindowSkin('winskin.png', 'ui', 360, 128, 120, 352);
|
||||
core.setFillStyle('ui', 'white');
|
||||
core.setStrokeStyle('ui', 'white');
|
||||
core.fillText('ui', '购买', 32, 84, 'white', bigFont);
|
||||
core.fillText('ui', '卖出', 152, 84);
|
||||
core.fillText('ui', '离开', 272, 84);
|
||||
core.fillText('ui', '当前' + useText, 374, 75, null, middleFont);
|
||||
core.setTextAlign('ui', 'right');
|
||||
core.fillText(
|
||||
'ui',
|
||||
core.formatBigNumber(core.status.hero.money),
|
||||
466,
|
||||
100
|
||||
);
|
||||
core.setTextAlign('ui', 'left');
|
||||
core.ui.drawUIEventSelector(
|
||||
1,
|
||||
'winskin.png',
|
||||
22 + 120 * type,
|
||||
76,
|
||||
60,
|
||||
33
|
||||
);
|
||||
if (selectItem != null) {
|
||||
core.setTextAlign('ui', 'center');
|
||||
core.fillText(
|
||||
'ui',
|
||||
type == 0 ? '买入个数' : '卖出个数',
|
||||
420,
|
||||
360,
|
||||
null,
|
||||
bigFont
|
||||
);
|
||||
core.fillText('ui', '< ' + selectCount + ' >', 420, 390);
|
||||
core.fillText('ui', '确定', 420, 420);
|
||||
}
|
||||
|
||||
// Step 2:获得列表并展示
|
||||
list = choices.filter(one => {
|
||||
if (one.condition != null && one.condition != '') {
|
||||
try {
|
||||
if (!core.calValue(one.condition)) return false;
|
||||
} catch (e) {}
|
||||
}
|
||||
return (
|
||||
(type == 0 && one.money != null) ||
|
||||
(type == 1 && one.sell != null)
|
||||
);
|
||||
});
|
||||
var per_page = 7;
|
||||
totalPage = Math.ceil(list.length / per_page);
|
||||
page = Math.floor((selectItem || 0) / per_page) + 1;
|
||||
|
||||
// 绘制分页
|
||||
if (totalPage > 1) {
|
||||
var half = 180;
|
||||
core.setTextAlign('ui', 'center');
|
||||
core.fillText(
|
||||
'ui',
|
||||
page + ' / ' + totalPage,
|
||||
half,
|
||||
450,
|
||||
null,
|
||||
middleFont
|
||||
);
|
||||
if (page > 1) core.fillText('ui', '上一页', half - 80, 450);
|
||||
if (page < totalPage)
|
||||
core.fillText('ui', '下一页', half + 80, 450);
|
||||
}
|
||||
core.setTextAlign('ui', 'left');
|
||||
|
||||
// 绘制每一项
|
||||
var start = (page - 1) * per_page;
|
||||
for (var i = 0; i < per_page; ++i) {
|
||||
var curr = start + i;
|
||||
if (curr >= list.length) break;
|
||||
var item = list[curr];
|
||||
core.drawIcon('ui', item.id, 10, 141 + i * 40);
|
||||
core.setTextAlign('ui', 'left');
|
||||
core.fillText(
|
||||
'ui',
|
||||
core.material.items[item.id].name,
|
||||
50,
|
||||
148 + i * 40,
|
||||
null,
|
||||
bigFont
|
||||
);
|
||||
core.setTextAlign('ui', 'right');
|
||||
core.fillText(
|
||||
'ui',
|
||||
(type == 0
|
||||
? core.calValue(item.money)
|
||||
: core.calValue(item.sell)) +
|
||||
useText +
|
||||
'/个',
|
||||
340,
|
||||
149 + i * 40,
|
||||
null,
|
||||
middleFont
|
||||
);
|
||||
core.setTextAlign('ui', 'left');
|
||||
if (curr == selectItem) {
|
||||
// 绘制描述,文字自动放缩
|
||||
var text =
|
||||
core.material.items[item.id].text || '该道具暂无描述';
|
||||
try {
|
||||
text = core.replaceText(text);
|
||||
} catch (e) {}
|
||||
for (var fontSize = 20; fontSize >= 8; fontSize -= 2) {
|
||||
var config = {
|
||||
left: 10,
|
||||
fontSize: fontSize,
|
||||
maxWidth: 467
|
||||
};
|
||||
var height = core.getTextContentHeight(text, config);
|
||||
if (height <= 60) {
|
||||
config.top = (64 - height) / 2;
|
||||
core.drawTextContent('ui', text, config);
|
||||
break;
|
||||
}
|
||||
}
|
||||
core.ui.drawUIEventSelector(
|
||||
2,
|
||||
'winskin.png',
|
||||
8,
|
||||
137 + i * 40,
|
||||
343,
|
||||
40
|
||||
);
|
||||
if (type == 0 && item.number != null) {
|
||||
core.fillText('ui', '存货', 370, 152, null, bigFont);
|
||||
core.setTextAlign('ui', 'right');
|
||||
core.fillText(
|
||||
'ui',
|
||||
item.number,
|
||||
470,
|
||||
152,
|
||||
null,
|
||||
null,
|
||||
60
|
||||
);
|
||||
} else if (type == 1) {
|
||||
core.fillText('ui', '数量', 370, 152, null, bigFont);
|
||||
core.setTextAlign('ui', 'right');
|
||||
core.fillText(
|
||||
'ui',
|
||||
core.itemCount(item.id),
|
||||
470,
|
||||
152,
|
||||
null,
|
||||
null,
|
||||
40
|
||||
);
|
||||
}
|
||||
core.setTextAlign('ui', 'left');
|
||||
core.fillText('ui', '预计' + useText, 370, 280);
|
||||
core.setTextAlign('ui', 'right');
|
||||
totalMoney =
|
||||
selectCount *
|
||||
(type == 0
|
||||
? core.calValue(item.money)
|
||||
: core.calValue(item.sell));
|
||||
core.fillText(
|
||||
'ui',
|
||||
core.formatBigNumber(totalMoney),
|
||||
470,
|
||||
310
|
||||
);
|
||||
|
||||
core.setTextAlign('ui', 'left');
|
||||
core.fillText(
|
||||
'ui',
|
||||
type == 0 ? '已购次数' : '已卖次数',
|
||||
370,
|
||||
190
|
||||
);
|
||||
core.setTextAlign('ui', 'right');
|
||||
core.fillText(
|
||||
'ui',
|
||||
(type == 0 ? item.money_count : item.sell_count) || 0,
|
||||
470,
|
||||
220
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
core.setTextAlign('ui', 'left');
|
||||
core.setTextBaseline('ui', 'alphabetic');
|
||||
};
|
||||
|
||||
var _add = (item, delta) => {
|
||||
if (item == null) return;
|
||||
selectCount = core.clamp(
|
||||
selectCount + delta,
|
||||
0,
|
||||
Math.min(
|
||||
type == 0
|
||||
? Math.floor(
|
||||
core.status.hero[use] / core.calValue(item.money)
|
||||
)
|
||||
: core.itemCount(item.id),
|
||||
type == 0 && item.number != null
|
||||
? item.number
|
||||
: Number.MAX_SAFE_INTEGER
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
var _confirm = item => {
|
||||
if (item == null || selectCount == 0) return;
|
||||
if (type == 0) {
|
||||
core.status.hero[use] -= totalMoney;
|
||||
core.getItem(item.id, selectCount);
|
||||
if (item.number != null) item.number -= selectCount;
|
||||
item.money_count = (item.money_count || 0) + selectCount;
|
||||
} else {
|
||||
core.status.hero[use] += totalMoney;
|
||||
core.removeItem(item.id, selectCount);
|
||||
core.drawTip(
|
||||
'成功卖出' +
|
||||
selectCount +
|
||||
'个' +
|
||||
core.material.items[item.id].name,
|
||||
item.id
|
||||
);
|
||||
if (item.number != null) item.number += selectCount;
|
||||
item.sell_count = (item.sell_count || 0) + selectCount;
|
||||
}
|
||||
selectCount = 0;
|
||||
};
|
||||
|
||||
this._performItemShopKeyBoard = function (keycode) {
|
||||
var item = list[selectItem] || null;
|
||||
// 键盘操作
|
||||
switch (keycode) {
|
||||
case 38: // up
|
||||
if (selectItem == null) break;
|
||||
if (selectItem == 0) selectItem = null;
|
||||
else selectItem--;
|
||||
selectCount = 0;
|
||||
break;
|
||||
case 37: // left
|
||||
if (selectItem == null) {
|
||||
if (type > 0) type--;
|
||||
break;
|
||||
}
|
||||
_add(item, -1);
|
||||
break;
|
||||
case 39: // right
|
||||
if (selectItem == null) {
|
||||
if (type < 2) type++;
|
||||
break;
|
||||
}
|
||||
_add(item, 1);
|
||||
break;
|
||||
case 40: // down
|
||||
if (selectItem == null) {
|
||||
if (list.length > 0) selectItem = 0;
|
||||
break;
|
||||
}
|
||||
if (list.length == 0) break;
|
||||
selectItem = Math.min(selectItem + 1, list.length - 1);
|
||||
selectCount = 0;
|
||||
break;
|
||||
case 13:
|
||||
case 32: // Enter/Space
|
||||
if (selectItem == null) {
|
||||
if (type == 2) core.insertAction({ type: 'break' });
|
||||
else if (list.length > 0) selectItem = 0;
|
||||
break;
|
||||
}
|
||||
_confirm(item);
|
||||
break;
|
||||
case 27: // ESC
|
||||
if (selectItem == null) {
|
||||
core.insertAction({ type: 'break' });
|
||||
break;
|
||||
}
|
||||
selectItem = null;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
this._performItemShopClick = function (px, py) {
|
||||
var item = list[selectItem] || null;
|
||||
// 鼠标操作
|
||||
if (px >= 22 && px <= 82 && py >= 81 && py <= 112) {
|
||||
// 买
|
||||
if (type != 0) {
|
||||
type = 0;
|
||||
selectItem = null;
|
||||
selectCount = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (px >= 142 && px <= 202 && py >= 81 && py <= 112) {
|
||||
// 卖
|
||||
if (type != 1) {
|
||||
type = 1;
|
||||
selectItem = null;
|
||||
selectCount = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (px >= 262 && px <= 322 && py >= 81 && py <= 112)
|
||||
// 离开
|
||||
return core.insertAction({ type: 'break' });
|
||||
// <,>
|
||||
if (px >= 370 && px <= 395 && py >= 392 && py <= 415)
|
||||
return _add(item, -1);
|
||||
if (px >= 445 && px <= 470 && py >= 302 && py <= 415)
|
||||
return _add(item, 1);
|
||||
// 确定
|
||||
if (px >= 392 && px <= 443 && py >= 421 && py <= 446)
|
||||
return _confirm(item);
|
||||
|
||||
// 上一页/下一页
|
||||
if (px >= 70 && px <= 130 && py >= 450) {
|
||||
if (page > 1) {
|
||||
selectItem -= 7;
|
||||
selectCount = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (px >= 230 && px <= 290 && py >= 450) {
|
||||
if (page < totalPage) {
|
||||
selectItem = Math.min(selectItem + 7, list.length - 1);
|
||||
selectCount = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 实际区域
|
||||
if (px >= 9 && px <= 351 && py >= 142 && py < 422) {
|
||||
if (list.length == 0) return;
|
||||
var index = parseInt((py - 142) / 40);
|
||||
var newItem = 7 * (page - 1) + index;
|
||||
if (newItem >= list.length) newItem = list.length - 1;
|
||||
if (newItem != selectItem) {
|
||||
selectItem = newItem;
|
||||
selectCount = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this._performItemShopAction = function () {
|
||||
if (flags.type == 0)
|
||||
return this._performItemShopKeyBoard(flags.keycode);
|
||||
else return this._performItemShopClick(flags.px, flags.py);
|
||||
};
|
||||
|
||||
this.openItemShop = function (itemShopId) {
|
||||
shopId = itemShopId;
|
||||
type = 0;
|
||||
page = 0;
|
||||
selectItem = null;
|
||||
selectCount = 0;
|
||||
core.isShopVisited(itemShopId);
|
||||
shopInfo = flags.__shops__[shopId];
|
||||
if (shopInfo.choices == null)
|
||||
shopInfo.choices = core.clone(
|
||||
core.status.shops[shopId].choices
|
||||
);
|
||||
choices = shopInfo.choices;
|
||||
use = core.status.shops[shopId].use;
|
||||
if (use != 'exp') use = 'money';
|
||||
useText = use == 'money' ? '金币' : '经验';
|
||||
|
||||
core.insertAction([
|
||||
{
|
||||
type: 'while',
|
||||
condition: 'true',
|
||||
data: [
|
||||
{
|
||||
type: 'function',
|
||||
function: '() => { core.plugin._drawItemShop(); }'
|
||||
},
|
||||
{ type: 'wait' },
|
||||
{
|
||||
type: 'function',
|
||||
function:
|
||||
'() => { core.plugin._performItemShopAction(); }'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'function',
|
||||
function:
|
||||
"() => { core.deleteCanvas('ui'); core.ui.clearUIEventSelector(); }"
|
||||
}
|
||||
]);
|
||||
if (!main.replayChecking) {
|
||||
core.plugin.openedShopId = itemShopId;
|
||||
core.plugin.shopOpened.value = true;
|
||||
}
|
||||
};
|
||||
},
|
||||
heroFourFrames: function () {
|
||||
@ -3932,6 +3512,53 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = {
|
||||
core.studySkill(enemy, num);
|
||||
return true;
|
||||
});
|
||||
|
||||
// 商店
|
||||
let shopOpened = false;
|
||||
let openedShopId = '';
|
||||
core.registerReplayAction('openShop', name => {
|
||||
if (!name.startsWith('openShop:')) return false;
|
||||
openedShopId = name.slice(9);
|
||||
shopOpened = true;
|
||||
return true;
|
||||
});
|
||||
|
||||
core.registerReplayAction('buy', name => {
|
||||
if (!name.startsWith('buy:') && !name.startsWith('sell:'))
|
||||
return false;
|
||||
if (!shopOpened) return false;
|
||||
if (!openedShopId) return false;
|
||||
const [type, id, num] = name
|
||||
.split(':')
|
||||
.map(v => (/^\d+$/.test(v) ? parseInt(v) : v));
|
||||
const shop = core.status.shops[id];
|
||||
const item = shop.choices.find(v => v.id === id);
|
||||
if (!item) return false;
|
||||
flags.itemShop ??= {};
|
||||
flags.itemShop[openedShopId] ??= {};
|
||||
flags.itemShop[openedShopId][id] ??= 0;
|
||||
if (num > item.number - flags.itemShop[openedShopId][id]) {
|
||||
return false;
|
||||
}
|
||||
let cost = 0;
|
||||
if (type === 'buy') {
|
||||
cost = item.money * num;
|
||||
} else {
|
||||
cost = -item.sell * num;
|
||||
}
|
||||
if (cost > core.status.hero.money) return false;
|
||||
core.status.hero.money -= cost;
|
||||
flags.itemShop[openedShopId][id] += type === 'buy' ? num : -num;
|
||||
return true;
|
||||
});
|
||||
|
||||
core.registerReplayAction('closeShop', name => {
|
||||
if (name !== 'closeShop') return false;
|
||||
if (!shopOpened) return false;
|
||||
shopOpened = false;
|
||||
openedShopId = '';
|
||||
return true;
|
||||
});
|
||||
},
|
||||
skillTree: function () {
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ export function getMarkInfo(id: EnemyIds, noMessage: boolean = false) {
|
||||
tip('success', `踩到了${core.material.enemys[id].name}的临界!`);
|
||||
}
|
||||
reached[info.nextCritical] = true;
|
||||
const n = core.nextCriticals(id, 1)[0]?.[0];
|
||||
const n = core.nextCriticals(id, 1, void 0, void 0, 'empty')[0]?.[0];
|
||||
const next = (n ?? 0) + core.status.hero.atk;
|
||||
info.nextCritical = next;
|
||||
}
|
||||
@ -80,37 +80,40 @@ export function checkMarkedEnemy(noMessage: boolean = false) {
|
||||
const hp = core.status.hero.hp;
|
||||
getMarkedEnemy().forEach(v => {
|
||||
getMarkInfo(v);
|
||||
const damage = core.getDamageInfo(v)?.damage ?? -1;
|
||||
const damage =
|
||||
core.getDamageInfo(v, void 0, void 0, void 0, 'empty')?.damage ??
|
||||
-1;
|
||||
if (damage === -1) return;
|
||||
const info = enemyDamageInfo[v]!;
|
||||
const name = core.material.enemys[v].name;
|
||||
let res = 0;
|
||||
if (damage <= 0) {
|
||||
if (!noMessage) tip('success', `${name}已经零伤了!`);
|
||||
} else if (damage < hp / 3) {
|
||||
if (!info[3] && !noMessage) {
|
||||
tip('success', `${name}的伤害已降至勇士生命值的1/3!`);
|
||||
}
|
||||
info[1] = true;
|
||||
info[2] = true;
|
||||
info[3] = true;
|
||||
res = 0b111;
|
||||
} else if (damage < (hp / 3) * 2) {
|
||||
if (!info[2] && !noMessage) {
|
||||
tip('success', `${name}的伤害已降至勇士生命值的2/3!`);
|
||||
}
|
||||
info[1] = true;
|
||||
info[2] = true;
|
||||
info[3] = false;
|
||||
res = 0b110;
|
||||
} else if (damage < hp) {
|
||||
if (!info[1] && !noMessage) {
|
||||
tip('success', `你已经能打过${name}了!`);
|
||||
}
|
||||
res = 0b100;
|
||||
}
|
||||
info[1] = info[2] = info[3] = false;
|
||||
if (res & 0b100) {
|
||||
info[1] = true;
|
||||
info[2] = false;
|
||||
info[3] = false;
|
||||
} else {
|
||||
info[1] = false;
|
||||
info[2] = false;
|
||||
info[3] = false;
|
||||
}
|
||||
if (res & 0b010) {
|
||||
info[2] = true;
|
||||
}
|
||||
if (res & 0b001) {
|
||||
info[3] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import Skill from '../ui/skill.vue';
|
||||
import SkillTree from '../ui/skillTree.vue';
|
||||
import Fly from '../ui/fly.vue';
|
||||
import FixedDetail from '../ui/fixedDetail.vue';
|
||||
import Shop from '../ui/shop.vue';
|
||||
|
||||
export const bookOpened = ref(false);
|
||||
export const toolOpened = ref(false);
|
||||
@ -21,6 +22,7 @@ export const skillTreeOpened = ref(false);
|
||||
export const flyOpened = ref(false);
|
||||
export const showStudiedSkill = ref(false);
|
||||
export const fixedDetailOpened = ref(false);
|
||||
export const shopOpened = ref(false);
|
||||
|
||||
export const transition = ref(true);
|
||||
export const noClosePanel = ref(false);
|
||||
@ -37,7 +39,8 @@ const UI_LIST: [Ref<boolean>, Component][] = [
|
||||
[skillOpened, Skill],
|
||||
[skillTreeOpened, SkillTree],
|
||||
[flyOpened, Fly],
|
||||
[fixedDetailOpened, FixedDetail]
|
||||
[fixedDetailOpened, FixedDetail],
|
||||
[shopOpened, Shop]
|
||||
];
|
||||
|
||||
/** ui栈 */
|
||||
@ -74,7 +77,8 @@ export default function init() {
|
||||
skillTreeOpened,
|
||||
flyOpened,
|
||||
showStudiedSkill,
|
||||
fixedDetailOpened
|
||||
fixedDetailOpened,
|
||||
shopOpened
|
||||
};
|
||||
}
|
||||
|
||||
|
4
src/source/items.d.ts
vendored
4
src/source/items.d.ts
vendored
@ -12,13 +12,13 @@ interface ItemDeclaration {
|
||||
greenPotion: 'items';
|
||||
sword0: 'items';
|
||||
sword1: 'equips';
|
||||
sword2: 'items';
|
||||
sword2: 'equips';
|
||||
sword3: 'items';
|
||||
sword4: 'items';
|
||||
sword5: 'items';
|
||||
shield0: 'items';
|
||||
shield1: 'equips';
|
||||
shield2: 'items';
|
||||
shield2: 'equips';
|
||||
shield3: 'items';
|
||||
shield4: 'items';
|
||||
shield5: 'items';
|
||||
|
@ -25,6 +25,7 @@
|
||||
transition: color 0.2s linear;
|
||||
}
|
||||
|
||||
.button-text[active='true'],
|
||||
.button-text:hover {
|
||||
color: aqua;
|
||||
}
|
||||
@ -33,6 +34,19 @@
|
||||
color: aquamarine;
|
||||
}
|
||||
|
||||
.button-text[danger='true'][danger-display='true'] {
|
||||
color: rgb(255, 47, 47);
|
||||
}
|
||||
|
||||
.button-text[danger='true']:hover,
|
||||
.button-text[danger='true'][active='true'] {
|
||||
color: rgb(255, 120, 120);
|
||||
}
|
||||
|
||||
.button-text[danger='true']:active {
|
||||
color: rgb(255, 182, 182);
|
||||
}
|
||||
|
||||
.selectable {
|
||||
border: #0000 0.5px solid;
|
||||
padding: 1% 3% 1% 3%;
|
||||
|
6
src/types/plugin.d.ts
vendored
6
src/types/plugin.d.ts
vendored
@ -152,6 +152,9 @@ interface PluginUis {
|
||||
/** 定点查看的界面,特殊属性还是临界 */
|
||||
fixedDetailPanel: 'special' | 'critical';
|
||||
|
||||
/** 打开的商店id */
|
||||
openedShopId: string;
|
||||
|
||||
/** ui是否使用渐变 */
|
||||
readonly transition: Ref<boolean>;
|
||||
|
||||
@ -200,6 +203,9 @@ interface PluginUis {
|
||||
/** 是否展示移动鼠标显示怪物信息的盒子 */
|
||||
readonly showFixed: Ref<boolean>;
|
||||
|
||||
/** 商店是否打开 */
|
||||
readonly shopOpened: Ref<boolean>;
|
||||
|
||||
/** ui栈 */
|
||||
readonly uiStack: Ref<Component[]>;
|
||||
|
||||
|
450
src/ui/shop.vue
Normal file
450
src/ui/shop.vue
Normal file
@ -0,0 +1,450 @@
|
||||
<template>
|
||||
<div id="shop">
|
||||
<div id="tools">
|
||||
<span class="button-text" @click="exit"
|
||||
><left-outlined /> 返回游戏</span
|
||||
>
|
||||
</div>
|
||||
<span id="item-name">{{ info.name }}</span>
|
||||
<a-divider dashed style="border-color: #ddd4" id="divider"></a-divider>
|
||||
<div id="item-info">
|
||||
<Scroll id="item-desc" :no-scroll="true">
|
||||
<span v-html="desc"></span>
|
||||
</Scroll>
|
||||
</div>
|
||||
<a-divider
|
||||
dashed
|
||||
style="border-color: #ddd4"
|
||||
id="divider-split"
|
||||
></a-divider>
|
||||
<div id="shop-bottom">
|
||||
<div id="item-list">
|
||||
<Scroll style="width: 100%; height: 100%">
|
||||
<div
|
||||
class="selectable item-one"
|
||||
v-for="(i, index) of choices"
|
||||
:selected="index === selected"
|
||||
@click="selected = index"
|
||||
>
|
||||
<div class="item-icon">
|
||||
<BoxAnimate
|
||||
:id="i.id"
|
||||
:noborder="true"
|
||||
></BoxAnimate>
|
||||
<span>{{ all[i.id].name }}</span>
|
||||
</div>
|
||||
<span
|
||||
>× {{
|
||||
(mode === 'buy'
|
||||
? i.number - (f.itemShop[id]?.[i.id] ?? 0)
|
||||
: cnt(i.id)) + (update ? 0 : 0)
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
</Scroll>
|
||||
</div>
|
||||
<a-divider
|
||||
dashed
|
||||
style="border-color: #ddd4"
|
||||
:type="isMobile ? 'horizontal' : 'vertical'"
|
||||
id="divider-vertical"
|
||||
></a-divider>
|
||||
<div id="item-sell-info">
|
||||
<div id="shop-mode">
|
||||
<span
|
||||
class="button-text mode-button"
|
||||
:active="mode === 'buy'"
|
||||
@click="mode = 'buy'"
|
||||
>购买</span
|
||||
>
|
||||
<a-divider
|
||||
dashed
|
||||
type="vertical"
|
||||
id="divider-vertical"
|
||||
style="border-color: #ddd4"
|
||||
></a-divider>
|
||||
<span
|
||||
class="button-text mode-button"
|
||||
:active="mode === 'sell'"
|
||||
danger="true"
|
||||
@click="mode = 'sell'"
|
||||
>售出</span
|
||||
>
|
||||
</div>
|
||||
<a-divider
|
||||
dashed
|
||||
style="border-color: #ddd4"
|
||||
id="divider-mode"
|
||||
></a-divider>
|
||||
<div
|
||||
class="item-sell-info"
|
||||
:style="{ color: mode === 'buy' ? 'lightgreen' : 'white' }"
|
||||
>
|
||||
<span>买价</span>
|
||||
<span>{{ item.money }}</span>
|
||||
</div>
|
||||
<div
|
||||
class="item-sell-info"
|
||||
:style="{ color: mode === 'sell' ? 'lightcoral' : 'white' }"
|
||||
>
|
||||
<span>卖价</span>
|
||||
<span>{{ item.sell }}</span>
|
||||
</div>
|
||||
<div class="item-sell-info">
|
||||
<span>存货</span>
|
||||
<span>{{ remain }}</span>
|
||||
</div>
|
||||
<div class="item-sell-info">
|
||||
<span>拥有</span>
|
||||
<span>{{ cnt(item.id) }}</span>
|
||||
</div>
|
||||
<a-divider
|
||||
dashed
|
||||
style="border-color: #ddd4"
|
||||
id="divider-mode"
|
||||
></a-divider>
|
||||
<div id="sell-count">
|
||||
<span>{{ mode === 'buy' ? '购买' : '售出' }}数量</span>
|
||||
<div id="sell-count-select">
|
||||
<double-left-outlined
|
||||
class="button-text"
|
||||
@click="count -= 10"
|
||||
/>
|
||||
<left-outlined class="button-text" @click="count--" />
|
||||
<span id="fly-now">{{ count }}</span>
|
||||
<right-outlined class="button-text" @click="count++" />
|
||||
<double-right-outlined
|
||||
class="button-text"
|
||||
@click="count += 10"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<a-divider
|
||||
dashed
|
||||
style="border-color: #ddd4; margin: 2vh 0 2vh 0"
|
||||
></a-divider>
|
||||
<div id="sell-confirm">
|
||||
<span
|
||||
id="sell-total"
|
||||
:style="{
|
||||
color:
|
||||
mode === 'buy'
|
||||
? nowMoney > cost
|
||||
? 'lightgreen'
|
||||
: 'lightcoral'
|
||||
: 'lightcoral'
|
||||
}"
|
||||
>总价:{{
|
||||
count *
|
||||
parseInt(mode === 'buy' ? item.money : item.sell)
|
||||
}}</span
|
||||
>
|
||||
<span
|
||||
id="sell-button"
|
||||
class="button-text"
|
||||
:danger="mode === 'sell'"
|
||||
danger-display="true"
|
||||
active="true"
|
||||
@click="confirm"
|
||||
>确认{{ mode === 'buy' ? '购买' : '售出' }}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
import {
|
||||
LeftOutlined,
|
||||
DoubleLeftOutlined,
|
||||
RightOutlined,
|
||||
DoubleRightOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import { keycode, splitText, tip } from '../plugin/utils';
|
||||
import Scroll from '../components/scroll.vue';
|
||||
import { isMobile } from '../plugin/use';
|
||||
import BoxAnimate from '../components/boxAnimate.vue';
|
||||
import { KeyCode } from '../plugin/keyCodes';
|
||||
import { sleep } from 'mutate-animate';
|
||||
|
||||
const id = core.plugin.openedShopId;
|
||||
const shop = core.status.shops[core.plugin.openedShopId] as ItemShopEvent;
|
||||
if (!shop.item) {
|
||||
throw new TypeError(
|
||||
`Wrong global shop type delivered in opening item shop.`
|
||||
);
|
||||
}
|
||||
|
||||
flags.itemShop ??= {};
|
||||
|
||||
const f = flags;
|
||||
|
||||
const choices = shop.choices;
|
||||
const selected = ref(0);
|
||||
const mode = ref<'sell' | 'buy'>('buy');
|
||||
const all = core.material.items;
|
||||
const cnt = core.itemCount;
|
||||
const count = ref(0);
|
||||
const nowMoney = ref(core.status.hero.money);
|
||||
const update = ref(false);
|
||||
|
||||
let bought = false;
|
||||
|
||||
watch(count, n => {
|
||||
if (n < 0) n = 0;
|
||||
if (mode.value === 'buy') {
|
||||
if (n > remain.value) n = remain.value;
|
||||
} else {
|
||||
const c = cnt(item.value.id);
|
||||
if (n > c) n = c;
|
||||
}
|
||||
count.value = n;
|
||||
});
|
||||
|
||||
const item = computed(() => {
|
||||
return choices[selected.value];
|
||||
});
|
||||
const remain = computed(() => {
|
||||
update.value;
|
||||
return item.value.number - (flags.itemShop[id]?.[item.value.id] ?? 0);
|
||||
});
|
||||
const info = computed(() => {
|
||||
return core.material.items[item.value.id];
|
||||
});
|
||||
const desc = computed(() => {
|
||||
const text = info.value.text!;
|
||||
const res = splitText([text.startsWith('!!html') ? text.slice(6) : text]);
|
||||
return res;
|
||||
});
|
||||
const cost = computed(() => {
|
||||
return (
|
||||
count.value *
|
||||
parseInt(mode.value === 'buy' ? item.value.money : item.value.sell)
|
||||
);
|
||||
});
|
||||
|
||||
watch(remain, n => {
|
||||
if (n < count.value) {
|
||||
count.value = n;
|
||||
}
|
||||
});
|
||||
|
||||
function confirm() {
|
||||
if (count.value === 0) return;
|
||||
const money = core.status.hero.money;
|
||||
bought = true;
|
||||
core.status.route.push(`openShop:${id}`);
|
||||
if (mode.value === 'buy') {
|
||||
if (cost.value <= money) {
|
||||
core.getItem(item.value.id, count.value);
|
||||
core.status.hero.money -= cost.value;
|
||||
nowMoney.value -= cost.value;
|
||||
flags.itemShop[id] ??= {};
|
||||
flags.itemShop[id][item.value.id] ??= 0;
|
||||
flags.itemShop[id][item.value.id] += count.value;
|
||||
tip('success', `成功购买${count.value}个${info.value.name}!`);
|
||||
core.status.route.push(`buy:${item.value.id}:${count.value}`);
|
||||
} else {
|
||||
tip('error', '你的金币不够!');
|
||||
}
|
||||
} else {
|
||||
core.addItem(item.value.id, -count.value);
|
||||
core.status.hero.money += cost.value;
|
||||
nowMoney.value += cost.value;
|
||||
flags.itemShop[id] ??= {};
|
||||
flags.itemShop[id][item.value.id] ??= 0;
|
||||
flags.itemShop[id][item.value.id] -= count.value;
|
||||
tip('success', `成功卖出${count.value}个${info.value.name}!`);
|
||||
core.status.route.push(`sell:${item.value.id}:${count.value}`);
|
||||
}
|
||||
count.value = 0;
|
||||
update.value = !update.value;
|
||||
}
|
||||
|
||||
function keyup(e: KeyboardEvent) {
|
||||
const c = keycode(e.keyCode);
|
||||
if (c === KeyCode.KeyX || c === KeyCode.Escape || c === KeyCode.KeyV) {
|
||||
exit();
|
||||
}
|
||||
if (c === KeyCode.UpArrow) {
|
||||
if (selected.value >= 1) {
|
||||
selected.value--;
|
||||
}
|
||||
}
|
||||
if (c === KeyCode.DownArrow) {
|
||||
if (selected.value <= choices.length - 2) {
|
||||
selected.value++;
|
||||
}
|
||||
}
|
||||
if (c === KeyCode.KeyC || c === KeyCode.Space || c === KeyCode.Enter) {
|
||||
confirm();
|
||||
}
|
||||
}
|
||||
|
||||
function keydown(e: KeyboardEvent) {
|
||||
const c = keycode(e.keyCode);
|
||||
if (c === KeyCode.LeftArrow) {
|
||||
count.value--;
|
||||
}
|
||||
if (c === KeyCode.RightArrow) {
|
||||
count.value++;
|
||||
}
|
||||
}
|
||||
|
||||
function exit() {
|
||||
if (bought) core.status.route.push('closeShop');
|
||||
core.plugin.shopOpened.value = false;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await sleep(50);
|
||||
if (core.plugin.transition.value) await sleep(600);
|
||||
document.addEventListener('keyup', keyup);
|
||||
document.addEventListener('keydown', keydown);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('keyup', keyup);
|
||||
document.removeEventListener('keydown', keydown);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
#shop {
|
||||
width: 90vh;
|
||||
height: 90vh;
|
||||
font-family: 'normal';
|
||||
font-size: 2.8vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
#tools {
|
||||
height: 5vh;
|
||||
font-size: 3.2vh;
|
||||
}
|
||||
|
||||
#item-name {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 4vh;
|
||||
height: 5vh;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
#item-info {
|
||||
height: 24vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#divider {
|
||||
width: 100%;
|
||||
margin: 1vh 0 1vh 0;
|
||||
}
|
||||
|
||||
#divider-split {
|
||||
margin: 1vh 0 0 0;
|
||||
}
|
||||
|
||||
#divider-vertical {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#shop-bottom {
|
||||
height: 53vh;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
#item-list {
|
||||
height: 53vh;
|
||||
width: 53vh;
|
||||
padding: 1vh 0 1vh 0;
|
||||
}
|
||||
|
||||
#item-sell-info {
|
||||
width: 47vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.item-icon {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
|
||||
span {
|
||||
margin-left: 5%;
|
||||
}
|
||||
}
|
||||
|
||||
.item-one {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-direction: row;
|
||||
margin-bottom: 1vh;
|
||||
}
|
||||
|
||||
#shop-mode {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
height: 5vh;
|
||||
}
|
||||
|
||||
.mode-button {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#divider-mode {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.item-sell-info {
|
||||
width: 60%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin: 1vh 0 1vh 0;
|
||||
transition: color 0.2s linear;
|
||||
}
|
||||
|
||||
#sell-count {
|
||||
width: 100%;
|
||||
padding-top: 1vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#sell-count-select {
|
||||
margin-top: 1vh;
|
||||
width: 90%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
#sell-confirm {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
#sell-total {
|
||||
transition: color 0.2s linear;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user