@sjtdev/koishi-plugin-dota2tracker 1.1.2-beta.5 → 1.1.2-hotfix

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -536,7 +536,7 @@ function getFormattedMatchData(match) {
536
536
  match[player.team].experience += Math.floor(player.experiencePerMinute / 60 * match.durationSeconds);
537
537
  player.titles = [];
538
538
  player.mvpScore = // 计算MVP分数
539
- player.kills * 5 + player.assists * 3 + player.stats.heroDamageReport.dealtTotal.stunDuration / 100 * 0.1 + (player.stats.heroDamageReport.dealtTotal.slowDuration + player.stats.heroDamageReport.dealtTotal.disableDuration) / 100 * 0.05 + player.heroDamage * 1e-3 + player.towerDamage * 0.01 + player.heroHealing * 2e-3 + player.imp * 0.25;
539
+ player.kills * 5 + player.assists * 3 + player.stats.heroDamageReport.dealtTotal.stunDuration / 100 * 0.1 + player.stats.heroDamageReport.dealtTotal.disableDuration / 100 * 0.05 + player.stats.heroDamageReport.dealtTotal.slowDuration / 100 * 0.025 + player.heroDamage * 1e-3 + player.towerDamage * 0.01 + player.heroHealing * 2e-3 + player.imp * 0.25;
540
540
  player.order = heroOrderList[player.hero.id];
541
541
  if (player.partyId != null) {
542
542
  if (!match.party[player.partyId])
@@ -695,7 +695,7 @@ function getFormattedMatchData(match) {
695
695
  findMaxByProperty("networth").titles.push({ name: "富", color: "#FFD700" });
696
696
  findMaxByProperty("experiencePerMinute").titles.push({ name: "睿", color: "#8888FF" });
697
697
  match.players.reduce(
698
- (max, player) => player.stats.heroDamageReport.dealtTotal.stunDuration + player.stats.heroDamageReport.dealtTotal.disableDuration + player.stats.heroDamageReport.dealtTotal.slowDuration / 2 > max.stats.heroDamageReport.dealtTotal.stunDuration + max.stats.heroDamageReport.dealtTotal.disableDuration + max.stats.heroDamageReport.dealtTotal.slowDuration / 2 ? player : max
698
+ (max, player) => player.stats.heroDamageReport.dealtTotal.stunDuration + player.stats.heroDamageReport.dealtTotal.disableDuration / 2 + player.stats.heroDamageReport.dealtTotal.slowDuration / 4 > max.stats.heroDamageReport.dealtTotal.stunDuration + max.stats.heroDamageReport.dealtTotal.disableDuration / 2 + max.stats.heroDamageReport.dealtTotal.slowDuration / 4 ? player : max
699
699
  ).titles.push({ name: "控", color: "#FF00FF" });
700
700
  findMaxByProperty("heroDamage").titles.push({ name: "爆", color: "#CC0088" });
701
701
  findMaxByProperty("kills", "heroDamage").titles.push({ name: "破", color: "#DD0000" });
@@ -1170,7 +1170,6 @@ async function apply(ctx, config) {
1170
1170
  if (subscribedPlayers.length <= 20) {
1171
1171
  try {
1172
1172
  const memberList = await session.bot.getGuildMemberList(session.event.guild.id);
1173
- ctx.logger.info(JSON.stringify(memberList.data));
1174
1173
  let queryRes = await query(PLAYERS_INFO_WITH_10_MATCHES_FOR_GUILD(subscribedPlayers.map((player) => player.steamId)));
1175
1174
  if (queryRes.status == 200) {
1176
1175
  const users = subscribedPlayers.map((subscribedPlayer) => {
@@ -1178,12 +1177,11 @@ async function apply(ctx, config) {
1178
1177
  const queryMember = memberList.data.find((member) => member.user?.id == subscribedPlayer.userId);
1179
1178
  return { ...subscribedPlayer, ...queryPlayer, ...queryMember };
1180
1179
  });
1181
- console.log(users);
1182
1180
  session.send(await ctx.puppeteer.render(genImageHTML(users, "guild_member" /* GuildMember */, "guild_member" /* GuildMember */)));
1183
1181
  } else
1184
1182
  throw 0;
1185
1183
  } catch (error) {
1186
- console.error(error);
1184
+ ctx.logger.error(error);
1187
1185
  session.send("查询群友失败。");
1188
1186
  }
1189
1187
  }
@@ -1210,7 +1208,7 @@ async function apply(ctx, config) {
1210
1208
  session.send("比赛尚未解析,将在解析完成后发布。");
1211
1209
  }
1212
1210
  } catch (error) {
1213
- console.error(error);
1211
+ ctx.logger.error(error);
1214
1212
  session.send("获取比赛信息失败。");
1215
1213
  ctx.database.remove("dt_previous_query_results", { matchId: parseInt(matchId) });
1216
1214
  }
@@ -1309,9 +1307,10 @@ async function apply(ctx, config) {
1309
1307
  player.heroesPerformanceTop10 = playerExtra.heroesPerformance.slice(0, 10);
1310
1308
  } else
1311
1309
  throw 0;
1310
+ console.log(player);
1312
1311
  session.send(await ctx.puppeteer.render(genImageHTML(player, config.template_player, "player" /* Player */)));
1313
1312
  } catch (error) {
1314
- console.error(error);
1313
+ ctx.logger.error(error);
1315
1314
  session.send("获取玩家信息失败。");
1316
1315
  }
1317
1316
  }
@@ -1366,7 +1365,7 @@ async function apply(ctx, config) {
1366
1365
  } else
1367
1366
  throw 0;
1368
1367
  } catch (error) {
1369
- console.error(error);
1368
+ ctx.logger.error(error);
1370
1369
  session.send("获取数据失败");
1371
1370
  return;
1372
1371
  }
@@ -1417,7 +1416,7 @@ async function apply(ctx, config) {
1417
1416
  );
1418
1417
  }
1419
1418
  } catch (error) {
1420
- console.error(error);
1419
+ ctx.logger.error(error);
1421
1420
  session.send("获取数据失败");
1422
1421
  return;
1423
1422
  }
@@ -1521,7 +1520,7 @@ KDA:${((player.kills + player.assists) / (player.deaths || 1)).toFixed(2)} [${
1521
1520
  } else
1522
1521
  ctx.logger.info("比赛 %d 尚未解析完成,继续等待。", match.id);
1523
1522
  } catch (error) {
1524
- console.error(error);
1523
+ ctx.logger.error(error);
1525
1524
  ctx.database.remove("dt_previous_query_results", { matchId: pendingMatch.matchId });
1526
1525
  }
1527
1526
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sjtdev/koishi-plugin-dota2tracker",
3
3
  "description": "",
4
- "version": "1.1.2-beta.5",
4
+ "version": "1.1.2-hotfix",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -147,8 +147,8 @@
147
147
  </div>
148
148
  <div class="avatar steam">
149
149
  <p>${user.steamAccount.seasonLeaderboardRank??""}</p>
150
- <img class="rank" src="${utils.getImageUrl('star_' + player.rank.star)}" alt="" />
151
- <img class="rank" src="${utils.getImageUrl('medal_' +(player.inTop100??player.rank.medal))}" alt="" />
150
+ <img class="rank" src="${utils.getImageUrl('star_' + user.rank.star)}" alt="" />
151
+ <img class="rank" src="${utils.getImageUrl('medal_' +(user.inTop100??user.rank.medal))}" alt="" />
152
152
  <img class="avatar" src="${user.steamAccount.avatar}" alt="" />
153
153
  </div>
154
154
  </div>
@@ -395,7 +395,7 @@
395
395
  matchCount : currentPositionMatches.length,
396
396
  winCount : winCount,
397
397
  loseCount : currentPositionMatches.length - winCount,
398
- imp : Math.round(currentPositionMatches.reduce((acc,match)=>acc+match.players[0].imp,0)/currentPositionMatches.length)
398
+ imp : currentPositionMatches.length>0? Math.round(currentPositionMatches.reduce((acc,match)=>acc+match.players[0].imp,0)/currentPositionMatches.length):"-"
399
399
  })
400
400
  }
401
401
  const highestCountsPosition = {
@@ -475,7 +475,7 @@
475
475
  .map((position) => `
476
476
  <span><img src="${utils.getImageUrl(position.icon,ImageType.Items)}"></span>
477
477
  <span class="count">${position.matchCount}</span>
478
- <span class="win_rate">${((position.winCount / position.matchCount) * 100).toFixed(0)}%</span>
478
+ <span class="win_rate">${position.matchCount>0?(((position.winCount / position.matchCount) * 100).toFixed(0)):"-"}%</span>
479
479
  <span class="imp">${(position.imp > 0 ? "+" : "") + position.imp}</span>
480
480
  <span class="win" style="${position.winCount == 0 ? "visibility:hidden;" : ""}width: ${position.winCount * pixelOfPerMatchInPosition}px">${position.winCount}</span>
481
481
  <span class="lose" style="${position.matchCount - position.winCount == 0 ? "visibility:hidden;" : ""}width: ${(position.matchCount - position.winCount) * pixelOfPerMatchInPosition}px">${position.matchCount - position.winCount}</span>`).join("") %>
@@ -518,14 +518,14 @@
518
518
  <td><img alt="" src="${utils.getImageUrl(match.players[0].hero.shortName, ImageType.HeroIcons)}" /></td>
519
519
  <td style="line-height: 20px">
520
520
  <p>${((match.players[0].kills + match.players[0].assists) / Math.max(1, match.players[0].deaths)).toFixed(2)} (${(((match.players[0].kills + match.players[0].assists) /
521
- (match.players[0].isRadiant ? match.radiantKills.reduce((acc, cva) => acc + cva, 0) : match.direKills.reduce((acc, cva) => acc + cva, 0))) * 100).toFixed(0)}%)</p>
521
+ (match.players[0].isRadiant ? match.radiantKills?.reduce((acc, cva) => acc + cva, 0) : match.direKills?.reduce((acc, cva) => acc + cva, 0))) * 100)?.toFixed(0)}%)</p>
522
522
  <p>${match.players[0].kills}/${match.players[0].deaths}/${match.players[0].assists}</p>
523
523
  </td>
524
524
  <td><div class="player_lane ${match.laneResult}">${laneSVG[match.laneResult]}</div></td>
525
525
  <td style="line-height: 20px">${moment(new Date(match.startDateTime * 1000)).format("YYYY-MM-DD HH:mm:ss").slice(2)}</td>
526
526
  <td>${utils.sec2time(match.durationSeconds)}</td>
527
527
  <td>${(match.players[0].imp > 0 ? "+" : "") + match.players[0].imp}</td>
528
- <td><img class="medal" src="${utils.getImageUrl("medal_" + match.rank.toString().split("")[0])}" style="width: 100%" /></td>
528
+ <td><img class="medal" src="${utils.getImageUrl("medal_" + match.rank?.toString().split("")[0])}" style="width: 100%" /></td>
529
529
  </tr>`).join("")%>
530
530
  </tbody>
531
531
  </table>