Open Baksztag opened 2 months ago
@CombustibleToast There is a lot of duplication, especially in drill.js
, so it might be a good time for some refactoring.
For now I just copied over index.html
and script.js
and worked on the copies to avoid breaking the main functionality and to leave the decision on how to approach the duplication to the maintainers.
Personally, I'd suggest moving core functions and game state to one script file (e.g. core.js
) and loading it together with page-specific script which uses necessary functions only. Loading the scripts as JS modules might help with clear code organisation. Also unit tests would be great to avoid breaking the game during refactoring.
I was testing this out with some stratagems, and it gets to a point where it stops scrolling them.
Fixed it changing pickNextStratagem()
function inside drill.js
to the following
function pickNextStratagem() {
let nextStratagemIndex = Math.floor(Math.random() * seletecedStratagems.length);
return seletecedStratagems[nextStratagemIndex];
}
I'll try to check it today. @choidavid4 what was the stratagem config that you started with?
These are the Stratagems that I selected
@choidavid4 thanks!
I found the culprit – Shield Generator Pack
was duplicated in the data. You've hit an edge case that wouldn't occur if you had anything else as selected as the last stratagem. I deleted the duplicate so now it works as intended. You must either clear your localStorage to make it work or select other stratagem set.
Regarding the fix
Fixed it changing pickNextStratagem() function inside drill.js to the following
It changes the behavior a bit as it introduces random ordering. We could add it as another config option if you'd like.
I think random ordering is the way to go. It helps training because you don't know what stratagem comes next.
I'd love to have the choice to enable it in a config.
Resolves https://github.com/CombustibleToast/StratagemHeroOnline/issues/34