init
This commit is contained in:
parent
7d8dff9799
commit
aefd1d0052
@ -3,12 +3,12 @@ FROM node:18-alpine
|
|||||||
|
|
||||||
ENV Param sid=0
|
ENV Param sid=0
|
||||||
|
|
||||||
|
RUN apk add tzdata
|
||||||
|
|
||||||
ADD ./dist ./app
|
ADD ./dist ./app
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apk add tzdata
|
|
||||||
|
|
||||||
RUN npm config set registry http://registry.npm.taobao.org/ && npm install pm2@5.2.2 -g
|
RUN npm config set registry http://registry.npm.taobao.org/ && npm install pm2@5.2.2 -g
|
||||||
|
|
||||||
CMD cd /app && sh zoeninfo.sh "Asia/Tokyo" && pm2-runtime start js_pm2.config.js -- ${Param}
|
CMD cd /app && sh zoeninfo.sh "Asia/Tokyo" && pm2-runtime start js_pm2.config.js -- ${Param}
|
||||||
|
@ -47,6 +47,8 @@ const localApps = [
|
|||||||
ignore_watch: [
|
ignore_watch: [
|
||||||
'logs'
|
'logs'
|
||||||
],
|
],
|
||||||
|
//out_file: "/dev/stdout",
|
||||||
|
//error_file: "/dev/stderr"
|
||||||
// 自定义应用程序的错误日志文件(错误日志文件)
|
// 自定义应用程序的错误日志文件(错误日志文件)
|
||||||
error_file: './logs/errMsg.log',
|
error_file: './logs/errMsg.log',
|
||||||
// 自定义应用程序日志文件(正常日志文件)
|
// 自定义应用程序日志文件(正常日志文件)
|
||||||
@ -71,6 +73,8 @@ const crossApps = [
|
|||||||
ignore_watch: [
|
ignore_watch: [
|
||||||
'logs'
|
'logs'
|
||||||
],
|
],
|
||||||
|
//out_file: "/dev/stdout",
|
||||||
|
//error_file: "/dev/stderr"
|
||||||
// 自定义应用程序的错误日志文件(错误日志文件)
|
// 自定义应用程序的错误日志文件(错误日志文件)
|
||||||
error_file: './logs/errCross.log',
|
error_file: './logs/errCross.log',
|
||||||
// 自定义应用程序日志文件(正常日志文件)
|
// 自定义应用程序日志文件(正常日志文件)
|
||||||
|
@ -84,7 +84,7 @@ client.connect({
|
|||||||
host: '10.0.1.20',
|
host: '10.0.1.20',
|
||||||
port: '21',
|
port: '21',
|
||||||
user: 'administrator',
|
user: 'administrator',
|
||||||
password: 'a123456789.',
|
password: ']v)CnD~r|yl[7??22uTI',
|
||||||
keepalive: 1000
|
keepalive: 1000
|
||||||
});
|
});
|
||||||
|
|
||||||
|
278
package-lock.json
generated
278
package-lock.json
generated
@ -11,9 +11,11 @@
|
|||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
|
"ioredis": "^5.3.2",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"mathjs": "^11.4.0",
|
"mathjs": "^11.4.0",
|
||||||
"mongodb": "^4.11.0",
|
"mongodb": "^4.17.1",
|
||||||
|
"ramda": "^0.29.1",
|
||||||
"redis": "^4.3.1",
|
"redis": "^4.3.1",
|
||||||
"shelljs": "^0.8.5",
|
"shelljs": "^0.8.5",
|
||||||
"sync-request": "^6.1.0",
|
"sync-request": "^6.1.0",
|
||||||
@ -1063,6 +1065,11 @@
|
|||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@ioredis/commands": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg=="
|
||||||
|
},
|
||||||
"node_modules/@jridgewell/resolve-uri": {
|
"node_modules/@jridgewell/resolve-uri": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmmirror.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz",
|
"resolved": "https://registry.npmmirror.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz",
|
||||||
@ -1088,6 +1095,15 @@
|
|||||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@mongodb-js/saslprep": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-t7c5K033joZZMspnHg/gWPE4kandgc2OxE74aYOtGKfgB9VPuVJPix0H6fhmm2erj5PBJ21mqcx34lpIGtUCsQ==",
|
||||||
|
"optional": true,
|
||||||
|
"dependencies": {
|
||||||
|
"sparse-bitfield": "^3.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@redis/bloom": {
|
"node_modules/@redis/bloom": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.0.2.tgz",
|
||||||
@ -1249,9 +1265,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/webidl-conversions": {
|
"node_modules/@types/webidl-conversions": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz",
|
||||||
"integrity": "sha512-xTE1E+YF4aWPJJeUzaZI5DRntlkY3+BCVJi0axFptnjGmAoWxkyREIh/XMrfxVLejwQxMCfDXdICo0VLxThrog=="
|
"integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA=="
|
||||||
},
|
},
|
||||||
"node_modules/@types/whatwg-url": {
|
"node_modules/@types/whatwg-url": {
|
||||||
"version": "8.2.2",
|
"version": "8.2.2",
|
||||||
@ -1535,9 +1551,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/bson": {
|
"node_modules/bson": {
|
||||||
"version": "4.7.0",
|
"version": "4.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz",
|
||||||
"integrity": "sha512-VrlEE4vuiO1WTpfof4VmaVolCVYkYTgB9iWgYNOrVlnifpME/06fhFRmONgBhClD5pFC1t9ZWqFUQEQAzY43bA==",
|
"integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"buffer": "^5.6.0"
|
"buffer": "^5.6.0"
|
||||||
},
|
},
|
||||||
@ -2662,6 +2678,50 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/ioredis": {
|
||||||
|
"version": "5.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.3.2.tgz",
|
||||||
|
"integrity": "sha512-1DKMMzlIHM02eBBVOFQ1+AolGjs6+xEcM4PDL7NqOS6szq7H9jSaEkIUH6/a5Hl241LzW6JLSiAbNvTQjUupUA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@ioredis/commands": "^1.1.1",
|
||||||
|
"cluster-key-slot": "^1.1.0",
|
||||||
|
"debug": "^4.3.4",
|
||||||
|
"denque": "^2.1.0",
|
||||||
|
"lodash.defaults": "^4.2.0",
|
||||||
|
"lodash.isarguments": "^3.1.0",
|
||||||
|
"redis-errors": "^1.2.0",
|
||||||
|
"redis-parser": "^3.0.0",
|
||||||
|
"standard-as-callback": "^2.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.22.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/ioredis"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ioredis/node_modules/debug": {
|
||||||
|
"version": "4.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||||
|
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"ms": "2.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"supports-color": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ioredis/node_modules/ms": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||||
|
},
|
||||||
"node_modules/ip": {
|
"node_modules/ip": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz",
|
||||||
@ -2886,6 +2946,16 @@
|
|||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/lodash.defaults": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz",
|
||||||
|
"integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ=="
|
||||||
|
},
|
||||||
|
"node_modules/lodash.isarguments": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg=="
|
||||||
|
},
|
||||||
"node_modules/log-symbols": {
|
"node_modules/log-symbols": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmmirror.com/log-symbols/-/log-symbols-4.1.0.tgz",
|
"resolved": "https://registry.npmmirror.com/log-symbols/-/log-symbols-4.1.0.tgz",
|
||||||
@ -3093,13 +3163,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mongodb": {
|
"node_modules/mongodb": {
|
||||||
"version": "4.11.0",
|
"version": "4.17.1",
|
||||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.17.1.tgz",
|
||||||
"integrity": "sha512-9l9n4Nk2BYZzljW3vHah3Z0rfS5npKw6ktnkmFgTcnzaXH1DRm3pDl6VMHu84EVb1lzmSaJC4OzWZqTkB5i2wg==",
|
"integrity": "sha512-MBuyYiPUPRTqfH2dV0ya4dcr2E5N52ocBuZ8Sgg/M030nGF78v855B3Z27mZJnp8PxjnUquEnAtjOsphgMZOlQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bson": "^4.7.0",
|
"bson": "^4.7.2",
|
||||||
"denque": "^2.1.0",
|
"mongodb-connection-string-url": "^2.6.0",
|
||||||
"mongodb-connection-string-url": "^2.5.4",
|
|
||||||
"socks": "^2.7.1"
|
"socks": "^2.7.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@ -3107,13 +3176,13 @@
|
|||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@aws-sdk/credential-providers": "^3.186.0",
|
"@aws-sdk/credential-providers": "^3.186.0",
|
||||||
"saslprep": "^1.0.3"
|
"@mongodb-js/saslprep": "^1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mongodb-connection-string-url": {
|
"node_modules/mongodb-connection-string-url": {
|
||||||
"version": "2.5.4",
|
"version": "2.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.4.tgz",
|
"resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.6.0.tgz",
|
||||||
"integrity": "sha512-SeAxuWs0ez3iI3vvmLk/j2y+zHwigTDKQhtdxTgt5ZCOQQS5+HW4g45/Xw5vzzbn7oQXCNQ24Z40AkJsizEy7w==",
|
"integrity": "sha512-WvTZlI9ab0QYtTYnuMLgobULWhokRjtC7db9LtcVfJ+Hsnyr5eo6ZtNAt3Ly24XZScGMelOcGtm7lSn0332tPQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/whatwg-url": "^8.2.1",
|
"@types/whatwg-url": "^8.2.1",
|
||||||
"whatwg-url": "^11.0.0"
|
"whatwg-url": "^11.0.0"
|
||||||
@ -3415,9 +3484,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/punycode": {
|
"node_modules/punycode": {
|
||||||
"version": "2.1.1",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
|
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
@ -3433,6 +3502,15 @@
|
|||||||
"node": ">=0.6"
|
"node": ">=0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/ramda": {
|
||||||
|
"version": "0.29.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.29.1.tgz",
|
||||||
|
"integrity": "sha512-OfxIeWzd4xdUNxlWhgFazxsA/nl3mS4/jGZI5n00uWOoSSFRhC1b6gl6xvmzUamgmqELraWp0J/qqVlXYPDPyA==",
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/ramda"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/randombytes": {
|
"node_modules/randombytes": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmmirror.com/randombytes/-/randombytes-2.1.0.tgz",
|
"resolved": "https://registry.npmmirror.com/randombytes/-/randombytes-2.1.0.tgz",
|
||||||
@ -3514,6 +3592,25 @@
|
|||||||
"@redis/time-series": "1.0.3"
|
"@redis/time-series": "1.0.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/redis-errors": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/redis-parser": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==",
|
||||||
|
"dependencies": {
|
||||||
|
"redis-errors": "^1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/regenerator-runtime": {
|
"node_modules/regenerator-runtime": {
|
||||||
"version": "0.13.11",
|
"version": "0.13.11",
|
||||||
"resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
"resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
||||||
@ -3585,18 +3682,6 @@
|
|||||||
"resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
"resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||||
},
|
},
|
||||||
"node_modules/saslprep": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==",
|
|
||||||
"optional": true,
|
|
||||||
"dependencies": {
|
|
||||||
"sparse-bitfield": "^3.0.3"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/seedrandom": {
|
"node_modules/seedrandom": {
|
||||||
"version": "3.0.5",
|
"version": "3.0.5",
|
||||||
"resolved": "https://registry.npmmirror.com/seedrandom/-/seedrandom-3.0.5.tgz",
|
"resolved": "https://registry.npmmirror.com/seedrandom/-/seedrandom-3.0.5.tgz",
|
||||||
@ -3776,6 +3861,11 @@
|
|||||||
"node": ">=0.8"
|
"node": ">=0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/standard-as-callback": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A=="
|
||||||
|
},
|
||||||
"node_modules/statuses": {
|
"node_modules/statuses": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
||||||
@ -5361,6 +5451,11 @@
|
|||||||
"@jridgewell/trace-mapping": "0.3.9"
|
"@jridgewell/trace-mapping": "0.3.9"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@ioredis/commands": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg=="
|
||||||
|
},
|
||||||
"@jridgewell/resolve-uri": {
|
"@jridgewell/resolve-uri": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmmirror.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz",
|
"resolved": "https://registry.npmmirror.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz",
|
||||||
@ -5383,6 +5478,15 @@
|
|||||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@mongodb-js/saslprep": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-t7c5K033joZZMspnHg/gWPE4kandgc2OxE74aYOtGKfgB9VPuVJPix0H6fhmm2erj5PBJ21mqcx34lpIGtUCsQ==",
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"sparse-bitfield": "^3.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@redis/bloom": {
|
"@redis/bloom": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.0.2.tgz",
|
||||||
@ -5529,9 +5633,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/webidl-conversions": {
|
"@types/webidl-conversions": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz",
|
||||||
"integrity": "sha512-xTE1E+YF4aWPJJeUzaZI5DRntlkY3+BCVJi0axFptnjGmAoWxkyREIh/XMrfxVLejwQxMCfDXdICo0VLxThrog=="
|
"integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA=="
|
||||||
},
|
},
|
||||||
"@types/whatwg-url": {
|
"@types/whatwg-url": {
|
||||||
"version": "8.2.2",
|
"version": "8.2.2",
|
||||||
@ -5762,9 +5866,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"bson": {
|
"bson": {
|
||||||
"version": "4.7.0",
|
"version": "4.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz",
|
||||||
"integrity": "sha512-VrlEE4vuiO1WTpfof4VmaVolCVYkYTgB9iWgYNOrVlnifpME/06fhFRmONgBhClD5pFC1t9ZWqFUQEQAzY43bA==",
|
"integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"buffer": "^5.6.0"
|
"buffer": "^5.6.0"
|
||||||
}
|
}
|
||||||
@ -6652,6 +6756,37 @@
|
|||||||
"integrity": "sha512-CYdFeFexxhv/Bcny+Q0BfOV+ltRlJcd4BBZBYFX/O0u4npJrgZtIcjokegtiSMAvlMTJ+Koq0GBCc//3bueQxw==",
|
"integrity": "sha512-CYdFeFexxhv/Bcny+Q0BfOV+ltRlJcd4BBZBYFX/O0u4npJrgZtIcjokegtiSMAvlMTJ+Koq0GBCc//3bueQxw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"ioredis": {
|
||||||
|
"version": "5.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.3.2.tgz",
|
||||||
|
"integrity": "sha512-1DKMMzlIHM02eBBVOFQ1+AolGjs6+xEcM4PDL7NqOS6szq7H9jSaEkIUH6/a5Hl241LzW6JLSiAbNvTQjUupUA==",
|
||||||
|
"requires": {
|
||||||
|
"@ioredis/commands": "^1.1.1",
|
||||||
|
"cluster-key-slot": "^1.1.0",
|
||||||
|
"debug": "^4.3.4",
|
||||||
|
"denque": "^2.1.0",
|
||||||
|
"lodash.defaults": "^4.2.0",
|
||||||
|
"lodash.isarguments": "^3.1.0",
|
||||||
|
"redis-errors": "^1.2.0",
|
||||||
|
"redis-parser": "^3.0.0",
|
||||||
|
"standard-as-callback": "^2.1.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"debug": {
|
||||||
|
"version": "4.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||||
|
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||||
|
"requires": {
|
||||||
|
"ms": "2.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"ip": {
|
"ip": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz",
|
||||||
@ -6826,6 +6961,16 @@
|
|||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"lodash.defaults": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz",
|
||||||
|
"integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ=="
|
||||||
|
},
|
||||||
|
"lodash.isarguments": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg=="
|
||||||
|
},
|
||||||
"log-symbols": {
|
"log-symbols": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmmirror.com/log-symbols/-/log-symbols-4.1.0.tgz",
|
"resolved": "https://registry.npmmirror.com/log-symbols/-/log-symbols-4.1.0.tgz",
|
||||||
@ -6987,22 +7132,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mongodb": {
|
"mongodb": {
|
||||||
"version": "4.11.0",
|
"version": "4.17.1",
|
||||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.17.1.tgz",
|
||||||
"integrity": "sha512-9l9n4Nk2BYZzljW3vHah3Z0rfS5npKw6ktnkmFgTcnzaXH1DRm3pDl6VMHu84EVb1lzmSaJC4OzWZqTkB5i2wg==",
|
"integrity": "sha512-MBuyYiPUPRTqfH2dV0ya4dcr2E5N52ocBuZ8Sgg/M030nGF78v855B3Z27mZJnp8PxjnUquEnAtjOsphgMZOlQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@aws-sdk/credential-providers": "^3.186.0",
|
"@aws-sdk/credential-providers": "^3.186.0",
|
||||||
"bson": "^4.7.0",
|
"@mongodb-js/saslprep": "^1.1.0",
|
||||||
"denque": "^2.1.0",
|
"bson": "^4.7.2",
|
||||||
"mongodb-connection-string-url": "^2.5.4",
|
"mongodb-connection-string-url": "^2.6.0",
|
||||||
"saslprep": "^1.0.3",
|
|
||||||
"socks": "^2.7.1"
|
"socks": "^2.7.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mongodb-connection-string-url": {
|
"mongodb-connection-string-url": {
|
||||||
"version": "2.5.4",
|
"version": "2.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.4.tgz",
|
"resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.6.0.tgz",
|
||||||
"integrity": "sha512-SeAxuWs0ez3iI3vvmLk/j2y+zHwigTDKQhtdxTgt5ZCOQQS5+HW4g45/Xw5vzzbn7oQXCNQ24Z40AkJsizEy7w==",
|
"integrity": "sha512-WvTZlI9ab0QYtTYnuMLgobULWhokRjtC7db9LtcVfJ+Hsnyr5eo6ZtNAt3Ly24XZScGMelOcGtm7lSn0332tPQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/whatwg-url": "^8.2.1",
|
"@types/whatwg-url": "^8.2.1",
|
||||||
"whatwg-url": "^11.0.0"
|
"whatwg-url": "^11.0.0"
|
||||||
@ -7241,9 +7385,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"punycode": {
|
"punycode": {
|
||||||
"version": "2.1.1",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
|
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="
|
||||||
},
|
},
|
||||||
"qs": {
|
"qs": {
|
||||||
"version": "6.11.0",
|
"version": "6.11.0",
|
||||||
@ -7253,6 +7397,11 @@
|
|||||||
"side-channel": "^1.0.4"
|
"side-channel": "^1.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ramda": {
|
||||||
|
"version": "0.29.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.29.1.tgz",
|
||||||
|
"integrity": "sha512-OfxIeWzd4xdUNxlWhgFazxsA/nl3mS4/jGZI5n00uWOoSSFRhC1b6gl6xvmzUamgmqELraWp0J/qqVlXYPDPyA=="
|
||||||
|
},
|
||||||
"randombytes": {
|
"randombytes": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmmirror.com/randombytes/-/randombytes-2.1.0.tgz",
|
"resolved": "https://registry.npmmirror.com/randombytes/-/randombytes-2.1.0.tgz",
|
||||||
@ -7319,6 +7468,19 @@
|
|||||||
"@redis/time-series": "1.0.3"
|
"@redis/time-series": "1.0.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"redis-errors": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w=="
|
||||||
|
},
|
||||||
|
"redis-parser": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==",
|
||||||
|
"requires": {
|
||||||
|
"redis-errors": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"regenerator-runtime": {
|
"regenerator-runtime": {
|
||||||
"version": "0.13.11",
|
"version": "0.13.11",
|
||||||
"resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
"resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
||||||
@ -7375,15 +7537,6 @@
|
|||||||
"resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
"resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||||
},
|
},
|
||||||
"saslprep": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==",
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"sparse-bitfield": "^3.0.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"seedrandom": {
|
"seedrandom": {
|
||||||
"version": "3.0.5",
|
"version": "3.0.5",
|
||||||
"resolved": "https://registry.npmmirror.com/seedrandom/-/seedrandom-3.0.5.tgz",
|
"resolved": "https://registry.npmmirror.com/seedrandom/-/seedrandom-3.0.5.tgz",
|
||||||
@ -7535,6 +7688,11 @@
|
|||||||
"frac": "~1.1.2"
|
"frac": "~1.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"standard-as-callback": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A=="
|
||||||
|
},
|
||||||
"statuses": {
|
"statuses": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
||||||
|
@ -37,9 +37,11 @@
|
|||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
|
"ioredis": "^5.3.2",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"mathjs": "^11.4.0",
|
"mathjs": "^11.4.0",
|
||||||
"mongodb": "^4.11.0",
|
"mongodb": "^4.17.1",
|
||||||
|
"ramda": "^0.29.1",
|
||||||
"redis": "^4.3.1",
|
"redis": "^4.3.1",
|
||||||
"shelljs": "^0.8.5",
|
"shelljs": "^0.8.5",
|
||||||
"sync-request": "^6.1.0",
|
"sync-request": "^6.1.0",
|
||||||
|
@ -4,7 +4,7 @@ import { FightFun } from '../../public/fight';
|
|||||||
|
|
||||||
export default async function (call: ApiCall<ReqLog, ResLog>) {
|
export default async function (call: ApiCall<ReqLog, ResLog>) {
|
||||||
if (call.req.result) {
|
if (call.req.result) {
|
||||||
FightFun.saveLog(call.req.uid, 'clsl', call.req.result);
|
// FightFun.saveLog(call.req.uid, 'clsl', call.req.result);
|
||||||
call.succ({});
|
call.succ({});
|
||||||
} else {
|
} else {
|
||||||
call.succ({
|
call.succ({
|
||||||
|
@ -6,5 +6,5 @@ export default async function (call: ApiCall<ReqRank, ResRank>) {
|
|||||||
let page = call.req.page || 0
|
let page = call.req.page || 0
|
||||||
let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题
|
let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题
|
||||||
let {min, max} = Rank.pageToMin(page, offset)
|
let {min, max} = Rank.pageToMin(page, offset)
|
||||||
call.succ(await Rank.list.clslCross.getRankList(call.req.gud.uid, { gud:call.req.gud, min, max }));
|
call.succ(await Rank.list.clslCross.getRankList(call.req.gud.uid, { min, max }));
|
||||||
}
|
}
|
11
src/api_cross/email/ApiDelCrossEmail.ts
Normal file
11
src/api_cross/email/ApiDelCrossEmail.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import {ApiCall} from "tsrpc";
|
||||||
|
import {ReqDelCrossEmail, ResDelCrossEmail} from "../../cross/protocols/email/PtlDelCrossEmail";
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqDelCrossEmail, ResDelCrossEmail>) {
|
||||||
|
let eids = call.req.eids;
|
||||||
|
G.mongodb.collection("email").updateMany({
|
||||||
|
_id: {$in: eids.map((i) => G.mongodb.conversionId(i))}
|
||||||
|
}, {isdel: true})
|
||||||
|
|
||||||
|
call.succ({result:true})
|
||||||
|
}
|
16
src/api_cross/email/ApiGetCrossEmail.ts
Normal file
16
src/api_cross/email/ApiGetCrossEmail.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import {ApiCall} from "tsrpc";
|
||||||
|
import {ReqGetCrossEmail, ResGetCrossEmail} from "../../cross/protocols/email/PtlGetCrossEmail";
|
||||||
|
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqGetCrossEmail, ResGetCrossEmail>) {
|
||||||
|
let emails = await G.mongodb.collection("email").find(
|
||||||
|
{sid: call.req.server_id, isdel: {$exists: false}},
|
||||||
|
{projection: {isdel: 0}}
|
||||||
|
).toArray()
|
||||||
|
|
||||||
|
call.succ({
|
||||||
|
emails: emails.map((e) => {
|
||||||
|
return {...e, _id: G.mongodb.conversionId(e._id)}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
25
src/api_cross/hbzb/ApiGetUser.ts
Normal file
25
src/api_cross/hbzb/ApiGetUser.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { ReqGetUser, ResGetUser } from "../../cross/protocols/hbzb/PtlGetUser";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从跨服中获取uids对应的数据
|
||||||
|
* @param call
|
||||||
|
*/
|
||||||
|
export default async function (call: ApiCall<ReqGetUser, ResGetUser>) {
|
||||||
|
let uids = call.req.uids;
|
||||||
|
let res = {};
|
||||||
|
let arr = await G.mongodb.collection('hbzb_user_cross').find({
|
||||||
|
uid: {
|
||||||
|
$in: uids
|
||||||
|
}
|
||||||
|
}).toArray();
|
||||||
|
|
||||||
|
arr.map(i=>{
|
||||||
|
res[i.uid] = {
|
||||||
|
data: i.data,
|
||||||
|
jifen:i.jifen,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
call.succ(res);
|
||||||
|
}
|
18
src/api_cross/hbzb/ApiUpdateHbzbCrossUser.ts
Normal file
18
src/api_cross/hbzb/ApiUpdateHbzbCrossUser.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { ReqUpdateHbzbCrossUser, ResUpdateHbzbCrossUser } from "../../cross/protocols/hbzb/PtlUpdateHbzbCrossUser";
|
||||||
|
|
||||||
|
/**更新跨服数据库里,黑帮争霸的玩家数据 */
|
||||||
|
export default async function (call: ApiCall<ReqUpdateHbzbCrossUser, ResUpdateHbzbCrossUser>) {
|
||||||
|
let setData = {
|
||||||
|
"data":{
|
||||||
|
player: call.req.user.player,
|
||||||
|
roles: call.req.user.roles,
|
||||||
|
uid: call.req.uid
|
||||||
|
},
|
||||||
|
"jifen": -999999,
|
||||||
|
"rank": -999999,
|
||||||
|
"zbsgroup":""
|
||||||
|
};
|
||||||
|
G.mongodb.collection('hbzb_user_cross').updateOne({ uid: setData.data.uid }, { $set: setData }, { upsert: true });
|
||||||
|
call.succ({ });
|
||||||
|
}
|
@ -4,53 +4,112 @@ import { Rank } from '../../../public/rank/rank';
|
|||||||
import { formatNpcData } from '../../../shared/fightControl/fightFun';
|
import { formatNpcData } from '../../../shared/fightControl/fightFun';
|
||||||
import { PublicShared } from "../../../shared/public/public";
|
import { PublicShared } from "../../../shared/public/public";
|
||||||
import { rankInfo } from "../../../shared/protocols/type";
|
import { rankInfo } from "../../../shared/protocols/type";
|
||||||
|
import { getWinScore } from "../../../api_s2c/hbzb/jfs/fun";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetEnemy, ResGetEnemy>) {
|
export default async function (call: ApiCall<ReqGetEnemy, ResGetEnemy>) {
|
||||||
// TODO ### debug allPlayer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// // TODO ### debug allPlayer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
let allPlayers:rankInfo[] = <rankInfo[]>await Rank.list.hbzbCross.getRankListRange();
|
// let allPlayers:rankInfo[] = <rankInfo[]>await Rank.list.hbzbCross.getRankListRange();
|
||||||
let user:rankInfo = <rankInfo>await Rank.list.hbzbCross.getRankData(call.req.uid);
|
// let user:rankInfo = <rankInfo>await Rank.list.hbzbCross.getRankData(call.req.uid);
|
||||||
if(!user?.player) {
|
// if(!user?.player) {
|
||||||
// 写入默认参数到数据库
|
// // 写入默认参数到数据库
|
||||||
user = {
|
// user = {
|
||||||
player: call.req.gud,
|
// player: call.req.gud,
|
||||||
valArr: [1000]
|
// valArr: [1000]
|
||||||
}
|
// }
|
||||||
await Rank.list.hbzbCross.addNew(user)
|
// await Rank.list.hbzbCross.addNew(user)
|
||||||
}
|
// }
|
||||||
// if(!user?.player) return call.succ({ enemy: [] });
|
// if(!user?.player) return call.succ({ enemy: [] });
|
||||||
|
|
||||||
let conf = call.req.auto ? G.gc.hbzb.jfsMatchingAuto : G.gc.hbzb.jfsMatchingHand;
|
let user = await G.mongodb.findOne('hbzb_user_cross', { uid: call.req.uid });
|
||||||
|
if(!user){
|
||||||
|
//玩家不存在
|
||||||
|
return call.error('', { code: -1, message: 'user is null' })
|
||||||
|
}
|
||||||
|
|
||||||
|
let conf = G.gc.hbzb.jfsMatchingHand;
|
||||||
let rang = conf.map(val => {
|
let rang = conf.map(val => {
|
||||||
return [PublicShared.eval(val.min, { zhanli: user.player.power }), PublicShared.eval(val.max, { zhanli: user.player.power })] as [number, number];
|
return [PublicShared.eval(val.min, { zhanli: user.data.player.power }), PublicShared.eval(val.max, { zhanli: user.data.player.power })] as [number, number];
|
||||||
});
|
});
|
||||||
let min = rang.slice(-1)[0][0];
|
/**
|
||||||
let max = rang[0][1];
|
0:[1029550, 1489437]
|
||||||
let players = allPlayers.filter(p => {
|
1:[936254, 1302845]
|
||||||
return p.player.power >= min && p.player.power <= max && p.player.uid != call.req.uid;
|
2:[656366, 1116254]
|
||||||
});
|
*/
|
||||||
let select: string[] = [];
|
let enemy =[];
|
||||||
let enemy = rang.map((r, index) => {
|
//已经刷到过的uid
|
||||||
let es = players.filter(p => p.player.power >= r[0] && p.player.power <= r[1] && !select.includes(p.player.uid));
|
let blackUids = [call.req.uid];
|
||||||
if (es.length > 0) {
|
|
||||||
let ops = es.random();
|
for(let i=0;i<rang.length;i++){
|
||||||
if(ops) {
|
let r = rang[i];
|
||||||
let data:any = {
|
let randRs = await G.mongodb.collection('hbzb_user_cross').aggregate([
|
||||||
data: {
|
{
|
||||||
player: ops.player,
|
$match: {
|
||||||
roles: ops.roles
|
$and: [
|
||||||
|
{"data.player.power": {$gte: r[0]}},
|
||||||
|
{"data.player.power": {$lte: r[1]}},
|
||||||
|
{uid: {$nin: blackUids}}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
jifen: ops.valArr[0]
|
{ $sample: { size: 1 } }
|
||||||
}
|
]).toArray();
|
||||||
return data;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return {
|
if (randRs.length>0) {
|
||||||
data: getNpc(user.player.lv, index),
|
blackUids.push(randRs[0].uid);
|
||||||
jifen: 1000
|
let score = getWinScore(user.data.player.power,randRs[0].data.player.power);
|
||||||
|
|
||||||
|
enemy[i] = {
|
||||||
|
data: {
|
||||||
|
player: randRs[0].data.player,
|
||||||
|
roles: randRs[0].data.roles
|
||||||
|
},
|
||||||
|
//这里的积分,只是战斗胜利时增加的积分
|
||||||
|
jifen: score
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
let npcData = getNpc(user.data.player.lv, i);
|
||||||
|
let score = getWinScore(user.data.player.power,npcData.player.power);
|
||||||
|
enemy[i] = {
|
||||||
|
data: npcData,
|
||||||
|
jifen: score
|
||||||
|
};;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
call.succ({ enemy: enemy });
|
call.succ({ enemy: enemy });
|
||||||
|
|
||||||
|
|
||||||
|
// let min = rang.slice(-1)[0][0];
|
||||||
|
// let max = rang[0][1];
|
||||||
|
// let players = allPlayers.filter(p => {
|
||||||
|
// return p.player.power >= min && p.player.power <= max && p.player.uid != call.req.uid;
|
||||||
|
// });
|
||||||
|
// let select: string[] = [];
|
||||||
|
// let enemy = rang.map((r, index) => {
|
||||||
|
// let es = players.filter(p => p.player.power >= r[0] && p.player.power <= r[1] && !select.includes(p.player.uid));
|
||||||
|
// if (es.length > 0) {
|
||||||
|
// let ops = es.random();
|
||||||
|
// players.removeOne(x => x.player.uid == ops.player.uid); // 删除已经出现的对手,避免重复刷到。
|
||||||
|
// if(ops) {
|
||||||
|
// let data:any = {
|
||||||
|
// data: {
|
||||||
|
// player: ops.player,
|
||||||
|
// roles: ops.roles
|
||||||
|
// },
|
||||||
|
// jifen: ops.valArr[0]
|
||||||
|
// }
|
||||||
|
// return data;
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// return {
|
||||||
|
// data: getNpc(user.player.lv, index),
|
||||||
|
// jifen: 1000
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//call.succ({ enemy: enemy });
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNpc(lv: number, index: number) {
|
function getNpc(lv: number, index: number) {
|
||||||
|
@ -3,12 +3,12 @@ import { ReqGetRankList, ResGetRankList } from "../../../cross/protocols/hbzb/jf
|
|||||||
import { Rank } from '../../../public/rank/rank';
|
import { Rank } from '../../../public/rank/rank';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetRankList, ResGetRankList>) {
|
export default async function (call: ApiCall<ReqGetRankList, ResGetRankList>) {
|
||||||
let page = call.req.page || 0
|
// let page = call.req.page || 0
|
||||||
let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题
|
// let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题
|
||||||
let {min, max} = Rank.pageToMin(page, offset)
|
// let {min, max} = Rank.pageToMin(page, offset)
|
||||||
let rankList = await Rank.list.hbzbCross.getRankListRange(min, max)
|
// let rankList = await Rank.list.hbzbCross.getRankListRange(min, max)
|
||||||
let myRankData = await Rank.list.hbzbCross.getRankData(call.conn.uid)
|
// let myRankData = await Rank.list.hbzbCross.getRankData(call.req.uid)
|
||||||
let jifen = myRankData?.valArr ? myRankData?.valArr[0] : 1000
|
// let jifen = myRankData?.valArr ? myRankData?.valArr[0] : 1000
|
||||||
// TODO ### debug
|
// // TODO ### debug
|
||||||
call.succ({ rankList: rankList, jifen: jifen });
|
// call.succ({ rankList: rankList, jifen: jifen });
|
||||||
}
|
}
|
@ -1,50 +1,44 @@
|
|||||||
import {ApiCall} from "tsrpc";
|
import { ApiCall } from "tsrpc";
|
||||||
import {ReqGetEnemy, ResGetEnemy} from "../../../cross/protocols/hbzb/zbs/PtlGetEnemy";
|
import { ReqGetEnemy, ResGetEnemy } from "../../../cross/protocols/hbzb/zbs/PtlGetEnemy";
|
||||||
import {Rank} from '../../../public/rank/rank';
|
import { Rank } from '../../../public/rank/rank';
|
||||||
import { rankInfo } from "../../../shared/protocols/type";
|
import { rankInfo } from "../../../shared/protocols/type";
|
||||||
|
import { e } from "mathjs";
|
||||||
|
|
||||||
|
function rand(min:number,max:number){
|
||||||
|
return Math.round(Math.random() * (max - min) + min);
|
||||||
|
}
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetEnemy, ResGetEnemy>) {
|
export default async function (call: ApiCall<ReqGetEnemy, ResGetEnemy>) {
|
||||||
let enemys:rankInfo[] = await Rank.list.hbzbZbsCross.getRankListRange(0, 10);
|
let uid = call.req.uid;
|
||||||
enemys.forEach((_, i) => {
|
let myData = await G.mongodb.collection("hbzb_user_cross").findOne({uid:uid});
|
||||||
enemys[i].rank = i
|
let myRank = myData.rank;
|
||||||
})
|
|
||||||
let myRank:number = await Rank.list.hbzbZbsCross.getRankSortByOne(call.req.uid);
|
|
||||||
|
|
||||||
// 随机匹配其它对手
|
let enemyRank = [];
|
||||||
let rankArr = []
|
let blackUids = [uid];
|
||||||
if (myRank > 8) {
|
|
||||||
if(myRank < 10) {
|
if(myRank == 1){
|
||||||
let min = myRank + 1
|
enemyRank = [4,3,2];
|
||||||
let max = myRank + 6
|
}else if(myRank == 2){
|
||||||
let randomRank = Math.round(Math.random() * (max - min) + min)
|
enemyRank = [4,3,1];
|
||||||
rankArr.push(randomRank)
|
}else if(myRank == 3){
|
||||||
}
|
enemyRank = [4,2,1];
|
||||||
if (myRank > 10) {
|
}else{
|
||||||
let min = 10
|
enemyRank = [
|
||||||
let max = myRank
|
rand(Math.floor(myRank*0.85-1), Math.floor(myRank*0.7)),
|
||||||
let arr = []
|
rand(Math.floor(myRank-1), Math.floor(myRank*0.85)),
|
||||||
for(let i = 0; i < 5 || arr.length >= 3; i++) {
|
rand(Math.floor(myRank*1.2), Math.floor(myRank+1)),
|
||||||
let randomRank = Math.round(Math.random() * (max - min) + min)
|
]
|
||||||
if(arr.indexOf(randomRank) == -1) arr.push(randomRank)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入随机的对手
|
let enemys = await G.mongodb.collection("hbzb_user_cross").find({
|
||||||
for(let rank of rankArr) {
|
zbsgroup:myData.zbsgroup,
|
||||||
let rankRange = await Rank.list.hbzbZbsCross.getRankSortDataByOne(rank);
|
uid : {$nin: blackUids},
|
||||||
if(rankRange) {
|
rank: {$in: enemyRank}
|
||||||
rankRange.rank = rank
|
}).toArray();
|
||||||
enemys.push(rankRange)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
enemy: enemys.map((e, i) => ({
|
enemy: enemys.map((e, i) => ({
|
||||||
data: {
|
data: e.data as any,
|
||||||
player: e.player,
|
|
||||||
roles: e.roles
|
|
||||||
},
|
|
||||||
rank: e.rank
|
rank: e.rank
|
||||||
})),
|
})),
|
||||||
rank: myRank
|
rank: myRank
|
||||||
|
@ -3,9 +3,9 @@ import { ReqGetRankList, ResGetRankList } from "../../../cross/protocols/hbzb/zb
|
|||||||
import { Rank } from '../../../public/rank/rank';
|
import { Rank } from '../../../public/rank/rank';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetRankList, ResGetRankList>) {
|
export default async function (call: ApiCall<ReqGetRankList, ResGetRankList>) {
|
||||||
let page = call.req.page || 0
|
// let page = call.req.page || 0
|
||||||
let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题
|
// let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题
|
||||||
let {min, max} = Rank.pageToMin(page, offset)
|
// let {min, max} = Rank.pageToMin(page, offset)
|
||||||
let rankList = await Rank.list.hbzbZbsCross.getRankListRange(min, max);
|
// let rankList = await Rank.list.hbzbZbsCross.getRankListRange(min, max);
|
||||||
call.succ({ rankList: rankList });
|
// call.succ({ rankList: rankList });
|
||||||
}
|
}
|
@ -3,6 +3,9 @@ import { ReqGetStatus, ResGetStatus } from "../../../cross/protocols/hbzb/zbs/Pt
|
|||||||
import { Rank } from '../../../public/rank/rank';
|
import { Rank } from '../../../public/rank/rank';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetStatus, ResGetStatus>) {
|
export default async function (call: ApiCall<ReqGetStatus, ResGetStatus>) {
|
||||||
let rank = await Rank.list.hbzbZbsCross.getRankSortByOne(call.req.uid)
|
let myData = await G.mongodb.collection("hbzb_user_cross").findOne({uid:call.req.uid});
|
||||||
call.succ({ status: rank});
|
if(!myData || !myData.rank){
|
||||||
|
return call.succ({ status: -999999});
|
||||||
|
}
|
||||||
|
call.succ({ status: (myData?.rank)});
|
||||||
}
|
}
|
@ -4,10 +4,10 @@ import { Rank } from '../../../public/rank/rank';
|
|||||||
|
|
||||||
export default async function (call: ApiCall<ReqSendJjcTop, ResSendJjcTop>) {
|
export default async function (call: ApiCall<ReqSendJjcTop, ResSendJjcTop>) {
|
||||||
// Rank.list.hbzbZbsCross.list.push(...call.req.tops);
|
// Rank.list.hbzbZbsCross.list.push(...call.req.tops);
|
||||||
for (let index = 0; index < call.req.tops.length; index++) {
|
// for (let index = 0; index < call.req.tops.length; index++) {
|
||||||
const element = call.req.tops[index];
|
// const element = call.req.tops[index];
|
||||||
element["valArr"] = [0];
|
// element["valArr"] = [0];
|
||||||
Rank.list.hbzbZbsCross.addNew(element)
|
// Rank.list.hbzbZbsCross.addNew(element)
|
||||||
|
|
||||||
};
|
// };
|
||||||
}
|
}
|
@ -2,8 +2,18 @@ import { ApiCall } from "tsrpc";
|
|||||||
import { ReqDldRefre, ResDldRefre } from "../../cross/protocols/wzry/PtlDldRefre";
|
import { ReqDldRefre, ResDldRefre } from "../../cross/protocols/wzry/PtlDldRefre";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqDldRefre, ResDldRefre>) {
|
export default async function (call: ApiCall<ReqDldRefre, ResDldRefre>) {
|
||||||
let others = await G.mongodb.collection('wzry_fight').find({ uid: { $nin: [call.req.uid] } }).toArray();
|
//let others = await G.mongodb.collection('wzry_fight').find({ uid: { $nin: [call.req.uid] } }).toArray();
|
||||||
let enemy = others.random();
|
//let enemy = others.random();
|
||||||
|
let enemy = await G.mongodb.collection('wzry_fight').aggregate([
|
||||||
|
{
|
||||||
|
$match: {uid: {
|
||||||
|
$nin: [call.req.uid]
|
||||||
|
}}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$sample: { size: 1 }
|
||||||
|
}
|
||||||
|
]).toArray();
|
||||||
|
|
||||||
call.succ({ info: enemy.data })
|
call.succ({ info: enemy[0].data })
|
||||||
}
|
}
|
@ -7,12 +7,56 @@ import { Rank } from '../../public/rank/rank';
|
|||||||
import { SchedulerWzryDlDstart, wzrygroup } from "../../public/scheduler/scheduler_wzry";
|
import { SchedulerWzryDlDstart, wzrygroup } from "../../public/scheduler/scheduler_wzry";
|
||||||
import { WangZheRongYaofun } from "../../public/wzry";
|
import { WangZheRongYaofun } from "../../public/wzry";
|
||||||
import { PublicShared } from "../../shared/public/public";
|
import { PublicShared } from "../../shared/public/public";
|
||||||
|
import { player } from "../../shared/protocols/user/type";
|
||||||
|
import { rankInfo } from "../../shared/protocols/type";
|
||||||
|
import { FindOptions } from "mongodb";
|
||||||
|
|
||||||
|
export async function getRankList(limit?: number, projection?:any){
|
||||||
|
let option : FindOptions = {
|
||||||
|
sort : {
|
||||||
|
'data.valArr': -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(limit!=null){
|
||||||
|
option.limit = limit;
|
||||||
|
}
|
||||||
|
if(projection!=null){
|
||||||
|
option.projection = projection;
|
||||||
|
}
|
||||||
|
|
||||||
|
let listArr = await G.mongodb.collection('rankList').find({ type: 'wzryCross' },option).toArray();
|
||||||
|
let list = listArr.map(l => l.data);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPlayerRank(uid: string) {
|
||||||
|
let _r = await getRankList(50,{
|
||||||
|
"data.player.uid":1,
|
||||||
|
"data.valArr":1,
|
||||||
|
});
|
||||||
|
if (!Object.keys(_r).length) {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
let myrank = _r.findIndex(li => li.player.uid == uid) + 1 || -1;
|
||||||
|
return myrank;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getWzryRankList(uid: string, gud: player){
|
||||||
|
let list = await getRankList(50);
|
||||||
|
return {
|
||||||
|
rankList: list,
|
||||||
|
myRank: {
|
||||||
|
rank: list.findIndex(li => li.player.uid == uid) + 1 || -1,
|
||||||
|
player: gud,
|
||||||
|
valArr: [(await G.mongodb.collection('wzry_fight').findOne({ uid: uid }))?.jifen || 0]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRank, ResRank>) {
|
export default async function (call: ApiCall<ReqRank, ResRank>) {
|
||||||
let page = call.req.page || 0
|
let _r = await getWzryRankList(call.req.gud.uid, call.req.gud)
|
||||||
let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题
|
_r.rankList = _r.rankList.splice(0, 50);
|
||||||
let {min, max} = Rank.pageToMin(page, offset)
|
|
||||||
let _r = await Rank.list.wzryCross.getRankList(call.req.gud.uid, {gud: call.req.gud, min, max})
|
|
||||||
|
|
||||||
call.succ(_r);
|
call.succ(_r);
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import { ApiCall } from "tsrpc";
|
||||||
import { ReqSetWzFight, ResSetWzFight } from "../../cross/protocols/wzry/PtlSetWzFight";
|
import { ReqSetWzFight, ResSetWzFight } from "../../cross/protocols/wzry/PtlSetWzFight";
|
||||||
import { Rank } from "../../public/rank/rank";
|
import { Rank } from "../../public/rank/rank";
|
||||||
|
import { getPlayerRank } from "./ApiRank";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqSetWzFight, ResSetWzFight>) {
|
export default async function (call: ApiCall<ReqSetWzFight, ResSetWzFight>) {
|
||||||
let _setData = {
|
let _setData = {
|
||||||
@ -16,9 +17,9 @@ export default async function (call: ApiCall<ReqSetWzFight, ResSetWzFight>) {
|
|||||||
valArr: [_setData.jifen],
|
valArr: [_setData.jifen],
|
||||||
..._setData.data
|
..._setData.data
|
||||||
}
|
}
|
||||||
Rank.list.wzryCross.addNew(data)
|
await Rank.list.wzryCross.addNew(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
let rank = await Rank.list.wzryCross.getPlayerRank(call.req.data.player.uid) || -1
|
let rank = await getPlayerRank(call.req.data.player.uid) || -1
|
||||||
call.succ({ mydata: _setData, rank: rank });
|
call.succ({ mydata: _setData, rank: rank });
|
||||||
}
|
}
|
@ -1,9 +1,17 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import { ApiCall } from "tsrpc";
|
||||||
import { ReqUpdateFight, ResUpdateFight } from "../../cross/protocols/wzry/PtlUpdateFight";
|
import { ReqUpdateFight, ResUpdateFight } from "../../cross/protocols/wzry/PtlUpdateFight";
|
||||||
|
import { Rank } from "../../public/rank/rank";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqUpdateFight, ResUpdateFight>) {
|
export default async function (call: ApiCall<ReqUpdateFight, ResUpdateFight>) {
|
||||||
if (call.req.setdata) {
|
if (call.req.setdata) {
|
||||||
await G.mongodb.collection('wzry_fight').updateOne({ uid: call.req.uid }, { $set: call.req.setdata })
|
await G.mongodb.collection('wzry_fight').updateOne({ uid: call.req.uid }, { $set: call.req.setdata })
|
||||||
|
if(call.req.setdata.jifen) {
|
||||||
|
let data = {
|
||||||
|
valArr: [call.req.setdata.jifen],
|
||||||
|
...call.req.setdata.data
|
||||||
|
}
|
||||||
|
Rank.list.wzryCross.addNew(data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (call.req.isjingcai) {
|
if (call.req.isjingcai) {
|
||||||
|
@ -2,6 +2,7 @@ import { ApiCall } from "tsrpc";
|
|||||||
import { ReqWzFightData, ResWzFightData } from "../../cross/protocols/wzry/PtlWzFightData";
|
import { ReqWzFightData, ResWzFightData } from "../../cross/protocols/wzry/PtlWzFightData";
|
||||||
import { Rank } from "../../public/rank/rank";
|
import { Rank } from "../../public/rank/rank";
|
||||||
import { PublicShared } from "../../shared/public/public";
|
import { PublicShared } from "../../shared/public/public";
|
||||||
|
import { getPlayerRank } from "./ApiRank";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqWzFightData, ResWzFightData>) {
|
export default async function (call: ApiCall<ReqWzFightData, ResWzFightData>) {
|
||||||
// 王者参与数据
|
// 王者参与数据
|
||||||
@ -10,7 +11,7 @@ export default async function (call: ApiCall<ReqWzFightData, ResWzFightData>) {
|
|||||||
let _myFight = await G.mongodb.collection('wzry_fight').findOne({ uid: call.req.uid })
|
let _myFight = await G.mongodb.collection('wzry_fight').findOne({ uid: call.req.uid })
|
||||||
if (_myFight && Object.keys(_myFight).length > 0) {
|
if (_myFight && Object.keys(_myFight).length > 0) {
|
||||||
if (_myFight?._id) delete _myFight._id
|
if (_myFight?._id) delete _myFight._id
|
||||||
_myFight['rank'] = await Rank.list.wzryCross.getPlayerRank(call.req.uid) || -1
|
_myFight['rank'] = await getPlayerRank(call.req.uid) || -1
|
||||||
changeInfo['info'] = _myFight
|
changeInfo['info'] = _myFight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
src/api_o2s/email/Apisendemail.ts
Normal file
35
src/api_o2s/email/Apisendemail.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import {ApiCall} from "tsrpc";
|
||||||
|
import {Reqsendemail, Ressendemail} from "../../monopoly/protocols/email/Ptlsendemail";
|
||||||
|
import {EmailFun} from '../../public/email';
|
||||||
|
import {ReqEmail} from '../../monopoly/protocols/PtlEmail';
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<Reqsendemail, Ressendemail>) {
|
||||||
|
//1. 接受参数
|
||||||
|
let prize = call.req.prize || [],
|
||||||
|
title = call.req.title,
|
||||||
|
content = call.req.content,
|
||||||
|
sendType = call.req.sendType,
|
||||||
|
uids = call.req.uids || [];
|
||||||
|
//2. 发送邮件model
|
||||||
|
let emailMsg: ReqEmail = {
|
||||||
|
uid: '',
|
||||||
|
type: 'system',
|
||||||
|
title: '',
|
||||||
|
content: '',
|
||||||
|
lngTitle: title,
|
||||||
|
lngContent: content
|
||||||
|
}
|
||||||
|
if (prize && prize.length > 0) emailMsg.prize = prize;
|
||||||
|
//3. 全服邮件
|
||||||
|
if (sendType == 2) {
|
||||||
|
emailMsg.uid = "system"
|
||||||
|
emailMsg.type = 'gm'
|
||||||
|
EmailFun.addQuanFuEmail(emailMsg)
|
||||||
|
} else {
|
||||||
|
for (let i = 0; i < uids.length; i++) {
|
||||||
|
emailMsg.uid = uids[i];
|
||||||
|
EmailFun.addEmail(emailMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
call.succ({result: 0, sendNum: sendType == 2 ? 0 : uids.length});
|
||||||
|
}
|
@ -1,14 +1,7 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import { ApiCall } from "tsrpc";
|
||||||
import { Reqdeploy, Resdeploy } from "../../monopoly/protocols/games/Ptldeploy";
|
import { Reqdeploy, Resdeploy } from "../../monopoly/protocols/games/Ptldeploy";
|
||||||
import { initStarupFun } from "../../starup";
|
|
||||||
|
|
||||||
export default async function (call: ApiCall<Reqdeploy, Resdeploy>) {
|
export default async function (call: ApiCall<Reqdeploy, Resdeploy>) {
|
||||||
try{
|
// TODO
|
||||||
initStarupFun.initStart()
|
call.error('API Not Implemented');
|
||||||
}catch(err){
|
|
||||||
call.succ({message:err.toString(), code:-1})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 区服初始化
|
|
||||||
call.succ({ message: "success", code: 0 });
|
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ import { Reqmetrics, Resmetrics } from "../../monopoly/protocols/games/Ptlmetric
|
|||||||
|
|
||||||
export default async function (call: ApiCall<Reqmetrics, Resmetrics>) {
|
export default async function (call: ApiCall<Reqmetrics, Resmetrics>) {
|
||||||
// 当前区服付费人数
|
// 当前区服付费人数
|
||||||
let now_paid_user_num = await G.mongodb.collection('payLog').countDocuments({})
|
let now_paid_user_num = await G.mongodb.collection('payLogNew').countDocuments({})
|
||||||
// 当前区服在线人数
|
// 当前区服在线人数
|
||||||
let now_login_user_num = await G.mongodb.collection('user').countDocuments({ newonlinetime: { $gte: G.time - 90, $lte: G.time + 30 } })
|
let now_login_user_num = await G.mongodb.collection('user').countDocuments({ newonlinetime: { $gte: G.time - 90, $lte: G.time + 30 } })
|
||||||
// 当前区服注册人数
|
// 当前区服注册人数
|
||||||
|
@ -4,6 +4,7 @@ import {env} from "process";
|
|||||||
import request from "sync-request";
|
import request from "sync-request";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import {initStarupFun} from "../../starup";
|
import {initStarupFun} from "../../starup";
|
||||||
|
const shell = require('shelljs');
|
||||||
|
|
||||||
export default async function (call: ApiCall<Reqopen, Resopen>) {
|
export default async function (call: ApiCall<Reqopen, Resopen>) {
|
||||||
// 设置开区时间
|
// 设置开区时间
|
||||||
@ -20,12 +21,14 @@ export default async function (call: ApiCall<Reqopen, Resopen>) {
|
|||||||
message: G.openTime
|
message: G.openTime
|
||||||
});
|
});
|
||||||
|
|
||||||
initStarupFun.initStart()
|
await initStarupFun.initStart()
|
||||||
|
|
||||||
if(call.req.utc){
|
if(call.req.utc){
|
||||||
console.log('---------------开始修改时区shell脚本---------------')
|
console.log('---------------开始修改时区shell脚本---------------')
|
||||||
const shell = require('shelljs');
|
|
||||||
shell.exec(`sh /app/zoeninfo.sh ${call.req.utc}`)
|
shell.exec(`sh /app/zoeninfo.sh ${call.req.utc}`)
|
||||||
|
}else{
|
||||||
|
console.log("o2s里收到开区命令 即将pm2 reload all");
|
||||||
|
shell.exec(`pm2 reload all`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,22 +1,25 @@
|
|||||||
import {ApiCall} from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import {Reqpopup, Respopup} from "../../monopoly/protocols/gift/Ptlpopup";
|
import {Reqpopup, Respopup} from "../../monopoly/protocols/gift/Ptlpopup";
|
||||||
|
import {redisClient} from "../../setRedis";
|
||||||
|
|
||||||
export default async function (call: ApiCall<Reqpopup, Respopup>) {
|
export default async function (call: ApiCall<Reqpopup, Respopup>) {
|
||||||
// 给用户推送礼包的逻辑实现
|
// 给用户推送礼包的逻辑实现
|
||||||
let popup_info = call.req
|
let popup_info = call.req
|
||||||
|
|
||||||
// todo 开发去实现
|
|
||||||
console.log("收到礼包推送", popup_info)
|
console.log("收到礼包推送", popup_info)
|
||||||
|
|
||||||
let user = G.server.uid_connections[popup_info.game_user_id]
|
let userPid = await redisClient.hGet(G.redis.fromatKey("uid2processId"), popup_info.game_user_id)
|
||||||
|
|
||||||
let giftLog: any = {...popup_info}
|
let giftLog: any = {...popup_info}
|
||||||
|
|
||||||
if (user) {
|
if (userPid) {
|
||||||
|
let duration = popup_info.duration || (popup_info.template_id == '100' && 86400) || (popup_info.template_id == '200' && 8640000) || 86400
|
||||||
|
|
||||||
giftLog = {
|
giftLog = {
|
||||||
...popup_info,
|
...popup_info,
|
||||||
|
duration: duration,
|
||||||
showTime: G.time,
|
showTime: G.time,
|
||||||
endTime: G.time + popup_info.duration
|
endTime: G.time + duration
|
||||||
}
|
}
|
||||||
G.server.sendMsgByUid(popup_info.game_user_id, 'msg_s2c/SendGift', giftLog)
|
G.server.sendMsgByUid(popup_info.game_user_id, 'msg_s2c/SendGift', giftLog)
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
import {ApiCall} from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import {ReqPay, ResPay} from "../../monopoly/protocols/gm/PtlPay";
|
import {ReqPay, ResPay} from "../../monopoly/protocols/gm/PtlPay";
|
||||||
import {PayFun} from "../../public/pay";
|
import {PayFun} from "../../public/pay";
|
||||||
|
import { clusterFunctionRunAtUidProcess } from "../../clusterUtils";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqPay, ResPay>) {
|
export default async function (call: ApiCall<ReqPay, ResPay>) {
|
||||||
|
|
||||||
await PayFun.pay(call.req.uid, call.req.payId, call.req.payArgs, call.req.type);
|
clusterFunctionRunAtUidProcess(call.req.uid , "pay", call.req.uid, call.req.payId, call.req.payArgs, call.req.type, call.req.orderNo)
|
||||||
|
//await PayFun.pay(call.req.uid, call.req.payId, call.req.payArgs, call.req.type, call.req.orderNo);
|
||||||
call.succ({});
|
call.succ({});
|
||||||
|
|
||||||
|
// 5秒后自动检测支付
|
||||||
|
setTimeout(async function(){
|
||||||
|
let payed = await G.mongodb.collection('payOrderLog' as any).count({"orderNo": call.req.orderNo});
|
||||||
|
if(!payed){
|
||||||
|
await PayFun.pay(call.req.uid, call.req.payId, call.req.payArgs, call.req.type, call.req.orderNo);
|
||||||
|
}
|
||||||
|
},5000)
|
||||||
}
|
}
|
36
src/api_o2s/user/Apidisable.ts
Normal file
36
src/api_o2s/user/Apidisable.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { Reqdisable, Resdisable } from "../../monopoly/protocols/user/Ptldisable";
|
||||||
|
import { setGud } from "../../public/gud";
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<Reqdisable, Resdisable>) {
|
||||||
|
//1. 接受参数
|
||||||
|
let value = call.req.value; //0. 正常, 1. 禁用
|
||||||
|
let uid = call.req.uid
|
||||||
|
let type = call.req.type; // 1. 封号,2. 禁言
|
||||||
|
let data:any = {}
|
||||||
|
let typeStr = ''
|
||||||
|
//2. 写入参数
|
||||||
|
switch(type) {
|
||||||
|
case 1:
|
||||||
|
typeStr = 'status'
|
||||||
|
data[typeStr] = value
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
typeStr = 'status_chat'
|
||||||
|
data[typeStr] = value
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
call.succ({result: 1})
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let res = await G.mongodb.collection('user').updateOne({uid}, {$set: data});
|
||||||
|
//G.redis.set('user', uid, typeStr, value);
|
||||||
|
setGud(uid, data);
|
||||||
|
let result = res.modifiedCount > 0 ? 0 : 1;
|
||||||
|
//3. 返回结果
|
||||||
|
if(result == 0) {
|
||||||
|
if(type == 1 && value == 1) await G.server.sendMsgByUid(uid, 'msg_s2c/OtherLogin', '1');
|
||||||
|
}
|
||||||
|
//3. 广播踢线
|
||||||
|
return call.succ({result})
|
||||||
|
}
|
@ -1,8 +1,10 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { HeroFun } from '../public/hero';
|
import {HeroFun} from '../public/hero';
|
||||||
import { PlayerFun } from '../public/player';
|
import {PlayerFun} from '../public/player';
|
||||||
import { defaultUserAppend, UserFun } from '../public/user';
|
import {defaultUserAppend, UserFun} from '../public/user';
|
||||||
import { ReqBingo, ResBingo } from "../shared/protocols/PtlBingo";
|
import {ReqBingo, ResBingo} from "../shared/protocols/PtlBingo";
|
||||||
|
import {ReqEmail} from "../monopoly/protocols/PtlEmail";
|
||||||
|
import {EmailFun} from "../public/email";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqBingo, ResBingo>) {
|
export default async function (call: ApiCall<ReqBingo, ResBingo>) {
|
||||||
// TODO
|
// TODO
|
||||||
@ -70,37 +72,37 @@ export default async function (call: ApiCall<ReqBingo, ResBingo>) {
|
|||||||
|
|
||||||
if (!G.gc.item[shell[1]]) return call.error(`道具id不存在:${shell[1]}`);
|
if (!G.gc.item[shell[1]]) return call.error(`道具id不存在:${shell[1]}`);
|
||||||
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
||||||
await PlayerFun.addItem(call, [{ a: 'item', t: shell[1], n: parseInt(shell[2]) }]);
|
await PlayerFun.addItem(call, [{a: 'item', t: shell[1], n: parseInt(shell[2])}]);
|
||||||
|
|
||||||
} else if (shell[0] == 'hero') {
|
} else if (shell[0] == 'hero') {
|
||||||
|
|
||||||
if (!G.gc.hero[shell[1]]) return call.error(`英雄id不存在:${shell[1]}`);
|
if (!G.gc.hero[shell[1]]) return call.error(`英雄id不存在:${shell[1]}`);
|
||||||
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
||||||
await PlayerFun.addHero(call, [{ a: 'item', t: shell[1], n: parseInt(shell[2]) }]);
|
await PlayerFun.addHero(call, [{a: 'item', t: shell[1], n: parseInt(shell[2])}]);
|
||||||
|
|
||||||
} else if (shell[0] == 'equip') {
|
} else if (shell[0] == 'equip') {
|
||||||
|
|
||||||
if (!G.gc.equip[shell[1]]) return call.error(`装备id不存在:${shell[1]}`);
|
if (!G.gc.equip[shell[1]]) return call.error(`装备id不存在:${shell[1]}`);
|
||||||
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
||||||
await PlayerFun.addEquip(call, [{ a: 'equip', t: shell[1], n: parseInt(shell[2]) }]);
|
await PlayerFun.addEquip(call, [{a: 'equip', t: shell[1], n: parseInt(shell[2])}]);
|
||||||
|
|
||||||
} else if (shell[0] == 'shiwu') {
|
} else if (shell[0] == 'shiwu') {
|
||||||
|
|
||||||
if (!G.gc.shiwu[shell[1]]) return call.error(`饰物id不存在:${shell[1]}`);
|
if (!G.gc.shiwu[shell[1]]) return call.error(`饰物id不存在:${shell[1]}`);
|
||||||
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
||||||
if (isNaN(parseInt(shell[3]))) return call.error(`请输入正确的品质`);
|
if (isNaN(parseInt(shell[3]))) return call.error(`请输入正确的品质`);
|
||||||
await PlayerFun.addShiwu(call, [{ a: 'shiwu', t: shell[1], n: parseInt(shell[2]), colour: parseInt(shell[3]) }]);
|
await PlayerFun.addShiwu(call, [{a: 'shiwu', t: shell[1], n: parseInt(shell[2]), colour: parseInt(shell[3])}]);
|
||||||
|
|
||||||
} else if (shell[0] == 'peijian') {
|
} else if (shell[0] == 'peijian') {
|
||||||
|
|
||||||
if (!G.gc.peijian[shell[1]]) return call.error(`配件id不存在:${shell[1]}`);
|
if (!G.gc.peijian[shell[1]]) return call.error(`配件id不存在:${shell[1]}`);
|
||||||
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
||||||
await PlayerFun.addPeijian(call, [{ a: 'peijian', t: shell[1], n: parseInt(shell[2]) }]);
|
await PlayerFun.addPeijian(call, [{a: 'peijian', t: shell[1], n: parseInt(shell[2])}]);
|
||||||
|
|
||||||
} else if (shell[0] == 'attr') {
|
} else if (shell[0] == 'attr') {
|
||||||
if (G.gc.attr[shell[1]] == undefined) return call.error(`道具id不存在:${shell[1]}`);
|
if (G.gc.attr[shell[1]] == undefined) return call.error(`道具id不存在:${shell[1]}`);
|
||||||
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
|
||||||
await PlayerFun.addAttr(call, [{ a: 'attr', t: shell[1], n: parseInt(shell[2]) }]);
|
await PlayerFun.addAttr(call, [{a: 'attr', t: shell[1], n: parseInt(shell[2])}]);
|
||||||
|
|
||||||
} else if (shell.length == 2) {
|
} else if (shell.length == 2) {
|
||||||
|
|
||||||
@ -120,8 +122,20 @@ export default async function (call: ApiCall<ReqBingo, ResBingo>) {
|
|||||||
} else if (shell[0] == 'heroMaxLv') {
|
} else if (shell[0] == 'heroMaxLv') {
|
||||||
let heros = await G.redis.get('hero', call.uid);
|
let heros = await G.redis.get('hero', call.uid);
|
||||||
for (let [_id, hero] of Object.entries(heros)) {
|
for (let [_id, hero] of Object.entries(heros)) {
|
||||||
await HeroFun.changeHeroAttr(call, hero, { lv: Object.keys(G.gc.playerLv).length * 3, jieji: Object.keys(G.gc.herogrow[hero.heroId]).length - 1 });
|
await HeroFun.changeHeroAttr(call, hero, {
|
||||||
|
lv: Object.keys(G.gc.playerLv).length * 3,
|
||||||
|
jieji: Object.keys(G.gc.herogrow[hero.heroId]).length - 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
} else if (shell[0] == 'email') {
|
||||||
|
let emailMsg: ReqEmail = {
|
||||||
|
uid: call.uid,
|
||||||
|
type: 'system',
|
||||||
|
title: shell[1],
|
||||||
|
content: shell[2]
|
||||||
|
}
|
||||||
|
if (shell[3]) emailMsg.prize = JSON.parse(shell[3])
|
||||||
|
EmailFun.addEmail(emailMsg);
|
||||||
}
|
}
|
||||||
call.succ('succ');
|
call.succ('succ');
|
||||||
}
|
}
|
@ -62,7 +62,7 @@ export default async function (call: ApiCall<ReqSyncBtn, ResSyncBtn>) {
|
|||||||
data[key] = {active: true, sTime: lastRunTime, round: round};
|
data[key] = {active: true, sTime: lastRunTime, round: round};
|
||||||
change[key] = data[key];
|
change[key] = data[key];
|
||||||
|
|
||||||
PayFun.setPayLog(call.uid, {payId: G.gc.zhanling.payId, val: []});
|
PayFun.delPayLog(call.uid, {payId: G.gc.zhanling.payId, val: []});
|
||||||
|
|
||||||
G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'}).then(data => {
|
G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'}).then(data => {
|
||||||
//新一轮战令 不管玩家多久没上线 只补发玩家上一轮没有领取的奖励
|
//新一轮战令 不管玩家多久没上线 只补发玩家上一轮没有领取的奖励
|
||||||
|
@ -1,22 +1,31 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { ChatFun } from '../../public/chat';
|
import {ChatFun} from '../../public/chat';
|
||||||
import { ReqGetList, ResGetList } from "../../shared/protocols/chat/PtlGetList";
|
import {ReqGetList, ResGetList} from "../../shared/protocols/chat/PtlGetList";
|
||||||
import { PublicShared } from "../../shared/public/public";
|
import {PublicShared} from "../../shared/public/public";
|
||||||
|
import {FriendManage} from "../../public/friend/manage";
|
||||||
|
import {filter} from "mathjs";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||||
|
|
||||||
let publicList = await G.mongodb.collection('chat').find({ type: { $in: ['cross', 'local', `guild${call.conn.gud.ghId || ''}`] } }).toArray();
|
let publicList = await G.mongodb.collection('chat').find({type: {$in: ['cross', 'local', `guild${call.conn.gud.ghId || ''}`]}}).toArray();
|
||||||
let _guildList = publicList.find(l => l.type.indexOf('guild') != -1)?.list || []
|
let _guildList = publicList.find(l => l.type.indexOf('guild') != -1)?.list || []
|
||||||
|
|
||||||
|
const my = await FriendManage.getFriend(call.uid);
|
||||||
|
|
||||||
|
const filterBlackList = (list) => list.filter(i => !my.data.blacklist.includes(i.sender.uid))
|
||||||
|
|
||||||
let list = {
|
let list = {
|
||||||
cross: publicList.find(l => l.type == 'cross')?.list || [],
|
cross: filterBlackList(publicList.find(l => l.type == 'cross')?.list || []) || [],
|
||||||
local: publicList.find(l => l.type == 'local')?.list || [],
|
local: filterBlackList(publicList.find(l => l.type == 'local')?.list || []) || [],
|
||||||
guild: _guildList.filter(l => { return PublicShared.getToDayZeroTime(G.time) < l.time }),
|
guild: filterBlackList(_guildList.filter(l => {
|
||||||
|
return PublicShared.getToDayZeroTime(G.time) < l.time
|
||||||
|
})),
|
||||||
private: await ChatFun.getPrivateList(call.uid)
|
private: await ChatFun.getPrivateList(call.uid)
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除过期帮助
|
// 删除过期帮助
|
||||||
if (_guildList.length != list.guild.length) {
|
if (_guildList.length != list.guild.length) {
|
||||||
G.mongodb.collection('chat').updateOne({ type: 'guild' + call.conn.gud.ghId }, { $set: { list: list.guild } });
|
G.mongodb.collection('chat').updateOne({type: 'guild' + call.conn.gud.ghId}, {$set: {list: list.guild}});
|
||||||
}
|
}
|
||||||
|
|
||||||
call.succ(list);
|
call.succ(list);
|
||||||
|
@ -3,6 +3,7 @@ import { PayFun } from '../../public/pay';
|
|||||||
import { PlayerFun } from '../../public/player';
|
import { PlayerFun } from '../../public/player';
|
||||||
import { ReqHelp, ResHelp } from "../../shared/protocols/chat/PtlHelp";
|
import { ReqHelp, ResHelp } from "../../shared/protocols/chat/PtlHelp";
|
||||||
import { PublicShared } from '../../shared/public/public';
|
import { PublicShared } from '../../shared/public/public';
|
||||||
|
import { getGud } from "../../public/gud";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqHelp, ResHelp>) {
|
export default async function (call: ApiCall<ReqHelp, ResHelp>) {
|
||||||
call.req.helps = call.req.helps.filter(h => {
|
call.req.helps = call.req.helps.filter(h => {
|
||||||
@ -60,7 +61,7 @@ export default async function (call: ApiCall<ReqHelp, ResHelp>) {
|
|||||||
});
|
});
|
||||||
li.otherData.helpUis.push(call.uid);
|
li.otherData.helpUis.push(call.uid);
|
||||||
if (G.gc.shili_com.resHelp[li.otherData.helpIndex] <= li.otherData.helpUis.length) {
|
if (G.gc.shili_com.resHelp[li.otherData.helpIndex] <= li.otherData.helpUis.length) {
|
||||||
PlayerFun.sendPrize(PayFun.getCall(await G.redis.get('user', li.sender.uid)), [G.gc.shili_com.resHelp[li.otherData.helpIndex].need]);
|
PlayerFun.sendPrize(PayFun.getCall(await getGud(li.sender.uid)), [G.gc.shili_com.resHelp[li.otherData.helpIndex].need]);
|
||||||
}
|
}
|
||||||
prize.push(...PublicShared.randomDropGroup(G.gc.shili_com.resHelp[li.otherData.helpIndex].helpPrizeDrop));
|
prize.push(...PublicShared.randomDropGroup(G.gc.shili_com.resHelp[li.otherData.helpIndex].helpPrizeDrop));
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import { ChatFun } from '../../public/chat';
|
|||||||
import { FriendManage } from '../../public/friend/manage';
|
import { FriendManage } from '../../public/friend/manage';
|
||||||
import { ReqPrivate, ResPrivate } from "../../shared/protocols/chat/PtlPrivate";
|
import { ReqPrivate, ResPrivate } from "../../shared/protocols/chat/PtlPrivate";
|
||||||
import { MsgPrivate } from '../../shared/protocols/msg_s2c/MsgPrivate';
|
import { MsgPrivate } from '../../shared/protocols/msg_s2c/MsgPrivate';
|
||||||
|
import { getGud } from "../../public/gud";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqPrivate, ResPrivate>) {
|
export default async function (call: ApiCall<ReqPrivate, ResPrivate>) {
|
||||||
let my = await FriendManage.getFriend(call.uid);
|
let my = await FriendManage.getFriend(call.uid);
|
||||||
@ -14,7 +15,8 @@ export default async function (call: ApiCall<ReqPrivate, ResPrivate>) {
|
|||||||
ChatFun.writePrivateId(call.uid, privateId);
|
ChatFun.writePrivateId(call.uid, privateId);
|
||||||
ChatFun.writePrivateId(call.req.uid, privateId);
|
ChatFun.writePrivateId(call.req.uid, privateId);
|
||||||
|
|
||||||
let recipient = await G.mongodb.collection('user').findOne({ uid: call.req.uid });
|
//let recipient = await G.mongodb.collection('user').findOne({ uid: call.req.uid });
|
||||||
|
let recipient = await getGud( call.req.uid );
|
||||||
let msg: MsgPrivate = {
|
let msg: MsgPrivate = {
|
||||||
msg: call.req.msg,
|
msg: call.req.msg,
|
||||||
time: G.time,
|
time: G.time,
|
||||||
@ -26,11 +28,19 @@ export default async function (call: ApiCall<ReqPrivate, ResPrivate>) {
|
|||||||
recipient: recipient
|
recipient: recipient
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 原私聊记录表,保留。
|
||||||
G.mongodb.collection('chat').updateOne(
|
G.mongodb.collection('chat').updateOne(
|
||||||
{ type: privateId },
|
{ type: privateId },
|
||||||
{ $push: { list: msg } },
|
{ $push: { list: msg } },
|
||||||
{ upsert: true }
|
{ upsert: true }
|
||||||
);
|
);
|
||||||
|
// 写入聊天记录
|
||||||
|
let msgLog = {
|
||||||
|
content: call.req.msg,
|
||||||
|
toUid: call.req.uid,
|
||||||
|
type: 'private',
|
||||||
|
}
|
||||||
|
ChatFun.setChatLog(call, msgLog)
|
||||||
|
|
||||||
G.server.sendMsgByUid(call.uid, 'msg_s2c/Private', msg);
|
G.server.sendMsgByUid(call.uid, 'msg_s2c/Private', msg);
|
||||||
G.server.sendMsgByUid(call.req.uid, 'msg_s2c/Private', msg);
|
G.server.sendMsgByUid(call.req.uid, 'msg_s2c/Private', msg);
|
||||||
|
@ -2,11 +2,14 @@ import { ApiCall, WsClientStatus } from "tsrpc";
|
|||||||
import { ActionLog } from '../../public/actionLog/actionLog';
|
import { ActionLog } from '../../public/actionLog/actionLog';
|
||||||
import { ChatFun } from '../../public/chat';
|
import { ChatFun } from '../../public/chat';
|
||||||
import { ReqSend, ResSend } from "../../shared/protocols/chat/PtlSend";
|
import { ReqSend, ResSend } from "../../shared/protocols/chat/PtlSend";
|
||||||
|
import { chatMsgLog } from "../../shared/protocols/type"
|
||||||
|
import { getGud } from "../../public/gud";
|
||||||
|
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqSend, ResSend>) {
|
export default async function (call: ApiCall<ReqSend, ResSend>) {
|
||||||
|
let status_chat = await getGud(call.uid)['status_chat'];
|
||||||
|
// 验证是否被禁言
|
||||||
|
if(status_chat == 1) return call.error(lng.chat_4);
|
||||||
let data = call.req;
|
let data = call.req;
|
||||||
if (data.msg.length < 1 || data.msg.length > 30) return call.error('', { code: -1 });
|
if (data.msg.length < 1 || data.msg.length > 30) return call.error('', { code: -1 });
|
||||||
|
|
||||||
@ -25,15 +28,24 @@ export default async function (call: ApiCall<ReqSend, ResSend>) {
|
|||||||
time: G.time,
|
time: G.time,
|
||||||
sender: gud
|
sender: gud
|
||||||
};
|
};
|
||||||
|
// 写入聊天记录
|
||||||
|
let msgLog:chatMsgLog = {
|
||||||
|
content: call.req.msg,
|
||||||
|
type: call.req.type
|
||||||
|
}
|
||||||
|
//往chatLog表插入记录
|
||||||
|
ChatFun.setChatLog(call, msgLog)
|
||||||
|
|
||||||
if (sendData.type == 'guild' && !gud.ghId) return call.error('', { code: -3, message: globalThis.lng.chat_3 });
|
if (sendData.type == 'guild' && !gud.ghId) return call.error('', { code: -3, message: globalThis.lng.chat_3 });
|
||||||
|
|
||||||
if (sendData.type == 'cross' && G.clientCross?.status == WsClientStatus.Opened) {
|
if (sendData.type == 'cross' && G.clientCross?.status == WsClientStatus.Opened) {
|
||||||
|
//如果是跨服的话,调用跨服API的这条协议
|
||||||
G.clientCross.sendMsg('msg_cross/CrossChat', sendData);
|
G.clientCross.sendMsg('msg_cross/CrossChat', sendData);
|
||||||
call.succ({});
|
call.succ({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatFun.newMsg(sendData);
|
ChatFun.newMsg(sendData);
|
||||||
|
|
||||||
call.succ({});
|
call.succ({});
|
||||||
}
|
}
|
@ -1,11 +1,11 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { PayFun } from '../../public/pay';
|
import {PayFun} from '../../public/pay';
|
||||||
import { ReqOpen, ResOpen } from "../../shared/protocols/chongzhi/PtlOpen";
|
import {ReqOpen, ResOpen} from "../../shared/protocols/chongzhi/PtlOpen";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
|
|
||||||
let data = await G.mongodb.cPlayerInfo('chongzhi').findOne({ uid: call.uid, type: 'chongzhi' });
|
let data = await G.mongodb.cPlayerInfo('chongzhi').findOne({uid: call.uid, type: 'chongzhi'});
|
||||||
let logs = await PayFun.getPayLog(call.uid);
|
let logs = await PayFun.getPayLogs(call.uid);
|
||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
payNum: Object.fromEntries(G.gc.chongzhi.payCom.map(pay => pay.payId).map(payId => [payId, logs?.[payId]?.length || 0])),
|
payNum: Object.fromEntries(G.gc.chongzhi.payCom.map(pay => pay.payId).map(payId => [payId, logs?.[payId]?.length || 0])),
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { FightFun } from '../../public/fight';
|
import {FightFun} from '../../public/fight';
|
||||||
import { PlayerFun } from '../../public/player';
|
import {PlayerFun} from '../../public/player';
|
||||||
import { ReqFind, ResFind } from "../../shared/protocols/conglinshoulie/PtlFind";
|
import {ReqFind, ResFind} from "../../shared/protocols/conglinshoulie/PtlFind";
|
||||||
import { PublicShared } from '../../shared/public/public';
|
import {PublicShared} from '../../shared/public/public';
|
||||||
import { addStar, clslDb } from './ApiOpen';
|
import {addStar, clslDb} from './ApiOpen';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqFind, ResFind>) {
|
export default async function (call: ApiCall<ReqFind, ResFind>) {
|
||||||
let weekZeroTime = PublicShared.getToWeekMondayZeroTime();
|
let weekZeroTime = PublicShared.getToWeekMondayZeroTime();
|
||||||
if (G.time < weekZeroTime + G.gc.clsl_com.fightTime[0] || G.time > weekZeroTime + G.gc.clsl_com.fightTime[1]) return call.errorCode(-1);
|
if (G.time < weekZeroTime + G.gc.clsl_com.fightTime[0] || G.time > weekZeroTime + G.gc.clsl_com.fightTime[1]) return call.errorCode(-1);
|
||||||
|
|
||||||
let db = await clslDb().findOne({ uid: call.uid, type: 'clsl' });
|
let db = await clslDb().findOne({uid: call.uid, type: 'clsl'});
|
||||||
let curStar = db?.allStar || 0;
|
let curStar = db?.allStar || 0;
|
||||||
let useNum = db?.useFightNum || 0;
|
let useNum = db?.useFightNum || 0;
|
||||||
let buyNum = db?.buyFightNum || 0;
|
let buyNum = db?.buyFightNum || 0;
|
||||||
@ -18,20 +18,23 @@ export default async function (call: ApiCall<ReqFind, ResFind>) {
|
|||||||
if (useNum >= buyNum + G.gc.clsl_com.fightNum) return call.errorCode(-2);
|
if (useNum >= buyNum + G.gc.clsl_com.fightNum) return call.errorCode(-2);
|
||||||
|
|
||||||
let my = await call.conn.getDefaultFightData();
|
let my = await call.conn.getDefaultFightData();
|
||||||
let other = (await G.clientCross.callApi('clsl/FindEnemy', { uid: call.uid })).res;
|
let other = (await G.clientCross.callApi('clsl/FindEnemy', {uid: call.uid})).res;
|
||||||
let result = FightFun.fight([my, other.info]);
|
let result = FightFun.fight([my, other.info]);
|
||||||
|
|
||||||
if ((result.winSide != 0 && starConf.failCut) || result.winSide == 0) {
|
if ((result.winSide != 0 && starConf.failCut) || result.winSide == 0) {
|
||||||
addStar(call, result.winSide == 0 ? 1 : -starConf.failCut, my);
|
addStar(call, result.winSide == 0 ? 1 : -starConf.failCut, my);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.winSide == 0 && clslDb().updateOne({ uid: call.uid, type: 'clsl' }, { $inc: { fightWinNum: 1 } });
|
result.initData[0].star = curStar
|
||||||
clslDb().updateOne({ uid: call.uid, type: 'clsl' }, { $inc: { useFightNum: 1 } });
|
result.initData[1].star = other.allStar
|
||||||
|
|
||||||
|
result.winSide == 0 && clslDb().updateOne({uid: call.uid, type: 'clsl'}, {$inc: {fightWinNum: 1}});
|
||||||
|
clslDb().updateOne({uid: call.uid, type: 'clsl'}, {$inc: {useFightNum: 1}});
|
||||||
|
|
||||||
await PlayerFun.sendPrize(call, starConf.fightPrize);
|
await PlayerFun.sendPrize(call, starConf.fightPrize);
|
||||||
|
|
||||||
G.clientCross?.callApi('clsl/Log', { uid: call.uid, result: result });
|
G.clientCross?.callApi('clsl/Log', {uid: call.uid, result: result});
|
||||||
G.clientCross?.callApi('clsl/Log', { uid: other.info.player.uid, result: result });
|
G.clientCross?.callApi('clsl/Log', {uid: other.info.player.uid, result: result});
|
||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
enemy: other,
|
enemy: other,
|
||||||
|
@ -11,6 +11,8 @@ export default async function (call: ApiCall<ReqQf, ResQf>) {
|
|||||||
let need: atn[];
|
let need: atn[];
|
||||||
let prize: atn[];
|
let prize: atn[];
|
||||||
let _num = await DiXiaQianZhuangFun.getMyData(call)
|
let _num = await DiXiaQianZhuangFun.getMyData(call)
|
||||||
|
let canbuyNum = await DiXiaQianZhuangFun.getCanBuyNum(call.conn.gud.vip);
|
||||||
|
|
||||||
let update: UpdateFilter<OptionalId<CollectionPlayerInfo<"dixiaqianzhuang">>>;
|
let update: UpdateFilter<OptionalId<CollectionPlayerInfo<"dixiaqianzhuang">>>;
|
||||||
let changeData: Partial<ResOpen>;
|
let changeData: Partial<ResOpen>;
|
||||||
let _rbj = {} // 返回的暴击次数
|
let _rbj = {} // 返回的暴击次数
|
||||||
@ -19,6 +21,12 @@ export default async function (call: ApiCall<ReqQf, ResQf>) {
|
|||||||
let _jinbi: number = 0
|
let _jinbi: number = 0
|
||||||
let isnum: number = 0 // 实际次数
|
let isnum: number = 0 // 实际次数
|
||||||
if (call.req.type == 1) {
|
if (call.req.type == 1) {
|
||||||
|
|
||||||
|
//兑换次数判断
|
||||||
|
if( canbuyNum-_num <= 0){
|
||||||
|
return call.error('', { code: -2, message: "dxqz_t3" })
|
||||||
|
}
|
||||||
|
|
||||||
let _myNeed = await DiXiaQianZhuangFun.getNumNeed(call, _num + 1)
|
let _myNeed = await DiXiaQianZhuangFun.getNumNeed(call, _num + 1)
|
||||||
// vip 条件不足
|
// vip 条件不足
|
||||||
if (_myNeed.needvip > call.conn.gud.vip) {
|
if (_myNeed.needvip > call.conn.gud.vip) {
|
||||||
@ -34,7 +42,11 @@ export default async function (call: ApiCall<ReqQf, ResQf>) {
|
|||||||
isnum = 1
|
isnum = 1
|
||||||
|
|
||||||
} else if (call.req.type == 10) {
|
} else if (call.req.type == 10) {
|
||||||
for (let index = 1; index <= call.req.type; index++) {
|
let _maxTimes = 10;
|
||||||
|
if( _maxTimes > canbuyNum-_num){
|
||||||
|
_maxTimes = canbuyNum-_num;
|
||||||
|
}
|
||||||
|
for (let index = 1; index <= _maxTimes; index++) {
|
||||||
let _myNeed = await DiXiaQianZhuangFun.getNumNeed(call, _num + index)
|
let _myNeed = await DiXiaQianZhuangFun.getNumNeed(call, _num + index)
|
||||||
if (_myNeed.needvip > call.conn.gud.vip) {
|
if (_myNeed.needvip > call.conn.gud.vip) {
|
||||||
break
|
break
|
||||||
@ -62,7 +74,7 @@ export default async function (call: ApiCall<ReqQf, ResQf>) {
|
|||||||
|
|
||||||
// 一次次数都没有
|
// 一次次数都没有
|
||||||
if (isnum == 0) {
|
if (isnum == 0) {
|
||||||
return call.error('', { code: -2, message: globalThis.lng.dixaiqianzhuang_1 })
|
return call.error('', { code: -2, message: "dxqz_t3" })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { EmailFun } from '../../public/email';
|
import {EmailFun} from '../../public/email';
|
||||||
import { PlayerFun } from '../../public/player';
|
import {PlayerFun} from '../../public/player';
|
||||||
import { ReqAllReceive, ResAllReceive } from "../../shared/protocols/email/PtlAllReceive";
|
import {ReqAllReceive, ResAllReceive} from "../../shared/protocols/email/PtlAllReceive";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqAllReceive, ResAllReceive>) {
|
export default async function (call: ApiCall<ReqAllReceive, ResAllReceive>) {
|
||||||
|
// 筛选出有奖励并且未领取的邮件
|
||||||
let emailList = (await EmailFun.getAllEmail(call.uid, true)).filter(email => (email.type == 'system' && email.prizeData?.isGet == false && email.prizeData?.prize?.length > 0)
|
let emailList = (await EmailFun.getAllEmail(call.uid, false)).filter(email => (
|
||||||
|| (email.type == 'system' && email.uid == "system" && (email?.prizelist?.indexOf(call.uid) == -1 && call.conn.gud && call.conn.gud.cTime <= email.createTime)));
|
email.prizeData.prize.length > 0 && !email.prizeData?.isGet
|
||||||
|
));
|
||||||
|
|
||||||
if (emailList.length < 1) return call.error(globalThis.lng.email_1);
|
if (emailList.length < 1) return call.error(globalThis.lng.email_1);
|
||||||
|
|
||||||
|
@ -3,9 +3,10 @@ import { EmailFun } from '../../public/email';
|
|||||||
import { ReqAllRemove, ResAllRemove } from "../../shared/protocols/email/PtlAllRemove";
|
import { ReqAllRemove, ResAllRemove } from "../../shared/protocols/email/PtlAllRemove";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqAllRemove, ResAllRemove>) {
|
export default async function (call: ApiCall<ReqAllRemove, ResAllRemove>) {
|
||||||
// TODO
|
// 筛选出没有奖励已读邮件和已经领取过奖励的邮件
|
||||||
let emailList = (await EmailFun.getAllEmail(call.uid, true)).filter(email => (email.type == 'system' && (!email.prizeData || email.prizeData?.isGet == true || !email.prizeData.prize || email.prizeData.prize.length < 1
|
let emailList = (await EmailFun.getAllEmail(call.uid, true)).filter(email => (
|
||||||
|| (email?.dellist?.indexOf(call.uid) == -1 && call.conn.gud && call.conn.gud.cTime <= email.createTime))));
|
(email.emailRead && email.prizeData.prize.length <= 0) || email.prizeData.isGet
|
||||||
|
));
|
||||||
|
|
||||||
if (emailList.length < 1) return call.error(globalThis.lng.email_2);
|
if (emailList.length < 1) return call.error(globalThis.lng.email_2);
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { EmailFun } from '../../public/email';
|
import {EmailFun} from '../../public/email';
|
||||||
import { ReqOpen, ResOpen } from "../../shared/protocols/email/PtlOpen";
|
import {ReqOpen, ResOpen} from "../../shared/protocols/email/PtlOpen";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
let list = await EmailFun.getAllEmail(call.uid);
|
let list = await EmailFun.getAllEmail(call.uid, false);
|
||||||
let obj: ResOpen = {};
|
let obj: ResOpen = {};
|
||||||
list.forEach(e => obj[e._id] = e);
|
list.forEach(e => obj[e._id] = e);
|
||||||
call.succ(obj);
|
call.succ(obj);
|
||||||
|
|
||||||
|
// 存入当前玩家多语言信息
|
||||||
|
G.redis.rawSet(`user:lng:${call.uid}`, call.req.lng, {EX: 259200})
|
||||||
}
|
}
|
@ -4,11 +4,16 @@ import { PlayerFun } from '../../public/player';
|
|||||||
import { ReqReceive, ResReceive } from "../../shared/protocols/email/PtlReceive";
|
import { ReqReceive, ResReceive } from "../../shared/protocols/email/PtlReceive";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
||||||
|
|
||||||
let email = await EmailFun.getEmail(call.uid, call.req._id);
|
let email = await EmailFun.getEmail(call.uid, call.req._id);
|
||||||
|
|
||||||
if (!email) return call.error(globalThis.lng.email_3);
|
if (!email) return call.error(globalThis.lng.email_3);
|
||||||
if (!email.prizeData || (email.prizeData.prize && email.prizeData.prize.length < 1)) return call.error(globalThis.lng.email_5);
|
if (!email.prizeData || (email.prizeData.prize && email.prizeData.prize.length < 1)) return call.error(globalThis.lng.email_5);
|
||||||
|
|
||||||
|
// 全服邮件领取判断
|
||||||
|
if (email.uid == "system" && (email?.prizelist || []).includes(call.uid)){
|
||||||
|
return call.error(globalThis.lng.email_4)
|
||||||
|
}
|
||||||
|
|
||||||
if (email.prizeData.isGet) return call.error(globalThis.lng.email_4);
|
if (email.prizeData.isGet) return call.error(globalThis.lng.email_4);
|
||||||
|
|
||||||
let prize = await PlayerFun.sendPrize(call, email.prizeData.prize);
|
let prize = await PlayerFun.sendPrize(call, email.prizeData.prize);
|
||||||
|
@ -6,6 +6,7 @@ export default async function (call: ApiCall<ReqRemove, ResRemove>) {
|
|||||||
let email = await EmailFun.getEmail(call.uid, call.req._id);
|
let email = await EmailFun.getEmail(call.uid, call.req._id);
|
||||||
|
|
||||||
if (!email) return call.error(globalThis.lng.email_3);
|
if (!email) return call.error(globalThis.lng.email_3);
|
||||||
|
|
||||||
if (email.prizeData?.isGet == false && email.prizeData?.prize?.length > 0) return call.error(globalThis.lng.email_6);
|
if (email.prizeData?.isGet == false && email.prizeData?.prize?.length > 0) return call.error(globalThis.lng.email_6);
|
||||||
|
|
||||||
call.succ(EmailFun.removeEmail(call.uid, call.req._id));
|
call.succ(EmailFun.removeEmail(call.uid, call.req._id));
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { Wjjl } from '../../module/collection_wjjl';
|
import {Wjjl} from '../../module/collection_wjjl';
|
||||||
import { EquipFun } from '../../public/equip';
|
import {EquipFun} from '../../public/equip';
|
||||||
import { HeroFun } from '../../public/hero';
|
import {HeroFun} from '../../public/hero';
|
||||||
import { PlayerFun } from '../../public/player';
|
import {PlayerFun} from '../../public/player';
|
||||||
import { ReqLvUp, ResLvUp } from "../../shared/protocols/equip/PtlLvUp";
|
import {ReqLvUp, ResLvUp} from "../../shared/protocols/equip/PtlLvUp";
|
||||||
import { ServiceType } from '../../shared/protocols/serviceProto';
|
import {ServiceType} from '../../shared/protocols/serviceProto';
|
||||||
import { EquipShared } from '../../shared/public/equip';
|
import {EquipShared} from '../../shared/public/equip';
|
||||||
import { PublicShared } from '../../shared/public/public';
|
import {PublicShared} from '../../shared/public/public';
|
||||||
import { HongDianChange } from "../hongdian/fun";
|
import {HongDianChange} from "../hongdian/fun";
|
||||||
|
import kfjsFun from "../../public/kaifujingsai";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqLvUp, ResLvUp, ServiceType>) {
|
export default async function (call: ApiCall<ReqLvUp, ResLvUp, ServiceType>) {
|
||||||
let equip = await EquipFun.getEquip(call, call.req.equipId);
|
let equip = await EquipFun.getEquip(call, call.req.equipId);
|
||||||
@ -20,11 +21,11 @@ export default async function (call: ApiCall<ReqLvUp, ResLvUp, ServiceType>) {
|
|||||||
|
|
||||||
for (let i = 1; i <= call.req.upLv; i++) {
|
for (let i = 1; i <= call.req.upLv; i++) {
|
||||||
if (equip.lv + i > call.conn.gud.lv * 2) break;
|
if (equip.lv + i > call.conn.gud.lv * 2) break;
|
||||||
let need = EquipShared.getEquipLvUpNeed({ lv: equip.lv + i });
|
let need = EquipShared.getEquipLvUpNeed({lv: equip.lv + i});
|
||||||
let isMeet = await PlayerFun.checkNeedIsMeet(call, PublicShared.mergePrize(allNeed.concat(need)), false);
|
let isMeet = await PlayerFun.checkNeedIsMeet(call, PublicShared.mergePrize(allNeed.concat(need)), false);
|
||||||
if (!isMeet.isOk) {
|
if (!isMeet.isOk) {
|
||||||
if (addLv == 0) {
|
if (addLv == 0) {
|
||||||
return call.error('', { code: -104, atn: isMeet.atn });
|
return call.error('', {code: -104, atn: isMeet.atn});
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -34,7 +35,7 @@ export default async function (call: ApiCall<ReqLvUp, ResLvUp, ServiceType>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await PlayerFun.cutNeed(call, allNeed);
|
await PlayerFun.cutNeed(call, allNeed);
|
||||||
await EquipFun.changeEquipAttr(call, equip, { lv: equip.lv + addLv });
|
await EquipFun.changeEquipAttr(call, equip, {lv: equip.lv + addLv});
|
||||||
|
|
||||||
Wjjl.setVal(call.uid, 'equip_qh_lv', equip.lv);
|
Wjjl.setVal(call.uid, 'equip_qh_lv', equip.lv);
|
||||||
|
|
||||||
@ -43,10 +44,12 @@ export default async function (call: ApiCall<ReqLvUp, ResLvUp, ServiceType>) {
|
|||||||
if (hero) {
|
if (hero) {
|
||||||
let wearData = hero.equip || {};
|
let wearData = hero.equip || {};
|
||||||
wearData[G.gc.equip[equip.equipId].type] = EquipShared.fmtEquip(equip);
|
wearData[G.gc.equip[equip.equipId].type] = EquipShared.fmtEquip(equip);
|
||||||
await HeroFun.changeHeroAttr(call, hero, { equip: wearData });
|
await HeroFun.changeHeroAttr(call, hero, {equip: wearData});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']);
|
HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']);
|
||||||
call.succ({ lv: equip.lv, addlv: addLv });
|
call.succ({lv: equip.lv, addlv: addLv});
|
||||||
|
|
||||||
|
kfjsFun.setEquipLvCount(call)
|
||||||
}
|
}
|
@ -8,6 +8,7 @@ import { ServiceType } from '../../shared/protocols/serviceProto';
|
|||||||
import { EquipShared } from '../../shared/public/equip';
|
import { EquipShared } from '../../shared/public/equip';
|
||||||
import { PublicShared } from '../../shared/public/public';
|
import { PublicShared } from '../../shared/public/public';
|
||||||
import { HongDianChange } from "../hongdian/fun";
|
import { HongDianChange } from "../hongdian/fun";
|
||||||
|
import kfjsFun from "../../public/kaifujingsai";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOneKeyLvUp, ResOneKeyLvUp, ServiceType>) {
|
export default async function (call: ApiCall<ReqOneKeyLvUp, ResOneKeyLvUp, ServiceType>) {
|
||||||
let hero = await HeroFun.getHero(call, call.req.heroId);
|
let hero = await HeroFun.getHero(call, call.req.heroId);
|
||||||
@ -65,4 +66,6 @@ export default async function (call: ApiCall<ReqOneKeyLvUp, ResOneKeyLvUp, Servi
|
|||||||
HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']);
|
HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']);
|
||||||
|
|
||||||
call.succ({ posLvUp: posLvUp, log: log, allNeed});
|
call.succ({ posLvUp: posLvUp, log: log, allNeed});
|
||||||
|
|
||||||
|
kfjsFun.setEquipLvCount(call)
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ import { EquipFun } from '../../public/equip';
|
|||||||
import { HeroFun } from '../../public/hero';
|
import { HeroFun } from '../../public/hero';
|
||||||
import { ReqOneKeyTakeOff, ResOneKeyTakeOff } from "../../shared/protocols/equip/PtlOneKeyTakeOff";
|
import { ReqOneKeyTakeOff, ResOneKeyTakeOff } from "../../shared/protocols/equip/PtlOneKeyTakeOff";
|
||||||
import { EquipShared } from '../../shared/public/equip';
|
import { EquipShared } from '../../shared/public/equip';
|
||||||
|
import kfjsFun from "../../public/kaifujingsai";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOneKeyTakeOff, ResOneKeyTakeOff>) {
|
export default async function (call: ApiCall<ReqOneKeyTakeOff, ResOneKeyTakeOff>) {
|
||||||
let hero = await HeroFun.getHero(call, call.req.h_id);
|
let hero = await HeroFun.getHero(call, call.req.h_id);
|
||||||
@ -19,4 +20,7 @@ export default async function (call: ApiCall<ReqOneKeyTakeOff, ResOneKeyTakeOff>
|
|||||||
}
|
}
|
||||||
|
|
||||||
call.succ({});
|
call.succ({});
|
||||||
|
|
||||||
|
kfjsFun.setEquipLvCount(call)
|
||||||
|
|
||||||
}
|
}
|
@ -1,21 +1,22 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { EquipFun } from '../../public/equip';
|
import {EquipFun} from '../../public/equip';
|
||||||
import { HeroFun } from '../../public/hero';
|
import {HeroFun} from '../../public/hero';
|
||||||
import { ReqOneKeyWear, ResOneKeyWear } from "../../shared/protocols/equip/PtlOneKeyWear";
|
import {ReqOneKeyWear, ResOneKeyWear} from "../../shared/protocols/equip/PtlOneKeyWear";
|
||||||
import { ServiceType } from '../../shared/protocols/serviceProto';
|
import {ServiceType} from '../../shared/protocols/serviceProto';
|
||||||
import { EquipShared } from '../../shared/public/equip';
|
import {EquipShared} from '../../shared/public/equip';
|
||||||
|
import kfjsFun from "../../public/kaifujingsai";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOneKeyWear, ResOneKeyWear, ServiceType>) {
|
export default async function (call: ApiCall<ReqOneKeyWear, ResOneKeyWear, ServiceType>) {
|
||||||
let hero = await HeroFun.getHero(call, call.req.heroId);
|
let hero = await HeroFun.getHero(call, call.req.heroId);
|
||||||
|
|
||||||
if (!hero) return call.error(globalThis.lng.equip_3);
|
if (!hero) return call.error(globalThis.lng.equip_3);
|
||||||
if (hero.lv < G.gc.herocom.equipOpenLv) return call.error(`英雄${G.gc.herocom.equipOpenLv}级开启`);
|
if (hero.lv < G.gc.herocom.equipOpenLv) return call.errorCode(-1)
|
||||||
|
|
||||||
let wearNum = 0;
|
let wearNum = 0;
|
||||||
let wearData = hero.equip || {};
|
let wearData = hero.equip || {};
|
||||||
let equipList = await G.redis.get('equip', call.conn.uid) || {};
|
let equipList = await G.redis.get('equip', call.conn.uid) || {};
|
||||||
let allEquip = Object.values(equipList);
|
let allEquip = Object.values(equipList);
|
||||||
let heroIds = Object.values(call.conn.gud.heroPos).filter(i=>!!i)
|
let heroIds = Object.values(call.conn.gud.heroPos).filter(i => !!i)
|
||||||
|
|
||||||
|
|
||||||
for (let pos = 1; pos < 5; pos++) {
|
for (let pos = 1; pos < 5; pos++) {
|
||||||
@ -29,8 +30,8 @@ export default async function (call: ApiCall<ReqOneKeyWear, ResOneKeyWear, Servi
|
|||||||
} else {
|
} else {
|
||||||
return (!e.wearaId || !heroIds.includes(e.wearaId)) && conf.type == pos && (
|
return (!e.wearaId || !heroIds.includes(e.wearaId)) && conf.type == pos && (
|
||||||
conf.colour > curEquipConf.colour
|
conf.colour > curEquipConf.colour
|
||||||
|| (conf.colour > curEquipConf.colour && e.lv > curEquip.lv)
|
|| (conf.colour >= curEquipConf.colour && e.star > curEquip.star)
|
||||||
|| (conf.colour > curEquipConf.colour && e.lv > curEquip.lv && e.star > curEquip.star));
|
|| (conf.colour >= curEquipConf.colour && e.star >= curEquip.star && e.lv > curEquip.lv));
|
||||||
}
|
}
|
||||||
}).sort((a, b) => {
|
}).sort((a, b) => {
|
||||||
if (G.gc.equip[a.equipId].colour != G.gc.equip[b.equipId].colour) {
|
if (G.gc.equip[a.equipId].colour != G.gc.equip[b.equipId].colour) {
|
||||||
@ -43,16 +44,20 @@ export default async function (call: ApiCall<ReqOneKeyWear, ResOneKeyWear, Servi
|
|||||||
})[0];
|
})[0];
|
||||||
if (!wearEquip) continue;
|
if (!wearEquip) continue;
|
||||||
if (posEquip) {
|
if (posEquip) {
|
||||||
await EquipFun.changeEquipAttr(call, equipList[G.formatRedisKey(EquipShared.fmtEquip(posEquip)._id)], { wearaId: '' }, false);
|
await EquipFun.changeEquipAttr(call, equipList[G.formatRedisKey(EquipShared.fmtEquip(posEquip)._id)], {wearaId: ''}, false);
|
||||||
}
|
}
|
||||||
await EquipFun.changeEquipAttr(call, wearEquip, { wearaId: hero._id });
|
await EquipFun.changeEquipAttr(call, wearEquip, {wearaId: hero._id});
|
||||||
wearNum++;
|
wearNum++;
|
||||||
wearData[pos] = EquipShared.fmtEquip(wearEquip);
|
wearData[pos] = EquipShared.fmtEquip(wearEquip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wearNum > 0) {
|
if (wearNum == 0) {
|
||||||
await HeroFun.changeHeroAttr(call, hero, { equip: wearData });
|
return call.errorCode(-2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await HeroFun.changeHeroAttr(call, hero, {equip: wearData});
|
||||||
call.succ({});
|
call.succ({});
|
||||||
|
|
||||||
|
kfjsFun.setEquipLvCount(call)
|
||||||
|
|
||||||
}
|
}
|
@ -27,6 +27,7 @@ export default async function (call: ApiCall<ReqStarUp, ResStarUp, ServiceType>)
|
|||||||
let equipArr: CollectionEquip[] = [];
|
let equipArr: CollectionEquip[] = [];
|
||||||
|
|
||||||
for (let _id of call.req.equipArr) {
|
for (let _id of call.req.equipArr) {
|
||||||
|
//遍历客户端传过来的所有装备,如果不存在或处于穿戴中,则报错
|
||||||
let equip = await G.redis.get('equip', call.conn.uid, _id);
|
let equip = await G.redis.get('equip', call.conn.uid, _id);
|
||||||
if (!equip) return call.error(globalThis.lng.equip_6);
|
if (!equip) return call.error(globalThis.lng.equip_6);
|
||||||
if (equip.wearaId) return call.error(globalThis.lng.equip_7);
|
if (equip.wearaId) return call.error(globalThis.lng.equip_7);
|
||||||
|
@ -2,6 +2,7 @@ import { ApiCall } from "tsrpc";
|
|||||||
import { EquipFun } from '../../public/equip';
|
import { EquipFun } from '../../public/equip';
|
||||||
import { ReqTakeOff, ResTakeOff } from "../../shared/protocols/equip/PtlTakeOff";
|
import { ReqTakeOff, ResTakeOff } from "../../shared/protocols/equip/PtlTakeOff";
|
||||||
import { ServiceType } from '../../shared/protocols/serviceProto';
|
import { ServiceType } from '../../shared/protocols/serviceProto';
|
||||||
|
import kfjsFun from "../../public/kaifujingsai";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqTakeOff, ResTakeOff, ServiceType>) {
|
export default async function (call: ApiCall<ReqTakeOff, ResTakeOff, ServiceType>) {
|
||||||
let equip = await G.redis.get('equip', call.conn.uid, call.req.equipId);
|
let equip = await G.redis.get('equip', call.conn.uid, call.req.equipId);
|
||||||
@ -12,4 +13,7 @@ export default async function (call: ApiCall<ReqTakeOff, ResTakeOff, ServiceType
|
|||||||
await EquipFun.changeEquipAttr(call, equip, { wearaId: '' });
|
await EquipFun.changeEquipAttr(call, equip, { wearaId: '' });
|
||||||
|
|
||||||
call.succ({});
|
call.succ({});
|
||||||
|
|
||||||
|
kfjsFun.setEquipLvCount(call)
|
||||||
|
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import { HeroFun } from '../../public/hero';
|
|||||||
import { ReqWear, ResWear } from "../../shared/protocols/equip/PtlWear";
|
import { ReqWear, ResWear } from "../../shared/protocols/equip/PtlWear";
|
||||||
import { ServiceType } from '../../shared/protocols/serviceProto';
|
import { ServiceType } from '../../shared/protocols/serviceProto';
|
||||||
import { EquipShared } from '../../shared/public/equip';
|
import { EquipShared } from '../../shared/public/equip';
|
||||||
|
import kfjsFun from "../../public/kaifujingsai";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqWear, ResWear, ServiceType>) {
|
export default async function (call: ApiCall<ReqWear, ResWear, ServiceType>) {
|
||||||
let hero = await G.redis.get('hero', call.conn.uid, call.req.heroId);
|
let hero = await G.redis.get('hero', call.conn.uid, call.req.heroId);
|
||||||
@ -29,4 +30,7 @@ export default async function (call: ApiCall<ReqWear, ResWear, ServiceType>) {
|
|||||||
await HeroFun.changeHeroAttr(call, hero, { equip: wearData });
|
await HeroFun.changeHeroAttr(call, hero, { equip: wearData });
|
||||||
|
|
||||||
call.succ({});
|
call.succ({});
|
||||||
|
|
||||||
|
kfjsFun.setEquipLvCount(call)
|
||||||
|
|
||||||
}
|
}
|
26
src/api_s2c/event/christmas/ApiGame.ts
Normal file
26
src/api_s2c/event/christmas/ApiGame.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { ReqGame, ResGame } from "../../../shared/protocols/event/christmas/PtlGame";
|
||||||
|
import { HongDianChange } from "../../hongdian/fun";
|
||||||
|
import { Christmasfun } from "./fun";
|
||||||
|
import {PlayerFun} from "../../../public/player";
|
||||||
|
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqGame, ResGame>) {
|
||||||
|
let initCon = await Christmasfun.getCon(call)
|
||||||
|
let need = initCon[call.req.hdid].data.gameneed;
|
||||||
|
let addval = initCon[call.req.hdid].data.game[call.req.index];
|
||||||
|
// 判断消耗是否满足
|
||||||
|
await PlayerFun.checkNeedIsMeet(call, need);
|
||||||
|
// 扣除消耗
|
||||||
|
await PlayerFun.cutNeed(call, need);
|
||||||
|
|
||||||
|
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
|
||||||
|
let _setData = {}
|
||||||
|
_mydata["val"] += addval
|
||||||
|
_setData["val"] = _mydata["val"]
|
||||||
|
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
|
||||||
|
let changedata = { mydata: _mydata}
|
||||||
|
// 推送红点
|
||||||
|
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
|
||||||
|
call.succ(changedata);
|
||||||
|
}
|
46
src/api_s2c/event/christmas/ApiLiBao.ts
Normal file
46
src/api_s2c/event/christmas/ApiLiBao.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { ReqLiBao, ResLiBao } from "../../../shared/protocols/event/christmas/PtlLiBao";
|
||||||
|
import {Christmasfun} from "./fun";
|
||||||
|
import {PlayerFun} from "../../../public/player";
|
||||||
|
import {HongDianChange} from "../../hongdian/fun";
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqLiBao, ResLiBao>) {
|
||||||
|
let initCon = await Christmasfun.getCon(call)
|
||||||
|
let lbid = call.req.lbid;
|
||||||
|
let _con = initCon[call.req.hdid].data.libao[call.req.lbid];
|
||||||
|
if (!_con) {
|
||||||
|
// 礼包id 不存在
|
||||||
|
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
if (_con.payid) {
|
||||||
|
// 判断是否能购买
|
||||||
|
return call.error('', { code: -2, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
|
||||||
|
let _buyNum = _mydata.libao[lbid] || 0
|
||||||
|
if (_buyNum >= _con.buynum) {
|
||||||
|
// 判断是否能购买
|
||||||
|
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
const _select = _mydata.select[lbid] || {}
|
||||||
|
if (Object.keys(_select).length >= _con.dlz.length) {
|
||||||
|
// 判断是否选择奖励了
|
||||||
|
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
|
||||||
|
let _prize: atn[] = _con.prize
|
||||||
|
for (let key in _select) {
|
||||||
|
_prize.push(_con.dlz[parseInt(key)][_select[key]])
|
||||||
|
}
|
||||||
|
|
||||||
|
let _setData = {}
|
||||||
|
_mydata.libao[lbid] = _buyNum + 1
|
||||||
|
_setData["libao"] = _mydata.libao
|
||||||
|
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
|
||||||
|
|
||||||
|
await PlayerFun.sendPrize(call, _prize);
|
||||||
|
let changedata = { mydata: _mydata, prize: _prize}
|
||||||
|
// 推送红点
|
||||||
|
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
|
||||||
|
call.succ(changedata);
|
||||||
|
}
|
16
src/api_s2c/event/christmas/ApiOpen.ts
Normal file
16
src/api_s2c/event/christmas/ApiOpen.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { HuoDongFun } from "../../../public/huodongfun";
|
||||||
|
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/yangchengmubiao/PtlOpen";
|
||||||
|
import { Christmasfun } from "./fun";
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
|
let _hdinfo = await HuoDongFun.getHdidInfo(call, call.req.hdid)
|
||||||
|
if (!_hdinfo || Object.keys(_hdinfo).length <= 0) {
|
||||||
|
// 无此活动
|
||||||
|
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
|
||||||
|
}
|
||||||
|
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
|
||||||
|
let changedata = { mydata: _mydata, hdinfo: _hdinfo }
|
||||||
|
call.succ(changedata);
|
||||||
|
}
|
||||||
|
|
38
src/api_s2c/event/christmas/ApiQianDao.ts
Normal file
38
src/api_s2c/event/christmas/ApiQianDao.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { ReqQianDao, ResQianDao } from "../../../shared/protocols/event/christmas/PtlQianDao";
|
||||||
|
import {Christmasfun} from "./fun";
|
||||||
|
import {PublicShared} from "../../../shared/public/public";
|
||||||
|
import {PlayerFun} from "../../../public/player";
|
||||||
|
import {HongDianChange} from "../../hongdian/fun";
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqQianDao, ResQianDao>) {
|
||||||
|
let initCon = await Christmasfun.getCon(call)
|
||||||
|
let _con = initCon[call.req.hdid].data.qiandao;
|
||||||
|
let _stime = initCon[call.req.hdid].stime
|
||||||
|
let _diff = PublicShared.getDiff(_stime)
|
||||||
|
|
||||||
|
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
|
||||||
|
// 循环判断是否有可以领取的
|
||||||
|
let _prize = []
|
||||||
|
for(let i = 0; i < _diff; i++) {
|
||||||
|
if (_mydata.qiandao.includes(i)) continue
|
||||||
|
_mydata.qiandao.push(i)
|
||||||
|
_prize.push(_con[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_prize){
|
||||||
|
// 没有奖励可以领取
|
||||||
|
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let _setData = {}
|
||||||
|
_setData["qiandao"] = _mydata.qiandao
|
||||||
|
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
|
||||||
|
|
||||||
|
await PlayerFun.sendPrize(call, _prize);
|
||||||
|
let changedata = { mydata: _mydata, prize: _prize}
|
||||||
|
// 推送红点
|
||||||
|
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
|
||||||
|
call.succ(changedata);
|
||||||
|
}
|
39
src/api_s2c/event/christmas/ApiSelect.ts
Normal file
39
src/api_s2c/event/christmas/ApiSelect.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { ReqSelect, ResSelect } from "../../../shared/protocols/event/christmas/PtlSelect";
|
||||||
|
import {Christmasfun} from "./fun";
|
||||||
|
import {HongDianChange} from "../../hongdian/fun";
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqSelect, ResSelect>) {
|
||||||
|
let initCon = await Christmasfun.getCon(call)
|
||||||
|
let index = call.req.index;
|
||||||
|
let pid = call.req.pid;
|
||||||
|
let lbid = call.req.lbid;
|
||||||
|
let _con = initCon[call.req.hdid].data.libao[lbid];
|
||||||
|
if (!_con) {
|
||||||
|
// 礼包id 不存在
|
||||||
|
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
if (index >= _con.dlz.length){
|
||||||
|
// 礼包id 不存在
|
||||||
|
return call.error('', { code: -2, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
if (index >= _con.dlz.length){
|
||||||
|
// 礼包id 不存在
|
||||||
|
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
if (!_con.dlz[index][pid]){
|
||||||
|
// 礼包id 不存在
|
||||||
|
return call.error('', { code: -4, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
|
||||||
|
let lb_select = _mydata.select[lbid] || {}
|
||||||
|
lb_select[index.toString()] = pid
|
||||||
|
_mydata.select[lbid] = lb_select
|
||||||
|
let _setData = {}
|
||||||
|
_setData["select"] = _mydata.select
|
||||||
|
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
|
||||||
|
let changedata = { mydata: _mydata}
|
||||||
|
// 推送红点
|
||||||
|
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
|
||||||
|
call.succ(changedata);
|
||||||
|
}
|
37
src/api_s2c/event/christmas/ApiTaskRec.ts
Normal file
37
src/api_s2c/event/christmas/ApiTaskRec.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { ReqTaskRec, ResTaskRec } from "../../../shared/protocols/event/christmas/PtlTaskRec";
|
||||||
|
import {Christmasfun} from "./fun";
|
||||||
|
import {HongDianChange} from "../../hongdian/fun";
|
||||||
|
import {PlayerFun} from "../../../public/player";
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqTaskRec, ResTaskRec>) {
|
||||||
|
let initCon = await Christmasfun.getCon(call)
|
||||||
|
let taskid = call.req.taskid;
|
||||||
|
let _con = initCon[call.req.hdid].data.task[taskid];
|
||||||
|
if (!_con) {
|
||||||
|
// 任务id 不存在
|
||||||
|
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
|
||||||
|
if (_mydata.taskval[taskid] < _con.pval) {
|
||||||
|
// 任务未完成
|
||||||
|
return call.error('', { code: -2, message: globalThis.lng.yangchengmubiao_3 })
|
||||||
|
}
|
||||||
|
if (_mydata.taskfinish.includes(taskid)) {
|
||||||
|
// 任务已领取
|
||||||
|
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_4 })
|
||||||
|
}
|
||||||
|
_mydata.taskfinish.push(taskid)
|
||||||
|
|
||||||
|
let _setData = {}
|
||||||
|
_setData["taskfinish"] = _mydata.taskfinish
|
||||||
|
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
|
||||||
|
let _prize = _con.prize
|
||||||
|
await PlayerFun.sendPrize(call, _prize);
|
||||||
|
let changedata = { mydata: _mydata, prize: _prize}
|
||||||
|
// 推送红点
|
||||||
|
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
|
||||||
|
call.succ(changedata);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
46
src/api_s2c/event/christmas/ApiZhanLingRec.ts
Normal file
46
src/api_s2c/event/christmas/ApiZhanLingRec.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { ReqZhanLingRec, ResZhanLingRec } from "../../../shared/protocols/event/christmas/PtlZhanLingRec";
|
||||||
|
import {Christmasfun} from "./fun";
|
||||||
|
import {PlayerFun} from "../../../public/player";
|
||||||
|
import {HongDianChange} from "../../hongdian/fun";
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqZhanLingRec, ResZhanLingRec>) {
|
||||||
|
let initCon = await Christmasfun.getCon(call)
|
||||||
|
let index = call.req.index;
|
||||||
|
let _con = initCon[call.req.hdid].data.zhanling[index];
|
||||||
|
if (!_con) {
|
||||||
|
// 礼包id 不存在
|
||||||
|
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
|
||||||
|
if (_mydata.val < _con.val) {
|
||||||
|
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
let _prize = []
|
||||||
|
|
||||||
|
if (!_mydata.pt.includes(index)){
|
||||||
|
// 如果普通奖励没有领取
|
||||||
|
_prize.push(_con.pt)
|
||||||
|
_mydata.pt.push(index)
|
||||||
|
}
|
||||||
|
if (_mydata.pay && !_mydata.gj.includes(index)){
|
||||||
|
// 如果普通奖励没有领取
|
||||||
|
_prize.push(_con.gj)
|
||||||
|
_mydata.gj.push(index)
|
||||||
|
}
|
||||||
|
if (!_prize) {
|
||||||
|
// 没有奖励可以领取
|
||||||
|
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
|
}
|
||||||
|
let _setData = {}
|
||||||
|
_setData["gj"] = _mydata.gj
|
||||||
|
_setData["pt"] = _mydata.pt
|
||||||
|
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
|
||||||
|
|
||||||
|
await PlayerFun.sendPrize(call, _prize);
|
||||||
|
let changedata = { mydata: _mydata, prize: _prize}
|
||||||
|
// 推送红点
|
||||||
|
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
|
||||||
|
call.succ(changedata);
|
||||||
|
|
||||||
|
}
|
168
src/api_s2c/event/christmas/fun.ts
Normal file
168
src/api_s2c/event/christmas/fun.ts
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
import { strict } from 'assert';
|
||||||
|
import { ApiCall } from 'tsrpc';
|
||||||
|
import { ReqAddHuoDong } from '../../../monopoly/protocols/PtlAddHuoDong';
|
||||||
|
import { HuoDongFun } from '../../../public/huodongfun';
|
||||||
|
import { TaskFun } from '../../../public/task';
|
||||||
|
import { christmas } from '../../../shared/protocols/event/christmas/PtlOpen';
|
||||||
|
import { PublicShared } from '../../../shared/public/public';
|
||||||
|
|
||||||
|
|
||||||
|
export class Christmasfun {
|
||||||
|
/**配置 */
|
||||||
|
static async getCon(call: ApiCall) {
|
||||||
|
let _con: { [id: string]: ReqAddHuoDong } = {}
|
||||||
|
let _hd = await HuoDongFun.gethdList(call, 8)
|
||||||
|
for (let index = 0; index < _hd.length; index++) {
|
||||||
|
const element = _hd[index];
|
||||||
|
if (element && element._id) delete element._id
|
||||||
|
_con[element.hdid] = element
|
||||||
|
}
|
||||||
|
return _con
|
||||||
|
}
|
||||||
|
/**获取所有符合时间的活动 */
|
||||||
|
static async gethdids(call: ApiCall) {
|
||||||
|
let _hdids = []
|
||||||
|
let _hd = await HuoDongFun.gethdList(call, 8)
|
||||||
|
for (let index = 0; index < _hd.length; index++) {
|
||||||
|
const element = _hd[index];
|
||||||
|
_hdids.push(element.hdid)
|
||||||
|
}
|
||||||
|
return _hdids
|
||||||
|
}
|
||||||
|
|
||||||
|
/**获取我的数据 */
|
||||||
|
static async getMyData(call: ApiCall, hdid: number) {
|
||||||
|
let db: any = await G.mongodb.cEvent(`christmas${hdid}`).findOne({ uid: call.uid, type: `christmas${hdid}`, hdid: hdid });
|
||||||
|
if (!db) {
|
||||||
|
db = await this.initData(call, hdid)
|
||||||
|
await G.mongodb.cEvent(`christmas${hdid}`).updateOne(
|
||||||
|
{ uid: call.uid, type: `christmas${hdid}`, hdid: hdid },
|
||||||
|
{ $set: db },
|
||||||
|
{ upsert: true }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
let { _id, ..._myData } = db
|
||||||
|
if (!PublicShared.chkSameDate(_myData.refresh, G.time)) {
|
||||||
|
// 刷新每日任务
|
||||||
|
_myData = await this.refreTask(call, _myData, hdid)
|
||||||
|
|
||||||
|
}
|
||||||
|
return _myData
|
||||||
|
}
|
||||||
|
|
||||||
|
/**初始数据 */
|
||||||
|
static async initData(call: ApiCall, hdid: number) {
|
||||||
|
let _initCon = await this.getCon(call)
|
||||||
|
let _con = _initCon[hdid]
|
||||||
|
let _r: christmas = {
|
||||||
|
type: `christmas${hdid}`,
|
||||||
|
uid: call.uid,
|
||||||
|
hdid: hdid,
|
||||||
|
taskval: await this.getTaskVal(call, hdid),
|
||||||
|
taskfinish: [],
|
||||||
|
refresh: G.time,
|
||||||
|
pt: [],
|
||||||
|
gj: [],
|
||||||
|
pay: false,
|
||||||
|
select:{},
|
||||||
|
val: 0,
|
||||||
|
qiandao: [],
|
||||||
|
libao:{}
|
||||||
|
}
|
||||||
|
return _r
|
||||||
|
}
|
||||||
|
|
||||||
|
/**设置数据 */
|
||||||
|
static async setMyData(uid: string, hdid: number, set: {}) {
|
||||||
|
await G.mongodb.cEvent(`christmas${hdid}`).updateOne(
|
||||||
|
{ uid: uid, type: `christmas${hdid}`, hdid: hdid },
|
||||||
|
set
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**获取所有taskid 及对应的值 */
|
||||||
|
static async getTaskVal(call: ApiCall, hdid: number) {
|
||||||
|
let _initCon = await this.getCon(call)
|
||||||
|
let _tasks = _initCon[hdid].data.task
|
||||||
|
let _res = {}
|
||||||
|
for (let index = 0; index < Object.keys(_tasks).length; index++) {
|
||||||
|
const element = Object.keys(_tasks)[index];
|
||||||
|
let _tmp = _tasks[element]
|
||||||
|
_tmp["id"] = element
|
||||||
|
// 每日登录直接完成
|
||||||
|
if (element == "1"){
|
||||||
|
_res[element] = 1
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
_res[element] = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return _res
|
||||||
|
}
|
||||||
|
|
||||||
|
/**刷新每日任务 */
|
||||||
|
static async refreTask(call: ApiCall, mydata: christmas, hdid: number) {
|
||||||
|
let _initCon = await this.getCon(call)
|
||||||
|
let _con = _initCon[hdid].data.task
|
||||||
|
if (!_con) return mydata
|
||||||
|
mydata.taskfinish = []
|
||||||
|
mydata.taskval = await this.getTaskVal(call, hdid)
|
||||||
|
mydata.refresh = G.time
|
||||||
|
await this.setMyData(call.uid, hdid, { $set: { refresh: mydata.refresh, taskfinish: mydata.taskfinish, taskval: mydata.taskval } })
|
||||||
|
return mydata
|
||||||
|
}
|
||||||
|
|
||||||
|
/**设置任务 */
|
||||||
|
static async setTaskVal(call: ApiCall, stype: number, val: number, chkCall: Function, chkval: number = 0, isinc: number = 0, alchangeVal: Function, arg) {
|
||||||
|
let hdids = await this.gethdids(call)
|
||||||
|
if (hdids.length <= 0) return // 活动过期,不计数
|
||||||
|
let _initCon = await this.getCon(call)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (let index = 0; index < hdids.length; index++) {
|
||||||
|
const hdid = hdids[index];
|
||||||
|
let _mydata = await Christmasfun.getMyData(call, hdid)
|
||||||
|
let _tasks = _initCon[hdid].data.task
|
||||||
|
|
||||||
|
let _setData = {
|
||||||
|
$inc: {},
|
||||||
|
$set: {}
|
||||||
|
}
|
||||||
|
let isset = 0
|
||||||
|
for (let indextask = 0; indextask < Object.keys(_tasks).length; indextask++) {
|
||||||
|
const ele = Object.keys(_tasks)[indextask];
|
||||||
|
// 具体任务配置
|
||||||
|
let _taskCon = _tasks[ele]
|
||||||
|
if (_taskCon.stype != stype) continue
|
||||||
|
|
||||||
|
let _pval = _taskCon.pval
|
||||||
|
// 不符合任务要求
|
||||||
|
if (!(await chkCall(_taskCon["cond"], chkval, arg))) continue
|
||||||
|
|
||||||
|
// 根据需求改写
|
||||||
|
val = await alchangeVal(call, _taskCon, val, arg)
|
||||||
|
|
||||||
|
isset = 1
|
||||||
|
if (isinc == 1) { // 累加
|
||||||
|
_setData["$inc"][`taskval.${ele}`] = val
|
||||||
|
} else {
|
||||||
|
_setData["$set"][`taskval.${ele}`] = val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置任务
|
||||||
|
if (isset == 1) {
|
||||||
|
await G.mongodb.collection('event').updateMany(
|
||||||
|
{ uid: call.uid, type: { $regex: "christmas" }, hdid: parseInt(hdid) },
|
||||||
|
_setData
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -12,7 +12,7 @@ const type:jijinType[] = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqCheckOpen, ResCheckOpen>) {
|
export default async function (call: ApiCall<ReqCheckOpen, ResCheckOpen>) {
|
||||||
let logs = await PayFun.getPayLog(call.uid);
|
let logs = await PayFun.getPayLogs(call.uid);
|
||||||
|
|
||||||
let data = await G.mongodb.collection('event').find({ uid: call.uid, type: { $in: type}}).toArray();
|
let data = await G.mongodb.collection('event').find({ uid: call.uid, type: { $in: type}}).toArray();
|
||||||
|
|
||||||
|
@ -10,18 +10,18 @@ import { PublicShared } from '../../../shared/public/public';
|
|||||||
* 天数基金、tianshujijin
|
* 天数基金、tianshujijin
|
||||||
* */
|
* */
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
let logs = await PayFun.getPayLog(call.uid);
|
|
||||||
let data = await G.mongodb.cEvent(call.req.type).findOne({ uid: call.uid, type: call.req.type });
|
let data = await G.mongodb.cEvent(call.req.type).findOne({ uid: call.uid, type: call.req.type });
|
||||||
let payId = call.req.type == 'tianshujijin' ? 'zhongshenka' : call.req.type;
|
let payId = call.req.type == 'tianshujijin' ? 'zhongshenka' : call.req.type;
|
||||||
|
let logs = await PayFun.getPayLog(call.uid,payId);
|
||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
isPay: logs?.[payId]?.length > 0,
|
isPay: logs?.length > 0,
|
||||||
rec: data?.rec || {},
|
rec: data?.rec || {},
|
||||||
finished: await getVal(call, logs)
|
finished: await getVal(call, logs)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getVal(call: { conn: BaseConnection, req: ReqOpen; }, logs: k_v<payLog[]>, type: jijinType | false = false) {
|
export async function getVal(call: { conn: BaseConnection; req: ReqOpen }, logs: { [p: string]: any }, type: jijinType | false = false) {
|
||||||
let val = 0;
|
let val = 0;
|
||||||
let _type = type || call.req.type;
|
let _type = type || call.req.type;
|
||||||
|
|
||||||
|
@ -15,11 +15,11 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
|||||||
let isErr = conf.map((c, i) => i).intersection(call.req.recIndexs).length != call.req.recIndexs.length;
|
let isErr = conf.map((c, i) => i).intersection(call.req.recIndexs).length != call.req.recIndexs.length;
|
||||||
if (isErr) return call.error(globalThis.lng.pata_getprize_1);
|
if (isErr) return call.error(globalThis.lng.pata_getprize_1);
|
||||||
|
|
||||||
let logs = await PayFun.getPayLog(call.uid);
|
let payId = call.req.type == 'tianshujijin' ? 'zhongshenka' : call.req.type;
|
||||||
|
let logs = await PayFun.getPayLog(call.uid,payId);
|
||||||
let rec = data?.rec || {};
|
let rec = data?.rec || {};
|
||||||
let val = await getVal(call, logs);
|
let val = await getVal(call, logs);
|
||||||
let payId = call.req.type == 'tianshujijin' ? 'zhongshenka' : call.req.type;
|
let isPay = logs?.length > 0;
|
||||||
let isPay = logs?.[payId]?.length > 0;
|
|
||||||
let prize: atn[] = [];
|
let prize: atn[] = [];
|
||||||
|
|
||||||
for (let index of call.req.recIndexs) {
|
for (let index of call.req.recIndexs) {
|
||||||
|
@ -80,7 +80,10 @@ export async function getTaskVal(gud: player, taskTyps: string[]) {
|
|||||||
let daystr = t.split('_')[1] || '1';
|
let daystr = t.split('_')[1] || '1';
|
||||||
let day = Number(daystr);
|
let day = Number(daystr);
|
||||||
let zeroTime = PublicShared.getToDayZeroTime(gud.cTime);
|
let zeroTime = PublicShared.getToDayZeroTime(gud.cTime);
|
||||||
val[t] = await PayFun.getPayDaysAllPayNum(gud.uid, zeroTime + (day - 1) * 24 * 3600, zeroTime + day * 24 * 3600);
|
val[t] = await PayFun.getPayDaysAllPayNum(
|
||||||
|
gud.uid,
|
||||||
|
zeroTime + (day - 1) * 24 * 3600, zeroTime + day * 24 * 3600
|
||||||
|
) * 10;
|
||||||
} else if (t == 'zccg_level') {
|
} else if (t == 'zccg_level') {
|
||||||
val[t] = (await G.mongodb.collection('pata').findOne({ uid: gud.uid }))?.lv || 0;
|
val[t] = (await G.mongodb.collection('pata').findOne({ uid: gud.uid }))?.lv || 0;
|
||||||
} else if (t.indexOf('has_equip_color') != -1) {
|
} else if (t.indexOf('has_equip_color') != -1) {
|
||||||
|
@ -28,7 +28,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (db.index == G.gc.xinshoulibao.length - 1) {
|
if (db.index == G.gc.xinshoulibao.length - 1) {
|
||||||
PayFun.setPayLog(call.uid, ...G.gc.xinshoulibao[db.index].pays.map(p => { return { payId: p.payId, val: [] }; }));
|
PayFun.delPayLog(call.uid, ...G.gc.xinshoulibao[db.index].pays.map(p => { return { payId: p.payId, val: [] }; }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,11 @@ export default async function (call: ApiCall<ReqRec, ResRec>) {
|
|||||||
// 任务id 不存在
|
// 任务id 不存在
|
||||||
return call.error('', { code: -2, message: globalThis.lng.yangchengmubiao_2 })
|
return call.error('', { code: -2, message: globalThis.lng.yangchengmubiao_2 })
|
||||||
}
|
}
|
||||||
|
|
||||||
let _mydata = await YangChengMuBiaofun.getMyData(call, call.req.hdid)
|
let _mydata = await YangChengMuBiaofun.getMyData(call, call.req.hdid)
|
||||||
if (_mydata.taskval[call.req.taskid] < _con.pval) {
|
if (_mydata.taskval[call.req.taskid] < _con.pval) {
|
||||||
// 任务未完成
|
// 任务未完成
|
||||||
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_3 })
|
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_3 })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_mydata.finishid[_con.type].includes(call.req.taskid)) {
|
if (_mydata.finishid[_con.type].includes(call.req.taskid)) {
|
||||||
// 任务已领取
|
// 任务已领取
|
||||||
return call.error('', { code: -4, message: globalThis.lng.yangchengmubiao_4 })
|
return call.error('', { code: -4, message: globalThis.lng.yangchengmubiao_4 })
|
||||||
|
@ -45,6 +45,6 @@ export async function checkNewRound(call, type) {
|
|||||||
}
|
}
|
||||||
}, {upsert: true});
|
}, {upsert: true});
|
||||||
|
|
||||||
PayFun.setPayLog(call.uid, {payId: type, val: []});
|
PayFun.delPayLog(call.uid, {payId: type, val: []});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,65 +1,81 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { ZhanLingTasks } from '../../../public/zhanling';
|
import {ZhanLingTasks} from '../../../public/zhanling';
|
||||||
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/zhanling/PtlOpen";
|
import {ReqOpen, ResOpen} from "../../../shared/protocols/event/zhanling/PtlOpen";
|
||||||
import { player } from '../../../shared/protocols/user/type';
|
import {player} from '../../../shared/protocols/user/type';
|
||||||
import { PublicShared } from '../../../shared/public/public';
|
import {PublicShared} from '../../../shared/public/public';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
|
let zls = await G.mongodb.collection('scheduler').findOne({type: 'zhanling'});
|
||||||
|
let data = await G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'});
|
||||||
|
|
||||||
let data = await G.mongodb.cEvent('zhanling').findOne({ uid: call.uid, type: 'zhanling' });
|
if (!data || data.round != (zls?.round | 0)) {
|
||||||
|
let set = {
|
||||||
|
lv: 1,
|
||||||
|
exp: 0,
|
||||||
if (data && PublicShared.getToDayZeroTime() > data.refreshTime) {
|
rec: {},
|
||||||
G.mongodb.cEvent('zhanling').updateOne({ uid: call.uid, type: 'zhanling' }, { $set: { refreshTime: G.time, taskRec: [] } });
|
isPay: false,
|
||||||
|
taskRec: [],
|
||||||
|
round: zls?.round || 0,
|
||||||
|
reWeekTime:G.time,
|
||||||
|
refreshTime: G.time,
|
||||||
}
|
}
|
||||||
|
|
||||||
let tasks = G.gc.zhanling.task.map(t => { return { type: t.type as 'day' | 'week' | 'round', key: t.taskId }; });
|
data = (await G.mongodb.cEvent('zhanling').findOneAndUpdate({
|
||||||
|
uid: call.uid,
|
||||||
|
type: 'zhanling'
|
||||||
|
}, {$set: set}, {upsert: true, returnDocument: 'after'})).value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PublicShared.getToWeekMondayZeroTime() > data.reWeekTime || PublicShared.getToDayZeroTime() > data.refreshTime) {
|
||||||
|
let set: any = {taskRec: []};
|
||||||
|
|
||||||
|
let reType = [];
|
||||||
|
if (PublicShared.getToWeekMondayZeroTime() > data.reWeekTime) {
|
||||||
|
set.reWeekTime = G.time;
|
||||||
|
reType.push("week");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PublicShared.getToDayZeroTime() > data.refreshTime) {
|
||||||
|
set.refreshTime = G.time;
|
||||||
|
reType.push("day")
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let idx of data.taskRec) {
|
||||||
|
if (reType && reType.indexOf(G.gc.zhanling.task[idx].type) == -1) {
|
||||||
|
set.taskRec.push(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data = (await G.mongodb.cEvent('zhanling').findOneAndUpdate({
|
||||||
|
uid: call.uid,
|
||||||
|
type: 'zhanling'
|
||||||
|
}, {$set: set}, {upsert: true, returnDocument: 'after'})).value;
|
||||||
|
}
|
||||||
|
|
||||||
|
let tasks = G.gc.zhanling.task.map(t => {
|
||||||
|
return {type: t.type as 'day' | 'week' | 'round', key: t.taskId};
|
||||||
|
});
|
||||||
let taskFinished = await ZhanLingTasks.getLog(call.uid, tasks);
|
let taskFinished = await ZhanLingTasks.getLog(call.uid, tasks);
|
||||||
|
|
||||||
let result: { rec: {}; isPay: boolean; taskRec: any[]; taskFinished: k_v<number>; refreshTime: number; lv: number; exp: number } = {
|
|
||||||
...data,
|
|
||||||
taskFinished: taskFinished
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!data){
|
let result: { rec: {}; isPay: boolean; taskRec: any[]; taskFinished: k_v<number>; refreshTime: number; lv: number; exp: number, nextRoundTime: number } = {
|
||||||
result = {
|
...data,
|
||||||
lv: 1,
|
taskFinished: taskFinished,
|
||||||
exp: 0,
|
nextRoundTime: PublicShared.getToDayZeroTime(zls?.lastRunTime || PublicShared.getToDayZeroTime(G.openTime)) + 86400 * G.gc.zhanling.eventOpen.day
|
||||||
rec: {},
|
|
||||||
isPay: false,
|
|
||||||
taskRec: [],
|
|
||||||
refreshTime: G.time,
|
|
||||||
taskFinished: taskFinished
|
|
||||||
}
|
|
||||||
G.mongodb.cEvent('zhanling').updateOne(
|
|
||||||
{uid: call.uid, type: 'zhanling'},
|
|
||||||
{
|
|
||||||
$set: {
|
|
||||||
lv: 1,
|
|
||||||
exp: 0,
|
|
||||||
rec: {},
|
|
||||||
isPay: false,
|
|
||||||
taskRec: [],
|
|
||||||
refreshTime: G.time
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{upsert: true}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
call.succ(result);
|
call.succ(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function payZhanLing(player: player) {
|
export async function payZhanLing(player: player) {
|
||||||
let zlData = await G.mongodb.cEvent('zhanling').findOne({ uid: player.uid, type: 'zhanling' });
|
let zlData = await G.mongodb.cEvent('zhanling').findOne({uid: player.uid, type: 'zhanling'});
|
||||||
let curLv = zlData?.lv || 1;
|
let curLv = zlData?.lv || 1;
|
||||||
let maxLv = Number(Object.keys(G.gc.zhanling.lv).slice(-1)[0]);
|
let maxLv = Number(Object.keys(G.gc.zhanling.lv).slice(-1)[0]);
|
||||||
let addLv = maxLv - curLv >= G.gc.zhanling.payAddLv ? G.gc.zhanling.payAddLv : maxLv - curLv;
|
let addLv = maxLv - curLv >= G.gc.zhanling.payAddLv ? G.gc.zhanling.payAddLv : maxLv - curLv;
|
||||||
|
|
||||||
await G.mongodb.cEvent('zhanling').updateOne(
|
await G.mongodb.cEvent('zhanling').updateOne(
|
||||||
{ uid: player.uid, type: 'zhanling' },
|
{uid: player.uid, type: 'zhanling'},
|
||||||
{ $set: { isPay: true, exp: G.gc.zhanling.lv[curLv + addLv], lv: curLv + addLv } },
|
{$set: {isPay: true, exp: G.gc.zhanling.lv[curLv + addLv], lv: curLv + addLv}},
|
||||||
{ upsert: true }
|
{upsert: true}
|
||||||
);
|
);
|
||||||
}
|
}
|
@ -1,28 +1,28 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { eventType } from '../../../module/collection_event';
|
import {eventType} from '../../../module/collection_event';
|
||||||
import { PlayerFun } from '../../../public/player';
|
import {PlayerFun} from '../../../public/player';
|
||||||
import { ZhanLingTasks } from '../../../public/zhanling';
|
import {ZhanLingTasks} from '../../../public/zhanling';
|
||||||
import { ReqRecTask, ResRecTask } from "../../../shared/protocols/event/zhanling/PtlRecTask";
|
import {ReqRecTask, ResRecTask} from "../../../shared/protocols/event/zhanling/PtlRecTask";
|
||||||
import { HongDianChange } from "../../hongdian/fun";
|
import {HongDianChange} from "../../hongdian/fun";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRecTask, ResRecTask>) {
|
export default async function (call: ApiCall<ReqRecTask, ResRecTask>) {
|
||||||
let conf = G.gc.zhanling.task[call.req.index];
|
let conf = G.gc.zhanling.task[call.req.index];
|
||||||
|
|
||||||
if (!conf) return call.error(globalThis.lng.event_kfkh_11);
|
if (!conf) return call.error(globalThis.lng.event_kfkh_11);
|
||||||
|
|
||||||
let data = await G.mongodb.cEvent('zhanling').findOne({ uid: call.uid, type: 'zhanling' });
|
let data = await G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'});
|
||||||
|
|
||||||
if (data.taskRec.includes(call.req.index)) return call.error(globalThis.lng.event_kfkh_12);
|
if (data.taskRec.includes(call.req.index)) return call.error(globalThis.lng.event_kfkh_12);
|
||||||
|
|
||||||
let taskVal = await ZhanLingTasks.getLog(call.uid, { type: conf.type as any, key: conf.taskId });
|
let taskVal = await ZhanLingTasks.getLog(call.uid, {type: conf.type as any, key: conf.taskId});
|
||||||
|
|
||||||
if (taskVal < conf.total) return call.error(globalThis.lng.event_kfkh_13);
|
if (taskVal < conf.total) return call.error(globalThis.lng.event_kfkh_13);
|
||||||
|
|
||||||
conf.prize && await PlayerFun.sendPrize(call, conf.prize);
|
conf.prize && await PlayerFun.sendPrize(call, conf.prize);
|
||||||
|
|
||||||
G.mongodb.cEvent('zhanling').updateOne(
|
G.mongodb.cEvent('zhanling').updateOne(
|
||||||
{ uid: call.uid, type: 'zhanling' },
|
{uid: call.uid, type: 'zhanling'},
|
||||||
{ $push: { taskRec: call.req.index } }
|
{$push: {taskRec: call.req.index}}
|
||||||
);
|
);
|
||||||
|
|
||||||
HongDianChange.sendChangeKey(call.uid, ['zhuishalinghd']);
|
HongDianChange.sendChangeKey(call.uid, ['zhuishalinghd']);
|
||||||
@ -34,23 +34,21 @@ export default async function (call: ApiCall<ReqRecTask, ResRecTask>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function addExp(uid: string, exp: number, data?: eventType['zhanling']) {
|
export async function addExp(uid: string, exp: number, data?: eventType['zhanling']) {
|
||||||
if (!data) data = await G.mongodb.cEvent('zhanling').findOne({ uid: uid, type: 'zhanling' });
|
if (!data) data = await G.mongodb.cEvent('zhanling').findOne({uid: uid, type: 'zhanling'});
|
||||||
let change: ResRecTask['change'] = {};
|
let change: ResRecTask['change'] = {};
|
||||||
|
|
||||||
change.exp = data.exp + exp;
|
change.exp = (data?.exp || 0) + exp;
|
||||||
if (G.gc.zhanling.lv[data.lv + 1] && change.exp >= G.gc.zhanling.lv[data.lv + 1]) {
|
|
||||||
let addLv = 1;
|
|
||||||
|
|
||||||
while (G.gc.zhanling.lv[data.lv + addLv] <= change.exp) {
|
let lv = data?.lv || 1
|
||||||
addLv++;
|
while (G.gc.zhanling.lv[lv + 1] < change.exp) {
|
||||||
|
lv += 1
|
||||||
}
|
}
|
||||||
|
if (lv > (data?.lv || 1)) {
|
||||||
change.lv = data.lv + addLv;
|
change.lv = lv
|
||||||
}
|
}
|
||||||
|
await G.mongodb.cEvent('zhanling').updateOne(
|
||||||
G.mongodb.cEvent('zhanling').updateOne(
|
{uid: uid, type: 'zhanling'},
|
||||||
{ uid: uid, type: 'zhanling' },
|
{$set: change}
|
||||||
{ $set: change }
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return change;
|
return change;
|
||||||
|
@ -18,7 +18,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
{ uid: call.uid, type: 'zhoulibao' },
|
{ uid: call.uid, type: 'zhoulibao' },
|
||||||
{ $set: { sTime: G.time } },
|
{ $set: { sTime: G.time } },
|
||||||
);
|
);
|
||||||
PayFun.setPayLog(call.uid, ...G.gc.dixiaheishi.zhoulibao.pays.map(p => { return { payId: p.payId, val: [] }; }));
|
PayFun.delPayLog(call.uid, ...G.gc.dixiaheishi.zhoulibao.pays.map(p => { return { payId: p.payId, val: [] }; }));
|
||||||
}
|
}
|
||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
|
@ -46,8 +46,12 @@ export default async function (call: ApiCall<ReqGift, ResGift>) {
|
|||||||
|
|
||||||
prize.length > 0 && await PlayerFun.sendPrize(call, prize);
|
prize.length > 0 && await PlayerFun.sendPrize(call, prize);
|
||||||
|
|
||||||
|
if(prize.length == 0 && !change.sendGift?.length ) {
|
||||||
|
return call.error(lng.friend_23)
|
||||||
|
} else {
|
||||||
call.succ({
|
call.succ({
|
||||||
prize: prize,
|
prize: prize,
|
||||||
change: change
|
change: change
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
@ -15,14 +15,17 @@ export default async function (call: ApiCall<ReqList, ResList>) {
|
|||||||
]).toArray();
|
]).toArray();
|
||||||
break;
|
break;
|
||||||
case 'friend':
|
case 'friend':
|
||||||
res = await G.redis.gets('user', ...my.data.friendList.map(uid => [uid] as [string]))
|
//res = await G.redis.gets('user', ...my.data.friendList.map(uid => [uid] as [string]))
|
||||||
|
res = (await G.mongodb.find('user',{uid:{$in:my.data.friendList}})) as any;
|
||||||
break;
|
break;
|
||||||
case 'apply':
|
case 'apply':
|
||||||
// 预防申请列表出现脏数据(过滤已添加好友)
|
// 预防申请列表出现脏数据(过滤已添加好友)
|
||||||
res = await G.redis.gets('user', ...my.data.applyList.filter(uid => my.data.friendList.indexOf(uid) == -1).map(uid => [uid] as [string]));
|
//res = await G.redis.gets('user', ...);
|
||||||
|
res = (await G.mongodb.find('user',{uid:{$in: my.data.applyList.filter(uid => my.data.friendList.indexOf(uid) == -1) }})) as any
|
||||||
break;
|
break;
|
||||||
case 'black':
|
case 'black':
|
||||||
res = await G.redis.gets('user', ...my.data.blacklist.map(uid => [uid] as [string]))
|
//res = await G.redis.gets('user', ...my.data.blacklist.map(uid => [uid] as [string]))
|
||||||
|
res = (await G.mongodb.find('user',{uid:{$in: my.data.blacklist}})) as any;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { FriendManage } from '../../public/friend/manage';
|
import {FriendManage} from '../../public/friend/manage';
|
||||||
import { ReqRespond, ResRespond } from "../../shared/protocols/friend/PtlRespond";
|
import {ReqRespond, ResRespond} from "../../shared/protocols/friend/PtlRespond";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRespond, ResRespond>) {
|
export default async function (call: ApiCall<ReqRespond, ResRespond>) {
|
||||||
const my = await FriendManage.getFriend(call.uid);
|
const my = await FriendManage.getFriend(call.uid);
|
||||||
@ -16,6 +16,7 @@ export default async function (call: ApiCall<ReqRespond, ResRespond>) {
|
|||||||
|
|
||||||
if (he) {
|
if (he) {
|
||||||
if (he.data.friendList.length >= G.gc.friend.maxFriendNum) return call.error(globalThis.lng.friend_19);
|
if (he.data.friendList.length >= G.gc.friend.maxFriendNum) return call.error(globalThis.lng.friend_19);
|
||||||
|
if (he.data.blacklist.includes(call.uid)) return call.error(globalThis.lng.friend_7)
|
||||||
he.addFriend(call.uid);
|
he.addFriend(call.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { FightFun } from '../../public/fight';
|
import {FightFun} from '../../public/fight';
|
||||||
import { PlayerFun } from "../../public/player";
|
import {PlayerFun} from "../../public/player";
|
||||||
import { formatNpcData } from '../../shared/fightControl/fightFun';
|
import {formatNpcData} from '../../shared/fightControl/fightFun';
|
||||||
import { ReqChallenge, ResChallenge } from "../../shared/protocols/ganbutexun/PtlChallenge";
|
import {ReqChallenge, ResChallenge} from "../../shared/protocols/ganbutexun/PtlChallenge";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqChallenge, ResChallenge>) {
|
export default async function (call: ApiCall<ReqChallenge, ResChallenge>) {
|
||||||
let heroid = call.req.id;
|
let heroid = call.req.id;
|
||||||
@ -11,7 +11,7 @@ export default async function (call: ApiCall<ReqChallenge, ResChallenge>) {
|
|||||||
// 判断关卡进度 TODO
|
// 判断关卡进度 TODO
|
||||||
let isUnlock = Object.entries(conf.cond).every(v => call.conn.gud[v[0]] >= v[1]);
|
let isUnlock = Object.entries(conf.cond).every(v => call.conn.gud[v[0]] >= v[1]);
|
||||||
if (!isUnlock) {
|
if (!isUnlock) {
|
||||||
return call.error('', { code: -1 });
|
return call.error('', {code: -1});
|
||||||
}
|
}
|
||||||
let need = [conf.need];
|
let need = [conf.need];
|
||||||
await PlayerFun.checkNeedIsMeet(call, need);
|
await PlayerFun.checkNeedIsMeet(call, need);
|
||||||
@ -19,7 +19,7 @@ export default async function (call: ApiCall<ReqChallenge, ResChallenge>) {
|
|||||||
|
|
||||||
let prize = [];
|
let prize = [];
|
||||||
let addnum = 0;
|
let addnum = 0;
|
||||||
let fightNum = (await G.mongodb.collection('gbtx').findOne({ uid: call.uid }))?.fightNum?.[call.req.id] || 0;
|
let fightNum = (await G.mongodb.collection('gbtx').findOne({uid: call.uid}))?.fightNum?.[call.req.id] || 0;
|
||||||
fightNum + 1;
|
fightNum + 1;
|
||||||
|
|
||||||
let lv = fightNum % 6 + fightNum;
|
let lv = fightNum % 6 + fightNum;
|
||||||
@ -46,7 +46,7 @@ export default async function (call: ApiCall<ReqChallenge, ResChallenge>) {
|
|||||||
await PlayerFun.addItem(call, prize);
|
await PlayerFun.addItem(call, prize);
|
||||||
|
|
||||||
G.mongodb.collection('gbtx').updateOne(
|
G.mongodb.collection('gbtx').updateOne(
|
||||||
{ uid: call.uid },
|
{uid: call.uid},
|
||||||
{
|
{
|
||||||
$inc: obj
|
$inc: obj
|
||||||
},
|
},
|
||||||
@ -57,9 +57,9 @@ export default async function (call: ApiCall<ReqChallenge, ResChallenge>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
G.mongodb.collection('gbtx').updateOne(
|
G.mongodb.collection('gbtx').updateOne(
|
||||||
{ uid: call.uid },
|
{uid: call.uid},
|
||||||
{
|
{
|
||||||
$inc: G.mongodb.createTreeObj({ key: `fightNum.${call.req.id}`, val: 1 })
|
$inc: G.mongodb.createTreeObj({key: `fightNum.${call.req.id}`, val: 1})
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
upsert: true
|
upsert: true
|
||||||
|
@ -4,22 +4,32 @@ import {ZhanLingTasks} from '../../public/zhanling';
|
|||||||
import {ReqOpen, ResOpen} from "../../shared/protocols/ganhai/PtlOpen";
|
import {ReqOpen, ResOpen} from "../../shared/protocols/ganhai/PtlOpen";
|
||||||
import {PublicShared} from '../../shared/public/public';
|
import {PublicShared} from '../../shared/public/public';
|
||||||
import {HongDianChange} from "../hongdian/fun";
|
import {HongDianChange} from "../hongdian/fun";
|
||||||
import { isArray } from "mathjs";
|
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
|
|
||||||
let dbData = await G.mongodb.collection('ganhai').findOne({uid: call.uid});
|
let dbData = await G.mongodb.collection('ganhai').findOne({uid: call.uid});
|
||||||
|
|
||||||
|
if (!dbData || dbData.refreshTime < PublicShared.getToDayZeroTime()) {
|
||||||
|
let set: any = {
|
||||||
|
refreshTime: G.time,
|
||||||
|
useFightNum: 0,
|
||||||
|
useEscortNum: 0,
|
||||||
|
useRefreshNum: 0
|
||||||
|
};
|
||||||
|
|
||||||
if (!dbData) {
|
if (!dbData) {
|
||||||
var shipIndexs = randomMyShips();
|
var shipIndexs = randomMyShips();
|
||||||
|
var ships = await randomShips(call.uid, call.conn.gud.ghId);
|
||||||
var ships = await randomShips(call.uid);
|
set = {
|
||||||
await G.mongodb.collection('ganhai').updateOne({uid: call.uid}, {
|
...set,
|
||||||
$set: {
|
|
||||||
myShips: shipIndexs,
|
myShips: shipIndexs,
|
||||||
ships: ships
|
ships: ships
|
||||||
}
|
}
|
||||||
}, {upsert: true});
|
}
|
||||||
|
dbData = (await G.mongodb.collection('ganhai').findOneAndUpdate({uid: call.uid}, {$set: set}, {
|
||||||
|
upsert: true,
|
||||||
|
returnDocument: 'after'
|
||||||
|
})).value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +38,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
let resShips = dbData?.ships
|
let resShips = dbData?.ships
|
||||||
if (resShips) {
|
if (resShips) {
|
||||||
let npc = []
|
let npc = []
|
||||||
let ids = resShips.filter(i=>!!i).map(i => {
|
let ids = resShips.filter(i => !!i).map(i => {
|
||||||
let uid = i.player?.player?.uid
|
let uid = i.player?.player?.uid
|
||||||
if (uid) return uid
|
if (uid) return uid
|
||||||
else npc.push(i)
|
else npc.push(i)
|
||||||
@ -49,16 +59,6 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
useRefreshNum: dbData?.useRefreshNum || 0,
|
useRefreshNum: dbData?.useRefreshNum || 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!dbData || dbData.refreshTime < PublicShared.getToDayZeroTime()) {
|
|
||||||
var refresObj = {
|
|
||||||
refreshTime: G.time,
|
|
||||||
useFightNum: 0,
|
|
||||||
useEscortNum: 0,
|
|
||||||
useRefreshNum: 0
|
|
||||||
};
|
|
||||||
await G.mongodb.collection('ganhai').updateOne({uid: call.uid}, {$set: refresObj}, {upsert: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dbData?.ship?.sTime && dbData.ship.sTime + G.gc.ganhai.ships[dbData.ship.index].time < G.time) {
|
if (dbData?.ship?.sTime && dbData.ship.sTime + G.gc.ganhai.ships[dbData.ship.index].time < G.time) {
|
||||||
let prize = calculatePrize(dbData.ship, dbData.ship.sTime + G.gc.ganhai.ships[dbData.ship.index].time);
|
let prize = calculatePrize(dbData.ship, dbData.ship.sTime + G.gc.ganhai.ships[dbData.ship.index].time);
|
||||||
await PlayerFun.sendPrize(call, prize);
|
await PlayerFun.sendPrize(call, prize);
|
||||||
@ -89,32 +89,24 @@ export function randomMyShips(isDj = false, yjdj = false) {
|
|||||||
return shipIndexs;
|
return shipIndexs;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function randomShips(uid: string) {
|
export async function randomShips(uid: string, ghId: string) {
|
||||||
// let shipss = await G.mongodb.collection('ganhai').find({uid: {$nin: [uid]}}).toArray();
|
let gonghui = await G.mongodb.collection('gonghui').findOne({_id: G.mongodb.conversionId(ghId)})
|
||||||
// console.log(shipss[0])
|
|
||||||
// 过滤不存在的用户
|
// todo 用户不存在不属于正常情况,考虑连表性能,先去掉连表查询所有用户
|
||||||
let ships = await G.mongodb.collection('ganhai').aggregate([
|
let ships = await G.mongodb.collection('ganhai').aggregate([
|
||||||
{
|
{
|
||||||
"$match": {
|
$match: {
|
||||||
uid: {$nin: [uid]}
|
$and: [
|
||||||
|
{uid: {$nin: [uid, ...gonghui.players.map(i => i.uid)]}},
|
||||||
|
{ship: {$exists: true, $ne: null}},
|
||||||
|
{"ship.beFightNum": {$lt: G.gc.ganhai.beBeatenMax}}]
|
||||||
}
|
}
|
||||||
},{
|
},
|
||||||
"$lookup": {
|
{
|
||||||
"from": "user",
|
$sample: {size: 5}
|
||||||
"localField": "uid",
|
|
||||||
"foreignField": "uid",
|
|
||||||
"as": "userInfo"
|
|
||||||
}
|
}
|
||||||
},{
|
|
||||||
"$match": {
|
|
||||||
"userInfo": {$ne: []}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
]).toArray()
|
]).toArray()
|
||||||
ships = ships.filter(s => s.ship != null && s.ship.beFightNum < G.gc.ganhai.ships[s.ship.index].ldNum);
|
return ships.map(s => s.ship)
|
||||||
ships.sort(() => Math.random() - .5);
|
|
||||||
return ships.slice(0, 5).map(s => s.ship);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calculatePrize(ship: ResOpen['ship'], time: number) {
|
export function calculatePrize(ship: ResOpen['ship'], time: number) {
|
||||||
@ -156,7 +148,7 @@ export class GanHaiRed {
|
|||||||
|
|
||||||
//let dbs = await G.mongodb.collection('ganhai').find({}).toArray();
|
//let dbs = await G.mongodb.collection('ganhai').find({}).toArray();
|
||||||
//let obj = Object.fromEntries(dbs.map(db => [db.uid, db.ship]));
|
//let obj = Object.fromEntries(dbs.map(db => [db.uid, db.ship]));
|
||||||
let dbs = await G.mongodb.find('ganhai',{},['uid','ship.sTime','ship.index']);
|
let dbs = await G.mongodb.find('ganhai', {}, ['uid', 'ship.sTime', 'ship.index']);
|
||||||
let obj = Object.fromEntries(dbs.map(db => [db.uid, db.ship]));
|
let obj = Object.fromEntries(dbs.map(db => [db.uid, db.ship]));
|
||||||
|
|
||||||
Object.assign(this.checkList, obj);
|
Object.assign(this.checkList, obj);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { ReqRefresh, ResRefresh } from "../../shared/protocols/ganhai/PtlRefresh";
|
import {ReqRefresh, ResRefresh} from "../../shared/protocols/ganhai/PtlRefresh";
|
||||||
import { randomShips } from './ApiOpen';
|
import {randomShips} from './ApiOpen';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
|
export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
|
||||||
let ships = await randomShips(call.uid);
|
let ships = await randomShips(call.uid, call.conn.gud.ghId);
|
||||||
|
|
||||||
G.mongodb.collection('ganhai').updateOne({ uid: call.uid }, { $set: { ships: ships } });
|
G.mongodb.collection('ganhai').updateOne({uid: call.uid}, {$set: {ships: ships}});
|
||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
change: {
|
change: {
|
||||||
|
22
src/api_s2c/gmapi/ApiGift.ts
Normal file
22
src/api_s2c/gmapi/ApiGift.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { ReqGift, ResGift } from "../../shared/protocols/gmapi/PtlGift";
|
||||||
|
import { PlayerFun } from "../../public/player";
|
||||||
|
import axios from 'axios'
|
||||||
|
import util from 'util'
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqGift, ResGift>) {
|
||||||
|
let baseUrl = util.format('https://%s', G.config.baseUrl)
|
||||||
|
// let params:any = {g:'admin', m:'data', a: "card_active",game: '12zWQ5fj8ikhjW03' } // 默认固定参数
|
||||||
|
let params:any = {g:'admin', m:'data', a: "card_active",game: '12zWQ5fj8ikhjW03' } // 默认固定参数
|
||||||
|
params.uid = call.uid;
|
||||||
|
params.uname = call.conn.gud.name; // 用户昵称name
|
||||||
|
params.cnum = call.req.cnum; //兑换码
|
||||||
|
params.owner = ''; // 渠道
|
||||||
|
let res = await axios.get(baseUrl + '/gm/index.php', {params});
|
||||||
|
if(res.data.result == 0) {
|
||||||
|
await PlayerFun.addItem(call, res.data.code.prize); // 发送奖励
|
||||||
|
call.succ({result: res.data.result, prize: res.data.code.prize});
|
||||||
|
} else {
|
||||||
|
call.error(lng.duihuanma_tips_4); // 兑换码已使用或不存在。
|
||||||
|
}
|
||||||
|
}
|
11
src/api_s2c/gmapi/ApiPost.ts
Normal file
11
src/api_s2c/gmapi/ApiPost.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { ApiCall } from "tsrpc";
|
||||||
|
import { ReqPost, ResPost } from "../../shared/protocols/gmapi/PtlPost";
|
||||||
|
import axios from 'axios';
|
||||||
|
import util from 'util';
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqPost, ResPost>) {
|
||||||
|
let baseUrl = util.format('https://%s', G.config.baseUrl)
|
||||||
|
let params = {g:'', m:'data', a: "out_notice",game: 'heijiao', owner: ''}
|
||||||
|
let res = await axios.get(baseUrl + '/gm/index.php', {params})
|
||||||
|
call.succ({data: res.data})
|
||||||
|
}
|
@ -17,5 +17,5 @@ export default async function (call: ApiCall<ReqApply, ResApply>) {
|
|||||||
}
|
}
|
||||||
HongDianChange.sendChangeKey(call.uid, ['gonghuihd'])
|
HongDianChange.sendChangeKey(call.uid, ['gonghuihd'])
|
||||||
|
|
||||||
call.succ({});
|
call.succ({ message: "success", code: 0 });
|
||||||
}
|
}
|
@ -3,9 +3,11 @@ import { ReqApplyList, ResApplyList } from "../../shared/protocols/gonghui/PtlAp
|
|||||||
|
|
||||||
export default async function (call: ApiCall<ReqApplyList, ResApplyList>) {
|
export default async function (call: ApiCall<ReqApplyList, ResApplyList>) {
|
||||||
let GHdata = await call.conn.gonghui
|
let GHdata = await call.conn.gonghui
|
||||||
if (GHdata.data.applyList?.length > 0) {
|
|
||||||
|
|
||||||
let players = await G.redis.gets('user', ...GHdata.data.applyList.map(a => [a.uid] as [string]));
|
if (GHdata.data.applyList?.length > 0) {
|
||||||
|
//let players = await G.redis.gets('user', ...GHdata.data.applyList.map(a => [a.uid] as [string]));
|
||||||
|
let uids = GHdata.data.applyList.map((i)=>i.uid);
|
||||||
|
let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any;
|
||||||
|
|
||||||
call.succ(players.map((p, i) => {
|
call.succ(players.map((p, i) => {
|
||||||
return {
|
return {
|
||||||
|
@ -11,9 +11,12 @@ export default async function (call: ApiCall<ReqChange, ResChange>) {
|
|||||||
|
|
||||||
await GongHuiFun.checkSetArgs(call.req);
|
await GongHuiFun.checkSetArgs(call.req);
|
||||||
|
|
||||||
|
if (call.req.name){
|
||||||
await PlayerFun.checkNeedIsMeet(call, G.gc.shili_com.changeNameNeed);
|
await PlayerFun.checkNeedIsMeet(call, G.gc.shili_com.changeNameNeed);
|
||||||
|
|
||||||
await PlayerFun.cutNeed(call, G.gc.shili_com.changeNameNeed);
|
await PlayerFun.cutNeed(call, G.gc.shili_com.changeNameNeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
(await GHManage.getGH(call.conn.gud.ghId)).updateSetting(call.req);
|
(await GHManage.getGH(call.conn.gud.ghId)).updateSetting(call.req);
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ export default async function (call: ApiCall<ReqFbFight, ResFbFight>) {
|
|||||||
bossInfo: {},
|
bossInfo: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
gh.addExp(conf.gongxianprize);
|
gh.addExp(conf.gongxianprize, call.uid);
|
||||||
} else {
|
} else {
|
||||||
Object.entries(result.fightData[1].roles).forEach(role => {
|
Object.entries(result.fightData[1].roles).forEach(role => {
|
||||||
gh.data.fuben.bossInfo[role[0]] = { hp: role[1].attr.hp, maxHp: role[1].attr.maxHp };
|
gh.data.fuben.bossInfo[role[0]] = { hp: role[1].attr.hp, maxHp: role[1].attr.maxHp };
|
||||||
|
@ -12,7 +12,8 @@ export default async function (call: ApiCall<ReqFbOpen, ResFbOpen>) {
|
|||||||
if (call.req.fbId != gh.data.fuben.id) {
|
if (call.req.fbId != gh.data.fuben.id) {
|
||||||
let md = await G.mongodb.collection('gonghuiFb').findOne({ ghId: gh.data._id, fbId: call.req.fbId });
|
let md = await G.mongodb.collection('gonghuiFb').findOne({ ghId: gh.data._id, fbId: call.req.fbId });
|
||||||
let uids = Object.keys(md.rankList);
|
let uids = Object.keys(md.rankList);
|
||||||
let players = await G.redis.gets('user', ...uids.map(uid => [uid] as [string]));
|
//let players = await G.redis.gets('user', ...uids.map(uid => [uid] as [string]));
|
||||||
|
let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any;
|
||||||
res.rankList = players.map(p => {
|
res.rankList = players.map(p => {
|
||||||
return {
|
return {
|
||||||
player: p,
|
player: p,
|
||||||
@ -21,7 +22,8 @@ export default async function (call: ApiCall<ReqFbOpen, ResFbOpen>) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let uids = Object.keys(gh.data.fuben.dps);
|
let uids = Object.keys(gh.data.fuben.dps);
|
||||||
let players = await G.redis.gets('user', ...uids.map(uid => [uid] as [string]));
|
//let players = await G.redis.gets('user', ...uids.map(uid => [uid] as [string]));
|
||||||
|
let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any;
|
||||||
res.rankList = players.map(p => {
|
res.rankList = players.map(p => {
|
||||||
return {
|
return {
|
||||||
player: p,
|
player: p,
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { GHManage } from '../../public/gonghui/manage';
|
import {GHManage} from '../../public/gonghui/manage';
|
||||||
import { ReqGetList, ResGetList } from "../../shared/protocols/gonghui/PtlGetList";
|
import {ReqGetList, ResGetList} from "../../shared/protocols/gonghui/PtlGetList";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||||
|
|
||||||
let arr: ResGetList['list'] = [];
|
let arr: ResGetList['list'] = [];
|
||||||
let GHData = await GHManage.getGHList();
|
let GHData = await GHManage.getGHList();
|
||||||
let ghs = Object.values(GHData).map(item => item.data);
|
let ghs = Object.values(GHData).map(item => item.data).filter(i => !!i.players);
|
||||||
let allRoles = await G.mongodb.collection('user').find().toArray();
|
|
||||||
|
let fuids = R.flatten(ghs.map(i => i.players.map(j => j.uid)))
|
||||||
|
|
||||||
|
let allRoles = await G.mongodb.find('user',{uid: {$in: fuids}},['uid','power'])
|
||||||
let zhanlis = Object.fromEntries(allRoles.map(r => [r.uid, r.power]));
|
let zhanlis = Object.fromEntries(allRoles.map(r => [r.uid, r.power]));
|
||||||
|
|
||||||
for (let gh of ghs) {
|
for (let gh of ghs) {
|
||||||
|
@ -2,11 +2,14 @@ import { ApiCall } from "tsrpc";
|
|||||||
import { GHManage } from '../../public/gonghui/manage';
|
import { GHManage } from '../../public/gonghui/manage';
|
||||||
import { ReqJoin, ResJoin } from "../../shared/protocols/gonghui/PtlJoin";
|
import { ReqJoin, ResJoin } from "../../shared/protocols/gonghui/PtlJoin";
|
||||||
import { HongDianChange } from "../hongdian/fun";
|
import { HongDianChange } from "../hongdian/fun";
|
||||||
|
import {PublicShared} from "../../shared/public/public";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqJoin, ResJoin>) {
|
export default async function (call: ApiCall<ReqJoin, ResJoin>) {
|
||||||
|
if (PublicShared.getOpenServerDay() > 1) {
|
||||||
if ((call.conn.gud.ghExitTime || 0) + G.gc.com.Guild_CD.value > G.time) {
|
if ((call.conn.gud.ghExitTime || 0) + G.gc.com.Guild_CD.value > G.time) {
|
||||||
return call.error(globalThis.lng.gonghui_5);
|
return call.error(globalThis.lng.gonghui_5);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (call.conn.gud.ghId) return call.error(globalThis.lng.gonghui_16);
|
if (call.conn.gud.ghId) return call.error(globalThis.lng.gonghui_16);
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import { ApiCall } from "tsrpc";
|
||||||
import { ReqTanHe, ResTanHe } from "../../shared/protocols/gonghui/PtlTanHe";
|
import { ReqTanHe, ResTanHe } from "../../shared/protocols/gonghui/PtlTanHe";
|
||||||
|
import { getGud } from "../../public/gud";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqTanHe, ResTanHe>) {
|
export default async function (call: ApiCall<ReqTanHe, ResTanHe>) {
|
||||||
let GHdata = await call.conn.gonghui;
|
let GHdata = await call.conn.gonghui;
|
||||||
let createPlayer = await G.redis.get('user', GHdata.data.createPlayer.uid);
|
//let createPlayer = await G.redis.get('user', GHdata.data.createPlayer.uid);
|
||||||
|
let createPlayer = await getGud(GHdata.data.createPlayer.uid);
|
||||||
|
|
||||||
if (GHdata.data.tanhe) call.error(globalThis.lng.gonghui_24);
|
if (GHdata.data.tanhe) call.error(globalThis.lng.gonghui_24);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ export default async function (call: ApiCall<ReqTaskReceive, ResTaskReceive>) {
|
|||||||
gh.data.task.finised++;
|
gh.data.task.finised++;
|
||||||
gh.updateDb({ $inc: { 'task.finised': 1 } });
|
gh.updateDb({ $inc: { 'task.finised': 1 } });
|
||||||
|
|
||||||
G.gc.shili_com.task[call.req.index].addExp && gh.addExp(G.gc.shili_com.task[call.req.index].addExp);
|
G.gc.shili_com.task[call.req.index].addExp && gh.addExp(G.gc.shili_com.task[call.req.index].addExp, call.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
await PlayerFun.sendPrize(call, prize);
|
await PlayerFun.sendPrize(call, prize);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { ChatFun } from '../../public/chat';
|
import {ChatFun} from '../../public/chat';
|
||||||
import { GongHuiBaoZang } from '../../public/gonghuibaozang';
|
import {GongHuiBaoZang} from '../../public/gonghuibaozang';
|
||||||
import { PlayerFun } from '../../public/player';
|
import {PlayerFun} from '../../public/player';
|
||||||
import { ReqLottery, ResLottery } from "../../shared/protocols/gonghuibaozang/PtlLottery";
|
import {ReqLottery, ResLottery} from "../../shared/protocols/gonghuibaozang/PtlLottery";
|
||||||
import { PublicShared } from '../../shared/public/public';
|
import {PublicShared} from '../../shared/public/public';
|
||||||
import { HongDianChange } from "../hongdian/fun";
|
import {HongDianChange} from "../hongdian/fun";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqLottery, ResLottery>) {
|
export default async function (call: ApiCall<ReqLottery, ResLottery>) {
|
||||||
let need: atn[];
|
let need: atn[];
|
||||||
@ -32,7 +32,7 @@ export default async function (call: ApiCall<ReqLottery, ResLottery>) {
|
|||||||
} else if (call.req.type == 10) {
|
} else if (call.req.type == 10) {
|
||||||
// 抽奖十次
|
// 抽奖十次
|
||||||
need = need.map(_n => {
|
need = need.map(_n => {
|
||||||
return { ..._n, n: _n.n * call.req.type };
|
return {..._n, n: _n.n * call.req.type};
|
||||||
});
|
});
|
||||||
|
|
||||||
await PlayerFun.checkNeedIsMeet(call, need);
|
await PlayerFun.checkNeedIsMeet(call, need);
|
||||||
@ -73,8 +73,9 @@ export default async function (call: ApiCall<ReqLottery, ResLottery>) {
|
|||||||
for (let index = 0; index < prize.length; index++) {
|
for (let index = 0; index < prize.length; index++) {
|
||||||
const element = prize[index];
|
const element = prize[index];
|
||||||
|
|
||||||
if (element.a == "item" && G.gc.item[element.t].type == 3){
|
if (element.a == "item" && G.gc.item[element.t].type == 3) {
|
||||||
let playName = G.gc.item[element.t].name
|
let playName = G.gc.item[element.t].name
|
||||||
|
let playColour = G.gc.item[element.t].colour
|
||||||
ChatFun.newMsg({
|
ChatFun.newMsg({
|
||||||
type: 'local',
|
type: 'local',
|
||||||
msg: G.gc.pmd.guild_pmd,
|
msg: G.gc.pmd.guild_pmd,
|
||||||
@ -82,7 +83,7 @@ export default async function (call: ApiCall<ReqLottery, ResLottery>) {
|
|||||||
sender: 'system',
|
sender: 'system',
|
||||||
otherData: {
|
otherData: {
|
||||||
pmd: true,
|
pmd: true,
|
||||||
args: [call.conn.gud.name, playName]
|
args: [call.conn.gud.name, playName, playColour]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -55,30 +55,32 @@ export async function refreshEnemys(call: ApiCall) {
|
|||||||
//let allUser = Object.values(await G.redis.get('user')).filter(u => u.mapId >= section[0] && u.mapId <= section[1] && u.uid != call.uid);
|
//let allUser = Object.values(await G.redis.get('user')).filter(u => u.mapId >= section[0] && u.mapId <= section[1] && u.uid != call.uid);
|
||||||
//let dbUser = await G.mongodb.collection('wanted').find({uid: {$in: allUser.map(u => u.uid)}}).toArray();
|
//let dbUser = await G.mongodb.collection('wanted').find({uid: {$in: allUser.map(u => u.uid)}}).toArray();
|
||||||
|
|
||||||
let allUser = await G.mongodb.find('user',{
|
let allUser = await G.mongodb.find('user', {
|
||||||
$and: [
|
$and: [
|
||||||
{ mapId: { $gte: section[0] } },
|
{mapId: {$gte: section[0]}},
|
||||||
{ mapid: { $lte: section[1] } },
|
{mapId: {$lte: section[1]}},
|
||||||
{ uid: { $ne: call.uid } }
|
{uid: {$ne: call.uid}}
|
||||||
]
|
]
|
||||||
}, ['uid']);
|
}, ['uid']);
|
||||||
let dbUser = await G.mongodb.find('wanted',{uid: {$in: allUser.map(u => u.uid)}},['uid','wanted']);
|
let dbUser = await G.mongodb.find('wanted', {uid: {$in: allUser.map(u => u.uid)}}, ['uid', 'wanted']);
|
||||||
|
|
||||||
let enemys: joinFightData[] = [];
|
let enemys: joinFightData[] = [];
|
||||||
|
|
||||||
let configs = G.gc.gonglukuangbiao.config.reverse()
|
// 自带reverse有时会失效
|
||||||
|
let configs = R.reverse(G.gc.gonglukuangbiao.config)
|
||||||
for (let idx = 0; idx < configs.length; idx++) {
|
for (let idx = 0; idx < configs.length; idx++) {
|
||||||
let conf = configs[idx]
|
let conf = configs[idx]
|
||||||
let needMax = configs[idx + 1]?.need || G.gc.gonglukuangbiao.wanted[idx].wanted[1]
|
let needMax = configs[idx + 1]?.need || G.gc.gonglukuangbiao.wanted[idx].wanted[1]
|
||||||
let filter = dbUser.filter(u => conf.need <= u.wanted && u.wanted < needMax);
|
let filter = dbUser.filter(u => conf.need <= u.wanted && u.wanted < needMax);
|
||||||
let uids = filter.map(f => f.uid);
|
let uids = filter.map(f => f.uid);
|
||||||
dbUser.remove(u => uids.includes(u.uid));
|
dbUser.remove(u => uids.includes(u.uid));
|
||||||
let enemy = uids.length > 0 ? await FightFun.getPlayerFightData(uids.random()) : formatNpcData(conf.npc.random());
|
let a = configs[0].npc.random()
|
||||||
if (!enemy) enemy = formatNpcData(conf.npc.random())
|
let enemy = uids.length > 0 ? await FightFun.getPlayerFightData(uids.random()) : formatNpcData(configs[0].npc.random());
|
||||||
|
if (!enemy) enemy = formatNpcData(configs[0].npc.random())
|
||||||
if (enemy.player.isNpc) enemy.player.name = G.gc.gonglukuangbiao.npcname.random()
|
if (enemy.player.isNpc) enemy.player.name = G.gc.gonglukuangbiao.npcname.random()
|
||||||
enemy["wanted"] = !enemy.player.isNpc ?
|
enemy["wanted"] = !enemy.player.isNpc ?
|
||||||
filter.filter(u => u.uid = enemy.player.uid)[0].wanted :
|
filter.filter(u => u.uid = enemy.player.uid)[0].wanted :
|
||||||
PublicShared.randomNum(G.gc.gonglukuangbiao.wanted[idx].wanted[0], G.gc.gonglukuangbiao.wanted[idx].wanted[1])
|
PublicShared.randomNum(G.gc.gonglukuangbiao.wanted[0].wanted[0], G.gc.gonglukuangbiao.wanted[0].wanted[1])
|
||||||
enemys.push(enemy);
|
enemys.push(enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { PlayerFun } from '../../../public/player';
|
import {PlayerFun} from '../../../public/player';
|
||||||
import { ReqRepair, ResRepair } from "../../../shared/protocols/gongyu/mingdao/PtlRepair";
|
import {ReqRepair, ResRepair} from "../../../shared/protocols/gongyu/mingdao/PtlRepair";
|
||||||
import { prizeType } from '../../../shared/protocols/type';
|
import {prizeType} from '../../../shared/protocols/type';
|
||||||
import { PublicShared } from '../../../shared/public/public';
|
import {PublicShared} from '../../../shared/public/public';
|
||||||
|
import {RankKfjs} from "../../../public/rank/rank_kfjs";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRepair, ResRepair>) {
|
export default async function (call: ApiCall<ReqRepair, ResRepair>) {
|
||||||
let id = call.req.id;
|
let id = call.req.id;
|
||||||
@ -12,14 +13,14 @@ export default async function (call: ApiCall<ReqRepair, ResRepair>) {
|
|||||||
if (call.conn.gud.shoucangping[id] >= conf.level) return call.errorCode(-2);
|
if (call.conn.gud.shoucangping[id] >= conf.level) return call.errorCode(-2);
|
||||||
|
|
||||||
let need: prizeType[] = [];
|
let need: prizeType[] = [];
|
||||||
let itemNeed = { ...conf.need, n: conf.need.n * call.req.num };
|
let itemNeed = {...conf.need, n: conf.need.n * call.req.num};
|
||||||
let itemNum = await PlayerFun.getAtnNum(call, itemNeed);
|
let itemNum = await PlayerFun.getAtnNum(call, itemNeed);
|
||||||
|
|
||||||
if (itemNum < itemNeed.n) {
|
if (itemNum < itemNeed.n) {
|
||||||
if (itemNum > 0) {
|
if (itemNum > 0) {
|
||||||
need.push({ ...itemNeed, n: itemNum });
|
need.push({...itemNeed, n: itemNum});
|
||||||
}
|
}
|
||||||
need.push({ ...G.gc.mingdao_com.changeNeed, n: G.gc.mingdao_com.changeNeed.n * itemNeed.n - itemNum });
|
need.push({...G.gc.mingdao_com.changeNeed, n: G.gc.mingdao_com.changeNeed.n * itemNeed.n - itemNum});
|
||||||
} else {
|
} else {
|
||||||
need.push(itemNeed);
|
need.push(itemNeed);
|
||||||
}
|
}
|
||||||
@ -28,14 +29,14 @@ export default async function (call: ApiCall<ReqRepair, ResRepair>) {
|
|||||||
|
|
||||||
let multiple = new Array(call.req.num).fill(1).map(v => PublicShared.randomDropAny(G.gc.mingdao_com.crit).multiple);
|
let multiple = new Array(call.req.num).fill(1).map(v => PublicShared.randomDropAny(G.gc.mingdao_com.crit).multiple);
|
||||||
let addExp = multiple.map(v => v * G.gc.mingdao_com.addExp).reduce((a, b) => a + b);// G.gc.mingdao_com.addExp * multiple * call.req.num;
|
let addExp = multiple.map(v => v * G.gc.mingdao_com.addExp).reduce((a, b) => a + b);// G.gc.mingdao_com.addExp * multiple * call.req.num;
|
||||||
let curExp = (await G.mongodb.collection('mingdao').findOne({ uid: call.uid }))?.list?.[id]?.pre || 0;
|
let curExp = (await G.mongodb.collection('mingdao').findOne({uid: call.uid}))?.list?.[id]?.pre || 0;
|
||||||
let newExp = 0;
|
let newExp = 0;
|
||||||
|
|
||||||
if (curExp + addExp >= conf.needExp) {
|
if (curExp + addExp >= conf.needExp) {
|
||||||
newExp = curExp + addExp - conf.needExp;
|
newExp = curExp + addExp - conf.needExp;
|
||||||
let send = Object.assign({}, call.conn.gud.shoucangping);
|
let send = Object.assign({}, call.conn.gud.shoucangping);
|
||||||
send[id] += 1;
|
send[id] += 1;
|
||||||
await PlayerFun.addAttr(call, { shoucangping: send });
|
await PlayerFun.addAttr(call, {shoucangping: send});
|
||||||
|
|
||||||
if (send[id] >= conf.level && G.gc.mingdao[~~id + 1]) {
|
if (send[id] >= conf.level && G.gc.mingdao[~~id + 1]) {
|
||||||
G.server.sendMsgByUid(call.uid, 'msg_s2c/HongDianChange', ['mingdao']);
|
G.server.sendMsgByUid(call.uid, 'msg_s2c/HongDianChange', ['mingdao']);
|
||||||
@ -45,13 +46,26 @@ export default async function (call: ApiCall<ReqRepair, ResRepair>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
G.mongodb.collection('mingdao').updateOne(
|
G.mongodb.collection('mingdao').updateOne(
|
||||||
{ uid: call.uid },
|
{uid: call.uid},
|
||||||
{ $set: G.mongodb.createTreeObj({ key: `list.${id}.pre`, val: newExp }) },
|
{$set: G.mongodb.createTreeObj({key: `list.${id}.pre`, val: newExp})},
|
||||||
{ upsert: true }
|
{upsert: true}
|
||||||
);
|
);
|
||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
multiple: multiple,
|
multiple: multiple,
|
||||||
pre: newExp
|
pre: newExp
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let cutItem = R.find(R.whereEq({a: "attr", t: "rmbmoney"}))(need)
|
||||||
|
if (cutItem) {
|
||||||
|
cutItem = {a: "item", t: "21", n: cutItem.n / 5}
|
||||||
|
} else {
|
||||||
|
cutItem = R.find(R.whereEq({a: "item", t: "21"}))(need)
|
||||||
|
}
|
||||||
|
let rankKfjs = new RankKfjs(6)
|
||||||
|
rankKfjs.setDataAndCheck({
|
||||||
|
player: call.conn.gud,
|
||||||
|
valArr: [await rankKfjs.getRankScore(call.uid) + cutItem.n]
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
22
src/api_s2c/hbzb/ApiGetStatus.ts
Normal file
22
src/api_s2c/hbzb/ApiGetStatus.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import {ApiCall} from "tsrpc";
|
||||||
|
import {ReqGetStatus, ResGetStatus} from "../../shared/protocols/hbzb/PtlGetStatus";
|
||||||
|
import {PublicShared} from "../../shared/public/public";
|
||||||
|
import {re} from "mathjs";
|
||||||
|
|
||||||
|
export default async function (call: ApiCall<ReqGetStatus, ResGetStatus>) {
|
||||||
|
|
||||||
|
let jfs = G.gc.hbzb.jfsOpenTime
|
||||||
|
let zbs = G.gc.hbzb.zbsOpenTime
|
||||||
|
|
||||||
|
let zeroTime = PublicShared.getToWeekMondayZeroTime()
|
||||||
|
|
||||||
|
if ((jfs[0] + zeroTime) < G.time && G.time < (jfs[1] + zeroTime)) {
|
||||||
|
return call.succ({type: 1, endTime: jfs[1] + zeroTime})
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zbs[0] + zeroTime) < G.time && G.time < (zbs[1] + zeroTime)) {
|
||||||
|
return call.succ({type: 2, endTime: zbs[1] + zeroTime})
|
||||||
|
}
|
||||||
|
|
||||||
|
return call.succ({type: 3});
|
||||||
|
}
|
@ -6,6 +6,7 @@ import { ReqFight, ResFight } from "../../../shared/protocols/hbzb/jfs/PtlFight"
|
|||||||
import { PublicShared } from '../../../shared/public/public';
|
import { PublicShared } from '../../../shared/public/public';
|
||||||
import { HongDianChange } from "../../hongdian/fun";
|
import { HongDianChange } from "../../hongdian/fun";
|
||||||
import { checkIsOpen } from './ApiOpen';
|
import { checkIsOpen } from './ApiOpen';
|
||||||
|
import { getMyRank, getWinScore } from "./fun";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqFight, ResFight>) {
|
export default async function (call: ApiCall<ReqFight, ResFight>) {
|
||||||
if (!checkIsOpen()) return call.error(globalThis.lng.hbzb_7);
|
if (!checkIsOpen()) return call.error(globalThis.lng.hbzb_7);
|
||||||
@ -22,20 +23,38 @@ export default async function (call: ApiCall<ReqFight, ResFight>) {
|
|||||||
let result = FightFun.fight([myData, enemy.data]);
|
let result = FightFun.fight([myData, enemy.data]);
|
||||||
enemy.result = result.winSide;
|
enemy.result = result.winSide;
|
||||||
|
|
||||||
let addJf = PublicShared.randomNum(30, 35);
|
//通过双方战力计算得分
|
||||||
if (result.winSide == 0) addJf = addJf;
|
|
||||||
else addJf = 0;
|
|
||||||
|
|
||||||
result.winSide == 0 && Rank.list.hbzbLocal.addNew({
|
// let myMaxPower = call.conn.gud?.maxpower || call.conn.gud?.power;
|
||||||
...myData,
|
// let enemyMaxPower = enemy.data.player.maxpower || enemy.data.player.power;
|
||||||
valArr: [data.jifen + addJf]
|
// let score = getWinScore(myMaxPower,enemyMaxPower);
|
||||||
});
|
// let addJf = score;//PublicShared.randomNum(30, 35);
|
||||||
|
|
||||||
let prize = result.winSide == 0 ? G.gc.hbzb.jfsFightWinPrize.map(i => { return { ...i, n: addJf }; }) : [];
|
//刷出怪的时候,已算过一次积分了,如果这里取当前gud重算积分,可能会导致
|
||||||
|
//实际获得的积分跟提前看到的积分不一致
|
||||||
|
//所以,这里增加的积分,直接以enemy里刷出来时的积分为准
|
||||||
|
|
||||||
|
let addJf = enemy.jifen;
|
||||||
|
if (result.winSide == 0){
|
||||||
|
addJf = addJf;
|
||||||
|
}else{
|
||||||
|
//输了给一半
|
||||||
|
addJf = Math.ceil(addJf*0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
// result.winSide == 0 && Rank.list.hbzbLocal.addNew({
|
||||||
|
// ...myData,
|
||||||
|
// valArr: [data.jifen + addJf]
|
||||||
|
// });
|
||||||
|
|
||||||
|
//let prize = result.winSide == 0 ? G.gc.hbzb.jfsFightWinPrize.map(i => { return { ...i, n: addJf }; }) : [];
|
||||||
|
|
||||||
|
//无论输赢都给
|
||||||
|
let prize = G.gc.hbzb.jfsFightWinPrize.map(i => { return { ...i, n: addJf }; });
|
||||||
await PlayerFun.sendPrize(call, prize);
|
await PlayerFun.sendPrize(call, prize);
|
||||||
|
|
||||||
let change: ResFight['change'] = { enemy: data.enemy, useFightNum: data.useFightNum + 1, jifen: data.jifen + addJf };
|
let change: ResFight['change'] = { enemy: data.enemy, useFightNum: data.useFightNum + 1, jifen: data.jifen + addJf };
|
||||||
if (data.enemy.filter(e => e.result == null).length < 1) {
|
if (data.enemy.filter(e => e.result === 0).length == 3) {
|
||||||
let callRes = await G.clientCross.callApi('hbzb/jfs/GetEnemy', { uid: call.uid, auto: true });
|
let callRes = await G.clientCross.callApi('hbzb/jfs/GetEnemy', { uid: call.uid, auto: true });
|
||||||
change.enemy = callRes.res.enemy.map(e => { return { ...e, result: null }; });
|
change.enemy = callRes.res.enemy.map(e => { return { ...e, result: null }; });
|
||||||
}
|
}
|
||||||
@ -58,7 +77,7 @@ export default async function (call: ApiCall<ReqFight, ResFight>) {
|
|||||||
prize: prize,
|
prize: prize,
|
||||||
change: {
|
change: {
|
||||||
...change,
|
...change,
|
||||||
rank: await Rank.list.hbzbLocal.getRankSortByOne(call.uid)
|
rank: await getMyRank(call.uid)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -2,16 +2,16 @@ import { ApiCall } from "tsrpc";
|
|||||||
import { Rank } from '../../../public/rank/rank';
|
import { Rank } from '../../../public/rank/rank';
|
||||||
import { ReqOpen, ResOpen } from "../../../shared/protocols/hbzb/jfs/PtlOpen";
|
import { ReqOpen, ResOpen } from "../../../shared/protocols/hbzb/jfs/PtlOpen";
|
||||||
import { PublicShared } from '../../../shared/public/public';
|
import { PublicShared } from '../../../shared/public/public';
|
||||||
|
import { getHbzbData, getMyRank, getToper200RankUid, updateHbzbCrossUser } from "./fun";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
let dbData = await G.mongodb.cPlayerInfo('hbzb').findOne({ uid: call.uid, type: 'hbzb' });
|
//查看本地数据库里,刷出来的玩家数据
|
||||||
|
let dbData = await getHbzbData(call.uid );
|
||||||
let data: typeof dbData.data = dbData?.data || {} as any;
|
let data: typeof dbData.data = dbData?.data || {} as any;
|
||||||
|
|
||||||
if (dbData == null) {
|
if (dbData == null) {
|
||||||
Rank.list.hbzbLocal.addNew({
|
//如果没有,则同步到跨服
|
||||||
...await call.conn.getDefaultFightData(),
|
await updateHbzbCrossUser(await call.conn.getDefaultFightData(), true);
|
||||||
valArr: [1000]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.refreshTime || data.refreshTime < PublicShared.getToDayZeroTime()) {
|
if (!data.refreshTime || data.refreshTime < PublicShared.getToDayZeroTime()) {
|
||||||
@ -23,8 +23,14 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
data.useRefreshNum = 0;
|
data.useRefreshNum = 0;
|
||||||
|
|
||||||
if (!data.enemy) {
|
if (!data.enemy) {
|
||||||
data.jifen = 1000;
|
//积分赛时的排行榜,是本服积分排序
|
||||||
|
data.jifen = 0;
|
||||||
|
//但是刷出来的对手,是跨服的玩家
|
||||||
let callRes = await G.clientCross.callApi('hbzb/jfs/GetEnemy', { uid: call.uid, auto: true });
|
let callRes = await G.clientCross.callApi('hbzb/jfs/GetEnemy', { uid: call.uid, auto: true });
|
||||||
|
if (!callRes.isSucc){
|
||||||
|
//todo 健壮性处理
|
||||||
|
return call.errorCode(-4)
|
||||||
|
}
|
||||||
if (callRes.res.enemy.length)
|
if (callRes.res.enemy.length)
|
||||||
data.enemy = callRes.res.enemy.map(e => { return { ...e, result: null }; });
|
data.enemy = callRes.res.enemy.map(e => { return { ...e, result: null }; });
|
||||||
}
|
}
|
||||||
@ -38,7 +44,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
...data,
|
...data,
|
||||||
rank: await Rank.list.hbzbLocal.getRankSortByOne(call.uid)
|
rank: await getMyRank(call.uid)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
113
src/api_s2c/hbzb/jfs/fun.ts
Normal file
113
src/api_s2c/hbzb/jfs/fun.ts
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
import { exp, index } from "mathjs";
|
||||||
|
import { rankInfo } from "../../../shared/protocols/type";
|
||||||
|
import { CollectionPlayerInfo } from "../../../module/collection_palyerInfo";
|
||||||
|
import { get } from "http";
|
||||||
|
import { fightResult } from "../../../shared/fightControl/fightType";
|
||||||
|
import { FightFun } from "../../../public/fight";
|
||||||
|
|
||||||
|
/**更新跨服里黑帮争霸的玩家数据 */
|
||||||
|
export async function updateHbzbCrossUser(info: rankInfo, isNew = false) {
|
||||||
|
let callRes = await G.clientCross.callApi('hbzb/UpdateHbzbCrossUser', { uid: info.player.uid, user: info, isNew: isNew });
|
||||||
|
return callRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**获取指定uid的数据 */
|
||||||
|
export async function getHbzbData(uid:string) {
|
||||||
|
let dbData = await G.mongodb.cPlayerInfo('hbzb').findOne({ uid: uid, type: 'hbzb' });
|
||||||
|
return dbData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**获取前200名玩家的uid */
|
||||||
|
export async function getToper200RankUid(){
|
||||||
|
let uids = []
|
||||||
|
let arr = await G.mongodb.collection("playerInfo").find(
|
||||||
|
{ "type": "hbzb" }
|
||||||
|
).sort(
|
||||||
|
{ "data.jifen": -1 }
|
||||||
|
).project({
|
||||||
|
uid:1
|
||||||
|
}).limit(200).toArray();
|
||||||
|
|
||||||
|
arr.map(i=>{
|
||||||
|
uids.push( i.uid );
|
||||||
|
})
|
||||||
|
return uids;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**获取我的排名 */
|
||||||
|
export async function getMyRank(uid:string) : Promise<number>{
|
||||||
|
let top200 = await getToper200RankUid();
|
||||||
|
let myRank = top200.indexOf(uid);
|
||||||
|
if(myRank > -1){
|
||||||
|
myRank += 1;
|
||||||
|
}
|
||||||
|
return myRank;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**获取前50名玩家信息 */
|
||||||
|
export async function getToper50RankInfo(uid?:string){
|
||||||
|
let rank = {
|
||||||
|
"myRank":{},
|
||||||
|
"rankList" : []
|
||||||
|
}
|
||||||
|
let arr = await G.mongodb.collection("playerInfo").find(
|
||||||
|
{ "type": "hbzb", "data.jifen":{$gt:0} },
|
||||||
|
).sort(
|
||||||
|
{ "data.jifen": -1 }
|
||||||
|
).limit(50).toArray();
|
||||||
|
|
||||||
|
//需要到跨服表去拉数据
|
||||||
|
let uids = [];
|
||||||
|
if(uid){
|
||||||
|
uids.push(uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
arr.map(i=>{
|
||||||
|
uids.push( i.uid );
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
let callRes = await G.clientCross.callApi('hbzb/GetUser', { uids: uids });
|
||||||
|
if(!callRes.isSucc){
|
||||||
|
//todo 健壮性处理
|
||||||
|
}
|
||||||
|
let myRank = -1;
|
||||||
|
arr.map((i,index)=>{
|
||||||
|
rank.rankList.push( {
|
||||||
|
player: callRes.res[i.uid]?.data?.player || {},
|
||||||
|
roles: callRes.res[i.uid]?.data?.roles || {},
|
||||||
|
utime: i.data.refreshTime,
|
||||||
|
rank : (index+1),
|
||||||
|
//积分在本地取,而不是跨服里的
|
||||||
|
valArr: [i.data.jifen]
|
||||||
|
});
|
||||||
|
|
||||||
|
if(uid){
|
||||||
|
if(i.uid == uid){
|
||||||
|
myRank = rank.rankList.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if(uid){
|
||||||
|
let myData = await getHbzbData(uid) as any;
|
||||||
|
rank.myRank = {
|
||||||
|
player: callRes.res[uid]?.data?.player || {},
|
||||||
|
rank: myRank,
|
||||||
|
valArr: [myData.data.jifen]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getWinScore(myMaxPower:number, enemyMaxPower:number){
|
||||||
|
//let myMaxPower = call.conn.gud?.maxpower || call.conn.gud?.power;
|
||||||
|
//let enemyMaxPower = enemy.data.player.maxpower || enemy.data.player.power;
|
||||||
|
let score = Math.floor((enemyMaxPower-myMaxPower)/50000+29);
|
||||||
|
//scroe需要在30到35之间
|
||||||
|
if (score < 30) score = 30;
|
||||||
|
if (score > 35) score = 35;
|
||||||
|
return score;
|
||||||
|
}
|
@ -7,33 +7,60 @@ export default async function (call: ApiCall<ReqFight, ResFight>) {
|
|||||||
let dbData = await G.mongodb.cPlayerInfo('hbzbZbs').findOne({ uid: call.uid, type: 'hbzbZbs' });
|
let dbData = await G.mongodb.cPlayerInfo('hbzbZbs').findOne({ uid: call.uid, type: 'hbzbZbs' });
|
||||||
let data = dbData.data;
|
let data = dbData.data;
|
||||||
if(!data) return call.errorCode(1);
|
if(!data) return call.errorCode(1);
|
||||||
|
//战败CD
|
||||||
if (data.failCd && data.failCd + G.gc.hbzb.zbsFightFailCd > G.time) return call.errorCode(0);
|
if (data.failCd && data.failCd + G.gc.hbzb.zbsFightFailCd > G.time) return call.errorCode(0);
|
||||||
|
//挑战次数
|
||||||
if (data.useFightNum >= data.buyFightNum + G.gc.hbzb.zbsFightNum) return call.errorCode(-1);
|
if (data.useFightNum >= data.buyFightNum + G.gc.hbzb.zbsFightNum) return call.errorCode(-1);
|
||||||
|
|
||||||
|
//选出战斗目标
|
||||||
let enemy = data.enemy.find(e => e.data.player.uid == call.req.uid);
|
let enemy = data.enemy.find(e => e.data.player.uid == call.req.uid);
|
||||||
if (!enemy) return call.errorCode(-2);
|
if (!enemy) return call.errorCode(-2);
|
||||||
|
|
||||||
|
//判断目标此时的排名已经发生了变化
|
||||||
let eRank = (await G.clientCross.callApi('hbzb/zbs/GetStatus', { uid: enemy.data.player.uid })).res.status;
|
let eRank = (await G.clientCross.callApi('hbzb/zbs/GetStatus', { uid: enemy.data.player.uid })).res.status;
|
||||||
if (eRank != enemy.rank) return call.errorCode(-3);
|
if (eRank != enemy.rank) return call.errorCode(-4);
|
||||||
|
|
||||||
let change: ResFight['change'] = {};
|
let change: ResFight['change'] = {};
|
||||||
|
//获取我的最新排名
|
||||||
let mRank = (await G.clientCross.callApi('hbzb/zbs/GetStatus', { uid: call.uid })).res.status;
|
let mRank = (await G.clientCross.callApi('hbzb/zbs/GetStatus', { uid: call.uid })).res.status;
|
||||||
let my = await call.conn.getDefaultFightData();
|
let my = await call.conn.getDefaultFightData();
|
||||||
let result = FightFun.fight([my, enemy.data]);
|
let result = FightFun.fight([my, enemy.data]);
|
||||||
|
|
||||||
|
//记录排名,前端显示需要
|
||||||
|
if(!result.otherData)result.otherData={};
|
||||||
|
result.otherData['userRank'] = mRank;
|
||||||
|
result.otherData['enemyRank'] = eRank;
|
||||||
|
|
||||||
if (result.winSide == 0 && mRank > eRank) {
|
if (result.winSide == 0 && mRank > eRank) {
|
||||||
G.clientCross?.sendMsg('msg_cross/HbzbChangeRank', {
|
//交换位置
|
||||||
uid: call.uid,
|
G.crossmongodb.collection("hbzb_user_cross").updateOne({
|
||||||
toUid: enemy.data.player.uid
|
uid: call.uid
|
||||||
});
|
},
|
||||||
|
{$set: {
|
||||||
|
rank: eRank
|
||||||
|
}}
|
||||||
|
)
|
||||||
|
G.crossmongodb.collection("hbzb_user_cross").updateOne({
|
||||||
|
uid: enemy.data.player.uid
|
||||||
|
},
|
||||||
|
{$set: {
|
||||||
|
rank: mRank
|
||||||
|
}}
|
||||||
|
)
|
||||||
|
|
||||||
|
//交换排名
|
||||||
|
result.otherData['userRank'] = eRank;
|
||||||
|
result.otherData['enemyRank'] = mRank;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//记录战报
|
||||||
G.clientCross?.sendMsg('msg_cross/HbzbZbsLog', {
|
G.clientCross?.sendMsg('msg_cross/HbzbZbsLog', {
|
||||||
uid: call.uid,
|
uid: call.uid,
|
||||||
toUid: enemy.data.player.uid,
|
toUid: enemy.data.player.uid,
|
||||||
log: result
|
log: result
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//更新战败cd时间
|
||||||
change.useFightNum = data.useFightNum + 1;
|
change.useFightNum = data.useFightNum + 1;
|
||||||
if (result.winSide != 0) change.failCd = G.time;
|
if (result.winSide != 0) change.failCd = G.time;
|
||||||
|
|
||||||
@ -49,6 +76,7 @@ export default async function (call: ApiCall<ReqFight, ResFight>) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//发放奖励
|
||||||
let prize = result.winSide == 0 ? G.gc.hbzb.zbsFightWinPrize : G.gc.hbzb.zbsFightFailPrize;
|
let prize = result.winSide == 0 ? G.gc.hbzb.zbsFightWinPrize : G.gc.hbzb.zbsFightFailPrize;
|
||||||
await PlayerFun.sendPrize(call, prize);
|
await PlayerFun.sendPrize(call, prize);
|
||||||
|
|
||||||
|
@ -1,38 +1,40 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { ReqOpen, ResOpen } from "../../../shared/protocols/hbzb/zbs/PtlOpen";
|
import {ReqOpen, ResOpen} from "../../../shared/protocols/hbzb/zbs/PtlOpen";
|
||||||
import { PublicShared } from '../../../shared/public/public';
|
import {PublicShared} from '../../../shared/public/public';
|
||||||
|
import {number, string} from "mathjs";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
if (G.time < PublicShared.getToWeekMondayZeroTime() + G.gc.hbzb.zbsOpenTime[0]) return call.error(globalThis.lng.hbzb_11);
|
if (G.time < PublicShared.getToWeekMondayZeroTime() + G.gc.hbzb.zbsOpenTime[0]) return call.error(globalThis.lng.hbzb_11);
|
||||||
|
|
||||||
let status = (await G.clientCross.callApi('hbzb/zbs/GetStatus', { uid: call.uid })).res.status;
|
let req =(await G.clientCross.callApi('hbzb/zbs/GetStatus', {uid: call.uid}));
|
||||||
if (status == -1) return call.errorCode(-1);
|
let status = req?.res?.status;
|
||||||
|
//没有资格
|
||||||
|
if (typeof status == 'number' && status == -999999) return call.errorCode(-1);
|
||||||
|
|
||||||
let dbData = await G.mongodb.cPlayerInfo('hbzbZbs').findOne({ uid: call.uid, type: 'hbzbZbs' });
|
let data = await G.mongodb.cPlayerInfo('hbzbZbs').findOne({uid: call.uid, type: 'hbzbZbs'}) as any;
|
||||||
let data: typeof dbData.data = dbData?.data || {} as any;
|
if(data){
|
||||||
if (!data.refreshTime || data.refreshTime < PublicShared.getToDayZeroTime()) {
|
data = data?.data;
|
||||||
|
}
|
||||||
|
if (!data || !data?.refreshTime || data?.refreshTime < PublicShared.getToDayZeroTime()) {
|
||||||
|
data = {};
|
||||||
data.winNum = 0;
|
data.winNum = 0;
|
||||||
data.buyFightNum = 0;
|
data.buyFightNum = 0;
|
||||||
data.useFightNum = 0;
|
data.useFightNum = 0;
|
||||||
data.refreshTime = G.time;
|
data.refreshTime = G.time;
|
||||||
data.winRecPrize = [];
|
data.winRecPrize = [];
|
||||||
|
|
||||||
if (!data.enemy) {
|
let callRes = await G.clientCross.callApi('hbzb/zbs/GetEnemy', {uid: call.uid});
|
||||||
let callRes = await G.clientCross.callApi('hbzb/zbs/GetEnemy', { uid: call.uid });
|
|
||||||
data.enemy = callRes.res.enemy;
|
data.enemy = callRes.res.enemy;
|
||||||
}
|
|
||||||
|
|
||||||
G.mongodb.cPlayerInfo('hbzbZbs').updateOne(
|
G.mongodb.cPlayerInfo('hbzbZbs').updateOne(
|
||||||
{ uid: call.uid, type: 'hbzbZbs' },
|
{uid: call.uid, type: 'hbzbZbs'},
|
||||||
{ $set: { data: data } },
|
{$set: {data: data}},
|
||||||
{ upsert: true }
|
{upsert: true}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
call.succ({
|
data.rank = (await G.crossmongodb.collection("hbzb_user_cross").findOne({ uid: call.uid }))?.rank || -999999;
|
||||||
...data,
|
call.succ(data);
|
||||||
rank: status
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function checkIsOpen() {
|
export function checkIsOpen() {
|
||||||
|
110
src/api_s2c/hbzb/zbs/fun.ts
Normal file
110
src/api_s2c/hbzb/zbs/fun.ts
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/**
|
||||||
|
* 争霸赛分组,每300个玩家分一组
|
||||||
|
* 最后一组:如果是有100人即往上人数 那就自己一组打
|
||||||
|
* 如果不够100 就合到前一组
|
||||||
|
*/
|
||||||
|
export async function zbsGroup(){
|
||||||
|
let arr = await G.mongodb.collection("hbzb_user_cross").find(
|
||||||
|
{ "jifen": { $gt: -999999 } }
|
||||||
|
).sort(
|
||||||
|
{ "data.player.cTime": -1 }
|
||||||
|
).project({
|
||||||
|
uid:1,
|
||||||
|
jifen:1
|
||||||
|
}).toArray();
|
||||||
|
|
||||||
|
//有积分的玩家总数
|
||||||
|
let groups = [];
|
||||||
|
let currGroup = [];
|
||||||
|
|
||||||
|
arr.map((u,index)=>{
|
||||||
|
if(currGroup.length >= 300){
|
||||||
|
//每300个丢一组
|
||||||
|
groups.push( currGroup );
|
||||||
|
currGroup = [];
|
||||||
|
}
|
||||||
|
currGroup.push({uid: u.uid, jifen: u.jifen});
|
||||||
|
});
|
||||||
|
|
||||||
|
//循环完毕后检查余量
|
||||||
|
if(currGroup.length > 0){
|
||||||
|
if(currGroup.length >= 100){
|
||||||
|
//如果有100人 就自己一组
|
||||||
|
groups.push( currGroup );
|
||||||
|
}else{
|
||||||
|
//不够100 就合到前一组
|
||||||
|
groups[groups.length] = (groups[groups.length]||[]).concat(currGroup);
|
||||||
|
}
|
||||||
|
currGroup = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
//循环groups里的数据,对每一组里按jifen降序排序,然后给每个玩家分组
|
||||||
|
groups.map((group,groupIndex)=>{
|
||||||
|
group.sort((a,b)=>{
|
||||||
|
return b.jifen - a.jifen;
|
||||||
|
});
|
||||||
|
for(let i=0;i<group.length;i++){
|
||||||
|
G.mongodb.collection("hbzb_user_cross").updateOne(
|
||||||
|
{ uid: group[i].uid },
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
"zbsgroup": "group"+(groupIndex+1),
|
||||||
|
"rank":(i+1),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取争霸赛阶段排行
|
||||||
|
*/
|
||||||
|
export async function getZbsRankList(uid?: string, _zbsgroup?: string) : Promise<{ myRank: any; rankList: any[]; }> {
|
||||||
|
let myData;
|
||||||
|
let zbsgroup = _zbsgroup;
|
||||||
|
|
||||||
|
if(uid){
|
||||||
|
myData = await G.crossmongodb.collection("hbzb_user_cross").findOne({uid:uid});
|
||||||
|
if(!myData || !myData?.zbsgroup)return null;
|
||||||
|
zbsgroup = myData?.zbsgroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
let arr = await G.crossmongodb.collection("hbzb_user_cross").find(
|
||||||
|
{ "zbsgroup": zbsgroup }
|
||||||
|
).sort(
|
||||||
|
{ "rank": 1 }
|
||||||
|
).limit(100).toArray();
|
||||||
|
|
||||||
|
|
||||||
|
let rank = {
|
||||||
|
"myRank":{},
|
||||||
|
"rankList" : []
|
||||||
|
}
|
||||||
|
|
||||||
|
let myRank = -1;
|
||||||
|
arr.map((u,index)=>{
|
||||||
|
rank.rankList.push( {
|
||||||
|
player: ((u.data) as any).player || {},
|
||||||
|
roles: ((u.data) as any).roles || {},
|
||||||
|
rank : (index+1),
|
||||||
|
//兼容前端
|
||||||
|
valArr: [ (index+1) ]
|
||||||
|
});
|
||||||
|
|
||||||
|
if(u.uid == uid){
|
||||||
|
myRank = rank.rankList.length;
|
||||||
|
rank.myRank = {
|
||||||
|
player: ((u.data) as any).player || {},
|
||||||
|
roles: ((u.data) as any).roles || {},
|
||||||
|
rank : (index+1),
|
||||||
|
//兼容前端
|
||||||
|
valArr: [ (index+1) ]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return rank;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,10 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { Wjjl } from '../../module/collection_wjjl';
|
import {Wjjl} from '../../module/collection_wjjl';
|
||||||
import { PlayerFun } from '../../public/player';
|
import {PlayerFun} from '../../public/player';
|
||||||
import { ReqChangePos, ResChangePos } from "../../shared/protocols/hero/PtlChangePos";
|
import {ReqChangePos, ResChangePos} from "../../shared/protocols/hero/PtlChangePos";
|
||||||
import {TaskFun} from "../../public/task";
|
import kfjsFun from "../../public/kaifujingsai";
|
||||||
|
import {HeroFun} from "../../public/hero";
|
||||||
|
|
||||||
|
|
||||||
export const maxPosNum = 6;
|
export const maxPosNum = 6;
|
||||||
|
|
||||||
@ -15,7 +17,7 @@ export default async function (call: ApiCall<ReqChangePos, ResChangePos>) {
|
|||||||
let posArr = Object.keys(heroPos).filter(pos => call.conn.gud.lv >= G.gc.herocom.szHeroLimit[pos]);
|
let posArr = Object.keys(heroPos).filter(pos => call.conn.gud.lv >= G.gc.herocom.szHeroLimit[pos]);
|
||||||
let idArr = Object.values(heroPos).filter(v => v != '');
|
let idArr = Object.values(heroPos).filter(v => v != '');
|
||||||
|
|
||||||
if (call.conn.gud.helpHeros.find(v => v._id == call.req.id)) return call.error('', { code: -1 });
|
if (call.conn.gud.helpHeros.find(v => v._id == call.req.id)) return call.error('', {code: -1});
|
||||||
if (idArr.includes(call.req.id)) return call.error(globalThis.lng.hero_2);
|
if (idArr.includes(call.req.id)) return call.error(globalThis.lng.hero_2);
|
||||||
if (call.req.pos && !posArr.includes(call.req.pos)) return call.error(globalThis.lng.hero_3);
|
if (call.req.pos && !posArr.includes(call.req.pos)) return call.error(globalThis.lng.hero_3);
|
||||||
|
|
||||||
@ -42,6 +44,7 @@ export default async function (call: ApiCall<ReqChangePos, ResChangePos>) {
|
|||||||
}
|
}
|
||||||
if (fightHeros.includes(hero.heroId.toString())) return call.errorCode(-2);
|
if (fightHeros.includes(hero.heroId.toString())) return call.errorCode(-2);
|
||||||
|
|
||||||
|
// todo 替换逻辑有问题
|
||||||
for (let type in matrixPos) {
|
for (let type in matrixPos) {
|
||||||
for (let pos in matrixPos[type]) {
|
for (let pos in matrixPos[type]) {
|
||||||
if (pos == call.req.pos) {
|
if (pos == call.req.pos) {
|
||||||
@ -56,7 +59,10 @@ export default async function (call: ApiCall<ReqChangePos, ResChangePos>) {
|
|||||||
|
|
||||||
Wjjl.setVal(call.uid, 'fight_hero_colour_4', fightHeros.map(id => G.gc.hero[id].colour).filter(c => c >= 4).length);
|
Wjjl.setVal(call.uid, 'fight_hero_colour_4', fightHeros.map(id => G.gc.hero[id].colour).filter(c => c >= 4).length);
|
||||||
|
|
||||||
await PlayerFun.addAttr(call, { heroPos: heroPos, fightHeros: fightHeros, matrixPos: matrixPos });
|
let checkMatrixPos = HeroFun.checkMatrixPosAndChange(call, heroPos, matrixPos)
|
||||||
|
await PlayerFun.addAttr(call, {heroPos: heroPos, fightHeros: fightHeros, matrixPos: checkMatrixPos});
|
||||||
call.succ(heroPos);
|
call.succ(heroPos);
|
||||||
|
|
||||||
call.conn.refreshPower();
|
call.conn.refreshPower();
|
||||||
|
kfjsFun.setHeroLvCount(call)
|
||||||
}
|
}
|
@ -7,8 +7,10 @@ import { HeroShared } from '../../shared/public/hero';
|
|||||||
import { event_cszl_record } from '../event/chuanshuozhilu/ApiOpen';
|
import { event_cszl_record } from '../event/chuanshuozhilu/ApiOpen';
|
||||||
import { HongDianChange } from "../hongdian/fun";
|
import { HongDianChange } from "../hongdian/fun";
|
||||||
import {PublicShared} from "../../shared/public/public";
|
import {PublicShared} from "../../shared/public/public";
|
||||||
|
import kfjsFun from "../../public/kaifujingsai";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqLvUp, ResLvUp, ServiceType>) {
|
export default async function (call: ApiCall<ReqLvUp, ResLvUp, ServiceType>) {
|
||||||
|
|
||||||
let hero = await G.redis.get('hero', call.uid, call.req.id);
|
let hero = await G.redis.get('hero', call.uid, call.req.id);
|
||||||
let up = call.req.up || 1
|
let up = call.req.up || 1
|
||||||
if (!hero) return call.errorCode(-1);
|
if (!hero) return call.errorCode(-1);
|
||||||
@ -31,6 +33,8 @@ export default async function (call: ApiCall<ReqLvUp, ResLvUp, ServiceType>) {
|
|||||||
HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']);
|
HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']);
|
||||||
|
|
||||||
call.succ({ lv: hero.lv });
|
call.succ({ lv: hero.lv });
|
||||||
|
|
||||||
|
kfjsFun.setHeroLvCount(call)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,11 +14,12 @@ import { PublicShared } from '../../shared/public/public';
|
|||||||
import { getShouChongRedPoint } from '../event/shouchong/ApiReceive';
|
import { getShouChongRedPoint } from '../event/shouchong/ApiReceive';
|
||||||
import { md_redPoint } from '../gongyu/mingdao/ApiOpen';
|
import { md_redPoint } from '../gongyu/mingdao/ApiOpen';
|
||||||
import { HongDianFun, HuoDongHongDianFun } from "./fun";
|
import { HongDianFun, HuoDongHongDianFun } from "./fun";
|
||||||
|
import { FunWeiXiuChang } from "../../public/weixiuchang";
|
||||||
|
|
||||||
const defaultKeys: hongdianKey[] = ['jiuba', 'jiaotang', 'shouchong', 'clslhd', 'dixiaqianzhuanghd', 'gonghuihd', 'hbzbhd', 'jjchd', 'taskhd',
|
const defaultKeys: hongdianKey[] = ['jiuba', 'jiaotang', 'shouchong', 'clslhd', 'dixiaqianzhuanghd', 'gonghuihd', 'hbzbhd', 'jjchd', 'taskhd',
|
||||||
'xstaskhd', 'lingzhulaixihd', 'dxlthd', 'wzcjhd', 'slzdhd', 'qjzzdhd', 'kuangdonghd', 'qiandaohd', 'kaifukuanghuanhd', 'jijinhd', 'zhuishalinghd',
|
'xstaskhd', 'lingzhulaixihd', 'dxlthd', 'wzcjhd', 'slzdhd', 'qjzzdhd', 'kuangdonghd', 'qiandaohd', 'kaifukuanghuanhd', 'jijinhd', 'zhuishalinghd',
|
||||||
'yibaichouhd', 'huobanzhaomuhd', 'qirileichonghd', 'jierihd', 'kbzzhd', 'wzryhd', 'yuedujijin', 'mingdao', 'patahd',
|
'yibaichouhd', 'huobanzhaomuhd', 'qirileichonghd', 'jierihd', 'kbzzhd', 'wzryhd', 'yuedujijin', 'mingdao', 'patahd',
|
||||||
'heishihd', 'huodonghd', 'renown'];
|
'heishihd', 'huodonghd', 'renown', 'weixiuchang', 'kaifujingsai'];
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGet, ResGet>) {
|
export default async function (call: ApiCall<ReqGet, ResGet>) {
|
||||||
|
|
||||||
@ -130,6 +131,10 @@ export default async function (call: ApiCall<ReqGet, ResGet>) {
|
|||||||
case 'mingdao':
|
case 'mingdao':
|
||||||
res[key] = await md_redPoint(call.conn);
|
res[key] = await md_redPoint(call.conn);
|
||||||
break;
|
break;
|
||||||
|
case 'weixiuchang':
|
||||||
|
// 维修厂
|
||||||
|
res[key] = await FunWeiXiuChang.getHongDian(call)
|
||||||
|
break;
|
||||||
// case 'heishiMrjx':
|
// case 'heishiMrjx':
|
||||||
// // 黑市-每日精选--集合到heishihd查询,待删除,需前端配合
|
// // 黑市-每日精选--集合到heishihd查询,待删除,需前端配合
|
||||||
// res[key] = await HuoDongHongDianFun.heiShiHongDian(call);
|
// res[key] = await HuoDongHongDianFun.heiShiHongDian(call);
|
||||||
@ -152,6 +157,9 @@ export default async function (call: ApiCall<ReqGet, ResGet>) {
|
|||||||
case 'renown':
|
case 'renown':
|
||||||
res[key] = await HongDianFun.renownHongDian(call);
|
res[key] = await HongDianFun.renownHongDian(call);
|
||||||
break;
|
break;
|
||||||
|
case 'kaifujingsai':
|
||||||
|
res[key] = await HongDianFun.kaifujingsai(call);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,26 @@
|
|||||||
import { ApiCall } from 'tsrpc';
|
import {ApiCall} from 'tsrpc';
|
||||||
import { ReqAddHuoDong } from '../../monopoly/protocols/PtlAddHuoDong';
|
import {ReqAddHuoDong} from '../../monopoly/protocols/PtlAddHuoDong';
|
||||||
import { ActionLog } from '../../public/actionLog/actionLog';
|
import {ActionLog} from '../../public/actionLog/actionLog';
|
||||||
import { HuoDongFun } from '../../public/huodongfun';
|
import {HuoDongFun} from '../../public/huodongfun';
|
||||||
import { PataFun } from '../../public/pata';
|
import {PataFun} from '../../public/pata';
|
||||||
import { PayFun } from '../../public/pay';
|
import {PayFun} from '../../public/pay';
|
||||||
import { ZhanLingTasks } from '../../public/zhanling';
|
import {ZhanLingTasks} from '../../public/zhanling';
|
||||||
import { jijinType } from '../../shared/protocols/event/jijin/PtlOpen';
|
import {jijinType} from '../../shared/protocols/event/jijin/PtlOpen';
|
||||||
import { hongdianKey, hongdianVal } from '../../shared/protocols/hongdian/PtlGet';
|
import {hongdianKey, hongdianVal} from '../../shared/protocols/hongdian/PtlGet';
|
||||||
import { payLog } from '../../shared/protocols/pay/PtlGetList';
|
import {payLog} from '../../shared/protocols/pay/PtlGetList';
|
||||||
import { PublicShared } from '../../shared/public/public';
|
import {PublicShared} from '../../shared/public/public';
|
||||||
import { clslDb } from '../conglinshoulie/ApiOpen';
|
import {clslDb} from '../conglinshoulie/ApiOpen';
|
||||||
import { getVal } from '../event/jijin/ApiOpen';
|
import {getVal} from '../event/jijin/ApiOpen';
|
||||||
import { getTaskVal } from '../event/kaifukuanghuan/ApiOpen';
|
import {getTaskVal} from '../event/kaifukuanghuan/ApiOpen';
|
||||||
import { YangChengMuBiaofun } from '../event/yangchengmubiao/fun';
|
import {YangChengMuBiaofun} from '../event/yangchengmubiao/fun';
|
||||||
import { checkIsOpen } from '../hbzb/jfs/ApiOpen';
|
import {checkIsOpen} from '../hbzb/jfs/ApiOpen';
|
||||||
import { PlayerShared } from "../../shared/public/player";
|
import {PlayerShared} from "../../shared/public/player";
|
||||||
import { kbzzUserDb } from '../kbzz/ApiOpen';
|
import {kbzzUserDb} from '../kbzz/ApiOpen';
|
||||||
import {number} from "mathjs";
|
|
||||||
import {PlayerFun} from "../../public/player";
|
import {PlayerFun} from "../../public/player";
|
||||||
|
import kfjsFun from "../../public/kaifujingsai";
|
||||||
|
import {RankKfjs} from "../../public/rank/rank_kfjs";
|
||||||
|
import {ShopFun} from "../../public/shop";
|
||||||
|
import { Christmasfun } from '../event/christmas/fun';
|
||||||
|
|
||||||
export class HongDianFun {
|
export class HongDianFun {
|
||||||
/**黑榜争霸红点 */
|
/**黑榜争霸红点 */
|
||||||
@ -26,8 +29,15 @@ export class HongDianFun {
|
|||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
if (!checkIsOpen()) return _res;
|
if (!checkIsOpen()) return _res;
|
||||||
let data = await G.mongodb.cPlayerInfo('hbzb').findOne({ uid: call.uid, type: 'hbzb' });
|
let data = await G.mongodb.cPlayerInfo('hbzb').findOne({uid: call.uid, type: 'hbzb'});
|
||||||
let _mydata = (data && data.data && data.data.refreshTime >= PublicShared.getToDayZeroTime()) ? data.data : { winNum: 0, buyFightNum: 0, useFightNum: 0, refreshTime: G.time, winRecPrize: [], useRefreshNum: 0 };
|
let _mydata = (data && data.data && data.data.refreshTime >= PublicShared.getToDayZeroTime()) ? data.data : {
|
||||||
|
winNum: 0,
|
||||||
|
buyFightNum: 0,
|
||||||
|
useFightNum: 0,
|
||||||
|
refreshTime: G.time,
|
||||||
|
winRecPrize: [],
|
||||||
|
useRefreshNum: 0
|
||||||
|
};
|
||||||
if (_mydata.useFightNum < _mydata.buyFightNum + G.gc.hbzb.jfsFightNum) {
|
if (_mydata.useFightNum < _mydata.buyFightNum + G.gc.hbzb.jfsFightNum) {
|
||||||
_res.show = true;
|
_res.show = true;
|
||||||
}
|
}
|
||||||
@ -51,7 +61,7 @@ export class HongDianFun {
|
|||||||
};
|
};
|
||||||
let weekZeroTime = PublicShared.getToWeekMondayZeroTime();
|
let weekZeroTime = PublicShared.getToWeekMondayZeroTime();
|
||||||
if (G.time < weekZeroTime + G.gc.clsl_com.fightTime[0] || G.time > weekZeroTime + G.gc.clsl_com.fightTime[1]) return _res;
|
if (G.time < weekZeroTime + G.gc.clsl_com.fightTime[0] || G.time > weekZeroTime + G.gc.clsl_com.fightTime[1]) return _res;
|
||||||
let _mydata = await clslDb().findOne({ uid: call.uid, type: 'clsl' });
|
let _mydata = await clslDb().findOne({uid: call.uid, type: 'clsl'});
|
||||||
let useNum = _mydata?.useFightNum || 0;
|
let useNum = _mydata?.useFightNum || 0;
|
||||||
let buyNum = _mydata?.buyFightNum || 0;
|
let buyNum = _mydata?.buyFightNum || 0;
|
||||||
if (useNum < buyNum + G.gc.clsl_com.fightNum) {
|
if (useNum < buyNum + G.gc.clsl_com.fightNum) {
|
||||||
@ -83,13 +93,13 @@ export class HongDianFun {
|
|||||||
let _res = {
|
let _res = {
|
||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
let _mydata = await G.mongodb.cPlayerInfo('meirishilian').findOne({ uid: call.uid, type: 'meirishilian' });
|
let _mydata = await G.mongodb.cPlayerInfo('meirishilian').findOne({uid: call.uid, type: 'meirishilian'});
|
||||||
let types = ['money', 'exp', 'qhs'];
|
let types = ['money', 'exp', 'qhs'];
|
||||||
for(let type of types) {
|
for (let type of types) {
|
||||||
let buyNum = _mydata?.data?.numInfo?.[type]?.['0']?.buyFightNum || 0;
|
let buyNum = _mydata?.data?.numInfo?.[type]?.['0']?.buyFightNum || 0;
|
||||||
let useNum = _mydata?.data?.numInfo?.[type]?.['0']?.useFightNum || 0;
|
let useNum = _mydata?.data?.numInfo?.[type]?.['0']?.useFightNum || 0;
|
||||||
_res.show = useNum < buyNum + (PlayerShared.getMingDaoBuff(call.conn.gud, 'wzsj_free') || 0) + G.gc.meirishilian_com.fightNum
|
_res.show = useNum < buyNum + (PlayerShared.getMingDaoBuff(call.conn.gud, 'wzsj_free') || 0) + G.gc.meirishilian_com.fightNum
|
||||||
if(_res.show) break
|
if (_res.show) break
|
||||||
}
|
}
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
@ -99,9 +109,13 @@ export class HongDianFun {
|
|||||||
let _res = {
|
let _res = {
|
||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
let db = await G.mongodb.collection('slzdUser').findOne({ uid: call.uid });
|
let db = await G.mongodb.collection('slzdUser').findOne({uid: call.uid});
|
||||||
|
|
||||||
let _mydata = (db && db.data && db.data.refreshTime >= PublicShared.getToDayZeroTime()) ? db.data : { fightNum: G.gc.slzd.ctorFightNum, winNum: 0, winRec: [] };
|
let _mydata = (db && db.data && db.data.refreshTime >= PublicShared.getToDayZeroTime()) ? db.data : {
|
||||||
|
fightNum: G.gc.slzd.ctorFightNum,
|
||||||
|
winNum: 0,
|
||||||
|
winRec: []
|
||||||
|
};
|
||||||
if (_mydata.fightNum >= 1) {
|
if (_mydata.fightNum >= 1) {
|
||||||
_res.show = true;
|
_res.show = true;
|
||||||
}
|
}
|
||||||
@ -125,11 +139,15 @@ export class HongDianFun {
|
|||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
return _res
|
return _res
|
||||||
let data = await G.mongodb.collection('scheduler').findOne({ type: 'qjzzd' });
|
let data = await G.mongodb.collection('scheduler').findOne({type: 'qjzzd'});
|
||||||
if (!data) return _res; // 功能未开放
|
if (!data) return _res; // 功能未开放
|
||||||
let db = await G.mongodb.cPlayerInfo('qjzzd').findOne({ uid: call.uid, type: 'qjzzd' });
|
let db = await G.mongodb.cPlayerInfo('qjzzd').findOne({uid: call.uid, type: 'qjzzd'});
|
||||||
|
|
||||||
let myData = (db && db.refreshTime >= data.lastRunTime) ? db : { refreshTime: data.lastRunTime, useFightNum: 0, maxDps: 0 };
|
let myData = (db && db.refreshTime >= data.lastRunTime) ? db : {
|
||||||
|
refreshTime: data.lastRunTime,
|
||||||
|
useFightNum: 0,
|
||||||
|
maxDps: 0
|
||||||
|
};
|
||||||
if (myData.useFightNum < G.gc.qjzzd.fightNum) {
|
if (myData.useFightNum < G.gc.qjzzd.fightNum) {
|
||||||
_res.show = true;
|
_res.show = true;
|
||||||
}
|
}
|
||||||
@ -144,15 +162,20 @@ export class HongDianFun {
|
|||||||
let second = G.time - PublicShared.getToWeekMondayZeroTime();
|
let second = G.time - PublicShared.getToWeekMondayZeroTime();
|
||||||
if (second >= G.gc.kbzz.time.apply[0] && second < G.gc.kbzz.time.apply[1]) {
|
if (second >= G.gc.kbzz.time.apply[0] && second < G.gc.kbzz.time.apply[1]) {
|
||||||
// 报名时间
|
// 报名时间
|
||||||
let state = await G.mongodb.cPlayerInfo('kbzzApply').findOne({ uid: call.uid, type: 'kbzzApply' });
|
let state = await G.mongodb.cPlayerInfo('kbzzApply').findOne({uid: call.uid, type: 'kbzzApply'});
|
||||||
let apply = state?.apply || false;
|
let apply = state?.apply || false;
|
||||||
if (!apply) {
|
if (!apply) {
|
||||||
_res.show = true;
|
_res.show = true;
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let dbData = await kbzzUserDb().findOne({ uid: call.uid, type: 'kbzzUser' });
|
let dbData = await kbzzUserDb().findOne({uid: call.uid, type: 'kbzzUser'});
|
||||||
let myData = dbData ? dbData : { score: G.gc.kbzz.playerScore, recScorePrize: [], toDayScore: 0, fightNum: G.gc.kbzz.fightNum };
|
let myData = dbData ? dbData : {
|
||||||
|
score: G.gc.kbzz.playerScore,
|
||||||
|
recScorePrize: [],
|
||||||
|
toDayScore: 0,
|
||||||
|
fightNum: G.gc.kbzz.fightNum
|
||||||
|
};
|
||||||
let conf = G.gc.kbzz.scorePrize;
|
let conf = G.gc.kbzz.scorePrize;
|
||||||
for (let index = 0; index < conf.length; index++) {
|
for (let index = 0; index < conf.length; index++) {
|
||||||
const element = conf[index];
|
const element = conf[index];
|
||||||
@ -200,22 +223,25 @@ export class HongDianFun {
|
|||||||
_res.show = _res.show || _res.val.saodang.show
|
_res.show = _res.show || _res.val.saodang.show
|
||||||
// 商店判断
|
// 商店判断
|
||||||
// 个人爬塔商店购买情况
|
// 个人爬塔商店购买情况
|
||||||
let shopData = await G.redis.get('shop', call.uid, '7'); // 商店编号7,未理清商店id存放的数据表,后续该出尽量改为数据库读取
|
// let shopData = await G.redis.get('shop', call.uid, '7'); // 商店编号7,未理清商店id存放的数据表,后续该出尽量改为数据库读取
|
||||||
if(shopData) {
|
|
||||||
let {buyNum, shopItems} = shopData
|
// 12.12策划确定爬塔id7的商店移除,此处商店不再需要红点
|
||||||
// 获取爬塔商店商品
|
// let shopData = await ShopFun.getShopData(call.uid, "7")
|
||||||
for(let index in shopItems) {
|
// if (shopData) {
|
||||||
let x = shopItems[index]
|
// let {buyNum, shopItems} = shopData
|
||||||
if(x.needZCCG > 0 && x.needZCCG < _myData.lv && (buyNum && !buyNum[index])) {
|
// // 获取爬塔商店商品
|
||||||
// 验证是否达到购买条件
|
// for (let index in shopItems) {
|
||||||
let isOk = await (await PlayerFun.checkNeedIsMeet(call, x.buyNeed, false)).isOk
|
// let x = shopItems[index]
|
||||||
if(isOk) {
|
// if (x.needZCCG > 0 && x.needZCCG < _myData.lv && (buyNum && !buyNum[index])) {
|
||||||
_res.show = true
|
// // 验证是否达到购买条件
|
||||||
_res.val.shopItems.show = true
|
// let isOk = await (await PlayerFun.checkNeedIsMeet(call, x.buyNeed, false)).isOk
|
||||||
}
|
// if (isOk) {
|
||||||
}
|
// _res.show = true
|
||||||
}
|
// _res.val.shopItems.show = true
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +251,7 @@ export class HongDianFun {
|
|||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
let _conf = G.gc.mw_com.gift
|
let _conf = G.gc.mw_com.gift
|
||||||
let _myData = await G.mongodb.collection('playerInfo', 'juewei').findOne({ uid: call.conn.uid, type: 'juewei' });
|
let _myData = await G.mongodb.collection('playerInfo', 'juewei').findOne({uid: call.conn.uid, type: 'juewei'});
|
||||||
// 无数据,有免费礼包
|
// 无数据,有免费礼包
|
||||||
if (!_myData) {
|
if (!_myData) {
|
||||||
_res.show = true
|
_res.show = true
|
||||||
@ -254,6 +280,27 @@ export class HongDianFun {
|
|||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**开服竞赛 */
|
||||||
|
static async kaifujingsai(call: ApiCall): Promise<hongdianVal> {
|
||||||
|
let status = kfjsFun.getStatus()
|
||||||
|
// 超过活动显示时间后,不查询直接返回false
|
||||||
|
if (status.type < 1 && PublicShared.getOpenServerDay() > R.values(G.gc.kfcb_content).slice(-1)[0].showDay[1] + 1) return {show: false}
|
||||||
|
let data = await G.mongodb.cEvent('kaifujingsai').findOne({uid: call.uid, type: 'kaifujingsai'})
|
||||||
|
let canGet = {}
|
||||||
|
for (let i = 1; i <= 7; i++) {
|
||||||
|
let prize = kfjsFun.getStatus(i)
|
||||||
|
if (PublicShared.getOpenServerDay() <= prize.conf.showDay[1]) continue
|
||||||
|
let rankKfjs = new RankKfjs(i)
|
||||||
|
let myRank = await rankKfjs.getRankSortByOne(call.uid)
|
||||||
|
if (prize.type > 0 && !data?.record?.[i] && myRank >= 0) {
|
||||||
|
canGet[i] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (R.values(canGet).length == 0) return {show: false}
|
||||||
|
return {show: true, val: canGet}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -269,13 +316,13 @@ export class HuoDongHongDianFun {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let _hdList = []
|
let _hdList = []
|
||||||
for (let i = 0; i < 8; i++){
|
for (let i = 0; i < 8; i++) {
|
||||||
_hdList.push(...await HuoDongFun.gethdList(call, i + 1))
|
_hdList.push(...await HuoDongFun.gethdList(call, i + 1))
|
||||||
}
|
}
|
||||||
// let _hdList = await HuoDongFun.gethdList(call)
|
// let _hdList = await HuoDongFun.gethdList(call)
|
||||||
for (let index = 0; index < _hdList.length; index++) {
|
for (let index = 0; index < _hdList.length; index++) {
|
||||||
const element = _hdList[index];
|
const element = _hdList[index];
|
||||||
let ishd: hongdianVal = { show: false }
|
let ishd: hongdianVal = {show: false}
|
||||||
if (element.htype == 1) {
|
if (element.htype == 1) {
|
||||||
// 检测 htype 1 养成目标活动红点
|
// 检测 htype 1 养成目标活动红点
|
||||||
ishd = await this.yangchengmubiaoHongDian(call, element)
|
ishd = await this.yangchengmubiaoHongDian(call, element)
|
||||||
@ -325,7 +372,7 @@ export class HuoDongHongDianFun {
|
|||||||
let [isOpen, tips] = PublicShared.getOpenCond(call, "kaifukuanghuan")
|
let [isOpen, tips] = PublicShared.getOpenCond(call, "kaifukuanghuan")
|
||||||
if (!isOpen) return _res;
|
if (!isOpen) return _res;
|
||||||
|
|
||||||
let db = await G.mongodb.cEvent('kaifukuanghuan').findOne({ uid: call.uid, type: 'kaifukuanghuan' });
|
let db = await G.mongodb.cEvent('kaifukuanghuan').findOne({uid: call.uid, type: 'kaifukuanghuan'});
|
||||||
let data = db || {
|
let data = db || {
|
||||||
receiveLogin: [],
|
receiveLogin: [],
|
||||||
receiveBox: [],
|
receiveBox: [],
|
||||||
@ -386,13 +433,13 @@ export class HuoDongHongDianFun {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let jijintype: jijinType[] = ["dengjijijin", "guanqiajijin", "dayjijin", "tianshujijin"];
|
let jijintype: jijinType[] = ["dengjijijin", "guanqiajijin", "dayjijin", "tianshujijin"];
|
||||||
let logs = await PayFun.getPayLog(call.uid);
|
let logs = await PayFun.getPayLogs(call.uid);
|
||||||
for (let index = 0; index < jijintype.length; index++) {
|
for (let index = 0; index < jijintype.length; index++) {
|
||||||
const element = jijintype[index];
|
const element = jijintype[index];
|
||||||
let conf = G.gc.jijin[element];
|
let conf = G.gc.jijin[element];
|
||||||
|
|
||||||
// 相关数据
|
// 相关数据
|
||||||
let data = await G.mongodb.cEvent(element).findOne({ uid: call.uid, type: element });
|
let data = await G.mongodb.cEvent(element).findOne({uid: call.uid, type: element});
|
||||||
let rec = data?.rec || {}; // 领取数据
|
let rec = data?.rec || {}; // 领取数据
|
||||||
let val = await getVal(call, logs, element);
|
let val = await getVal(call, logs, element);
|
||||||
let payId = element == 'tianshujijin' ? 'zhongshenka' : element;
|
let payId = element == 'tianshujijin' ? 'zhongshenka' : element;
|
||||||
@ -433,8 +480,10 @@ export class HuoDongHongDianFun {
|
|||||||
|
|
||||||
// 任务奖励
|
// 任务奖励
|
||||||
let conf = G.gc.zhanling.task;
|
let conf = G.gc.zhanling.task;
|
||||||
let _mydata = await G.mongodb.cEvent('zhanling').findOne({ uid: call.uid, type: 'zhanling' });
|
let _mydata = await G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'});
|
||||||
let tasks = G.gc.zhanling.task.map(t => { return { type: t.type as 'day' | 'week' | 'round', key: t.taskId }; });
|
let tasks = G.gc.zhanling.task.map(t => {
|
||||||
|
return {type: t.type as 'day' | 'week' | 'round', key: t.taskId};
|
||||||
|
});
|
||||||
let taskFinished = await ZhanLingTasks.getLog(call.uid, tasks);
|
let taskFinished = await ZhanLingTasks.getLog(call.uid, tasks);
|
||||||
for (let index = 0; index < conf.length; index++) {
|
for (let index = 0; index < conf.length; index++) {
|
||||||
const element = conf[index];
|
const element = conf[index];
|
||||||
@ -482,7 +531,7 @@ export class HuoDongHongDianFun {
|
|||||||
let _con = hdCon.data.arr;
|
let _con = hdCon.data.arr;
|
||||||
let day = await ActionLog.getRetainLog(call.uid, `login_day_qiridenglu_${hdCon.hdid}`);
|
let day = await ActionLog.getRetainLog(call.uid, `login_day_qiridenglu_${hdCon.hdid}`);
|
||||||
let _dbType: `qiridenglu${number}` = `qiridenglu${hdCon.hdid}`
|
let _dbType: `qiridenglu${number}` = `qiridenglu${hdCon.hdid}`
|
||||||
let _mydata = await G.mongodb.cEvent(_dbType).findOne({ uid: call.uid, type: _dbType });
|
let _mydata = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType});
|
||||||
for (let index = 0; index < _con.length; index++) {
|
for (let index = 0; index < _con.length; index++) {
|
||||||
const element = _con[index];
|
const element = _con[index];
|
||||||
if (element.day > day) continue;
|
if (element.day > day) continue;
|
||||||
@ -516,7 +565,7 @@ export class HuoDongHongDianFun {
|
|||||||
|
|
||||||
let _con = G.gc.yibaichou;
|
let _con = G.gc.yibaichou;
|
||||||
let _type = ['online', 'login'];
|
let _type = ['online', 'login'];
|
||||||
let _mydata = await G.mongodb.cEvent('yibaichou').findOne({ uid: call.uid, type: 'yibaichou' });
|
let _mydata = await G.mongodb.cEvent('yibaichou').findOne({uid: call.uid, type: 'yibaichou'});
|
||||||
for (let index = 0; index < _type.length; index++) {
|
for (let index = 0; index < _type.length; index++) {
|
||||||
const element = _type[index];
|
const element = _type[index];
|
||||||
|
|
||||||
@ -542,7 +591,7 @@ export class HuoDongHongDianFun {
|
|||||||
if (!isOpen) return _res;
|
if (!isOpen) return _res;
|
||||||
|
|
||||||
let _con = G.gc.huobanzhaomu;
|
let _con = G.gc.huobanzhaomu;
|
||||||
let _mydata = await G.mongodb.cEvent('huobanzhaomu').findOne({ uid: call.uid, type: 'huobanzhaomu' });
|
let _mydata = await G.mongodb.cEvent('huobanzhaomu').findOne({uid: call.uid, type: 'huobanzhaomu'});
|
||||||
for (let index = 0; index < _con.length; index++) {
|
for (let index = 0; index < _con.length; index++) {
|
||||||
const element = _con[index];
|
const element = _con[index];
|
||||||
if (_mydata?.rec.includes(index)) continue; // 已领取
|
if (_mydata?.rec.includes(index)) continue; // 已领取
|
||||||
@ -561,8 +610,8 @@ export class HuoDongHongDianFun {
|
|||||||
};
|
};
|
||||||
let _dbType: `leijichongzhi${number}` = `leijichongzhi${hdCon.hdid}`
|
let _dbType: `leijichongzhi${number}` = `leijichongzhi${hdCon.hdid}`
|
||||||
let _con = hdCon.data.tasks;
|
let _con = hdCon.data.tasks;
|
||||||
let db = await G.mongodb.cEvent(_dbType).findOne({ uid: call.uid, type: _dbType });
|
let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType});
|
||||||
let _mydata = db || { sTime: PublicShared.getToDayZeroTime(G.time), recIndex: [] };
|
let _mydata = db || {sTime: PublicShared.getToDayZeroTime(G.time), recIndex: []};
|
||||||
let payNum = await PayFun.getPayDaysAllPayNum(call.uid, hdCon.stime, hdCon.rtime);
|
let payNum = await PayFun.getPayDaysAllPayNum(call.uid, hdCon.stime, hdCon.rtime);
|
||||||
for (let index = 0; index < _con.length; index++) {
|
for (let index = 0; index < _con.length; index++) {
|
||||||
const element = _con[index];
|
const element = _con[index];
|
||||||
@ -579,8 +628,8 @@ export class HuoDongHongDianFun {
|
|||||||
let _res: hongdianVal = {
|
let _res: hongdianVal = {
|
||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
let db = await G.mongodb.cEvent('qirichongzhi').findOne({ uid: call.uid, type: 'qirichongzhi' });
|
let db = await G.mongodb.cEvent('qirichongzhi').findOne({uid: call.uid, type: 'qirichongzhi'});
|
||||||
let _mydata = db || { round: 0, sTime: PublicShared.getToDayZeroTime(G.time), recIndexs: [] };
|
let _mydata = db || {round: 0, sTime: PublicShared.getToDayZeroTime(G.time), recIndexs: []};
|
||||||
let _con = G.gc.qirichongzhi[_mydata.round];
|
let _con = G.gc.qirichongzhi[_mydata.round];
|
||||||
let finished = await PayFun.getPayDaysAllPayNum(call.uid, _mydata.sTime, _mydata.sTime + G.gc.qirichongzhi[_mydata.round].time);
|
let finished = await PayFun.getPayDaysAllPayNum(call.uid, _mydata.sTime, _mydata.sTime + G.gc.qirichongzhi[_mydata.round].time);
|
||||||
for (let index = 0; index < _con.tasks.length; index++) {
|
for (let index = 0; index < _con.tasks.length; index++) {
|
||||||
@ -612,8 +661,8 @@ export class HuoDongHongDianFun {
|
|||||||
let _res: hongdianVal = {
|
let _res: hongdianVal = {
|
||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
let db = await G.mongodb.cEvent('jierihuodong').findOne({ uid: call.uid, type: 'jierihuodong' });
|
let db = await G.mongodb.cEvent('jierihuodong').findOne({uid: call.uid, type: 'jierihuodong'});
|
||||||
let _mydata = db || { refreshTime: G.time, recTask: [], recLogin: [] };
|
let _mydata = db || {refreshTime: G.time, recTask: [], recLogin: []};
|
||||||
let _types = ['login', 'task'];
|
let _types = ['login', 'task'];
|
||||||
let finish = call.conn.gud.loginDays;
|
let finish = call.conn.gud.loginDays;
|
||||||
for (let index = 0; index < _types.length; index++) {
|
for (let index = 0; index < _types.length; index++) {
|
||||||
@ -629,6 +678,67 @@ export class HuoDongHongDianFun {
|
|||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**圣诞节活动红点 */
|
||||||
|
static async christmasHongDian(call: ApiCall, hdCon: ReqAddHuoDong) {
|
||||||
|
let _res: hongdianVal = {
|
||||||
|
show: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
let _hdCon = hdCon.data;
|
||||||
|
let stime = hdCon.stime
|
||||||
|
let _mydata = await Christmasfun.getMyData(call, hdCon.hdid);
|
||||||
|
let _tasks = hdCon.data.task; // 所有任务 taskid 为key
|
||||||
|
|
||||||
|
for (let indextask = 0; indextask < Object.keys(_tasks).length; indextask++) {
|
||||||
|
const elementtask = Object.keys(_tasks)[indextask];
|
||||||
|
let _tmp = _tasks[elementtask];
|
||||||
|
if (_tmp.pval <= (_mydata.taskval[elementtask] || 0) && !_mydata.taskfinsih.includes(elementtask)) {
|
||||||
|
// 任务完成且没有领取
|
||||||
|
_res.show = true;
|
||||||
|
return _res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let libaos = _hdCon.libao
|
||||||
|
for (let indexlibao = 0; indexlibao < Object.keys(libaos).length; indexlibao++) {
|
||||||
|
const elementlibao = Object.keys(libaos)[indexlibao];
|
||||||
|
let _tmp = _tasks[elementlibao];
|
||||||
|
if (_tmp.payid) continue
|
||||||
|
let _buyNum = _mydata.libao[elementlibao] || 0
|
||||||
|
if (_buyNum < _tmp.buynum) {
|
||||||
|
_res.show = true;
|
||||||
|
return _res;
|
||||||
|
}}
|
||||||
|
let _diff = PublicShared.getDiff(stime)
|
||||||
|
// 循环判断是否有可以领取的
|
||||||
|
for(let i = 0; i < _diff; i++) {
|
||||||
|
if (_mydata.qiandao.includes(i)) continue
|
||||||
|
_res.show = true;
|
||||||
|
return _res;
|
||||||
|
}
|
||||||
|
let need = _hdCon.gameneed;
|
||||||
|
// 判断消耗是否满足
|
||||||
|
let meet = await PlayerFun.checkNeedIsMeet(call, need, false);
|
||||||
|
if (meet.isOk == true) {
|
||||||
|
_res.show = true;
|
||||||
|
return _res;
|
||||||
|
}
|
||||||
|
let zhanling = _hdCon.zhanling
|
||||||
|
for (let indexzhanling = 0; indexzhanling < zhanling.length; indexzhanling++){
|
||||||
|
if (!_mydata.pt.includes(indexzhanling)){
|
||||||
|
_res.show = true;
|
||||||
|
return _res;
|
||||||
|
}
|
||||||
|
if (_mydata.pay && !_mydata.gj.includes(indexzhanling)){
|
||||||
|
_res.show = true;
|
||||||
|
return _res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**养成目标红点 */
|
/**养成目标红点 */
|
||||||
static async yangchengmubiaoHongDian(call: ApiCall, hdCon: ReqAddHuoDong) {
|
static async yangchengmubiaoHongDian(call: ApiCall, hdCon: ReqAddHuoDong) {
|
||||||
let _res: hongdianVal = {
|
let _res: hongdianVal = {
|
||||||
@ -656,7 +766,7 @@ export class HuoDongHongDianFun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_ishd != 1) {
|
if (_ishd != 1) {
|
||||||
let _gift = _hdCon.gift.filter(l => !l.payId && l.need.length <= 0);
|
let _gift = _hdCon.gift.filter(l => (!l.payId && l.need.length <= 0) || l.free);
|
||||||
for (let indexgift = 0; indexgift < _gift.length; indexgift++) {
|
for (let indexgift = 0; indexgift < _gift.length; indexgift++) {
|
||||||
const elementgift = _gift[indexgift];
|
const elementgift = _gift[indexgift];
|
||||||
let buyNum = _mydata.record?.[indexgift] || 0;
|
let buyNum = _mydata.record?.[indexgift] || 0;
|
||||||
@ -676,13 +786,13 @@ export class HuoDongHongDianFun {
|
|||||||
let data = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType})
|
let data = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType})
|
||||||
// 循环活动商店,判断免费与领取
|
// 循环活动商店,判断免费与领取
|
||||||
let confEvent = Object.keys(hdCon.data.event).filter(k => Array.isArray(hdCon.data.event[k]))
|
let confEvent = Object.keys(hdCon.data.event).filter(k => Array.isArray(hdCon.data.event[k]))
|
||||||
for(let key of confEvent){
|
for (let key of confEvent) {
|
||||||
let item = hdCon.data.event[key]
|
let item = hdCon.data.event[key]
|
||||||
for(let i in item) {
|
for (let i in item) {
|
||||||
if(item[i].free && !(data && data.record && data.record[key] && data.record[key][i])) return {show: true}
|
if (item[i].free && !(data && data.record && data.record[key] && data.record[key][i])) return {show: true}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { show: false };
|
return {show: false};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**传说之路 */
|
/**传说之路 */
|
||||||
@ -690,27 +800,27 @@ export class HuoDongHongDianFun {
|
|||||||
let _dbType: `chuanshuozhilu${number}` = `chuanshuozhilu${hdCon.hdid}`
|
let _dbType: `chuanshuozhilu${number}` = `chuanshuozhilu${hdCon.hdid}`
|
||||||
|
|
||||||
let task = hdCon.data
|
let task = hdCon.data
|
||||||
let db = await G.mongodb.cEvent(_dbType).findOne({ uid: call.uid, type: _dbType });
|
let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType});
|
||||||
let info: Partial<typeof db.info['']> = db?.info?.[task.hid] || {};
|
let info: Partial<typeof db.info['']> = db?.info?.[task.hid] || {};
|
||||||
|
|
||||||
for (let conf of task.task) {
|
for (let conf of task.task) {
|
||||||
if (info[conf.type] >= conf.total && !(info.rec || []).includes(conf.idx)) return { show: true };
|
if (info[conf.type] >= conf.total && !(info.rec || []).includes(conf.idx)) return {show: true};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.rec?.length >= task.box.total && !info.box) return { show: true };
|
if (info.rec?.length >= task.box.total && !info.box) return {show: true};
|
||||||
|
|
||||||
return { show: false };
|
return {show: false};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**自选礼包红点 */
|
/**自选礼包红点 */
|
||||||
static async zixuanlibaoHongDian(call: ApiCall, hdCon: ReqAddHuoDong): Promise<hongdianVal> {
|
static async zixuanlibaoHongDian(call: ApiCall, hdCon: ReqAddHuoDong): Promise<hongdianVal> {
|
||||||
let _dbType: `zixuanlibao${number}` = `zixuanlibao${hdCon.hdid}`
|
let _dbType: `zixuanlibao${number}` = `zixuanlibao${hdCon.hdid}`
|
||||||
let db = await G.mongodb.cEvent(_dbType).findOne({ uid: call.uid, type: _dbType });
|
let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType});
|
||||||
if (!db?.record?.[0]){
|
if (!db?.record?.[0]) {
|
||||||
return { show: true }
|
return {show: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { show: false };
|
return {show: false};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**月度基金 */
|
/**月度基金 */
|
||||||
@ -724,20 +834,23 @@ export class HuoDongHongDianFun {
|
|||||||
if (logs.length > 0) pays++;
|
if (logs.length > 0) pays++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pays < 1) return { show: false };
|
if (pays < 1) return {show: false};
|
||||||
|
|
||||||
for (let conf of G.gc.yuedujijin) {
|
for (let conf of G.gc.yuedujijin) {
|
||||||
let id = conf.payId;
|
let id = conf.payId;
|
||||||
let logs = obj[conf.payId];
|
let logs = obj[conf.payId];
|
||||||
if (logs.length < 1) continue;
|
if (logs.length < 1) continue;
|
||||||
let db = await G.mongodb.cEvent(id as `${number}jijin`).findOne({ uid: call.uid, type: id as `${number}jijin` });
|
let db = await G.mongodb.cEvent(id as `${number}jijin`).findOne({
|
||||||
|
uid: call.uid,
|
||||||
|
type: id as `${number}jijin`
|
||||||
|
});
|
||||||
let rec = db?.rec || [];
|
let rec = db?.rec || [];
|
||||||
let days = db?.days || 0;
|
let days = db?.days || 0;
|
||||||
let round = db?.round || 0;
|
let round = db?.round || 0;
|
||||||
if (rec.length < days + 1 && rec.length < conf.prize.length * (round + 1)) return { show: true };
|
if (rec.length < days + 1 && rec.length < conf.prize.length * (round + 1)) return {show: true};
|
||||||
}
|
}
|
||||||
|
|
||||||
return { show: false };
|
return {show: false};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 黑市活动 */
|
/** 黑市活动 */
|
||||||
@ -764,8 +877,8 @@ export class HuoDongHongDianFun {
|
|||||||
show: false,
|
show: false,
|
||||||
val: {stask: []}
|
val: {stask: []}
|
||||||
};
|
};
|
||||||
let db = await G.mongodb.cEvent('136Gift').findOne({ uid: call.uid, type: '136Gift' });
|
let db = await G.mongodb.cEvent('136Gift').findOne({uid: call.uid, type: '136Gift'});
|
||||||
let payData = await PayFun.getPayLog(call.uid)
|
let payData = await PayFun.getPayLogs(call.uid)
|
||||||
let payLen = (payData[payKey] || []).length
|
let payLen = (payData[payKey] || []).length
|
||||||
let isBuy = !(!payLen || payData[payKey][payLen - 1].eTime < G.time)
|
let isBuy = !(!payLen || payData[payKey][payLen - 1].eTime < G.time)
|
||||||
let _myData = (db && db.refreshTime >= PublicShared.getToDayZeroTime() && db.recIndex) ? db.recIndex : [];
|
let _myData = (db && db.refreshTime >= PublicShared.getToDayZeroTime() && db.recIndex) ? db.recIndex : [];
|
||||||
@ -780,19 +893,20 @@ export class HuoDongHongDianFun {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_res.val.stask.push(index)
|
_res.val.stask.push(index)
|
||||||
if(index > 1 && !_res.val.stask.includes(0)) _res.val.stask.push(0)
|
if (index > 1 && !_res.val.stask.includes(0)) _res.val.stask.push(0)
|
||||||
_res.show = true
|
_res.show = true
|
||||||
}
|
}
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**黑市 积天豪礼 */
|
/**黑市 积天豪礼 */
|
||||||
static async heiShiLCHongDian(call: ApiCall): Promise<hongdianVal> {
|
static async heiShiLCHongDian(call: ApiCall): Promise<hongdianVal> {
|
||||||
let _res: hongdianVal = {
|
let _res: hongdianVal = {
|
||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
let db = await G.mongodb.cEvent('15leichong').findOne({ uid: call.uid, type: '15leichong' });
|
let db = await G.mongodb.cEvent('15leichong').findOne({uid: call.uid, type: '15leichong'});
|
||||||
|
|
||||||
if(!db) return _res;
|
if (!db) return _res;
|
||||||
|
|
||||||
let _con = G.gc.shiwuleichong.data[db.index];
|
let _con = G.gc.shiwuleichong.data[db.index];
|
||||||
let payDay = await PayFun.getPayDaysBuyPayNum(call.uid, db.sTime, db.sTime + _con.time, G.gc.shiwuleichong.dayPayNeed);
|
let payDay = await PayFun.getPayDaysBuyPayNum(call.uid, db.sTime, db.sTime + _con.time, G.gc.shiwuleichong.dayPayNeed);
|
||||||
@ -814,8 +928,8 @@ export class HuoDongHongDianFun {
|
|||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
// 等级不满足,上锁,不查询红点。
|
// 等级不满足,上锁,不查询红点。
|
||||||
if(call.conn.gud.lv < openCondConf.display.lv) return _res
|
if (call.conn.gud.lv < openCondConf.display.lv) return _res
|
||||||
let db = await G.mongodb.cEvent('niudanji').findOne({ uid: call.uid, type: 'niudanji' });
|
let db = await G.mongodb.cEvent('niudanji').findOne({uid: call.uid, type: 'niudanji'});
|
||||||
let useNum = db?.useNum || 0
|
let useNum = db?.useNum || 0
|
||||||
let hasNum = Math.floor(call.conn.gud.payExp / G.gc.niudanji.pay2num)
|
let hasNum = Math.floor(call.conn.gud.payExp / G.gc.niudanji.pay2num)
|
||||||
_res.show = useNum < hasNum
|
_res.show = useNum < hasNum
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user