mirror of
https://ghproxy.com/https://github.com/StreakingMan/solvable-sheep-game
synced 2025-05-25 03:17:37 +08:00
fix: 入队顺序维护
This commit is contained in:
parent
f8e27e70f3
commit
57224e8015
10
src/App.tsx
10
src/App.tsx
|
@ -62,7 +62,7 @@ const makeScene: (level: number, icons: Icon[]) => Scene = (level, icons) => {
|
||||||
isCover: false,
|
isCover: false,
|
||||||
status: 0,
|
status: 0,
|
||||||
icon,
|
icon,
|
||||||
id: randomString(4),
|
id: randomString(6),
|
||||||
x: column * 100 + offset,
|
x: column * 100 + offset,
|
||||||
y: row * 100 + offset,
|
y: row * 100 + offset,
|
||||||
});
|
});
|
||||||
|
@ -201,11 +201,13 @@ const App: FC = () => {
|
||||||
// 队列区排序
|
// 队列区排序
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const cache: Record<string, MySymbol[]> = {};
|
const cache: Record<string, MySymbol[]> = {};
|
||||||
|
// 加上索引,避免以id字典序来排
|
||||||
|
const idx = 0;
|
||||||
for (const symbol of queue) {
|
for (const symbol of queue) {
|
||||||
if (cache[symbol.icon.name]) {
|
if (cache[idx + symbol.icon.name]) {
|
||||||
cache[symbol.icon.name].push(symbol);
|
cache[idx + symbol.icon.name].push(symbol);
|
||||||
} else {
|
} else {
|
||||||
cache[symbol.icon.name] = [symbol];
|
cache[idx + symbol.icon.name] = [symbol];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const temp = [];
|
const temp = [];
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export const randomString: (len: number) => string = (len) => {
|
export const randomString: (len: number) => string = (len) => {
|
||||||
const pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
const pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
let res = '';
|
let res = '';
|
||||||
while (len >= 0) {
|
while (len > 0) {
|
||||||
res += pool[Math.floor(pool.length * Math.random())];
|
res += pool[Math.floor(pool.length * Math.random())];
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user