为chooseButton添加缓存上下文

This commit is contained in:
kuangthree 2024-02-03 13:14:28 +08:00
parent 0006a38c54
commit 80e9e7a972
1 changed files with 10 additions and 0 deletions

View File

@ -24,15 +24,21 @@ export class Basic extends Uninstantable {
if (ui.selected.buttons.length >= range[0]) {
ok = true;
}
CacheContext.setCacheContext(new CacheContext());
CacheContext.setInCacheEnvironment(true);
if (range[1] <= -1) {
j = 0;
for (i = 0; i < ui.selected.buttons.length; i++) {
j += check(ui.selected.buttons[i]);
}
CacheContext.setInCacheEnvironment(false);
CacheContext.removeCacheContext();
return (j > 0);
}
buttons = get.selectableButtons();
if (buttons.length == 0) {
CacheContext.setInCacheEnvironment(false);
CacheContext.removeCacheContext();
return ok;
}
buttons2 = buttons.slice(0);
@ -50,9 +56,13 @@ export class Basic extends Uninstantable {
// });
if (check(buttons[ix]) <= 0) {
if (!forced || ok) {
CacheContext.setInCacheEnvironment(false);
CacheContext.removeCacheContext();
return ok;
}
}
CacheContext.setInCacheEnvironment(false);
CacheContext.removeCacheContext();
buttons[ix].classList.add('selected');
ui.selected.buttons.add(buttons[ix]);
game.check();