mirror of
https://ghproxy.com/https://github.com/StreakingMan/solvable-sheep-game
synced 2025-05-24 00:49:43 +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,
|
||||
status: 0,
|
||||
icon,
|
||||
id: randomString(4),
|
||||
id: randomString(6),
|
||||
x: column * 100 + offset,
|
||||
y: row * 100 + offset,
|
||||
});
|
||||
|
@ -201,11 +201,13 @@ const App: FC = () => {
|
|||
// 队列区排序
|
||||
useEffect(() => {
|
||||
const cache: Record<string, MySymbol[]> = {};
|
||||
// 加上索引,避免以id字典序来排
|
||||
const idx = 0;
|
||||
for (const symbol of queue) {
|
||||
if (cache[symbol.icon.name]) {
|
||||
cache[symbol.icon.name].push(symbol);
|
||||
if (cache[idx + symbol.icon.name]) {
|
||||
cache[idx + symbol.icon.name].push(symbol);
|
||||
} else {
|
||||
cache[symbol.icon.name] = [symbol];
|
||||
cache[idx + symbol.icon.name] = [symbol];
|
||||
}
|
||||
}
|
||||
const temp = [];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export const randomString: (len: number) => string = (len) => {
|
||||
const pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
let res = '';
|
||||
while (len >= 0) {
|
||||
while (len > 0) {
|
||||
res += pool[Math.floor(pool.length * Math.random())];
|
||||
len--;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user