修正生成卡组某些卡无法匹配效果卡的bug, 增加vscode的launch配置

This commit is contained in:
zhl 2020-12-04 10:07:25 +08:00
parent 6f9082c3b2
commit 1f1a942eba
4 changed files with 28 additions and 14 deletions

19
.vscode/launch.json vendored
View File

@ -4,12 +4,17 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
{
"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"
}
]
}

View File

@ -5,7 +5,7 @@
"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",
"loadtest": "colyseus-loadtest loadtest/example.ts --room my_room --numClients 3",
"test": "echo \"Error: no test specified\" && exit 1"
},

View File

@ -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);
}
},

View File

@ -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('生成卡组时, 无法匹配效果卡, 请确认效果卡的最大数量是否等于点数卡总数')
}