feat: card in result view
This commit is contained in:
@@ -90,22 +90,21 @@ function stopLoading(loading) {
|
||||
loading['root'].removeChild(loading['element']);
|
||||
}
|
||||
|
||||
function scoreToString(score) {
|
||||
const scorePrint = (s1) => {
|
||||
switch (s1) {
|
||||
case -997:
|
||||
return i18next.t('disc.');
|
||||
case -998:
|
||||
return i18next.t('abs.');
|
||||
case -999:
|
||||
return i18next.t('for.');
|
||||
case -1000:
|
||||
return "";
|
||||
default:
|
||||
return String(s1);
|
||||
}
|
||||
function scorePrint(s1) {
|
||||
switch (s1) {
|
||||
case -997:
|
||||
return i18next.t('disc.');
|
||||
case -998:
|
||||
return i18next.t('abs.');
|
||||
case -999:
|
||||
return i18next.t('for.');
|
||||
case -1000:
|
||||
return "";
|
||||
default:
|
||||
return String(s1);
|
||||
}
|
||||
|
||||
}
|
||||
function scoreToString(score) {
|
||||
return score.map(o => scorePrint(o.at(0)) + "-" + scorePrint(o.at(1))).join(" | ");
|
||||
}
|
||||
|
||||
@@ -867,7 +866,7 @@ function drawGraph(root = []) {
|
||||
ctx.textBaseline = 'top';
|
||||
|
||||
for (let i = 0; i < scores.length; i++) {
|
||||
const score = scores[i].s1 + "-" + scores[i].s2;
|
||||
const score = scorePrint(scores[i].s1) + "-" + scorePrint(scores[i].s2);
|
||||
const div = (scores.length <= 2) ? 2 : (scores.length >= 4) ? 4 : 3;
|
||||
const text = ctx.measureText(score);
|
||||
let dx = (size * 2 - text.width) / 2;
|
||||
@@ -945,20 +944,6 @@ function drawGraph(root = []) {
|
||||
if (tree.right != null) drawNode(tree.right, px - size * 2 - size * 8, py + size * 2 * death);
|
||||
}
|
||||
|
||||
function win(scores) {
|
||||
let sum = 0;
|
||||
for (const score of scores) {
|
||||
if (score.s1 === -1000 || score.s2 === -1000)
|
||||
continue;
|
||||
|
||||
if (score.s1 > score.s2)
|
||||
sum++;
|
||||
else if (score.s1 < score.s2)
|
||||
sum--;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
let px = max_x;
|
||||
let py;
|
||||
let max_y
|
||||
@@ -971,7 +956,7 @@ function drawGraph(root = []) {
|
||||
for (const node of root) {
|
||||
let win_name = "";
|
||||
if (node.data.end) {
|
||||
if (win(node.data.scores) > 0)
|
||||
if (node.data.win > 0)
|
||||
win_name = (node.data.c1FullName === null) ? "???" : node.data.c1FullName;
|
||||
else
|
||||
win_name = (node.data.c2FullName === null) ? "???" : node.data.c2FullName;
|
||||
|
||||
Reference in New Issue
Block a user