增加版面的状态合并
This commit is contained in:
parent
473cfa9a68
commit
1dd3275fbe
Binary file not shown.
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Binary file not shown.
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 97 KiB |
|
@ -96,6 +96,22 @@ function isEqual(obj1,obj2) {
|
|||
// 3.全相等
|
||||
return true
|
||||
}
|
||||
class Orb
|
||||
{
|
||||
color = null;
|
||||
states = [];
|
||||
enhanced = false; //锁定
|
||||
locked = false; //锁定
|
||||
bound = false;
|
||||
variation = false; //随机变换
|
||||
constructor(color)
|
||||
{
|
||||
this.color = color;
|
||||
}
|
||||
valueOf() {
|
||||
return this.color;
|
||||
}
|
||||
}
|
||||
class Board
|
||||
{
|
||||
rowCount = 6;
|
||||
|
@ -105,8 +121,14 @@ class Board
|
|||
{
|
||||
for (let ri=0;ri<this.rowCount;ri++)
|
||||
{
|
||||
this.data.push(new Array(this.columnCount).fill(Array.isArray(def) ? null : def));
|
||||
const col = [];
|
||||
for (let ci=0;ci<this.columnCount;ci++)
|
||||
{
|
||||
col.push(new Orb(Array.isArray(def) ? null : def));
|
||||
}
|
||||
this.data.push(col);
|
||||
}
|
||||
//如果传入的是数组,直接随机分布
|
||||
if (Array.isArray(def))
|
||||
{
|
||||
this.randomFill(def);
|
||||
|
@ -127,8 +149,12 @@ class Board
|
|||
{
|
||||
if (ci == 3) ci++;
|
||||
//从数组中随机取出一个
|
||||
if (exclude && exclude.includes(row[ci])) continue;
|
||||
row[ci] = o.next().value?.[1] ?? row[ci];
|
||||
if (exclude && exclude.includes(row[ci].color)) continue;
|
||||
const c = o.next().value?.[1] ?? row[ci].color;
|
||||
if (c == "variation")
|
||||
row[ci].states.push(c);
|
||||
else
|
||||
row[ci].color = c;
|
||||
}
|
||||
}
|
||||
//填充剩下的部分
|
||||
|
@ -136,14 +162,22 @@ class Board
|
|||
{
|
||||
if (ri == 2) ri++;
|
||||
const row = this.data[ri];
|
||||
if (exclude && exclude.includes(row[3])) continue;
|
||||
row[3] = o.next().value?.[1] ?? row[3] ;
|
||||
if (exclude && exclude.includes(row[3].color)) continue;
|
||||
const c = o.next().value?.[1] ?? row[3].color;
|
||||
if (c == "variation")
|
||||
row[3].states.push(c);
|
||||
else
|
||||
row[3].color = c;
|
||||
}
|
||||
const row = this.data[2];
|
||||
for (let ci=0;ci<row.length;ci++)
|
||||
{
|
||||
if (exclude && exclude.includes(row[ci])) continue;
|
||||
row[ci] = o.next().value?.[1] ?? row[ci] ;
|
||||
if (exclude && exclude.includes(row[ci].color)) continue;
|
||||
const c = o.next().value?.[1] ?? row[3].color;
|
||||
if (c == "variation")
|
||||
row[ci].states.push(c);
|
||||
else
|
||||
row[ci].color = c;
|
||||
}
|
||||
}
|
||||
//将有序数组转为随机的数组
|
||||
|
@ -196,27 +230,27 @@ class Board
|
|||
this.sequenceFill(randomData, exclude);
|
||||
}
|
||||
//设定横行
|
||||
setRow(rows, attr = 0)
|
||||
setRow(rowsNumber, attr = 0)
|
||||
{
|
||||
for (let row of rows)
|
||||
for (let row of rowsNumber)
|
||||
{
|
||||
if (row >= 2) row++;
|
||||
const rowData = this.data[row];
|
||||
for (let ri=0;ri<rowData.length;ri++)
|
||||
{
|
||||
rowData[ri] = attr;
|
||||
rowData[ri].color = attr;
|
||||
}
|
||||
}
|
||||
}
|
||||
//设定竖列
|
||||
setColumn(cols, attr = 0)
|
||||
setColumn(colsNumber, attr = 0)
|
||||
{
|
||||
for (let col of cols)
|
||||
for (let col of colsNumber)
|
||||
{
|
||||
if (col >= 3) col++;
|
||||
for (let row of this.data)
|
||||
{
|
||||
row[col] = attr;
|
||||
row[col].color = attr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,14 +259,22 @@ class Board
|
|||
{
|
||||
function fillRow(rowData, inputRow, attr)
|
||||
{
|
||||
for (let col of inputRow)
|
||||
for (const col of inputRow)
|
||||
{
|
||||
if (col == 3) rowData[col] = attr;
|
||||
if (col == 3) {
|
||||
if (attr == "variation")
|
||||
rowData[col].states.push(attr);
|
||||
else
|
||||
rowData[col].color = attr;
|
||||
}
|
||||
if (col >= 3) col++;
|
||||
rowData[col] = attr;
|
||||
if (attr == "variation")
|
||||
rowData[col].states.push(attr);
|
||||
else
|
||||
rowData[col].color = attr;
|
||||
}
|
||||
}
|
||||
for (let ri=0;ri<matrix.length;ri++)
|
||||
for (let ri=0; ri<matrix.length; ri++)
|
||||
{
|
||||
if (ri == 2)
|
||||
{
|
||||
|
@ -244,13 +286,13 @@ class Board
|
|||
//面板叠加
|
||||
overlayBoard(board)
|
||||
{
|
||||
for (let ri=0;ri<board.length;ri++)
|
||||
for (let ri=0; ri<board.length; ri++)
|
||||
{
|
||||
const rowNew = board[ri];
|
||||
const rowOld = this.data[ri];
|
||||
for (let ci=0;ci<rowNew.length;ci++)
|
||||
for (let ci=0; ci < rowNew.length; ci++)
|
||||
{
|
||||
rowOld[ci] = rowNew[ci] ?? rowOld[ci];
|
||||
rowOld[ci] = Object.assign(rowOld[ci], rowNew[ci]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -263,6 +305,7 @@ class Board
|
|||
toTable()
|
||||
{
|
||||
const table = document.createElement("table");
|
||||
table.boardData = this.data;
|
||||
table.className = "board";
|
||||
this.data.forEach((rowData, ri, rArr) => {
|
||||
const row = table.insertRow();
|
||||
|
@ -272,15 +315,16 @@ class Board
|
|||
const cell = row.insertCell();
|
||||
const orb = cell.appendChild(document.createElement('icon'));
|
||||
orb.className = "orb";
|
||||
if (orbType != null) orb.setAttribute("data-orb-icon", orbType);
|
||||
if (orbType.color != null) orb.setAttribute("data-orb-icon", orbType.color);
|
||||
orbType.states.forEach(state=>orb.classList.add(state));
|
||||
if (ci == 3 && cArr.length > 6) cell.classList.add("board-cell5");
|
||||
});
|
||||
});
|
||||
if (this.data.length > 5)
|
||||
{
|
||||
table.onclick = function() {
|
||||
this.classList.toggle("board-76");
|
||||
};
|
||||
if (this.data.length > 5) {
|
||||
table.onclick = toggle76;
|
||||
}
|
||||
function toggle76() {
|
||||
this.classList.toggle("board-76");
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
@ -1522,8 +1566,9 @@ function renderSkillEntry(skills)
|
|||
let boardChange = skills.filter(skill=>
|
||||
skill.kind == SkillKinds.BoardChange ||
|
||||
skill.kind == SkillKinds.GenerateOrbs ||
|
||||
skill.kind == SkillKinds.FixedOrbs
|
||||
);
|
||||
skill.kind == SkillKinds.FixedOrbs ||
|
||||
skill.kind == SkillKinds.ActiveTurns && (skill.skill.kind == SkillKinds.FixedOrbs || skill.skill.kind == SkillKinds.GenerateOrbs)
|
||||
).map(skill=>skill.kind == SkillKinds.ActiveTurns ? skill.skill : skill);
|
||||
if (boardChange.length > 0)
|
||||
{
|
||||
const board = new Board();
|
||||
|
@ -1559,6 +1604,21 @@ function renderSkillEntry(skills)
|
|||
}
|
||||
}
|
||||
}
|
||||
const setOrbState = skills.filter(skill=>skill.kind == SkillKinds.SetOrbState ||
|
||||
skill.kind == SkillKinds.ActiveTurns && (skill.skill.kind == SkillKinds.SetOrbState)
|
||||
).map(skill=>skill.kind == SkillKinds.ActiveTurns ? skill.skill : skill);
|
||||
const boardData = board.data.flat();
|
||||
for (let skill of setOrbState) {
|
||||
if (["enhanced", "locked", "bound"].includes(skill.state)) {
|
||||
const orbCount = skill.arg?.count?.value ?? boardData.length;
|
||||
for (let oi = 0; oi < orbCount; oi++) {
|
||||
const orb = boardData[oi];
|
||||
if (skill.orbs.includes(orb.color)) {
|
||||
orb.states.push(skill.state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const li = ul.appendChild(document.createElement("li"));
|
||||
li.appendChild(board.toTable());
|
||||
li.className = "merge-board";
|
||||
|
@ -2366,7 +2426,10 @@ function renderOrbs(attrs, option = {}) {
|
|||
const icon = document.createElement("icon");
|
||||
icon.className = "orb";
|
||||
if (option.className) icon.className += " " + option.className;
|
||||
icon.setAttribute("data-orb-icon",attr);
|
||||
if (attr == 'variation')
|
||||
icon.classList.add('variation');
|
||||
else
|
||||
icon.setAttribute("data-orb-icon",attr);
|
||||
let dict = {
|
||||
icon: icon,
|
||||
}
|
||||
|
|
|
@ -5979,7 +5979,7 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"script-skill-parser.js",
|
||||
"1380f9e54d6bbceb605181b7bfeb2c3b"
|
||||
"7acbb8fc22d0112f01beb8c6bf040a93"
|
||||
],
|
||||
[
|
||||
"script-universal_function.js",
|
||||
|
@ -5999,7 +5999,7 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"style-monsterimages.css",
|
||||
"98897b24652c22acd257c7b9e3fe2c25"
|
||||
"773e7da6f8f97545e5b193339b2a66f4"
|
||||
],
|
||||
[
|
||||
"style.css",
|
||||
|
@ -6147,7 +6147,7 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"images/icon-orbs.png",
|
||||
"c781a7f8165730312529ddb49f439870"
|
||||
"5a984aca3416ae5e739aebe8518fb1f2"
|
||||
],
|
||||
[
|
||||
"images/icon-poison.png",
|
||||
|
|
|
@ -1342,6 +1342,11 @@ icon.type
|
|||
background-position-y:calc(-36px * 3);
|
||||
animation: hidden-visible-animate 0.8s infinite ease-out alternate;
|
||||
}
|
||||
.orb.variation::before
|
||||
{
|
||||
content: "";
|
||||
background-position-y:calc(-36px * 7);
|
||||
}
|
||||
|
||||
.orb[data-orb-icon='_5color']
|
||||
{
|
||||
|
@ -1391,8 +1396,4 @@ icon.type
|
|||
.orb[data-orb-icon='9']
|
||||
{
|
||||
background-position-y:calc(-36px * 9);
|
||||
}
|
||||
.orb[data-orb-icon='variation']
|
||||
{
|
||||
background-position-y:calc(-36px * 10);
|
||||
}
|
Loading…
Reference in New Issue