Merge branch 'master' of http://git.kingsome.cn/node/card_svr
This commit is contained in:
commit
2c91b7d2a4
27
.vscode/launch.json
vendored
27
.vscode/launch.json
vendored
@ -5,11 +5,30 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "pwa-chrome",
|
||||
"name": "Local Svr",
|
||||
"request": "launch",
|
||||
"name": "Launch Chrome against localhost",
|
||||
"url": "http://localhost:8080",
|
||||
"webRoot": "${workspaceFolder}"
|
||||
"runtimeArgs": [
|
||||
"run-script",
|
||||
"debug"
|
||||
],
|
||||
"runtimeExecutable": "npm",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "pwa-node"
|
||||
},
|
||||
|
||||
{
|
||||
"address": "192.168.100.24",
|
||||
"localRoot": "${workspaceFolder}",
|
||||
"name": "192.168.100.24",
|
||||
"port": 9229,
|
||||
"remoteRoot": "Absolute path to the remote directory containing the program",
|
||||
"request": "attach",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "pwa-node"
|
||||
}
|
||||
]
|
||||
}
|
@ -5,7 +5,8 @@
|
||||
"main": "lib/index.js",
|
||||
"typings": "src/global.d.ts",
|
||||
"scripts": {
|
||||
"start": "ts-node-dev --files src/index.ts",
|
||||
"start": "ts-node-dev --inspect --files src/index.ts",
|
||||
"debug": "node --require ts-node/register --inspect src/index.ts",
|
||||
"loadtest": "colyseus-loadtest loadtest/example.ts --room my_room --numClients 3",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
|
@ -12,7 +12,7 @@ Object.defineProperties(Room.prototype, {
|
||||
},
|
||||
sSelectHero: {
|
||||
value: function (client: Client, data?: any) {
|
||||
this.send(client, 'select_hero_s2c', data);
|
||||
client.send('select_hero_s2c', data);
|
||||
},
|
||||
writable: true
|
||||
},
|
||||
@ -24,7 +24,7 @@ Object.defineProperties(Room.prototype, {
|
||||
},
|
||||
sDrawCard: {
|
||||
value: function (client: Client, data?: any) {
|
||||
this.send(client, 'draw_card_s2c', data);
|
||||
client.send('draw_card_s2c', data);
|
||||
}
|
||||
},
|
||||
bPartResult: {
|
||||
@ -41,7 +41,7 @@ Object.defineProperties(Room.prototype, {
|
||||
|
||||
sMsgQueue: {
|
||||
value: function (client:Client, datas?: PetInfoMsg) {
|
||||
this.broadcast("msg_queue_s2c", datas);
|
||||
client.send("msg_queue_s2c", datas);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -18,7 +18,7 @@ let gameUtil = {
|
||||
let countMap: Map<number, number> = new Map();
|
||||
let localId = 1;
|
||||
for (let [id, cfg] of numCfgMap) {
|
||||
for (let i = 0; i <= cfg.count; i++) {
|
||||
for (let i = 0; i < cfg.count; i++) {
|
||||
if (cfg.type_id == 1) {
|
||||
let effid = this.getRandomEffect(cfg.weightArr, effCfgMap, countMap);
|
||||
let card = new Card(localId ++, cfg.point, cfg.type_id, effid);
|
||||
@ -47,18 +47,27 @@ let gameUtil = {
|
||||
total += data[1];
|
||||
tmpArr.push([data[0], total]);
|
||||
}
|
||||
let num = Math.random() * total;
|
||||
let num = Math.random() * total; //TODO:: fix bug!
|
||||
let effid;
|
||||
for (let data of tmpArr) {
|
||||
if (data[1] >= num ) {
|
||||
let count = countMap.has(data[0]) ? countMap.get(data[0]) : 0;
|
||||
if (count <= effCfgMap.get(data[0]).count) {
|
||||
if (count < effCfgMap.get(data[0]).count) {
|
||||
effid = effCfgMap.get(data[0]).id;
|
||||
countMap.set(effid, count + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!effid) {
|
||||
for (let [id, count] of countMap) {
|
||||
if (count < effCfgMap.get(id).count) {
|
||||
effid = id;
|
||||
countMap.set(effid, count + 1);
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!effid) {
|
||||
console.warn('生成卡组时, 无法匹配效果卡, 请确认效果卡的最大数量是否等于点数卡总数')
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user