From a2c60d9fb864bf3eb1fb5244d1682bbb147704f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E8=B0=B7=E5=89=91=E4=BB=99?= Date: Wed, 11 Aug 2021 22:39:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=B4=97=E7=89=88=E7=9A=84?= =?UTF-8?q?=E5=88=B6=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-skill-parser.js | 242 ++++++++++++++++++++++------------- script-universal_function.js | 3 + style.css | 39 +++++- 3 files changed, 191 insertions(+), 93 deletions(-) diff --git a/script-skill-parser.js b/script-skill-parser.js index 4283b7b4..a750bed7 100644 --- a/script-skill-parser.js +++ b/script-skill-parser.js @@ -80,6 +80,148 @@ Attributes.orbs = function () { ]; } +class Board +{ + #rowCount = 6; + #columnCount = 7; + #data = []; + constructor(def = null) + { + for (let ri=0;ri attrs[x % attrs.length])); //用所有宝珠随机填充 + //之后用每种颜色填充前3个 + attrs.forEach((attr,idx)=>{ + valueArray.fill(attr, idx * 3, idx * 3 + 3); + }); + //将上方数据重新乱序排列 + const randomData = []; + //将65版之后的的提出来 + let secondaryData = valueArray.splice((this.#rowCount - 1) * (this.#columnCount - 1)); + + while(valueArray.length > 0) + { + randomData.push(valueArray.randomShift()); + } + while(secondaryData.length > 0) + { + randomData.push(secondaryData.randomShift()); + } + const o = randomData.entries(); + //65版部分 + for (let ri=0;ri= 2) row++; + const rowData = this.#data[row]; + for (let ri=0;riattr); + } + } + setColumn(cols, attr = 0) //设定横行 + { + for (let col of cols) + { + if (col >= 3) col++; + for (let row of this.#data) + { + row[col] = attr; + } + } + } + setShape(matrix, attr = 0) + { + function fillRow(rowData, inputRow, attr) + { + for (let col of inputRow) + { + if (col == 3) rowData[col] = attr; + if (col >= 3) col++; + rowData[col] = attr; + } + } + for (let ri=0;ri= 2 ? ri+1 : ri], matrix[ri], attr); + } + } + valueOf() + { + return this.#data; + } + toTable() + { + const table = document.createElement("table"); + table.className = "board"; + this.#data.forEach((rowData, ri, rArr) => { + const row = table.insertRow(); + if (ri == 2 && rArr.length > 5) row.classList.add("board-row4"); + + rowData.forEach((orbType, ci, cArr) => { + const cell = row.insertCell(); + const orb = cell.appendChild(document.createElement('icon')); + orb.className = "orb"; + if (orbType != null) orb.setAttribute("data-orb-icon", orbType); + if (ci == 3 && cArr.length > 6) cell.classList.add("board-cell5"); + }); + }); + if (this.#data.length > 5) + { + table.onclick = function() { + this.classList.toggle("board-76"); + }; + } + return table; + } +} + const SkillValue = { isLess: function (value) { if (value.kind === SkillValueKind.Percent) return value.value < 1; @@ -104,8 +246,6 @@ const SkillValueKind = { xAwakenings: 'mul-awakenings', }; - - const SkillPowerUpKind = { Multiplier: 'mul', ScaleAttributes: 'scale-attrs', @@ -1034,7 +1174,9 @@ function renderSkill(skill, option = {}) dict = { attrs: renderOrbs(attrs), }; + let board = new Board(attrs); frg.ap(tsp.skill.board_change(dict)); + frg.ap(board.toTable()); break; } case SkillKinds.SkillBoost: { //溜 @@ -1148,7 +1290,8 @@ function renderSkill(skill, option = {}) let generates = skill.generates; let slight_pause = tsp.word.slight_pause().textContent; let changesDocument = []; - let board = new Array(5).fill(null).map(i=>new Array(6).fill(null)); + //let board = new Array(5).fill(null).map(i=>new Array(6).fill(null)); + let board = new Board(); function posSplit(pos, max) { return {sequence: pos.filter(n=>n<=2).map(n=>n+1), reverse: pos.filter(n=>n>=3).reverse().map(n=>max-n)}; @@ -1162,94 +1305,34 @@ function renderSkill(skill, option = {}) if (generate.type == 'shape') { dict.position = tsp.position.shape(); - for (let ri=0;ri= 2) row++; - board[row] = board[row].map(()=>_to); - } + board.setRow(generate.positions, _to); }else { const pos = posSplit(generate.positions, 6); if (pos.sequence.length) posFrgs.push(tsp.position.left({pos: pos.sequence.join(slight_pause)})); if (pos.reverse.length) posFrgs.push(tsp.position.right({pos: pos.reverse.join(slight_pause)})); - for (let col of generate.positions) - { - //if (col >= 3) col++; - for (let row of board) - { - row[col] = _to; - } - } + board.setColumn(generate.positions, _to); } dict.position = posFrgs.nodeJoin(tsp.word.slight_pause()); } changesDocument.push(tsp.skill.fixed_orbs(dict)); } frg.ap(changesDocument.nodeJoin(tsp.word.comma())); - frg.ap(renderBoard(board)); + frg.ap(board.toTable()); break; } /* - case SkillKinds.ChangeOrbs: { - const { changes } = skill as Skill.ChangeOrbs; - return ( - - - - - - - {changes.map((change, i) => { - switch (change.kind) { - case 'from': - return ( - - {renderOrbs(change.from)} ⇒ {renderOrbs(change.to)} - - ); - case 'gen': - return ( - - {renderOrbs(change.exclude).map((orb, j) => ( - - {orb} - - - ))} ⇒ {renderOrbs(change.to)} × {change.count} - - ); - case 'fixed': - return (change.positions.length > 0 && - - {change.type === 'col' ? 'column' : 'row'}  - {change.positions.map(p => p + 1).join(', ')} -  ⇒ {renderOrbs(change.to)} - - ); - } - })} - - - ); - } case SkillKinds.OrbDropIncrease: { const { attrs, value } = skill as Skill.OrbDropIncrease; let attrElems: React.ReactNode[]; @@ -1445,29 +1528,6 @@ function renderOrbs(attrs, option = {}) { return frg; } -function renderBoard(boardData) { - const table = document.createElement("table"); - table.className = "board fixed-shape-orb"; - boardData.forEach((rowData, ri, rArr) => { - const row = table.insertRow(); - if (ri == 2 && rArr.length > 5) row.classList.add("board-row4"); - - rowData.forEach((orbType, ci, cArr) => { - const cell = row.insertCell(); - const orb = cell.appendChild(document.createElement('icon')); - orb.className = "orb"; - if (orbType != null) orb.setAttribute("data-orb-icon", orbType); - if (ci == 3 && cArr.length > 6) cell.classList.add("board-cell5"); - }); - }); - if (boardData.length > 5) - { - table.onclick = function() { - this.classList.toggle("board-76"); - }; - } - return table; -} /* function renderTypes(types: Types | Types[]) { if (!Array.isArray(types)) diff --git a/script-universal_function.js b/script-universal_function.js index 81e08b73..b478d097 100644 --- a/script-universal_function.js +++ b/script-universal_function.js @@ -112,6 +112,9 @@ Array.prototype.DeleteLatter = function(item = null) { this.splice(index + 1); return this; } +Array.prototype.randomShift = function() { + return this.splice(Math.random() * this.length, 1)?.[0]; +} Math.randomInteger = function(max, min = 0) { return this.floor(this.random() * (max - min + 1) + min); diff --git a/style.css b/style.css index a17bf1e2..aefbe596 100644 --- a/style.css +++ b/style.css @@ -3190,9 +3190,11 @@ table .orb-icon border-collapse: collapse; background-color: #532; background-image: url(images/slate.svg); - background-size: 120px 120px; + background-size: 100px 100px; background-attachment: scroll; background-position: 0 0; + --board-light-color: unset; + --board-deep-color: rgba(0,0,0,0.4); } .skill-datail-parsed .board .orb { @@ -3204,7 +3206,40 @@ table .orb-icon .skill-datail-parsed .board tr:nth-of-type(2n+1)>td:nth-of-type(2n+1), .skill-datail-parsed .board tr:nth-of-type(2n)>td:nth-of-type(2n) { - background-color: rgba(0,0,0,0.4); + background-color: var(--board-deep-color); +} +/*前两行右侧区域*/ +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n+1)>td:nth-of-type(2n+4), +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n)>td:nth-of-type(2n+5) +{ + background-color: var(--board-deep-color); +} +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n)>td:nth-of-type(2n+4), +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n+1)>td:nth-of-type(2n+5) +{ + background-color: var(--board-light-color); +} +/*后两行左侧区域*/ +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n+3)>td:nth-of-type(2n), +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n+4)>td:nth-of-type(2n+1) +{ + background-color: var(--board-deep-color); +} +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n+3)>td:nth-of-type(2n+1), +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n+4)>td:nth-of-type(2n) +{ + background-color: var(--board-light-color); +} +/*后两行右侧区域*/ +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n+4)>td:nth-of-type(2n+4), +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n+3)>td:nth-of-type(2n+5) +{ + background-color: var(--board-deep-color); +} +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n+3)>td:nth-of-type(2n+4), +.skill-datail-parsed .board:not(.board-76) tr:nth-of-type(2n+4)>td:nth-of-type(2n+5) +{ + background-color: var(--board-light-color); } .card-skill-list>.fixed-time,