remove solution code from source

fix purgecss safelist with animate-pulse
master
Peter Babič 3 years ago
parent 7bfb708ca9
commit c34634e2bf
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 8
      src/About.svelte
  2. 61
      src/App.svelte
  3. 5
      tailwind.config.js

@ -24,7 +24,7 @@
<div class="relative"> <div class="relative">
<div <div
class="absolute z-10 rounded text-blue-darker text-justify border-1 border-orange" class="absolute z-10 rounded text-blue-darker text-left border-1 border-orange"
class:hidden> class:hidden>
<h1>Triangles.fun</h1> <h1>Triangles.fun</h1>
A game. Leave only a single dot to win. Eliminate other dots by jumping A game. Leave only a single dot to win. Eliminate other dots by jumping
@ -35,11 +35,11 @@
clicking on the darker spot. clicking on the darker spot.
<h2>Installation</h2> <h2>Installation</h2>
This game can be installed into your device. Look for "Add to Home This game can be installed into your device. Look for "Add to Home
Screen" in the browser menu. Screen" in the browser tab menu.
<h2>Support</h2> <h2>Support</h2>
You can send me your feedback or complains via You can send me your feedback or complains via
<a href="mailto:peter@triangles.fun">peter@triangles.fun</a> <a href="mailto:peter@triangles.fun">peter@triangles.fun</a>
and you can even and help me keep this game running via
<a href="https://www.buymeacoffee.com/peterbabic">buy me a coffee</a>. <a href="https://www.buymeacoffee.com/peterbabic">Buy Me a Coffee.</a>
</div> </div>
</div> </div>

@ -76,6 +76,7 @@
let moveStack = [] let moveStack = []
let gameover = false let gameover = false
let victory = false let victory = false
let about = false
let maxSteps let maxSteps
$: if (variant || side) { $: if (variant || side) {
@ -110,8 +111,6 @@
j++ j++
} }
} }
printSolutions(-1)
} }
const undo = () => { const undo = () => {
@ -238,62 +237,6 @@
} }
} }
const printSolutions = maxSolutionCount => {
if (maxSolutionCount < 0) {
return
}
let depth = 0
let solutions = []
let gameovers = []
let shadow = [...circles]
const moves = new Tree("", depth)
const recurse = move => {
if (
maxSolutionCount != 0 &&
maxSolutionCount != undefined &&
maxSolutionCount <= solutions.length
) {
return
}
const hints = getHints(shadow)
if (hints.length == 0) {
gameovers.push(move.solution)
return
}
hints.forEach(hint => {
getDests(shadow, hint).forEach(destination => {
const solution = `${move.solution} ${hint}>${destination}`
const child = new Tree(solution, depth)
const lastIndex = move.children.push(child) - 1
jumpOver(shadow, hint, destination)
depth = depth + 1
if (depth == maxSteps) {
solutions.push(solution)
}
recurse(move.children[lastIndex])
depth = depth - 1
jumpReverse(shadow, hint, destination)
})
})
}
recurse(moves)
console.log(solutions)
if (maxSolutionCount < 1) {
console.log(gameovers)
const proportion = (solutions.length * 100) / gameovers.length
console.log(proportion.toFixed(2) + "% moves are victory")
}
}
const handleKeydown = event => { const handleKeydown = event => {
if (event.key == "u") { if (event.key == "u") {
undo() undo()
@ -302,8 +245,6 @@
restart() restart()
} }
} }
let about = false
</script> </script>
<style> <style>

@ -4,8 +4,13 @@ module.exports = {
mode: "all", mode: "all",
content: ["./public/index.html", "./src/**/*.svelte"], content: ["./public/index.html", "./src/**/*.svelte"],
options: { options: {
// defaultExtractor: content => [
// ...(content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || []),
// ...(content.match(/(?<=class:)[^=>\/\s]*/g) || []),
// ],
safelist: [ safelist: [
/^bg\-(green|cyan|blue|yellow|orange|red|purple)(\-(lighter|darker))?/, /^bg\-(green|cyan|blue|yellow|orange|red|purple)(\-(lighter|darker))?/,
/animate-pulse/,
], ],
}, },
}, },

Loading…
Cancel
Save