Skip to content

Conversation

@RedWideWeb
Copy link

Click a solution to fill it in the editor

RedWideWeb and others added 10 commits June 27, 2022 22:47
Click a solution to fill it in the editor
Minor typo :)
…Only your solutions. Items in menu also don't have selectors in them.
…let you pass level 6 because the game actually checks the selector on html different from HTML Editor window. Now it properly parses html from level.boardMarkup
Comment on lines +738 to +749
.display-help solution {
display: inline-block;
color: #AAA;
background: rgba(255,255,255,.1);
border: none;
padding: 0 6px 0 6px;
margin: 2px 4px 2px 0;
font-size: 13px;
font-family: menlo,monospace;
font-weight: normal;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy paste from tag but with slighlty different margins to look good inline

Comment on lines +1285 to +1292
solution {
cursor: pointer;
padding: 0 3px;
color: #AAA;
font-size: 13px;
font-weight: bold;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show it's clickable via pointer cursor

Comment on lines +155 to +156
<h4 class="solutions-title">Solutions</h4>
<div class="solutions"></div>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Sulotions title and container much like examples

Comment on lines +327 to +332
var solutions = []
if (progress.guessHistory[currentLevel]) {
if (progress.guessHistory[currentLevel].solutions) {
solutions = progress.guessHistory[currentLevel].solutions;
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get solutions from progress. If the progress exists it will populate its solutions. But additional check is needed because level progress might exist without solutions and in that case progress.guessHistory[currentLevel].solutions will return undefined which is obviously not iterable

Comment on lines 434 to 449
if (progress.guessHistory[currentLevel]) {
if (progress.guessHistory[currentLevel].solutions) {
if (!progress.guessHistory[currentLevel].solutions.includes(rule)) {
$(".display-help .solutions-title").show();
let solution = $("<solution>" + rule + "</solution>");
$(".display-help .solutions").append(solution);
}
}
}
else {
console.log('shit')
$(".display-help .solutions-title").show();
let solution = $("<solution>" + rule + "</solution>");
$(".display-help .solutions").append(solution);
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are solutions check the input rule if it matches existing solution. If it's new then add it to solutions container.
If there were no solutions previously you need to show solutions-title also

js/restaurant.js Outdated
if (progress.guessHistory[currentLevel]) {
if (progress.guessHistory[currentLevel].solutions) {
if (!progress.guessHistory[currentLevel].solutions.includes(rule)) {
$(".display-help .solutions-title").show();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this line is redundant since if we have solutions the title should have been shown

Comment on lines 464 to 485
if (localStorage.getItem("hardcore") === "1" && progress.guessHistory[currentLevel]) {
for (let s of document.querySelectorAll('.display-help .solutions *')) {
if (s.textContent === rule) {

$(".strobe").removeClass("strobe");
ruleSelected.removeClass("strobe");
ruleSelected.addClass("shake");

s.classList.add("shake")
setTimeout(function(){
s.classList.remove("shake");
$(".shake").removeClass("shake");
$(".strobe").removeClass("strobe");
levelSelected.addClass("strobe");
},500);

$(".result").fadeOut();

return;
}
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the solution exists find it in the solutions container and shake it to indicate it's there

js/restaurant.js Outdated
Comment on lines 487 to 498
if (progress.guessHistory[currentLevel]) {
$(".display-help .solutions-title").show();
let solution = $("<solution>" + rule + "</solution>");
$(".display-help .solutions").show();
if (progress.guessHistory[currentLevel].solutions) {
if (!progress.guessHistory[currentLevel].solutions.includes(rule)) {
$(".display-help .solutions-title").show();
let solution = $("<solution>" + rule + "</solution>");
$(".display-help .solutions").append(solution);
}
}
else {
$(".display-help .solutions").append(solution);
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay this fixes the redundancy from previous commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant