Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
935debe2df | ||
|
|
e062a435d5 | ||
|
|
e9827d9429 | ||
|
|
aa9dc3afbc | ||
|
|
ca419431d2 | ||
|
|
14e8f30b4e |
@@ -21,7 +21,7 @@
|
||||
<link rel="preload" as="script" href="/WebGames-master/WebGames-master/Accementunlocked/jquery.min.js" />
|
||||
<link media="all" rel="stylesheet" href="/WebGames-master/WebGames-master/Accementunlocked/theme.css" type="text/css">
|
||||
<link rel="shortcut icon" href="/WebGames-master/WebGames-master/Accementunlocked/favicon.svg">
|
||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/lazyload.min.js"></script>
|
||||
<script src="/WebGames-master/WebGames-master/Accementunlocked/lazyload.min.js"></script>
|
||||
<script src="/WebGames-master/WebGames-master/Accementunlocked/load-games.js"></script>
|
||||
<script src="/assets/js/recent_games.js"></script>
|
||||
<script type="text/javascript">
|
||||
@@ -55,12 +55,6 @@
|
||||
<button class="navbar-toggler border-0 shadow-none px-0" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<a href="/" class="navbar-brand dark-logo me-lg-4">
|
||||
<img src="/assets/static/logo.png" height="30" alt="Unblocked Cool Browser Games (UCBG)">
|
||||
</a>
|
||||
<a href="/" class="navbar-brand light-logo me-lg-4">
|
||||
<img src="/assets/static/dark_logo.png" height="30" alt="Unblocked Cool Browser Games (UCBG)">
|
||||
</a>
|
||||
<button class="navbar-toggler border-0 shadow-none px-0" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<svg width="24" height="24" stroke="currentColor" stroke-width="1.75" fill="none">
|
||||
<use xlink:href="/assets/sprite/sprite.svg#search"></use>
|
||||
|
||||
@@ -153,7 +153,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
}
|
||||
|
||||
// Oyunları yükle ve rastgele seç
|
||||
const response = await fetch("/data-json/games.json");
|
||||
const response = await fetch("/WebGames-master/WebGames-master/Accementunlocked/games.json");
|
||||
const games = await response.json();
|
||||
|
||||
// Oyunları rastgele seçmek için yardımcı fonksiyon
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title class="cloak">Townscaper | MacVG</title>
|
||||
<link class="favicon" rel="shortcut icon" href="/logo.png" />
|
||||
<script src="/macvg/cloaker.js"></script>
|
||||
<span id="macvgmacvg" name="game256"></span>
|
||||
<link rel="stylesheet" href="TemplateData/style.css">
|
||||
<script type="application/javascript" src="/js/main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="unity-container" class="unity-desktop">
|
||||
<canvas id="unity-canvas"></canvas>
|
||||
<div id="unity-loading-bar">
|
||||
<div id="unity-progress-bar-empty">
|
||||
<div id="unity-progress-bar-full"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="unity-mobile-warning">
|
||||
WebGL builds are not supported on mobile devices.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var buildUrl = "Build";
|
||||
var loaderUrl = buildUrl + "/WebGL.loader.js";
|
||||
var config = {
|
||||
dataUrl: buildUrl + "/WebGL.data",
|
||||
frameworkUrl: buildUrl + "/WebGL.framework.js",
|
||||
codeUrl: buildUrl + "/WebGL.wasm",
|
||||
streamingAssetsUrl: "StreamingAssets",
|
||||
companyName: "3kh0",
|
||||
productName: "Townscaper",
|
||||
productVersion: "0.23",
|
||||
};
|
||||
|
||||
var container = document.querySelector("#unity-container");
|
||||
var canvas = document.querySelector("#unity-canvas");
|
||||
var loadingBar = document.querySelector("#unity-loading-bar");
|
||||
var progressBarFull = document.querySelector("#unity-progress-bar-full");
|
||||
var mobileWarning = document.querySelector("#unity-mobile-warning");
|
||||
|
||||
// By default Unity keeps WebGL canvas render target size matched with
|
||||
// the DOM size of the canvas element (scaled by window.devicePixelRatio)
|
||||
// Set this to false if you want to decouple this synchronization from
|
||||
// happening inside the engine, and you would instead like to size up
|
||||
// the canvas DOM size and WebGL render target sizes yourself.
|
||||
// config.matchWebGLToCanvasSize = false;
|
||||
|
||||
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
|
||||
container.className = "unity-mobile";
|
||||
// Avoid draining fillrate performance on mobile devices,
|
||||
// and default/override low DPI mode on mobile browsers. Hello3
|
||||
config.devicePixelRatio = 1;
|
||||
mobileWarning.style.display = "block";
|
||||
setTimeout(() => {
|
||||
mobileWarning.style.display = "none";
|
||||
}, 5000);
|
||||
} else {
|
||||
//canvas.style.width = "100%";
|
||||
//canvas.style.height = "100%";
|
||||
}
|
||||
canvas.style.background = "url('" + buildUrl + "/WebGL.jpg') center / cover";
|
||||
loadingBar.style.display = "block";
|
||||
|
||||
var script = document.createElement("script");
|
||||
script.src = loaderUrl;
|
||||
script.onload = () => {
|
||||
createUnityInstance(canvas, config, (progress) => {
|
||||
progressBarFull.style.width = 100 * progress + "%";
|
||||
}).then((unityInstance) => {
|
||||
loadingBar.style.display = "none";
|
||||
}).catch((message) => {
|
||||
alert(message);
|
||||
});
|
||||
};
|
||||
document.body.appendChild(script);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,125 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script
|
||||
async
|
||||
src="https://www.googletagmanager.com/gtag/js?id=G-Y71QM9DR66"
|
||||
></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() {
|
||||
dataLayer.push(arguments);
|
||||
}
|
||||
gtag("js", new Date());
|
||||
|
||||
gtag("config", "G-Y71QM9DR66");
|
||||
</script>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title class="cloak">Townscaper | MacVG</title>
|
||||
<span id="macvgmacvg" name="game256"></span>
|
||||
<link
|
||||
rel="shortcut icon"
|
||||
href="/logo.png"
|
||||
type="image/x-icon"
|
||||
class="favicon"
|
||||
/>
|
||||
<link rel="stylesheet" href="/macvg/projects/style.css" />
|
||||
<script src="../app.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
// Add an event listener to handle messages from the parent window
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
||||
function receiveMessage(event) {
|
||||
// Ensure that the message is from a trusted source (replace "http://yourparent.com" with the actual origin of your parent window)
|
||||
if (event.origin !== "127.0.0.1:5500") return;
|
||||
|
||||
// Handle the received message and data
|
||||
var receivedData = event.data;
|
||||
// Process the data as needed
|
||||
}
|
||||
|
||||
// Send a message to the parent window
|
||||
var messageData = "Your message and data";
|
||||
// Replace "http://yourparent.com" with the actual origin of your parent window
|
||||
parent.postMessage(messageData, "127.0.0.1:5500");
|
||||
</script>
|
||||
<div class="game-container">
|
||||
<div class="game-related">
|
||||
<div class="actual" id="gameframe">
|
||||
<iframe src="game.html" frameborder="0" id="iframe"> </iframe>
|
||||
<div class="tool-bar">
|
||||
<div class="more-left">
|
||||
<img src="img/cover.jpg" alt="" />
|
||||
</div>
|
||||
<div class="leftest">
|
||||
<h5 class="title">Townscaper</h5>
|
||||
<a href="">Oskar Stålberg</a>
|
||||
</div>
|
||||
<img src="/macvg/back.svg" id="back" style="width: 20pxoo" />
|
||||
<img src="/macvg/star-regular.svg" style="width: 20px" id="star" />
|
||||
<img src="/macvg/share-solid.svg" style="width: 20px" id="share" />
|
||||
<img src="/macvg/download.svg" id="download" />
|
||||
<img src="/macvg/expand.svg" id="fullscreen" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-info">
|
||||
<div class="info">
|
||||
<h3>About</h3>
|
||||
Oops, you caught us, we're still working hard to provide game
|
||||
description on this game! In the upcoming updates, more and more
|
||||
games will have their descriptions and instructions to help you beat
|
||||
it, so stay tuned for more updates!<br /><br /><br /><br /><br /><br /><br />
|
||||
</div>
|
||||
<div class="info">
|
||||
<h3>Controls</h3>
|
||||
<ul>
|
||||
Still working on this one O_O
|
||||
</ul>
|
||||
</div>
|
||||
<div class="info">
|
||||
<h3>Game Information</h3>
|
||||
<ul>
|
||||
<li>Release Date: June 30, 2020</li>
|
||||
<li>Developer: Oskar Stålberg</li>
|
||||
<li>Players: 30M+</li>
|
||||
<li>Catagory:
|
||||
<a href="/macvg/casual.html" style="color: white"
|
||||
>Casual</a
|
||||
>
|
||||
</li>
|
||||
<li>Genre: Relaxing Games</li>
|
||||
<li>Build: Unity WebGL</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="info similar">
|
||||
<h3>Similar Games</h3>
|
||||
<div class="games">
|
||||
Still working on this one!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
<div class="nav">
|
||||
<a href="/macvg/" class="logo">
|
||||
<img src="/macvg/macvg-logo.png" alt="" />
|
||||
</a>
|
||||
<div class="links">
|
||||
<a href="/macvg/new.html" class="nav-link">New</a>
|
||||
<a href="/macvg/trending.html" class="nav-link">Trending</a>
|
||||
<a href="/macvg/groups.html" class="nav-link">Groups</a>
|
||||
<a href="/macvg/bot.html" class="nav-link">Chat</a>
|
||||
<a href="/macvg/projects/macboard/" class="nav-link">MacBoard</a>
|
||||
<a href="/macvg/settings.html" class="nav-link">Settings</a>
|
||||
</div>
|
||||
|
||||
<div class="copyright">© 2023 MacWeb</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a bug report to help me improve my game
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Browser Version [e.g. 22]
|
||||
- Game Version [e.g. 1.2.0]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Browser Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Description**
|
||||
Describe the feature you'd like to have added
|
||||
|
||||
**Reasoning**
|
||||
Why do you think your feature would be a good addition to the game.
|
||||
|
||||
**Implementation (optional)**
|
||||
A technical description of how you envision the feature being implemented.
|
||||
@@ -0,0 +1,25 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: install node v16
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 16
|
||||
- name: install dependencies
|
||||
run: npm i
|
||||
- name: compile
|
||||
run: npm run build
|
||||
- name: deploy to pages branch
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_branch: gh-pages
|
||||
publish_dir: ./dist
|
||||
@@ -0,0 +1,7 @@
|
||||
/node_modules/
|
||||
/public/build/
|
||||
/dist/
|
||||
|
||||
package-lock.json
|
||||
test.html
|
||||
setVersion.mjs
|
||||
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,65 @@
|
||||

|
||||
<div align="center">
|
||||
<a href="https://mikhad.github.io/wordle/" ><img src="https://github.com/MikhaD/wordle/workflows/Publish/badge.svg?branch=main" alt="Publish workflow"/></a>
|
||||
<img src="https://img.shields.io/github/package-json/v/MikhaD/wordle" alt="GitHub package.json version" />
|
||||
</div>
|
||||
|
||||
---
|
||||
A recreation of the popular game [Wordle](https://www.nytimes.com/games/wordle/) by Josh Wardle (now purchased by the New York Times), with additional modes and features.
|
||||
Hosted on GitHub pages [here](https://mikhad.github.io/wordle/).
|
||||
|
||||
# Additional Features
|
||||
- Words are chosen from the list of words at random instead of in sequence, and the solution is not stored in localStorage, making it harder to cheat. The seed for the random number is created from the date, ensuring that everyone gets the same random number, so people can still compare answers.
|
||||
- When you complete a game the definition of the word is shown on the end of game modal.
|
||||
- In addition to the other statistics, your average guesses and your losses are also displayed on the win modal.
|
||||
- When the timer reaches 0 for a given game mode it changes into a refresh button instead of just staying at 00:00:00.
|
||||
- When the timer reaches 0 for a given game mode a refresh button appears in the top left corner.
|
||||
- A tips widget in the settings menu with useful information about the functionality of the game.
|
||||
- Right clicking a submitted word on the board will tell you its definition.
|
||||
- Right clicking a submitted word on the board will tell you how many possible words could have been played there, taking all previous information into account.
|
||||
- Right clicking the row below the last submitted word will tell you how many possibilities there are taking all previous information into account.
|
||||
- The game mode is reflected in the url, allowing you to share a game mode directly.
|
||||
- You can share a link to a specific game number, allowing you to play historical games, and share specific rounds of the faster changing modes with your friends.
|
||||
- You can access previous games from the settings menu by inputting a game number or link.
|
||||
- Service worker which allows the game to be easily downloaded as a progressive web app and run offline.
|
||||
- Give Up button.
|
||||
|
||||
## Additional modes
|
||||
The game mode can be changed by clicking WORDLE+ at the top of the screen or swiping the board in either direction.
|
||||
|
||||
**Hourly mode**: A new word every hour.
|
||||
|
||||
**Infinite mode**: A new word every time you refresh, for the true addicts.
|
||||
|
||||
# Technical details
|
||||
This is written with Svelte in Typescript. This is my first Svelte project, and is intended as an exercise to help me learn and become proficient in Svelte. It also uses some basic scss for styling.
|
||||
|
||||
The project was initialized using `npm init vite@latest` and selecting the Svelte template.
|
||||
|
||||
# Forking this project
|
||||
Anybody is welcome to fork this repository and do what they like with it, provided they follow the accompanying license (GPL-3.0).
|
||||
I would also appreciate if you could link back to this repository and credit me in your project.
|
||||
|
||||
Have fun :)
|
||||
|
||||
# Analytics
|
||||
This project contains basic google analytics which log the following information:
|
||||
- Number of visitors
|
||||
- Visitor's Country
|
||||
- Whether they arrived via a direct link or a search engine
|
||||
- Total number of people on site
|
||||
|
||||
This information cannot be linked back to individual users. It is for my own personal use and is not shared with anyone else. This is my first "major" public facing project and being able to see how many people are playing from all over the world is a big factor in my motivation to continue working on it.
|
||||
|
||||
<details>
|
||||
<summary>How to create a new mode</summary>
|
||||
|
||||
- Add the mode name to the **end** of the GameMode enum in `enums.ts`
|
||||
- Add a case for that mode in the newSeed function in `utils.ts`
|
||||
- Add a ModeData object to the modeData modes array in `utils.ts`
|
||||
</details>
|
||||
|
||||
## Stargazers over time
|
||||
[](https://starchart.cc/MikhaD/wordle)
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 109 KiB |
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
|
||||
|
||||
<meta name="theme-color" content="#6aaa64" />
|
||||
<link rel="manifest" href="/WebGames-master/WebGames-master/games/wordle/wordle-main.zip_unzipped/wordle-main/public/manifest.json">
|
||||
<link rel="shortcut icon" href="/WebGames-master/WebGames-master/games/wordle/wordle-main.zip_unzipped/wordle-main/public/img/logo_32x32.png" type="image/x-icon">
|
||||
<link rel="apple-touch-icon" href="/WebGames-master/WebGames-master/games/wordle/wordle-main.zip_unzipped/wordle-main/public/img/logo_192x192.png" />
|
||||
<link rel="stylesheet" href="/WebGames-master/WebGames-master/games/wordle/wordle-main.zip_unzipped/wordle-main/public/global.css">
|
||||
|
||||
<meta name="author" content="MikhaD">
|
||||
<meta name="description"
|
||||
content="Wordle with infinite, hourly and daily modes. Double tap on a word to learn it's definition.">
|
||||
<meta name="keywords"
|
||||
content="wordle, infinite wordle, wordle infinite, infinate wordle, infinte wordle, unlimited, daily wordle, wordle+, word game, puzzle, game">
|
||||
|
||||
<!-- FB Meta Tags -->
|
||||
<meta property="og:url" content="https://mikhad.github.io/wordle/">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:title" content="Wordle+ | An infinite word guessing game">
|
||||
<meta property="og:description" content="Guess the word in 6 tries. Play daily, hourly and infinite modes.">
|
||||
<meta property="og:image" content="https://mikhad.github.io/wordle/img/og_1200x630.png">
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<meta name="google-site-verification" content="nfr4xQiyHWYkamHQq6M7E9kXoXp8tmNihRU0c5yXjlw" />
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-RHN319RJ6V"></script>
|
||||
|
||||
<script type="module" src="/WebGames-master/WebGames-master/games/wordle/wordle-main.zip_unzipped/wordle-main/src/main.ts"></script>
|
||||
<!-- changed to something more suited to being the title of a tab in App.svelte. This title is for SEO -->
|
||||
<title>Infinite wordle - Play unlimited wordles | Wordle+</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "wordle+",
|
||||
"description": "A remake of the popular game Wordle with additional modes and features.",
|
||||
"version": "1.5.2",
|
||||
"type": "module",
|
||||
"private": "true",
|
||||
"license": "GPL-3.0",
|
||||
"scripts": {
|
||||
"dev": "vite --host",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/MikhaD/wordle.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "MikhaD",
|
||||
"bugs": {
|
||||
"url": "https://github.com/MikhaD/wordle/issues"
|
||||
},
|
||||
"homepage": "https://github.com/MikhaD/wordle#readme",
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^2.0.2",
|
||||
"@tsconfig/svelte": "^3.0.0",
|
||||
"svelte": "^3.55.0",
|
||||
"svelte-check": "^3.0.1",
|
||||
"tslib": "^2.4.1",
|
||||
"typescript": "^4.9.4",
|
||||
"vite": "^4.0.4",
|
||||
"sass": "^1.57.1",
|
||||
"seedrandom": "^3.0.5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
:root {
|
||||
font-family: Arial, sans-serif;
|
||||
background: var(--bg-primary);
|
||||
color: var(--fg-primary);
|
||||
font-size: var(--fs-regular);
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
|
||||
--fs-tiny: 12px;
|
||||
--fs-small: 14px;
|
||||
--fs-regular: 16px;
|
||||
--fs-medium: 20px;
|
||||
--fs-large: 36px;
|
||||
|
||||
--game-width: 500px;
|
||||
|
||||
--fg-primary: #d7dadc;
|
||||
--fg-secondary: #818384;
|
||||
--icon-color: #565758;
|
||||
--border-primary: #3a3a3c;
|
||||
--border-secondary: #272729;
|
||||
--bg-secondary: #1a1a1b;
|
||||
--mode-symbol-color: var(--bg-secondary);
|
||||
--bg-primary: #121213;
|
||||
|
||||
--red: #9C2323;
|
||||
--color-present: #b59f3b;
|
||||
--color-correct: #538d4e;
|
||||
--color-absent: var(--border-primary);
|
||||
--evaluated-key-color: var(--fg-primary);
|
||||
--key-bg: var(--fg-secondary);
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%
|
||||
}
|
||||
|
||||
.light {
|
||||
--fg-primary: #1a1a1b;
|
||||
--fg-secondary: #787c7e;
|
||||
--icon-color: var(--fg-secondary);
|
||||
--border-primary: #d3d6da;
|
||||
--border-secondary: var(--border-primary);
|
||||
--bg-secondary: #e0e0e0;
|
||||
--mode-symbol-color: #f1f1f1;
|
||||
--bg-primary: #ffffff;
|
||||
|
||||
--red: #C42C2C;
|
||||
--color-present: #c9b458;
|
||||
--color-correct: #6aaa64;
|
||||
--color-absent: var(--fg-secondary);
|
||||
--evaluated-key-color: var(--bg-primary);
|
||||
--key-bg: var(--border-primary);
|
||||
}
|
||||
|
||||
.colorblind {
|
||||
--color-correct: #f5793a;
|
||||
--color-present: #85c0f9;
|
||||
}
|
||||
|
||||
h3 {
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.⬛,
|
||||
.🟨,
|
||||
.🟩 {
|
||||
color: var(--evaluated-key-color);
|
||||
}
|
||||
|
||||
a:link,
|
||||
a:visited {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.tutorial {
|
||||
--arrow-size: 10px;
|
||||
--padding: 10px;
|
||||
font-size: var(--fs-small);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: initial;
|
||||
position: absolute;
|
||||
top: calc(var(--arrow-size) + var(--height));
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: max-content;
|
||||
max-width: min(var(--game-width), 95vw);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: var(--padding);
|
||||
border-radius: 4px;
|
||||
color: var(--bg-primary);
|
||||
background: var(--fg-primary);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.tutorial::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translate(-50%);
|
||||
top: calc(-2 * var(--arrow-size));
|
||||
border: var(--arrow-size) solid transparent;
|
||||
border-bottom: var(--arrow-size) solid var(--fg-primary);
|
||||
}
|
||||
|
||||
.ok {
|
||||
padding: 10px;
|
||||
margin-left: var(--padding);
|
||||
border-radius: 4px;
|
||||
color: white;
|
||||
background: var(--color-correct);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button {
|
||||
margin-top: 15px;
|
||||
text-transform: uppercase;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
font-size: var(--fs-medium);
|
||||
font-weight: bold;
|
||||
padding: 15px;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
select {
|
||||
border: solid 1px var(--border-secondary);
|
||||
padding: 8px;
|
||||
min-width: 85px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
background: var(--bg-secondary);
|
||||
color: var(--fg-primary);
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 705 B |
|
After Width: | Height: | Size: 918 B |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"short_name": "Wordle+",
|
||||
"name": "Wordle+",
|
||||
"start_url": "https://mikhad.github.io/wordle/",
|
||||
"background_color": "#6aaa64",
|
||||
"theme_color": "#6aaa64",
|
||||
"description": "A daily, hourly, INFINITE word game",
|
||||
"display": "standalone",
|
||||
"icons": [
|
||||
{
|
||||
"src": "img/logo_48x48.png",
|
||||
"type": "image/png",
|
||||
"sizes": "48x48",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "img/logo_72x72.png",
|
||||
"type": "image/png",
|
||||
"sizes": "72x72",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "img/logo_96x96.png",
|
||||
"type": "image/png",
|
||||
"sizes": "96x96",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "img/logo_144x144.png",
|
||||
"type": "image/png",
|
||||
"sizes": "144x144",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "img/logo_168x168.png",
|
||||
"type": "image/png",
|
||||
"sizes": "168x168",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "img/logo_192x192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "img/logo_512x512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512",
|
||||
"purpose": "maskable any"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
//! IF ANYTHING IN THIS FILE IS CHANGED MAKE SURE setVersion.js HAS ALSO BEEN UPDATED
|
||||
// Increase the v number when the app is updated
|
||||
const version = "1.5.2";
|
||||
const cacheName = `wordle+-v${version}`;
|
||||
|
||||
const assetsToCache = [
|
||||
"./",
|
||||
"./index.html",
|
||||
`./index-${version}.css`,
|
||||
`./index-${version}.js`,
|
||||
"./global.css",
|
||||
];
|
||||
|
||||
/**
|
||||
* Special log function to clearly distinguish logs from the service worker.
|
||||
* @param {string} text - The text to log
|
||||
*/
|
||||
function log(text) {
|
||||
console.log("%cService Worker", "color: purple; font-weight: 600; background: white; padding: 0 5px; border-radius: 2px", text);
|
||||
}
|
||||
|
||||
self.addEventListener("install", e => {
|
||||
log("Installing");
|
||||
e.waitUntil((async () => {
|
||||
const cache = await caches.open(cacheName);
|
||||
await cache.addAll(assetsToCache);
|
||||
})());
|
||||
});
|
||||
|
||||
self.addEventListener("fetch", e => {
|
||||
log("Fetching definition");
|
||||
e.respondWith((async () => {
|
||||
const r = await caches.match(e.request);
|
||||
if (r) {
|
||||
log("Definition found in cache");
|
||||
return r;
|
||||
};
|
||||
const response = await fetch(e.request);
|
||||
const cache = await caches.open("defs");
|
||||
log("Caching definition");
|
||||
cache.put(e.request, response.clone());
|
||||
return response;
|
||||
})());
|
||||
});
|
||||
|
||||
// When the name of the cache changes (because the app has been updated) delete the old cache
|
||||
self.addEventListener("activate", e => {
|
||||
e.waitUntil(caches.keys().then(keys => {
|
||||
return Promise.all(keys.map((key) => {
|
||||
if (key === cacheName || key === "defs") return;
|
||||
log(`Cache updated to ${cacheName.split("-")[1]}, old cache deleted`);
|
||||
return caches.delete(key);
|
||||
}));
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
<script context="module" lang="ts">
|
||||
import {
|
||||
modeData,
|
||||
seededRandomInt,
|
||||
Stats,
|
||||
GameState,
|
||||
Settings,
|
||||
LetterStates,
|
||||
getWordNumber,
|
||||
words,
|
||||
} from "./utils";
|
||||
import Game from "./components/Game.svelte";
|
||||
import { letterStates, settings, mode } from "./stores";
|
||||
import { GameMode } from "./enums";
|
||||
import { Toaster } from "./components/widgets";
|
||||
import { setContext } from "svelte";
|
||||
|
||||
document.title = "Wordle+ | An infinite word guessing game";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export let version: string;
|
||||
setContext("version", version);
|
||||
localStorage.setItem("version", version);
|
||||
let stats: Stats;
|
||||
let word: string;
|
||||
let state: GameState;
|
||||
let toaster: Toaster;
|
||||
|
||||
settings.set(new Settings(localStorage.getItem("settings")));
|
||||
settings.subscribe((s) => localStorage.setItem("settings", JSON.stringify(s)));
|
||||
|
||||
const hash = window.location.hash.slice(1).split("/");
|
||||
const modeVal: GameMode = !isNaN(GameMode[hash[0]])
|
||||
? GameMode[hash[0]]
|
||||
: +localStorage.getItem("mode") || modeData.default;
|
||||
mode.set(modeVal);
|
||||
// If this is a link to a specific word make sure that that is the word
|
||||
if (!isNaN(+hash[1]) && +hash[1] < getWordNumber(modeVal)) {
|
||||
modeData.modes[modeVal].seed =
|
||||
(+hash[1] - 1) * modeData.modes[modeVal].unit + modeData.modes[modeVal].start;
|
||||
modeData.modes[modeVal].historical = true;
|
||||
}
|
||||
mode.subscribe((m) => {
|
||||
localStorage.setItem("mode", `${m}`);
|
||||
window.location.hash = GameMode[m];
|
||||
stats = new Stats(localStorage.getItem(`stats-${m}`) || m);
|
||||
word = words.words[seededRandomInt(0, words.words.length, modeData.modes[m].seed)];
|
||||
if (modeData.modes[m].historical) {
|
||||
state = new GameState(m, localStorage.getItem(`state-${m}-h`));
|
||||
} else {
|
||||
state = new GameState(m, localStorage.getItem(`state-${m}`));
|
||||
}
|
||||
// Set the letter states when data for a new game mode is loaded so the keyboard is correct
|
||||
letterStates.set(new LetterStates(state.board));
|
||||
});
|
||||
|
||||
$: saveState(state);
|
||||
function saveState(state: GameState) {
|
||||
if (modeData.modes[$mode].historical) {
|
||||
localStorage.setItem(`state-${$mode}-h`, state.toString());
|
||||
} else {
|
||||
localStorage.setItem(`state-${$mode}`, state.toString());
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Toaster bind:this={toaster} />
|
||||
{#if toaster}
|
||||
<Game {stats} bind:word {toaster} bind:game={state} />
|
||||
{/if}
|
||||
@@ -0,0 +1,288 @@
|
||||
<script lang="ts">
|
||||
import { fade } from "svelte/transition";
|
||||
import Header from "./Header.svelte";
|
||||
import { Board } from "./board";
|
||||
import Keyboard from "./keyboard";
|
||||
import Modal from "./Modal.svelte";
|
||||
import { getContext, onMount, setContext } from "svelte";
|
||||
import Settings from "./settings";
|
||||
import {
|
||||
Share,
|
||||
Separator,
|
||||
Definition,
|
||||
Tutorial,
|
||||
Statistics,
|
||||
Distribution,
|
||||
Timer,
|
||||
Toaster,
|
||||
ShareGame,
|
||||
Tips,
|
||||
Historical,
|
||||
} from "./widgets";
|
||||
import {
|
||||
contractNum,
|
||||
DELAY_INCREMENT,
|
||||
PRAISE,
|
||||
modeData,
|
||||
ROWS,
|
||||
COLS,
|
||||
newSeed,
|
||||
GameState,
|
||||
seededRandomInt,
|
||||
LetterStates,
|
||||
words,
|
||||
Stats,
|
||||
} from "../utils";
|
||||
import { letterStates, settings, mode } from "../stores";
|
||||
|
||||
export let word: string;
|
||||
export let stats: Stats;
|
||||
export let game: GameState;
|
||||
export let toaster: Toaster;
|
||||
|
||||
setContext("toaster", toaster);
|
||||
const version = getContext<string>("version");
|
||||
|
||||
// implement transition delay on keys
|
||||
const delay = DELAY_INCREMENT * ROWS + 800;
|
||||
|
||||
let showTutorial = $settings.tutorial === 3;
|
||||
let showSettings = false;
|
||||
let showStats = false;
|
||||
let showHistorical = false;
|
||||
let showRefresh = false;
|
||||
|
||||
let board: Board;
|
||||
let timer: Timer;
|
||||
|
||||
function submitWord() {
|
||||
if (game.latestWord.length !== COLS) {
|
||||
toaster.pop("Not enough letters");
|
||||
board.shake(game.guesses);
|
||||
} else if (words.contains(game.latestWord)) {
|
||||
if (game.guesses > 0) {
|
||||
const hm = game.checkHardMode();
|
||||
if ($settings.hard[$mode]) {
|
||||
if (hm.type === "🟩") {
|
||||
toaster.pop(
|
||||
`${contractNum(hm.pos + 1)} letter must be ${hm.char.toUpperCase()}`
|
||||
);
|
||||
board.shake(game.guesses);
|
||||
return;
|
||||
} else if (hm.type === "🟨") {
|
||||
toaster.pop(`Guess must contain ${hm.char.toUpperCase()}`);
|
||||
board.shake(game.guesses);
|
||||
return;
|
||||
}
|
||||
} else if (hm.type !== "⬛") {
|
||||
game.validHard = false;
|
||||
}
|
||||
}
|
||||
game.board.state[game.guesses] = game.guess(word);
|
||||
++game.guesses;
|
||||
$letterStates.update(game.lastState, game.lastWord);
|
||||
$letterStates = $letterStates;
|
||||
if (game.lastWord === word) win();
|
||||
else if (game.guesses === ROWS) lose();
|
||||
} else {
|
||||
toaster.pop("Not in word list");
|
||||
board.shake(game.guesses);
|
||||
}
|
||||
}
|
||||
|
||||
function win() {
|
||||
board.bounce(game.guesses - 1);
|
||||
game.active = false;
|
||||
setTimeout(
|
||||
() => toaster.pop(PRAISE[game.guesses - 1]),
|
||||
DELAY_INCREMENT * COLS + DELAY_INCREMENT
|
||||
);
|
||||
setTimeout(setShowStatsTrue, delay * 1.4);
|
||||
if (!modeData.modes[$mode].historical) {
|
||||
stats.addWin(game.guesses, modeData.modes[$mode]);
|
||||
stats = stats;
|
||||
localStorage.setItem(`stats-${$mode}`, stats.toString());
|
||||
}
|
||||
}
|
||||
|
||||
function lose() {
|
||||
game.active = false;
|
||||
setTimeout(setShowStatsTrue, delay);
|
||||
if (!modeData.modes[$mode].historical) {
|
||||
stats.addLoss(modeData.modes[$mode]);
|
||||
stats = stats;
|
||||
localStorage.setItem(`stats-${$mode}`, stats.toString());
|
||||
}
|
||||
}
|
||||
|
||||
function concede() {
|
||||
showSettings = false;
|
||||
setTimeout(setShowStatsTrue, DELAY_INCREMENT);
|
||||
lose();
|
||||
}
|
||||
|
||||
function reload() {
|
||||
modeData.modes[$mode].historical = false;
|
||||
modeData.modes[$mode].seed = newSeed($mode);
|
||||
game = new GameState($mode, localStorage.getItem(`state-${$mode}`));
|
||||
word = words.words[seededRandomInt(0, words.words.length, modeData.modes[$mode].seed)];
|
||||
$letterStates = new LetterStates();
|
||||
showStats = false;
|
||||
showRefresh = false;
|
||||
timer.reset($mode);
|
||||
}
|
||||
|
||||
function setShowStatsTrue() {
|
||||
if (!game.active) showStats = true;
|
||||
}
|
||||
|
||||
function onSwipe(e: Swipe) {
|
||||
switch (e.detail.direction) {
|
||||
case "left":
|
||||
$mode = ($mode + 1) % modeData.modes.length;
|
||||
toaster.pop(modeData.modes[$mode].name);
|
||||
break;
|
||||
case "right":
|
||||
$mode = ($mode - 1 + modeData.modes.length) % modeData.modes.length;
|
||||
toaster.pop(modeData.modes[$mode].name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if (!game.active) setTimeout(setShowStatsTrue, delay);
|
||||
});
|
||||
// $: toaster.pop(word);
|
||||
</script>
|
||||
|
||||
<svelte:body on:click={board.hideCtx} on:contextmenu={board.hideCtx} />
|
||||
|
||||
<main class:guesses={game.guesses !== 0} style="--rows: {ROWS}; --cols: {COLS}">
|
||||
<Header
|
||||
bind:showRefresh
|
||||
tutorial={$settings.tutorial === 2}
|
||||
on:closeTutPopUp|once={() => ($settings.tutorial = 1)}
|
||||
showStats={stats.played > 0 || (modeData.modes[$mode].historical && !game.active)}
|
||||
on:stats={() => (showStats = true)}
|
||||
on:tutorial={() => (showTutorial = true)}
|
||||
on:settings={() => (showSettings = true)}
|
||||
on:reload={reload}
|
||||
/>
|
||||
<Board
|
||||
bind:this={board}
|
||||
bind:value={game.board.words}
|
||||
tutorial={$settings.tutorial === 1}
|
||||
on:closeTutPopUp|once={() => ($settings.tutorial = 0)}
|
||||
board={game.board}
|
||||
guesses={game.guesses}
|
||||
icon={modeData.modes[$mode].icon}
|
||||
on:swipe={onSwipe}
|
||||
/>
|
||||
<Keyboard
|
||||
on:keystroke={() => {
|
||||
if ($settings.tutorial) $settings.tutorial = 0;
|
||||
board.hideCtx();
|
||||
}}
|
||||
bind:value={game.board.words[game.guesses === ROWS ? 0 : game.guesses]}
|
||||
on:submitWord={submitWord}
|
||||
on:esc={() => {
|
||||
showTutorial = false;
|
||||
showStats = false;
|
||||
showSettings = false;
|
||||
}}
|
||||
disabled={!game.active || $settings.tutorial === 3 || showHistorical}
|
||||
/>
|
||||
</main>
|
||||
|
||||
<Modal
|
||||
bind:visible={showTutorial}
|
||||
on:close|once={() => $settings.tutorial === 3 && --$settings.tutorial}
|
||||
fullscreen={$settings.tutorial === 0}
|
||||
>
|
||||
<Tutorial visible={showTutorial} />
|
||||
</Modal>
|
||||
|
||||
<Modal bind:visible={showStats}>
|
||||
{#if modeData.modes[$mode].historical}
|
||||
<h2 class="historical">Statistics not available for historical games</h2>
|
||||
{:else}
|
||||
<Statistics data={stats} />
|
||||
<Distribution distribution={stats.guesses} {game} />
|
||||
{/if}
|
||||
<Separator visible={!game.active}>
|
||||
<Timer
|
||||
slot="1"
|
||||
bind:this={timer}
|
||||
on:timeup={() => (showRefresh = true)}
|
||||
on:reload={reload}
|
||||
/>
|
||||
<Share slot="2" state={game} />
|
||||
</Separator>
|
||||
<ShareGame wordNumber={game.wordNumber} />
|
||||
{#if !game.active}
|
||||
<Definition {word} alternates={2} />
|
||||
{:else}
|
||||
<!-- Fade with delay is to prevent a bright red button from appearing as soon as refresh is pressed -->
|
||||
<div
|
||||
in:fade={{ delay: 300 }}
|
||||
class="button concede"
|
||||
on:click={concede}
|
||||
on:keydown={concede}
|
||||
>
|
||||
give up
|
||||
</div>
|
||||
{/if}
|
||||
</Modal>
|
||||
|
||||
<Modal fullscreen={true} bind:visible={showSettings}>
|
||||
<Settings state={game} on:historical={() => (showHistorical = true)} />
|
||||
{#if game.active}
|
||||
<div class="button concede" on:click={concede} on:keydown={concede}>give up</div>
|
||||
{/if}
|
||||
<Tips change={showSettings} />
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<a href="https://www.nytimes.com/games/wordle/" target="_blank" rel="noreferrer"
|
||||
>Original Wordle</a
|
||||
>
|
||||
<div>
|
||||
<div>v{version}</div>
|
||||
<div
|
||||
title="double click to reset your stats"
|
||||
class="word"
|
||||
on:dblclick={() => {
|
||||
localStorage.clear();
|
||||
toaster.pop("localStorage cleared");
|
||||
}}
|
||||
>
|
||||
{modeData.modes[$mode].name} word #{game.wordNumber}
|
||||
</div>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
|
||||
<Modal bind:visible={showHistorical}>
|
||||
<Historical bind:showSettings />
|
||||
</Modal>
|
||||
|
||||
<style lang="scss">
|
||||
main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
max-width: var(--game-width);
|
||||
margin: auto;
|
||||
position: relative;
|
||||
}
|
||||
.historical {
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
padding: 0 20px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.concede {
|
||||
background-color: var(--red);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script lang="ts">
|
||||
export let onClick = () => {};
|
||||
</script>
|
||||
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
on:click={onClick}
|
||||
on:keypress={onClick}
|
||||
>
|
||||
<slot />
|
||||
</svg>
|
||||
|
||||
<style lang="scss">
|
||||
svg {
|
||||
cursor: pointer;
|
||||
width: 24px;
|
||||
margin: 0 4px;
|
||||
:global(path) {
|
||||
fill: var(--icon-color);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,109 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher, getContext } from "svelte";
|
||||
import { scale, fade } from "svelte/transition";
|
||||
import { mode } from "../stores";
|
||||
import { modeData, timeRemaining } from "../utils";
|
||||
import GameIcon from "./GameIcon.svelte";
|
||||
import type { Toaster } from "./widgets";
|
||||
|
||||
export let showStats: boolean;
|
||||
export let tutorial: boolean;
|
||||
export let showRefresh: boolean;
|
||||
|
||||
export let toaster = getContext<Toaster>("toaster");
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
mode.subscribe((m) => {
|
||||
if (timeRemaining(modeData.modes[m]) > 0) {
|
||||
showRefresh = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<header>
|
||||
<div class="icons">
|
||||
<GameIcon onClick={() => dispatch("tutorial")}>
|
||||
<path
|
||||
d="M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"
|
||||
/>
|
||||
</GameIcon>
|
||||
{#if showRefresh}
|
||||
<GameIcon onClick={() => dispatch("reload")}>
|
||||
<path
|
||||
transition:fade={{ duration: 200 }}
|
||||
d="M4.609 12c0-4.082 3.309-7.391 7.391-7.391a7.39 7.39 0 0 1 6.523 3.912l-1.653 1.567H22v-5.13l-1.572 1.659C18.652 3.841 15.542 2 12 2 6.477 2 2 6.477 2 12s4.477 10 10 10c4.589 0 8.453-3.09 9.631-7.301l-2.512-.703c-.871 3.113-3.73 5.395-7.119 5.395-4.082 0-7.391-3.309-7.391-7.391z"
|
||||
/>
|
||||
</GameIcon>
|
||||
{/if}
|
||||
</div>
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<h1
|
||||
on:click|self={() => {
|
||||
$mode = ($mode + 1) % modeData.modes.length;
|
||||
toaster.pop(modeData.modes[$mode].name);
|
||||
}}
|
||||
on:contextmenu|preventDefault|self={() => {
|
||||
$mode = ($mode - 1 + modeData.modes.length) % modeData.modes.length;
|
||||
toaster.pop(modeData.modes[$mode].name);
|
||||
}}
|
||||
>
|
||||
wordle+
|
||||
</h1>
|
||||
<div class="icons">
|
||||
{#if showStats}
|
||||
<GameIcon onClick={() => dispatch("stats")}>
|
||||
<path
|
||||
transition:fade={{ duration: 200 }}
|
||||
d="M16,11V3H8v6H2v12h20V11H16z M10,5h4v14h-4V5z M4,11h4v8H4V11z M20,19h-4v-6h4V19z"
|
||||
/>
|
||||
</GameIcon>
|
||||
{/if}
|
||||
<GameIcon onClick={() => dispatch("settings")}>
|
||||
<path
|
||||
d="M19.14,12.94c0.04-0.3,0.06-0.61,0.06-0.94c0-0.32-0.02-0.64-0.07-0.94l2.03-1.58c0.18-0.14,0.23-0.41,0.12-0.61 l-1.92-3.32c-0.12-0.22-0.37-0.29-0.59-0.22l-2.39,0.96c-0.5-0.38-1.03-0.7-1.62-0.94L14.4,2.81c-0.04-0.24-0.24-0.41-0.48-0.41 h-3.84c-0.24,0-0.43,0.17-0.47,0.41L9.25,5.35C8.66,5.59,8.12,5.92,7.63,6.29L5.24,5.33c-0.22-0.08-0.47,0-0.59,0.22L2.74,8.87 C2.62,9.08,2.66,9.34,2.86,9.48l2.03,1.58C4.84,11.36,4.8,11.69,4.8,12s0.02,0.64,0.07,0.94l-2.03,1.58 c-0.18,0.14-0.23,0.41-0.12,0.61l1.92,3.32c0.12,0.22,0.37,0.29,0.59,0.22l2.39-0.96c0.5,0.38,1.03,0.7,1.62,0.94l0.36,2.54 c0.05,0.24,0.24,0.41,0.48,0.41h3.84c0.24,0,0.44-0.17,0.47-0.41l0.36-2.54c0.59-0.24,1.13-0.56,1.62-0.94l2.39,0.96 c0.22,0.08,0.47,0,0.59-0.22l1.92-3.32c0.12-0.22,0.07-0.47-0.12-0.61L19.14,12.94z M12,15.6c-1.98,0-3.6-1.62-3.6-3.6 s1.62-3.6,3.6-3.6s3.6,1.62,3.6,3.6S13.98,15.6,12,15.6z"
|
||||
/>
|
||||
</GameIcon>
|
||||
</div>
|
||||
{#if tutorial}
|
||||
<div
|
||||
transition:scale
|
||||
class="tutorial"
|
||||
on:click={() => dispatch("closeTutPopUp")}
|
||||
on:keydown={() => dispatch("closeTutPopUp")}
|
||||
>
|
||||
Swipe board or tap WORDLE+ to change game mode
|
||||
<span class="ok">OK</span>
|
||||
</div>
|
||||
{/if}
|
||||
</header>
|
||||
|
||||
<style lang="scss">
|
||||
header {
|
||||
--height: 51px;
|
||||
position: relative;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
width: 100%;
|
||||
height: var(--height);
|
||||
position: relative;
|
||||
}
|
||||
.icons {
|
||||
height: 100%;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
}
|
||||
h1 {
|
||||
position: absolute;
|
||||
width: max-content;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: var(--fs-large);
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,106 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
import GameIcon from "./GameIcon.svelte";
|
||||
|
||||
export let visible = false;
|
||||
export let fullscreen = false;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
function close() {
|
||||
visible = false;
|
||||
dispatch("close");
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
class:visible
|
||||
class="overlay {fullscreen ? 'fullscreen' : 'popup'}"
|
||||
on:click|self={close}
|
||||
on:keydown|self={close}
|
||||
>
|
||||
<div class="modal">
|
||||
<div class="exit" on:click={close} on:keydown={close}>
|
||||
<GameIcon>
|
||||
<path
|
||||
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
|
||||
/>
|
||||
</GameIcon>
|
||||
</div>
|
||||
<div class="content" on:close={close}>
|
||||
<slot />
|
||||
</div>
|
||||
<div class="footer">
|
||||
<slot name="footer" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.overlay {
|
||||
transition: all 0.2s ease;
|
||||
font-size: var(--fs-small);
|
||||
visibility: hidden;
|
||||
z-index: 1;
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
inset: 0;
|
||||
background: #0008;
|
||||
}
|
||||
.fullscreen.overlay {
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
.modal {
|
||||
margin: auto;
|
||||
background: var(--bg-primary);
|
||||
max-width: var(--game-width);
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
top: 10vh;
|
||||
transition: all 0.2s ease;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.popup .modal {
|
||||
--modal-padding: 16px;
|
||||
height: min-content;
|
||||
max-height: 90%;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--bg-secondary);
|
||||
padding: var(--modal-padding);
|
||||
padding-top: calc(2 * var(--modal-padding));
|
||||
width: 90%;
|
||||
}
|
||||
.content > :global(div) {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.fullscreen .modal {
|
||||
height: 100%;
|
||||
padding: 10px 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
.exit {
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
}
|
||||
}
|
||||
.overlay.visible,
|
||||
.visible .modal {
|
||||
top: 0;
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
.exit {
|
||||
position: absolute;
|
||||
top: var(--modal-padding);
|
||||
right: var(--modal-padding);
|
||||
}
|
||||
.footer {
|
||||
color: var(--fg-secondary);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
text-align: end;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,130 @@
|
||||
<script lang="ts">
|
||||
import { getRowData, words } from "../../utils";
|
||||
|
||||
import Row from "./Row.svelte";
|
||||
import ContextMenu from "../widgets/ContextMenu.svelte";
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { scale } from "svelte/transition";
|
||||
|
||||
export let value: string[];
|
||||
export let board: GameBoard;
|
||||
export let guesses: number;
|
||||
export let icon: string;
|
||||
export let tutorial: boolean;
|
||||
export function shake(row: number) {
|
||||
rows[row].shake();
|
||||
}
|
||||
export function bounce(row: number) {
|
||||
rows[row].bounce();
|
||||
}
|
||||
export function hideCtx(e?: MouseEvent) {
|
||||
if (!e || !e.defaultPrevented) showCtx = false;
|
||||
}
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let rows: Row[] = [];
|
||||
let showCtx = false;
|
||||
let pAns = 0;
|
||||
let pSols = 0;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
let word = "";
|
||||
|
||||
function context(cx: number, cy: number, num: number, val: string) {
|
||||
if (guesses >= num) {
|
||||
x = cx;
|
||||
y = cy;
|
||||
showCtx = true;
|
||||
word = guesses > num ? val : "";
|
||||
|
||||
const match = getRowData(num, board);
|
||||
pAns = words.words.filter((w) => match(w)).length;
|
||||
pSols = pAns + words.valid.filter((w) => match(w)).length;
|
||||
}
|
||||
}
|
||||
|
||||
const swipeThreshold = 120;
|
||||
const swipeTolerance = 100;
|
||||
const maxSwipePeriod = 300;
|
||||
|
||||
let startX: number;
|
||||
let startY: number;
|
||||
let startTime: number;
|
||||
|
||||
function swipeStart(e: TouchEvent) {
|
||||
startX = e.changedTouches[0].pageX;
|
||||
startY = e.changedTouches[0].pageY;
|
||||
startTime = Date.now();
|
||||
}
|
||||
|
||||
function swipeEnd(e: TouchEvent) {
|
||||
let deltaX = e.changedTouches[0].clientX - startX;
|
||||
let deltaY = e.changedTouches[0].clientY - startY;
|
||||
let elapsed = Date.now() - startTime;
|
||||
if (elapsed > maxSwipePeriod) return;
|
||||
if (Math.abs(deltaX) >= swipeThreshold && Math.abs(deltaY) < swipeTolerance) {
|
||||
dispatch("swipe", { direction: deltaX < 0 ? "left" : "right" });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if showCtx}
|
||||
<ContextMenu {pAns} {pSols} {x} {y} {word} />
|
||||
{/if}
|
||||
|
||||
<div class="board" on:touchstart={swipeStart} on:touchend={swipeEnd} on:touchmove|preventDefault>
|
||||
{#each value as _, i}
|
||||
<Row
|
||||
num={i}
|
||||
{guesses}
|
||||
bind:this={rows[i]}
|
||||
bind:value={value[i]}
|
||||
state={board.state[i]}
|
||||
on:ctx={(e) => context(e.detail.x, e.detail.y, i, value[i])}
|
||||
/>
|
||||
{/each}
|
||||
{#if icon}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" fill="none">
|
||||
<path d={icon} stroke-width="14" />
|
||||
</svg>
|
||||
{/if}
|
||||
{#if tutorial}
|
||||
<div
|
||||
transition:scale
|
||||
class="tutorial"
|
||||
on:click={() => dispatch("closeTutPopUp")}
|
||||
on:keydown={() => dispatch("closeTutPopUp")}
|
||||
>
|
||||
double tap a row to see a word's definition, or how many words can be played there
|
||||
<span class="ok">OK</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.board {
|
||||
display: grid;
|
||||
grid-template-rows: repeat(var(--rows), 1fr);
|
||||
gap: 5.5px;
|
||||
max-height: 420px;
|
||||
flex-grow: 1;
|
||||
aspect-ratio: var(--cols) / var(--rows);
|
||||
padding: 10px;
|
||||
position: relative;
|
||||
}
|
||||
svg {
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: min(130%, 100vw);
|
||||
max-height: 100%;
|
||||
}
|
||||
path {
|
||||
stroke: var(--mode-symbol-color);
|
||||
}
|
||||
.tutorial {
|
||||
top: calc(100 / var(--rows) * 1%);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,81 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { COLS } from "../../utils";
|
||||
|
||||
import Tile from "./Tile.svelte";
|
||||
export let guesses: number;
|
||||
export let num: number;
|
||||
export let value = "";
|
||||
export let state: LetterState[];
|
||||
export function shake() {
|
||||
animation = "shake";
|
||||
}
|
||||
export function bounce() {
|
||||
tiles.forEach((e) => e.bounce());
|
||||
}
|
||||
const dispatch = createEventDispatcher();
|
||||
let animation = "";
|
||||
let tiles: Tile[] = [];
|
||||
|
||||
const MAX_DOUBLE_CLICK_INTERVAL = 400;
|
||||
let lastTouch = 0;
|
||||
/**
|
||||
* Detect double clicks on mobile devices by detecting touches <= 500ms apart. This is needed
|
||||
* because listening to touch events on Board prevents Row from receiving dblclick events.
|
||||
*/
|
||||
function onTouch(e: TouchEvent) {
|
||||
if (Date.now() - lastTouch <= MAX_DOUBLE_CLICK_INTERVAL) {
|
||||
e.preventDefault();
|
||||
dispatch("ctx", { x: e.changedTouches[0].clientX, y: e.changedTouches[0].clientY });
|
||||
} else {
|
||||
lastTouch = Date.now();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="board-row"
|
||||
on:contextmenu|preventDefault={(e) => dispatch("ctx", { x: e.clientX, y: e.clientY })}
|
||||
on:dblclick|preventDefault={(e) => dispatch("ctx", { x: e.clientX, y: e.clientY })}
|
||||
on:touchstart={onTouch}
|
||||
on:animationend={() => (animation = "")}
|
||||
data-animation={animation}
|
||||
class:complete={guesses > num}
|
||||
>
|
||||
{#each Array(COLS) as _, i}
|
||||
<Tile bind:this={tiles[i]} state={state[i]} value={value.charAt(i)} position={i} />
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.board-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--cols), 1fr);
|
||||
gap: 5px;
|
||||
&[data-animation="shake"] {
|
||||
animation: shake 0.6s;
|
||||
}
|
||||
}
|
||||
@keyframes shake {
|
||||
10%,
|
||||
90% {
|
||||
transform: translateX(-1px);
|
||||
}
|
||||
|
||||
20%,
|
||||
80% {
|
||||
transform: translateX(2px);
|
||||
}
|
||||
|
||||
30%,
|
||||
50%,
|
||||
70% {
|
||||
transform: translateX(-4px);
|
||||
}
|
||||
|
||||
40%,
|
||||
60% {
|
||||
transform: translateX(4px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,133 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy } from "svelte";
|
||||
|
||||
import { mode } from "../../stores";
|
||||
|
||||
import { DELAY_INCREMENT, ROWS } from "../../utils";
|
||||
|
||||
export let value = "";
|
||||
export let state: LetterState;
|
||||
export let position = 0;
|
||||
export function bounce() {
|
||||
setTimeout(() => (animation = "bounce"), (ROWS + position) * DELAY_INCREMENT);
|
||||
}
|
||||
let s: string;
|
||||
let pop = false;
|
||||
let animation = "";
|
||||
|
||||
// reset animation when value changes, because for some reason changing anination to "" when the game is over causes the tiles to flash
|
||||
$: !value && (animation = "");
|
||||
|
||||
// ensure all animations play
|
||||
const unsub = mode.subscribe(() => {
|
||||
animation = "";
|
||||
s = "🔳";
|
||||
setTimeout(() => (s = ""), 10);
|
||||
});
|
||||
// prevent pop animation from playing at the beginning
|
||||
setTimeout(() => (pop = true), 200);
|
||||
|
||||
onDestroy(unsub);
|
||||
</script>
|
||||
|
||||
<div
|
||||
data-animation={animation}
|
||||
class:value
|
||||
class:pop
|
||||
class="tile {state} {s}"
|
||||
style="transition-delay: {position * DELAY_INCREMENT}ms"
|
||||
>
|
||||
<div class="front">{value}</div>
|
||||
<div class="back">{value}</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
:not(.pop),
|
||||
:global(.complete) .value {
|
||||
scale: 1 !important;
|
||||
opacity: 1 !important;
|
||||
}
|
||||
.value {
|
||||
animation: pop 0.1s;
|
||||
.front {
|
||||
border-color: var(--border-primary);
|
||||
}
|
||||
}
|
||||
.tile {
|
||||
font-size: 2rem;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
position: relative;
|
||||
transform-style: preserve-3d;
|
||||
&[data-animation="bounce"] {
|
||||
animation: bounce 1s;
|
||||
}
|
||||
}
|
||||
.back,
|
||||
.front {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
backface-visibility: hidden;
|
||||
-webkit-backface-visibility: hidden;
|
||||
transition: transform 0s ease-in-out;
|
||||
}
|
||||
.front {
|
||||
border: 2px solid var(--border-primary);
|
||||
transform: rotateX(0deg);
|
||||
color: var(--fg-primary);
|
||||
}
|
||||
.back {
|
||||
background: var(--color-absent);
|
||||
transform: rotateX(180deg);
|
||||
}
|
||||
.🟩 .back {
|
||||
background: var(--color-correct);
|
||||
}
|
||||
.🟨 .back {
|
||||
background: var(--color-present);
|
||||
}
|
||||
:global(.complete) .tile:not(.🔳) .front {
|
||||
transition-delay: inherit !important;
|
||||
transition-duration: 0.8s;
|
||||
transform: rotateX(180deg);
|
||||
}
|
||||
:global(.complete) .tile:not(.🔳) .back {
|
||||
transition-delay: inherit !important;
|
||||
transition-duration: 0.8s;
|
||||
transform: rotateX(0deg);
|
||||
}
|
||||
@keyframes pop {
|
||||
from {
|
||||
scale: 0.8;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
40% {
|
||||
scale: 1.1;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@keyframes bounce {
|
||||
0%,
|
||||
20% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
40% {
|
||||
transform: translateY(-30px);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(5px);
|
||||
}
|
||||
60% {
|
||||
transform: translateY(-15px);
|
||||
}
|
||||
80% {
|
||||
transform: translateY(2px);
|
||||
}
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,2 @@
|
||||
export { default as Board } from "./Board.svelte";
|
||||
export { default as Tile } from "./Tile.svelte";
|
||||
@@ -0,0 +1,50 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
export let letter: string;
|
||||
export let state: LetterState = "🔳";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class={state} class:big={letter.length !== 1} on:click={() => dispatch("keystroke", letter)}>
|
||||
{letter}<slot />
|
||||
</div>
|
||||
|
||||
<style>
|
||||
div {
|
||||
font-size: calc(var(--fs-tiny) + 1px);
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
border-radius: 4px;
|
||||
height: 58px;
|
||||
background: var(--key-bg);
|
||||
cursor: pointer;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex: 1;
|
||||
transition: background-color 0.3s ease-in-out;
|
||||
}
|
||||
:global(.guesses) div {
|
||||
transition-delay: 1s;
|
||||
}
|
||||
:global(.guesses .preventChange) div {
|
||||
transition-duration: 0.15s;
|
||||
transition-delay: 0s;
|
||||
background: var(--key-bg) !important;
|
||||
}
|
||||
.big {
|
||||
font-size: var(--fs-tiny);
|
||||
flex-grow: 1.5;
|
||||
}
|
||||
.⬛ {
|
||||
background: var(--color-absent);
|
||||
}
|
||||
.🟨 {
|
||||
background: var(--color-present);
|
||||
}
|
||||
.🟩 {
|
||||
background: var(--color-correct);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,108 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher, onDestroy } from "svelte/internal";
|
||||
import { letterStates, mode } from "../../stores";
|
||||
import { COLS, keys } from "../../utils";
|
||||
import Key from "./Key.svelte";
|
||||
|
||||
export let value = "";
|
||||
export let disabled = false;
|
||||
let preventChange = true;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
function appendValue(char: string) {
|
||||
if (!disabled && value.length < COLS) {
|
||||
dispatch("keystroke", char);
|
||||
value += char;
|
||||
}
|
||||
}
|
||||
function backspaceValue() {
|
||||
if (!disabled) {
|
||||
value = value.slice(0, value.length - 1);
|
||||
}
|
||||
}
|
||||
function handleKeystroke(e: KeyboardEvent) {
|
||||
if (e.defaultPrevented) return;
|
||||
if (!disabled && !e.ctrlKey && !e.altKey) {
|
||||
if (e.key && /^[a-z]$/.test(e.key.toLowerCase())) {
|
||||
return appendValue(e.key.toLowerCase());
|
||||
}
|
||||
if (e.key === "Backspace") return backspaceValue();
|
||||
|
||||
if (e.key === "Enter") return dispatch("submitWord");
|
||||
}
|
||||
if (e.key === "Escape") dispatch("esc");
|
||||
}
|
||||
|
||||
// Ensure keys change on load instead of loading their state color & change the color of all the keys to neutral, then to their correct color on mode change
|
||||
const unsub = mode.subscribe(() => {
|
||||
preventChange = true;
|
||||
setTimeout(() => (preventChange = false), 200);
|
||||
});
|
||||
onDestroy(unsub);
|
||||
</script>
|
||||
|
||||
<svelte:body on:keydown={handleKeystroke} />
|
||||
|
||||
<div class:preventChange class="keyboard">
|
||||
<div class="row">
|
||||
{#each keys[0] as letter}
|
||||
<Key
|
||||
{letter}
|
||||
on:keystroke={(e) => appendValue(e.detail)}
|
||||
state={$letterStates[letter]}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="row">
|
||||
{#each keys[1] as letter}
|
||||
<Key
|
||||
{letter}
|
||||
on:keystroke={(e) => appendValue(e.detail)}
|
||||
state={$letterStates[letter]}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="row">
|
||||
<Key letter="ENTER" on:keystroke={() => !disabled && dispatch("submitWord")} />
|
||||
{#each keys[2] as letter}
|
||||
<Key
|
||||
{letter}
|
||||
on:keystroke={(e) => appendValue(e.detail)}
|
||||
state={$letterStates[letter]}
|
||||
/>
|
||||
{/each}
|
||||
<Key letter="" on:keystroke={backspaceValue}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
<path
|
||||
d="M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7.07L2.4 12l4.66-7H22v14zm-11.59-2L14 13.41 17.59 17 19 15.59 15.41 12 19 8.41 17.59 7 14 10.59 10.41 7 9 8.41 12.59 12 9 15.59z"
|
||||
/>
|
||||
</svg>
|
||||
</Key>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.keyboard {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.row {
|
||||
touch-action: manipulation;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
margin: 0 auto 8px;
|
||||
padding: 0 8px;
|
||||
gap: 6px;
|
||||
}
|
||||
.row:nth-of-type(2) {
|
||||
padding: 0 30px;
|
||||
}
|
||||
svg {
|
||||
fill: var(--fg-primary);
|
||||
width: 24px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "./Keyboard.svelte";
|
||||
@@ -0,0 +1,11 @@
|
||||
<script lang="ts">
|
||||
export let value: number;
|
||||
export let options: (string | number)[];
|
||||
export let disabled = false;
|
||||
</script>
|
||||
|
||||
<select bind:value {disabled}>
|
||||
{#each options as val, i}
|
||||
<option value={i}>{val}</option>
|
||||
{/each}
|
||||
</select>
|
||||
@@ -0,0 +1,41 @@
|
||||
<script lang="ts">
|
||||
import Switch from "./Switch.svelte";
|
||||
import DropDown from "./DropDown.svelte";
|
||||
export let value: any;
|
||||
export let type: SettingType;
|
||||
export let options: (string | number)[] = [];
|
||||
export let disabled = false;
|
||||
const types = {
|
||||
switch: Switch,
|
||||
dropdown: DropDown,
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="setting">
|
||||
<div>
|
||||
<div class="title"><slot name="title" /></div>
|
||||
<div class="desc"><slot name="desc" /></div>
|
||||
</div>
|
||||
{#if type === "custom"}
|
||||
<slot name="custom" />
|
||||
{:else}
|
||||
<svelte:component this={types[type]} bind:value {options} {disabled} />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.setting {
|
||||
/* border-bottom: 1px solid var(--border-primary); */
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.title {
|
||||
font-size: var(--fs-medium);
|
||||
font-weight: 500;
|
||||
}
|
||||
.desc {
|
||||
font-size: var(--fs-tiny);
|
||||
color: var(--fg-secondary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,114 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher, getContext, onMount } from "svelte";
|
||||
|
||||
import { mode, settings } from "../../stores";
|
||||
import { modeData, GameState } from "../../utils";
|
||||
import type { Toaster } from "../widgets";
|
||||
import Setting from "./Setting.svelte";
|
||||
|
||||
export let state: GameState;
|
||||
|
||||
const toaster = getContext<Toaster>("toaster");
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let root: HTMLElement;
|
||||
onMount(() => {
|
||||
root = document.documentElement;
|
||||
});
|
||||
$: {
|
||||
if (root) {
|
||||
$settings.dark ? root.classList.remove("light") : root.classList.add("light");
|
||||
$settings.colorblind
|
||||
? root.classList.add("colorblind")
|
||||
: root.classList.remove("colorblind");
|
||||
localStorage.setItem("settings", $settings.toString());
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- not currently supported, see https://github.com/sveltejs/svelte/issues/3105 -->
|
||||
<!-- <svelte:body class:light={!$settings.dark} class:colorblind={$settings.colorblind} /> -->
|
||||
<div class="outer">
|
||||
<div class="settings-top">
|
||||
<h3>settings</h3>
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
on:click={() => {
|
||||
if (!state.validHard) {
|
||||
toaster.pop("Game has already violated hard mode");
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Setting type="switch" bind:value={$settings.hard[$mode]} disabled={!state.validHard}>
|
||||
<svelte:fragment slot="title">Hard Mode</svelte:fragment>
|
||||
<svelte:fragment slot="desc">
|
||||
Any revealed hints must be used in subsequent guesses
|
||||
</svelte:fragment>
|
||||
</Setting>
|
||||
</div>
|
||||
<Setting type="switch" bind:value={$settings.dark}>
|
||||
<svelte:fragment slot="title">Dark Theme</svelte:fragment>
|
||||
</Setting>
|
||||
<Setting type="switch" bind:value={$settings.colorblind}>
|
||||
<svelte:fragment slot="title">Color Blind Mode</svelte:fragment>
|
||||
<svelte:fragment slot="desc">High contrast colors</svelte:fragment>
|
||||
</Setting>
|
||||
<Setting type="dropdown" bind:value={$mode} options={modeData.modes.map((e) => e.name)}>
|
||||
<svelte:fragment slot="title">Game Mode</svelte:fragment>
|
||||
<svelte:fragment slot="desc">
|
||||
The game mode determines how often the word refreshes
|
||||
</svelte:fragment>
|
||||
</Setting>
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<Setting type="custom" bind:value={$mode}>
|
||||
<svelte:fragment slot="title">Play Historical Game</svelte:fragment>
|
||||
<svelte:fragment slot="desc">
|
||||
Play a previous word by pasting in a link or setting the date number
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="custom">
|
||||
<svg
|
||||
class="custom"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
on:click={() => dispatch("historical")}
|
||||
>
|
||||
<path
|
||||
d="M19.391 12c0-4.082-3.309-7.391-7.391-7.391a7.39 7.39 0 0 0-6.523 3.912l1.653 1.567H2v-5.13l1.572 1.659A9.99 9.99 0 0 1 12 2a10 10 0 1 1 0 20c-4.589 0-8.453-3.09-9.631-7.301l2.512-.703c.871 3.113 3.73 5.395 7.119 5.395 4.082 0 7.391-3.309 7.391-7.391zM12 7.5a1 1 0 0 1 1 1v3.062l3.288 3.031a1 1 0 0 1-1.356 1.471L11 12.438V8.5a1 1 0 0 1 1-1z"
|
||||
/>
|
||||
</svg>
|
||||
</svelte:fragment>
|
||||
</Setting>
|
||||
<div class="links">
|
||||
<a href="https://github.com/MikhaD/wordle" target="_blank" rel="noreferrer">
|
||||
Leave a ⭐
|
||||
</a>
|
||||
<a href="https://github.com/MikhaD/wordle/issues" target="_blank" rel="noreferrer">
|
||||
Report a Bug
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.outer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.links {
|
||||
font-size: var(--fs-medium);
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
color: var(--fg-secondary);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
:global(.settings-top > div) {
|
||||
padding: 16px 0;
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
}
|
||||
.custom {
|
||||
height: 2rem;
|
||||
fill: var(--fg-secondary);
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,40 @@
|
||||
<script lang="ts">
|
||||
export let value: boolean;
|
||||
export let disabled = false;
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div on:click={(e) => !disabled && (value = !value)} class:checked={value} {disabled} />
|
||||
|
||||
<style lang="scss">
|
||||
div[disabled="true"] {
|
||||
opacity: 0.5;
|
||||
cursor: unset;
|
||||
}
|
||||
div {
|
||||
width: 32px;
|
||||
height: 20px;
|
||||
border-radius: 10px;
|
||||
background: var(--icon-color);
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s ease;
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 16px;
|
||||
aspect-ratio: 1;
|
||||
background: white;
|
||||
border-radius: 50%;
|
||||
margin: 2px;
|
||||
left: 0;
|
||||
transition: left 0.3s ease;
|
||||
}
|
||||
}
|
||||
.checked {
|
||||
background: var(--color-correct);
|
||||
&::before {
|
||||
left: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "./Settings.svelte";
|
||||
@@ -0,0 +1,56 @@
|
||||
<script lang="ts">
|
||||
import Definition from "./Definition.svelte";
|
||||
|
||||
export let x = 0;
|
||||
export let y = 0;
|
||||
export let word = "";
|
||||
export let pAns: number;
|
||||
export let pSols: number;
|
||||
const width = +getComputedStyle(document.body).getPropertyValue("--game-width") / 2;
|
||||
|
||||
$: x = window.innerWidth - x < width ? window.innerWidth - width : x;
|
||||
</script>
|
||||
|
||||
<div class="ctx-menu" style="top: {y}px; left: {x}px;">
|
||||
{#if word !== ""}
|
||||
<div>
|
||||
Considering all hints, this row had:
|
||||
<br /><br />
|
||||
{pAns} possible answer{pAns > 1 ? "s" : ""}
|
||||
<br />
|
||||
{pSols} valid guess{pSols > 1 ? "es" : ""}
|
||||
</div>
|
||||
<Definition {word} alternates={1} />
|
||||
{:else}
|
||||
<div>
|
||||
Considering all hints, there {pAns > 1 ? "are" : "is"}:
|
||||
<br /><br />
|
||||
{pAns} possible answer{pAns > 1 ? "s" : ""}
|
||||
<br />
|
||||
{pSols} valid guess{pSols > 1 ? "es" : ""}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.ctx-menu {
|
||||
position: fixed;
|
||||
z-index: 2;
|
||||
font-size: var(--fs-small);
|
||||
background-color: var(--bg-secondary);
|
||||
border: solid 1px var(--border-primary);
|
||||
border-radius: 4px;
|
||||
padding: 10px;
|
||||
width: calc(var(--game-width) / 2);
|
||||
|
||||
& > :global(*) {
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
& > :global(*:last-child) {
|
||||
border-bottom: none;
|
||||
padding-bottom: unset;
|
||||
padding-top: 5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,62 @@
|
||||
<script context="module" lang="ts">
|
||||
const cache = new Map<string, Promise<DictionaryEntry>>();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export let word: string;
|
||||
/** The maximum number of alternate definitions to provide*/
|
||||
export let alternates = 9;
|
||||
|
||||
async function getWordData(word: string): Promise<DictionaryEntry> {
|
||||
if (!cache.has(word)) {
|
||||
const data = await fetch(`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`, {
|
||||
mode: "cors",
|
||||
});
|
||||
if (data.ok) {
|
||||
cache.set(word, (await data.json())[0]);
|
||||
} else {
|
||||
throw new Error(`Failed to fetch definition`);
|
||||
}
|
||||
}
|
||||
return cache.get(word);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="def">
|
||||
{#await getWordData(word)}
|
||||
<h4>Fetching definition...</h4>
|
||||
{:then data}
|
||||
<h2>{word}</h2>
|
||||
<em>{data.meanings[0].partOfSpeech}</em>
|
||||
<ol>
|
||||
{#if word !== data.word}
|
||||
<li>variant of {data.word}.</li>
|
||||
{/if}
|
||||
{#each data.meanings[0].definitions.slice(0, 1 + alternates - (word !== data.word ? 1 : 0)) as def}
|
||||
<li>{def.definition}</li>
|
||||
{/each}
|
||||
</ol>
|
||||
{:catch}
|
||||
<div>Your word was <strong>{word}</strong>. (failed to fetch definition)</div>
|
||||
{/await}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
h2 {
|
||||
display: inline-block;
|
||||
margin-right: 1rem;
|
||||
margin-bottom: 0.8rem;
|
||||
}
|
||||
ol {
|
||||
padding-left: 1.5rem;
|
||||
}
|
||||
li {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
li::first-letter {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
li::marker {
|
||||
color: var(--fg-secondary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,178 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from "svelte";
|
||||
import { custom_event } from "svelte/internal";
|
||||
import type { Toaster } from ".";
|
||||
import { GameMode } from "../../enums";
|
||||
import { mode } from "../../stores";
|
||||
import { getWordNumber, modeData, newSeed } from "../../utils";
|
||||
|
||||
export let showSettings: boolean;
|
||||
|
||||
const toaster = getContext<Toaster>("toaster");
|
||||
|
||||
const modes = modeData.modes.map((e) => e.name.toLowerCase());
|
||||
let validLink = false;
|
||||
let validNumber = false;
|
||||
let linkValue = "";
|
||||
let numValue = "";
|
||||
let linkMode: GameMode;
|
||||
let newWordNum: number;
|
||||
|
||||
function reset() {
|
||||
linkValue = "";
|
||||
numValue = "";
|
||||
validLink = false;
|
||||
validNumber = false;
|
||||
}
|
||||
|
||||
function validateNumber(num: number, wordNum: number) {
|
||||
if (!isNaN(num) && num > 0 && num < wordNum) {
|
||||
newWordNum = num;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function validateLink() {
|
||||
const data = linkValue
|
||||
.slice(linkValue.indexOf("#") + 1)
|
||||
.toLowerCase()
|
||||
.split("/");
|
||||
if (data.length !== 2) return false;
|
||||
if (!(data[0] in GameMode)) return false;
|
||||
if (!validateNumber(+data[1], getWordNumber(GameMode[data[0]], true))) {
|
||||
return false;
|
||||
}
|
||||
linkMode = GameMode[data[0]];
|
||||
return true;
|
||||
}
|
||||
|
||||
function submit(e: MouseEvent | KeyboardEvent) {
|
||||
if (!validLink && !validNumber) return;
|
||||
const newMode = validNumber ? $mode : linkMode;
|
||||
const currentModeData = modeData.modes[newMode];
|
||||
|
||||
currentModeData.historical = true;
|
||||
currentModeData.seed = newSeed(
|
||||
$mode,
|
||||
(newWordNum - 1) * currentModeData.unit + currentModeData.start
|
||||
);
|
||||
mode.set(newMode, true);
|
||||
|
||||
e.currentTarget.dispatchEvent(custom_event("close", null, { bubbles: true }));
|
||||
showSettings = false;
|
||||
toaster.pop(`${GameMode[$mode]} wordle #${newWordNum}`, 2);
|
||||
reset();
|
||||
}
|
||||
mode.subscribe(() => {
|
||||
if (!showSettings) {
|
||||
reset();
|
||||
}
|
||||
});
|
||||
|
||||
function onInput(e: KeyboardEvent & { currentTarget: EventTarget & HTMLInputElement }) {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
e.currentTarget.blur();
|
||||
submit(e);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<h3>Play a historical game</h3>
|
||||
{#key $mode}
|
||||
<form>
|
||||
<input
|
||||
type="text"
|
||||
bind:value={linkValue}
|
||||
placeholder="Example: {window.location}/1"
|
||||
class:valid={validLink}
|
||||
on:input={() => (validLink = validateLink())}
|
||||
on:keydown={onInput}
|
||||
/>
|
||||
</form>
|
||||
{/key}
|
||||
<div>Paste in a link</div>
|
||||
<h3>or</h3>
|
||||
<div class="number">
|
||||
<form>
|
||||
<input
|
||||
type="number"
|
||||
bind:value={numValue}
|
||||
placeholder="Example: 1"
|
||||
class:valid={validNumber}
|
||||
on:input={() => (validNumber = validateNumber(+numValue, getWordNumber($mode, true)))}
|
||||
on:keydown={onInput}
|
||||
/>
|
||||
</form>
|
||||
<select bind:value={$mode}>
|
||||
{#each modes as mode, i}
|
||||
<option value={i}>{mode}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
<div>Enter a game number between 1 and {getWordNumber($mode, true) - 1}</div>
|
||||
<div
|
||||
class:disabled={!validLink && !validNumber}
|
||||
class="button"
|
||||
on:click={submit}
|
||||
on:keydown={submit}
|
||||
>
|
||||
play
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
div {
|
||||
text-align: center;
|
||||
margin-top: 0.4rem;
|
||||
}
|
||||
input {
|
||||
text-align: center;
|
||||
color: inherit;
|
||||
font-size: inherit;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 4px;
|
||||
background-color: var(--border-secondary);
|
||||
border: none;
|
||||
padding: 0.5rem;
|
||||
outline: solid 1px var(--red);
|
||||
}
|
||||
input:placeholder-shown {
|
||||
outline: none;
|
||||
}
|
||||
input::-webkit-outer-spin-button,
|
||||
input::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
input[type="number"] {
|
||||
-moz-appearance: textfield;
|
||||
appearance: textfield;
|
||||
}
|
||||
.valid {
|
||||
outline-color: var(--color-correct);
|
||||
}
|
||||
select {
|
||||
display: inline;
|
||||
background: var(--border-secondary);
|
||||
}
|
||||
.number {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
form {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
.button {
|
||||
background-color: var(--color-correct);
|
||||
}
|
||||
.disabled {
|
||||
background-color: var(--fg-secondary);
|
||||
cursor: default;
|
||||
pointer-events: none;
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
export let visible = true;
|
||||
</script>
|
||||
|
||||
<div class="sep" class:visible>
|
||||
<div>
|
||||
<slot name="1" />
|
||||
</div>
|
||||
<div>
|
||||
<slot name="2" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.sep.visible {
|
||||
display: flex;
|
||||
}
|
||||
.sep {
|
||||
display: none;
|
||||
}
|
||||
.sep :first-child {
|
||||
border-right: 1px solid var(--fg-primary);
|
||||
}
|
||||
.sep div {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,53 @@
|
||||
<script lang="ts">
|
||||
import type Toaster from "./Toaster.svelte";
|
||||
|
||||
import { mode } from "../../stores";
|
||||
import { failed, modeData, GameState } from "../../utils";
|
||||
import { getContext } from "svelte";
|
||||
|
||||
export let state: GameState;
|
||||
const toaster = getContext<Toaster>("toaster");
|
||||
|
||||
function copyStats() {
|
||||
navigator.clipboard.writeText(
|
||||
`${modeData.modes[$mode].name} Wordle+ #${state.wordNumber} ${
|
||||
failed(state) ? "X" : state.guesses
|
||||
}/${state.board.words.length}\n\n ${state.board.state
|
||||
.slice(0, state.guesses)
|
||||
.map((r) => r.join(""))
|
||||
.join("\n ")}\nmikhad.github.io/wordle`
|
||||
);
|
||||
toaster.pop("Copied");
|
||||
}
|
||||
</script>
|
||||
|
||||
<div on:click={copyStats} on:keydown={copyStats}>
|
||||
share
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
||||
<path
|
||||
fill="white"
|
||||
d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92s2.92-1.31 2.92-2.92c0-1.61-1.31-2.92-2.92-2.92zM18 4c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zM6 13c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm12 7.02c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
div {
|
||||
color: #fff;
|
||||
font-size: var(--fs-medium);
|
||||
text-transform: uppercase;
|
||||
font-weight: bold;
|
||||
background: var(--color-correct);
|
||||
border-radius: 4px;
|
||||
height: 52px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
width: 80%;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,38 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from "svelte";
|
||||
import { GameMode } from "../../enums";
|
||||
import { mode } from "../../stores";
|
||||
import { modeData } from "../../utils";
|
||||
import GameIcon from "../GameIcon.svelte";
|
||||
import type Toaster from "./Toaster.svelte";
|
||||
|
||||
export let wordNumber: number;
|
||||
|
||||
const toaster: Toaster = getContext("toaster");
|
||||
|
||||
function share() {
|
||||
toaster.pop("Copied");
|
||||
navigator.clipboard.writeText(`${window.location.href}/${wordNumber}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="share-historic" on:click={share} on:keypress={share}>
|
||||
<GameIcon>
|
||||
<path
|
||||
d="M4.167 4.167c-1.381 1.381-1.381 3.619 0 5L6.5 11.5a1.18 1.18 0 0 1 0 1.667 1.18 1.18 0 0 1-1.667 0L2.5 10.833C.199 8.532.199 4.801 2.5 2.5s6.032-2.301 8.333 0l3.333 3.333c2.301 2.301 2.301 6.032 0 8.333a1.18 1.18 0 0 1-1.667 0 1.18 1.18 0 0 1 0-1.667c1.381-1.381 1.381-3.619 0-5L9.167 4.167c-1.381-1.381-3.619-1.381-5 0zm5.667 14c-2.301-2.301-2.301-6.032 0-8.333a1.18 1.18 0 0 1 1.667 0 1.18 1.18 0 0 1 0 1.667c-1.381 1.381-1.381 3.619 0 5l3.333 3.333c1.381 1.381 3.619 1.381 5 0s1.381-3.619 0-5L17.5 12.5a1.18 1.18 0 0 1 0-1.667 1.18 1.18 0 0 1 1.667 0l2.333 2.333c2.301 2.301 2.301 6.032 0 8.333s-6.032 2.301-8.333 0l-3.333-3.333z"
|
||||
/>
|
||||
</GameIcon>
|
||||
Copy link to this game ({modeData.modes[$mode].name} #{wordNumber})
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.share-historic {
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-regular);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,81 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
import type { GameMode } from "../../enums";
|
||||
import { ms as MS } from "../../enums";
|
||||
import { mode } from "../../stores";
|
||||
import { modeData, timeRemaining } from "../../utils";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let ms = 1000;
|
||||
|
||||
let countDown: number;
|
||||
|
||||
export function reset(m: GameMode) {
|
||||
clearInterval(countDown);
|
||||
ms = timeRemaining(modeData.modes[m]);
|
||||
if (ms < 0) dispatch("timeup");
|
||||
countDown = setInterval(() => {
|
||||
ms = timeRemaining(modeData.modes[m]);
|
||||
if (ms < 0) {
|
||||
clearInterval(countDown);
|
||||
dispatch("timeup");
|
||||
}
|
||||
}, MS.SECOND);
|
||||
}
|
||||
$: reset($mode);
|
||||
</script>
|
||||
|
||||
<h3>Next wordle</h3>
|
||||
<div class="container">
|
||||
{#if ms > 0}
|
||||
<div class="timer">
|
||||
{`${Math.floor(ms / MS.HOUR)}`.padStart(2, "0")}:{`${Math.floor(
|
||||
(ms % MS.HOUR) / MS.MINUTE
|
||||
)}`.padStart(2, "0")}:{`${Math.floor((ms % MS.MINUTE) / MS.SECOND)}`.padStart(2, "0")}
|
||||
</div>
|
||||
{:else}
|
||||
<div
|
||||
class="button"
|
||||
on:click={() => dispatch("reload")}
|
||||
on:keydown={() => dispatch("reload")}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
<path
|
||||
d="M4.609 12c0-4.082 3.309-7.391 7.391-7.391a7.39 7.39 0 0 1 6.523 3.912l-1.653 1.567H22v-5.13l-1.572 1.659C18.652 3.841 15.542 2 12 2 6.477 2 2 6.477 2 12s4.477 10 10 10c4.589 0 8.453-3.09 9.631-7.301l-2.512-.703c-.871 3.113-3.73 5.395-7.119 5.395-4.082 0-7.391-3.309-7.391-7.391z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
h3 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.container {
|
||||
height: 45px;
|
||||
min-width: 70%;
|
||||
}
|
||||
.timer {
|
||||
font-size: clamp(25px, 8vw, var(--fs-large));
|
||||
text-align: center;
|
||||
}
|
||||
.button {
|
||||
height: 80%;
|
||||
aspect-ratio: 1;
|
||||
padding: 4px;
|
||||
background: var(--color-correct);
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin: auto;
|
||||
}
|
||||
svg {
|
||||
fill: white;
|
||||
height: 100%;
|
||||
}
|
||||
.button:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,92 @@
|
||||
<script context="module" lang="ts">
|
||||
const tips = [
|
||||
"You can change the gamemode by clicking WORDLE+ or swiping the board left or right.",
|
||||
"Hard mode is game mode specific. Turning it on in one game mode won't change it on the others.",
|
||||
"Double tap or right click a word on the board to learn its definition.",
|
||||
"Hard mode can be enabled during a game if you haven't violated the hard mode rules yet.",
|
||||
"Double tap or right click the next row to see how many possible words can be played there, if you use all the previous information.",
|
||||
"Because words are chosen from the list randomly it is possible to get the same word again.",
|
||||
"When you see the refresh button in the top left corner it means a new word is ready.",
|
||||
"Everyone has the same wordle at the same time. Your word #73 is the same as everyone elses #73.",
|
||||
"There are more valid guesses than possible words, ie. not all 5 letter words can be selected as an answer by the game.",
|
||||
"Historical games don't count towards your stats. Historical games are when you follow a link to a specific game number.",
|
||||
"Only the data for latest historical game is saved for each game mode.",
|
||||
];
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export let change: boolean;
|
||||
let index = Math.floor(tips.length * Math.random());
|
||||
$: if (change) index = Math.floor(tips.length * Math.random());
|
||||
|
||||
function nextTip() {
|
||||
index = (index + 1) % tips.length;
|
||||
}
|
||||
function previousTip() {
|
||||
index = (index - 1 + tips.length) % tips.length;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="outer">
|
||||
<div class="number">Tip {index + 1}/{tips.length}</div>
|
||||
<div class="tip">{tips[index]}</div>
|
||||
<svg
|
||||
class="left"
|
||||
on:click={previousTip}
|
||||
on:keydown={previousTip}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 100 100"
|
||||
>
|
||||
<path d="M75,0L25,50L75,100z" />
|
||||
</svg>
|
||||
<svg
|
||||
on:click={nextTip}
|
||||
on:keypress={nextTip}
|
||||
class="right"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 100 100"
|
||||
>
|
||||
<path d="M25,0L75,50L25,100z" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.outer {
|
||||
margin: 15px auto;
|
||||
padding: 10px 20px;
|
||||
max-width: calc(0.6 * var(--game-width));
|
||||
border: solid 1px var(--border-secondary);
|
||||
background: var(--bg-secondary);
|
||||
border-radius: 4px;
|
||||
position: relative;
|
||||
}
|
||||
.number {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.left,
|
||||
.right {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
border-radius: 4px;
|
||||
background: var(--fg-primary);
|
||||
fill: var(--bg-primary);
|
||||
height: 45px;
|
||||
padding: 10px 0;
|
||||
top: 50%;
|
||||
}
|
||||
.left {
|
||||
left: 0;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.right {
|
||||
right: 0;
|
||||
transform: translate(50%, -50%);
|
||||
}
|
||||
.tip {
|
||||
text-align: center;
|
||||
min-height: 70px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import { fade } from "svelte/transition";
|
||||
|
||||
export function pop(text: string, duration = 1) {
|
||||
toast = [text, ...toast];
|
||||
setTimeout(() => (toast = toast.slice(0, toast.length - 1)), duration * 1000);
|
||||
}
|
||||
let toast: string[] = [];
|
||||
</script>
|
||||
|
||||
<div class="toast">
|
||||
{#each toast as slice}
|
||||
<div class="slice" out:fade={{ duration: 200 }}>{slice}</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.toast {
|
||||
top: 10%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
font-weight: bold;
|
||||
}
|
||||
.slice {
|
||||
color: var(--bg-primary);
|
||||
background: var(--fg-primary);
|
||||
padding: 16px;
|
||||
margin: 16px auto;
|
||||
border-radius: 4px;
|
||||
width: fit-content;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,77 @@
|
||||
<script lang="ts">
|
||||
import { COLS, ROWS } from "../../utils";
|
||||
|
||||
import { Tile } from "../board";
|
||||
export let visible: boolean;
|
||||
</script>
|
||||
|
||||
<h3>how to play</h3>
|
||||
<div>Guess the <strong>WORDLE</strong> in {ROWS} tries.</div>
|
||||
<div>Each guess must be a valid {COLS} letter word. Hit the enter button to submit.</div>
|
||||
<div>
|
||||
After each guess, the color of the tiles will change to show how close your guess was to the
|
||||
word.
|
||||
</div>
|
||||
<div class:complete={visible} class="examples">
|
||||
<div><strong>Examples</strong></div>
|
||||
<div class="row">
|
||||
<Tile value="w" state="🟩" />
|
||||
<Tile value="e" state="🔳" />
|
||||
<Tile value="a" state="🔳" />
|
||||
<Tile value="r" state="🔳" />
|
||||
<Tile value="y" state="🔳" />
|
||||
</div>
|
||||
<div>The letter <strong>W</strong> is in the word and in the correct spot.</div>
|
||||
<div class="row">
|
||||
<Tile value="p" state="🔳" />
|
||||
<Tile value="i" state="🟨" />
|
||||
<Tile value="l" state="🔳" />
|
||||
<Tile value="l" state="🔳" />
|
||||
<Tile value="s" state="🔳" />
|
||||
</div>
|
||||
<div>The letter <strong>I</strong> is in the word but in the wrong spot.</div>
|
||||
<div class="row">
|
||||
<Tile value="v" state="🔳" />
|
||||
<Tile value="a" state="🔳" />
|
||||
<Tile value="g" state="🔳" />
|
||||
<Tile value="u" state="⬛" />
|
||||
<Tile value="e" state="🔳" />
|
||||
</div>
|
||||
<div>The letter <strong>U</strong> is not in the word in any spot.</div>
|
||||
</div>
|
||||
<div>
|
||||
This is a recreation of the original <a
|
||||
href="https://www.nytimes.com/games/wordle/"
|
||||
target="_blank"
|
||||
rel="noreferrer">Wordle</a
|
||||
>
|
||||
by Josh Wardle with additional modes and features, allowing you to play infinite wordles. Switch
|
||||
to infinite mode to play an unlimited number of times.
|
||||
<br /><br />
|
||||
Open the settings menu to see some of the additional features.
|
||||
<br />
|
||||
Written with Svelte, in Typescript by
|
||||
<a href="https://github.com/MikhaD" target="_blank" rel="noreferrer">MikhaD</a>.
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
div {
|
||||
margin: 14px 0;
|
||||
}
|
||||
.examples {
|
||||
border-top: 1px solid var(--border-primary);
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
:global(.row > *) {
|
||||
height: 100%;
|
||||
aspect-ratio: 1;
|
||||
}
|
||||
&:not(.complete) :global(.row .back) {
|
||||
transition-delay: 0.3s;
|
||||
}
|
||||
}
|
||||
.row {
|
||||
height: 40px;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,11 @@
|
||||
export { default as Separator } from "./Separator.svelte";
|
||||
export { default as Definition } from "./Definition.svelte";
|
||||
export { default as Share } from "./Share.svelte";
|
||||
export { default as Tutorial } from "./Tutorial.svelte";
|
||||
export { default as Timer } from "./Timer.svelte";
|
||||
export { default as Toaster } from "./Toaster.svelte";
|
||||
export { default as Tips } from "./Tips.svelte";
|
||||
export { default as ContextMenu } from "./ContextMenu.svelte";
|
||||
export { default as ShareGame } from "./ShareGame.svelte";
|
||||
export { default as Historical } from "./Historical.svelte";
|
||||
export * from "./stats";
|
||||
@@ -0,0 +1,64 @@
|
||||
<script lang="ts">
|
||||
import { failed, GameState } from "../../../utils";
|
||||
|
||||
export let game: GameState;
|
||||
export let distribution: Guesses;
|
||||
|
||||
$: max = Object.entries(distribution).reduce((p, c) => {
|
||||
if (!isNaN(Number(c[0]))) return Math.max(c[1], p);
|
||||
return p;
|
||||
}, 1);
|
||||
</script>
|
||||
|
||||
<h3>guess distribution</h3>
|
||||
<div class="container">
|
||||
{#each Object.entries(distribution) as guess, i (guess[0])}
|
||||
{@const g = Number(guess[0])}
|
||||
{#if !isNaN(g)}
|
||||
<div class="graph">
|
||||
<span class="guess">{guess[0]}</span>
|
||||
<div
|
||||
class="bar"
|
||||
class:this={g === game.guesses && !game.active && !failed(game)}
|
||||
style="width: {(guess[1] / max) * 100}%;"
|
||||
>
|
||||
{guess[1]}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.guess {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}
|
||||
.container {
|
||||
width: 80%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
.graph {
|
||||
height: 20px;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
.bar {
|
||||
min-width: 7%;
|
||||
transition: width 0.3s ease-out;
|
||||
background: var(--color-absent);
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
justify-content: end;
|
||||
align-items: center;
|
||||
padding-right: min(0.8rem, 1vw);
|
||||
}
|
||||
.bar.this {
|
||||
background: var(--color-correct);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<script lang="ts">
|
||||
export let stat: number | string;
|
||||
export let name: string;
|
||||
</script>
|
||||
|
||||
<section>
|
||||
<div class="stat">{stat}</div>
|
||||
<div class="name">{name}</div>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 60px;
|
||||
}
|
||||
.stat {
|
||||
font-size: var(--fs-large);
|
||||
}
|
||||
.name {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,48 @@
|
||||
<script lang="ts">
|
||||
import { mode } from "../../../stores";
|
||||
import { modeData, Stats } from "../../../utils";
|
||||
|
||||
import Stat from "./Stat.svelte";
|
||||
export let data: Stats;
|
||||
|
||||
let stats: [string, string | number][];
|
||||
$: {
|
||||
stats = [
|
||||
["Played", data.played],
|
||||
["Win %", Math.round(((data.played - data.guesses.fail) / data.played) * 100) || 0],
|
||||
[
|
||||
"Average Guesses",
|
||||
(
|
||||
Object.entries(data.guesses).reduce((a, b) => {
|
||||
if (!isNaN(+b[0])) {
|
||||
return a + +b[0] * b[1];
|
||||
}
|
||||
return a;
|
||||
}, 0) / data.played || 0
|
||||
).toFixed(1),
|
||||
],
|
||||
];
|
||||
if (data.guesses.fail > 0) {
|
||||
stats.push(["Lost", data.guesses.fail]);
|
||||
}
|
||||
if (data.hasStreak) {
|
||||
stats.push(["Current Streak", data.streak]);
|
||||
stats.push(["Max Streak", data.maxStreak]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<h3>Statistics ({modeData.modes[$mode].name})</h3>
|
||||
<div>
|
||||
{#each stats as stat}
|
||||
<Stat name={stat[0]} stat={stat[1]} />
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
div {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,2 @@
|
||||
export { default as Statistics } from "./Statistics.svelte";
|
||||
export { default as Distribution } from "./Distribution.svelte";
|
||||
@@ -0,0 +1,13 @@
|
||||
export enum GameMode {
|
||||
"daily",
|
||||
"hourly",
|
||||
"infinite",
|
||||
// "minutely",
|
||||
};
|
||||
|
||||
export const enum ms {
|
||||
SECOND = 1000,
|
||||
MINUTE = 1000 * 60,
|
||||
HOUR = 1000 * 60 * 60,
|
||||
DAY = 1000 * 60 * 60 * 24,
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
//! IF ANYTHING IN THIS FILE IS CHANGED MAKE SURE setVersion.js HAS ALSO BEEN UPDATED
|
||||
import App from "./App.svelte";
|
||||
|
||||
const app = new App({
|
||||
target: document.body,
|
||||
props: {
|
||||
version: "1.5.2",
|
||||
}
|
||||
});
|
||||
|
||||
export default app;
|
||||
@@ -0,0 +1,90 @@
|
||||
import { writable } from "svelte/store";
|
||||
import type { GameMode } from "./enums";
|
||||
import { Settings, LetterStates } from "./utils";
|
||||
|
||||
/**
|
||||
* A writable store identical in functionality to the Svelte writable store with an extra parameter
|
||||
* in the set function.
|
||||
*/
|
||||
class Writable<T> {
|
||||
static subscriber_queue = [];
|
||||
private stop: () => void;
|
||||
private start: (set: (val: T) => void) => () => void;
|
||||
private value: T;
|
||||
private subscribers: Set<Subscriber<T>>;
|
||||
constructor(value?: T, start = Writable.noop) {
|
||||
this.subscribers = new Set();
|
||||
this.start = start;
|
||||
this.value = value;
|
||||
}
|
||||
/**
|
||||
* Set value and inform subscribers. If the new value is the same as the old value subscribers
|
||||
* will not be updated unless `always_update` is true.
|
||||
* @param new_value - The value to set.
|
||||
* @param always_update - If true subscribers will be updated even if the new value is the same
|
||||
* as the previous value.
|
||||
*/
|
||||
public set(new_value: T, always_update: boolean = false) {
|
||||
if (always_update || Writable.safe_not_equal(this.value, new_value)) {
|
||||
this.value = new_value;
|
||||
if (stop) { // store is ready
|
||||
const run_queue = !Writable.subscriber_queue.length;
|
||||
for (const subscriber of this.subscribers) {
|
||||
subscriber[1]();
|
||||
Writable.subscriber_queue.push(subscriber, this.value);
|
||||
}
|
||||
if (run_queue) {
|
||||
for (let i = 0; i < Writable.subscriber_queue.length; i += 2) {
|
||||
Writable.subscriber_queue[i][0](Writable.subscriber_queue[i + 1]);
|
||||
}
|
||||
// empty queue
|
||||
Writable.subscriber_queue.length = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Update value using callback and inform subscribers.
|
||||
* @param updater - callback
|
||||
*/
|
||||
public update(updater: (val: T) => T) {
|
||||
this.set(updater(this.value));
|
||||
}
|
||||
/**
|
||||
* Subscribe on value changes.
|
||||
* @param run - subscription callback
|
||||
* @param invalidate - cleanup callback
|
||||
*/
|
||||
public subscribe(run: (val: T) => void, invalidate: (val?: T) => void = Writable.noop) {
|
||||
const subscriber: Subscriber<T> = [run, invalidate];
|
||||
this.subscribers.add(subscriber);
|
||||
if (this.subscribers.size === 1) {
|
||||
this.stop = this.start(this.set) || Writable.noop;
|
||||
}
|
||||
run(this.value);
|
||||
return () => {
|
||||
this.subscribers.delete(subscriber);
|
||||
if (this.subscribers.size === 0) {
|
||||
this.stop();
|
||||
this.stop = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* check that two values are not equal to each other while avoiding some of JavaScript's
|
||||
* unintuitive comparison nonsense.
|
||||
*/
|
||||
private static safe_not_equal(a: any, b: any) {
|
||||
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
||||
}
|
||||
/** Dummy function to be used as a default value. */
|
||||
private static noop() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export const mode = new Writable<GameMode>();
|
||||
|
||||
export const letterStates = writable(new LetterStates());
|
||||
|
||||
export const settings = writable(new Settings());
|
||||
@@ -0,0 +1,88 @@
|
||||
/** A list of words of the same length */
|
||||
type Words = WordData & {
|
||||
contains: (word: string) => boolean;
|
||||
};
|
||||
|
||||
type WordData = {
|
||||
/** A list of possible words to guess */
|
||||
words: string[];
|
||||
/** A list of words that are valid when input by the user but will never get chosen as the word to guess */
|
||||
valid: string[];
|
||||
};
|
||||
|
||||
type RowData = {
|
||||
length: number;
|
||||
guess: number;
|
||||
};
|
||||
|
||||
type LetterState = "🔳" | "⬛" | "🟨" | "🟩";
|
||||
|
||||
type GameBoard = {
|
||||
words: string[],
|
||||
state: LetterState[][],
|
||||
};
|
||||
|
||||
type SettingType = "switch" | "dropdown" | "custom";
|
||||
|
||||
type DictionaryEntry = {
|
||||
word: string;
|
||||
phonetic: string;
|
||||
phonetics: Phonetic[];
|
||||
origin: string;
|
||||
meanings: Meaning[];
|
||||
};
|
||||
|
||||
type Meaning = {
|
||||
partOfSpeech: string;
|
||||
definitions: Definition[];
|
||||
};
|
||||
|
||||
type Definition = {
|
||||
definition: string;
|
||||
synonyms: string[];
|
||||
antonyms: any[];
|
||||
example?: string;
|
||||
};
|
||||
|
||||
type Phonetic = {
|
||||
text: string;
|
||||
audio: string;
|
||||
};
|
||||
|
||||
type Guesses = {
|
||||
"1": number;
|
||||
"2": number;
|
||||
"3": number;
|
||||
"4": number;
|
||||
"5": number;
|
||||
"6": number;
|
||||
"fail": number;
|
||||
};
|
||||
|
||||
type ModeData = {
|
||||
default: GameMode,
|
||||
modes: Mode[],
|
||||
};
|
||||
|
||||
type Mode = {
|
||||
name: string,
|
||||
unit: number,
|
||||
start: number,
|
||||
seed: number,
|
||||
historical: boolean,
|
||||
icon?: string,
|
||||
streak?: boolean,
|
||||
useTimeZone?: boolean,
|
||||
};
|
||||
|
||||
type HardModeData = {
|
||||
pos: number,
|
||||
char: string,
|
||||
type: "🟩" | "🟨" | "⬛",
|
||||
};
|
||||
|
||||
type Subscriber<T> = [(val: T) => void, (val?: T) => void];
|
||||
|
||||
type Direction = "top" | "right" | "bottom" | "left";
|
||||
|
||||
type Swipe = CustomEvent<{ direction: Direction; }>;
|
||||
@@ -0,0 +1,463 @@
|
||||
import seedRandom from "seedrandom";
|
||||
import { GameMode, ms } from "./enums";
|
||||
import wordList from "./words_5";
|
||||
|
||||
export const ROWS = 6;
|
||||
export const COLS = 5;
|
||||
|
||||
export const words = {
|
||||
...wordList,
|
||||
contains: (word: string) => {
|
||||
return wordList.words.includes(word) || wordList.valid.includes(word);
|
||||
},
|
||||
};
|
||||
|
||||
class Tile {
|
||||
public value: string;
|
||||
public notSet: Set<string>;
|
||||
constructor() {
|
||||
this.notSet = new Set<string>();
|
||||
}
|
||||
not(char: string) {
|
||||
this.notSet.add(char);
|
||||
}
|
||||
}
|
||||
|
||||
class WordData {
|
||||
public letterCounts: Map<string, [number, boolean]>;
|
||||
private notSet: Set<string>;
|
||||
public word: Tile[];
|
||||
constructor() {
|
||||
this.notSet = new Set<string>();
|
||||
this.letterCounts = new Map<string, [number, boolean]>();
|
||||
this.word = [];
|
||||
for (let col = 0; col < COLS; ++col) {
|
||||
this.word.push(new Tile());
|
||||
}
|
||||
}
|
||||
confirmCount(char: string) {
|
||||
let c = this.letterCounts.get(char);
|
||||
if (!c) {
|
||||
this.not(char);
|
||||
} else {
|
||||
c[1] = true;
|
||||
}
|
||||
}
|
||||
countConfirmed(char: string) {
|
||||
const val = this.letterCounts.get(char);
|
||||
return val ? val[1] : false;
|
||||
}
|
||||
setCount(char: string, count: number) {
|
||||
let c = this.letterCounts.get(char);
|
||||
if (!c) {
|
||||
this.letterCounts.set(char, [count, false]);
|
||||
} else {
|
||||
c[0] = count;
|
||||
}
|
||||
}
|
||||
incrementCount(char: string) {
|
||||
++this.letterCounts.get(char)[0];
|
||||
}
|
||||
not(char: string) {
|
||||
this.notSet.add(char);
|
||||
}
|
||||
inGlobalNotList(char: string) {
|
||||
return this.notSet.has(char);
|
||||
}
|
||||
lettersNotAt(pos: number) {
|
||||
return new Set([...this.notSet, ...this.word[pos].notSet]);
|
||||
}
|
||||
}
|
||||
|
||||
export function getRowData(n: number, board: GameBoard) {
|
||||
const wd = new WordData();
|
||||
for (let row = 0; row < n; ++row) {
|
||||
const occurred = new Set<string>();
|
||||
for (let col = 0; col < COLS; ++col) {
|
||||
const state = board.state[row][col];
|
||||
const char = board.words[row][col];
|
||||
if (state === "⬛") {
|
||||
wd.confirmCount(char);
|
||||
// if char isn't in the global not list add it to the not list for that position
|
||||
if (!wd.inGlobalNotList(char)) {
|
||||
wd.word[col].not(char);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// If this isn't the first time this letter has occurred in this row
|
||||
if (occurred.has(char)) {
|
||||
wd.incrementCount(char);
|
||||
} else if (!wd.countConfirmed(char)) {
|
||||
occurred.add(char);
|
||||
wd.setCount(char, 1);
|
||||
}
|
||||
if (state === "🟩") {
|
||||
wd.word[col].value = char;
|
||||
}
|
||||
else { // if (state === "🟨")
|
||||
wd.word[col].not(char);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let exp = "";
|
||||
for (let pos = 0; pos < wd.word.length; ++pos) {
|
||||
exp += wd.word[pos].value ? wd.word[pos].value : `[^${[...wd.lettersNotAt(pos)].join(" ")}]`;
|
||||
}
|
||||
return (word: string) => {
|
||||
if (new RegExp(exp).test(word)) {
|
||||
const chars = word.split("");
|
||||
for (const e of wd.letterCounts) {
|
||||
const occurrences = countOccurrences(chars, e[0]);
|
||||
if (!occurrences || (e[1][1] && occurrences !== e[1][0])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
function countOccurrences<T>(arr: T[], val: T) {
|
||||
return arr.reduce((count, v) => v === val ? count + 1 : count, 0);
|
||||
}
|
||||
|
||||
export function contractNum(n: number) {
|
||||
switch (n % 10) {
|
||||
case 1: return `${n}st`;
|
||||
case 2: return `${n}nd`;
|
||||
case 3: return `${n}rd`;
|
||||
default: return `${n}th`;
|
||||
}
|
||||
}
|
||||
|
||||
export const keys = ["qwertyuiop", "asdfghjkl", "zxcvbnm"];
|
||||
|
||||
/**
|
||||
* Return a deterministic number based on the given mode and current or given time.
|
||||
* @param mode - The mode
|
||||
* @param time - The time. If omitted current time is used
|
||||
*/
|
||||
export function newSeed(mode: GameMode, time?: number) {
|
||||
const now = time ?? Date.now();
|
||||
switch (mode) {
|
||||
case GameMode.daily:
|
||||
// Adds time zone offset to UTC time, calculates how many days that falls after 1/1/1970
|
||||
// and returns the unix time for the beginning of that day.
|
||||
return Date.UTC(1970, 0, 1 + Math.floor((now - (new Date().getTimezoneOffset() * ms.MINUTE)) / ms.DAY));
|
||||
case GameMode.hourly:
|
||||
return now - (now % ms.HOUR);
|
||||
// case GameMode.minutely:
|
||||
// return now - (now % ms.MINUTE);
|
||||
case GameMode.infinite:
|
||||
return now - (now % ms.SECOND);
|
||||
}
|
||||
}
|
||||
|
||||
export const modeData: ModeData = {
|
||||
default: GameMode.daily,
|
||||
modes: [
|
||||
{
|
||||
name: "Daily",
|
||||
unit: ms.DAY,
|
||||
start: 1642370400000, // 17/01/2022 UTC+2
|
||||
seed: newSeed(GameMode.daily),
|
||||
historical: false,
|
||||
streak: true,
|
||||
useTimeZone: true,
|
||||
},
|
||||
{
|
||||
name: "Hourly",
|
||||
unit: ms.HOUR,
|
||||
start: 1642528800000, // 18/01/2022 8:00pm UTC+2
|
||||
seed: newSeed(GameMode.hourly),
|
||||
historical: false,
|
||||
icon: "m50,7h100v33c0,40 -35,40 -35,60c0,20 35,20 35,60v33h-100v-33c0,-40 35,-40 35,-60c0,-20 -35,-20 -35,-60z",
|
||||
streak: true,
|
||||
},
|
||||
{
|
||||
name: "Infinite",
|
||||
unit: ms.SECOND,
|
||||
start: 1642428600000, // 17/01/2022 4:10:00pm UTC+2
|
||||
seed: newSeed(GameMode.infinite),
|
||||
historical: false,
|
||||
icon: "m7,100c0,-50 68,-50 93,0c25,50 93,50 93,0c0,-50 -68,-50 -93,0c-25,50 -93,50 -93,0z",
|
||||
},
|
||||
// {
|
||||
// name: "Minutely",
|
||||
// unit: ms.MINUTE,
|
||||
// start: 1642528800000, // 18/01/2022 8:00pm
|
||||
// seed: newSeed(GameMode.minutely),
|
||||
// historical: false,
|
||||
// icon: "m7,200v-200l93,100l93,-100v200",
|
||||
// streak: true,
|
||||
// },
|
||||
]
|
||||
};
|
||||
/**
|
||||
* Return the word number for the given mode at the time that that mode's seed was set.
|
||||
* @param mode - The game mode
|
||||
* @param current - If true the word number will be for the current time rather than for the current
|
||||
* seed for the given mode. Useful if you want the current game number during a historical game.
|
||||
*/
|
||||
export function getWordNumber(mode: GameMode, current?: boolean) {
|
||||
const seed = current ? newSeed(mode) : modeData.modes[mode].seed;
|
||||
return Math.round((seed - modeData.modes[mode].start) / modeData.modes[mode].unit) + 1;
|
||||
}
|
||||
|
||||
export function seededRandomInt(min: number, max: number, seed: number) {
|
||||
const rng = seedRandom(`${seed}`);
|
||||
return Math.floor(min + (max - min) * rng());
|
||||
}
|
||||
|
||||
export const DELAY_INCREMENT = 200;
|
||||
|
||||
export const PRAISE = [
|
||||
"Genius",
|
||||
"Magnificent",
|
||||
"Impressive",
|
||||
"Splendid",
|
||||
"Great",
|
||||
"Phew",
|
||||
];
|
||||
|
||||
abstract class Storable {
|
||||
toString() { return JSON.stringify(this); }
|
||||
}
|
||||
|
||||
export class GameState extends Storable {
|
||||
public active: boolean;
|
||||
public guesses: number;
|
||||
public validHard: boolean;
|
||||
public time: number;
|
||||
public wordNumber: number;
|
||||
public board: GameBoard;
|
||||
|
||||
#valid = false;
|
||||
#mode: GameMode;
|
||||
|
||||
constructor(mode: GameMode, data?: string) {
|
||||
super();
|
||||
this.#mode = mode;
|
||||
if (data) {
|
||||
this.parse(data);
|
||||
}
|
||||
if (!this.#valid) {
|
||||
this.active = true;
|
||||
this.guesses = 0;
|
||||
this.validHard = true;
|
||||
this.time = modeData.modes[mode].seed;
|
||||
this.wordNumber = getWordNumber(mode);
|
||||
this.board = {
|
||||
words: Array(ROWS).fill(""),
|
||||
state: Array.from({ length: ROWS }, () => (Array(COLS).fill("🔳"))),
|
||||
};
|
||||
|
||||
this.#valid = true;
|
||||
}
|
||||
}
|
||||
get latestWord() {
|
||||
return this.board.words[this.guesses];
|
||||
}
|
||||
get lastState() {
|
||||
return this.board.state[this.guesses - 1];
|
||||
}
|
||||
get lastWord() {
|
||||
return this.board.words[this.guesses - 1];
|
||||
}
|
||||
/**
|
||||
* Returns an object containing the position of the character in the latest word that violates
|
||||
* hard mode, and what type of violation it is, if there is a violation.
|
||||
*/
|
||||
checkHardMode(): HardModeData {
|
||||
for (let i = 0; i < COLS; ++i) {
|
||||
if (this.board.state[this.guesses - 1][i] === "🟩" && this.board.words[this.guesses - 1][i] !== this.board.words[this.guesses][i]) {
|
||||
return { pos: i, char: this.board.words[this.guesses - 1][i], type: "🟩" };
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < COLS; ++i) {
|
||||
if (this.board.state[this.guesses - 1][i] === "🟨" && !this.board.words[this.guesses].includes(this.board.words[this.guesses - 1][i])) {
|
||||
return { pos: i, char: this.board.words[this.guesses - 1][i], type: "🟨" };
|
||||
}
|
||||
}
|
||||
return { pos: -1, char: "", type: "⬛" };
|
||||
}
|
||||
guess(word: string) {
|
||||
const characters = word.split("");
|
||||
const result = Array<LetterState>(COLS).fill("⬛");
|
||||
for (let i = 0; i < COLS; ++i) {
|
||||
if (characters[i] === this.latestWord.charAt(i)) {
|
||||
result[i] = "🟩";
|
||||
characters[i] = "$";
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < COLS; ++i) {
|
||||
const pos = characters.indexOf(this.latestWord[i]);
|
||||
if (result[i] !== "🟩" && pos >= 0) {
|
||||
characters[pos] = "$";
|
||||
result[i] = "🟨";
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private parse(str: string) {
|
||||
const parsed = JSON.parse(str) as GameState;
|
||||
if (parsed.wordNumber !== getWordNumber(this.#mode)) return;
|
||||
this.active = parsed.active;
|
||||
this.guesses = parsed.guesses;
|
||||
this.validHard = parsed.validHard;
|
||||
this.time = parsed.time;
|
||||
this.wordNumber = parsed.wordNumber;
|
||||
this.board = parsed.board;
|
||||
|
||||
this.#valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
export class Settings extends Storable {
|
||||
public hard = new Array(modeData.modes.length).fill(false);
|
||||
public dark = true;
|
||||
public colorblind = false;
|
||||
public tutorial: 0 | 1 | 2 | 3 = 3;
|
||||
|
||||
constructor(settings?: string) {
|
||||
super();
|
||||
if (settings) {
|
||||
const parsed = JSON.parse(settings) as Settings;
|
||||
this.hard = parsed.hard;
|
||||
this.dark = parsed.dark;
|
||||
this.colorblind = parsed.colorblind;
|
||||
this.tutorial = parsed.tutorial;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class Stats extends Storable {
|
||||
public played = 0;
|
||||
public lastGame = 0;
|
||||
public guesses = {
|
||||
fail: 0,
|
||||
1: 0,
|
||||
2: 0,
|
||||
3: 0,
|
||||
4: 0,
|
||||
5: 0,
|
||||
6: 0,
|
||||
};
|
||||
public streak: number;
|
||||
public maxStreak: number;
|
||||
#hasStreak = false;
|
||||
|
||||
constructor(param: string | GameMode) {
|
||||
super();
|
||||
if (typeof param === "string") {
|
||||
this.parse(param);
|
||||
} else if (modeData.modes[param].streak) {
|
||||
this.streak = 0;
|
||||
this.maxStreak = 0;
|
||||
this.#hasStreak = true;
|
||||
}
|
||||
}
|
||||
private parse(str: string) {
|
||||
const parsed = JSON.parse(str) as Stats;
|
||||
this.played = parsed.played;
|
||||
this.lastGame = parsed.lastGame;
|
||||
this.guesses = parsed.guesses;
|
||||
if (parsed.streak != undefined) {
|
||||
this.streak = parsed.streak;
|
||||
this.maxStreak = parsed.maxStreak;
|
||||
this.#hasStreak = true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* IMPORTANT: When this method is called svelte will not register the update, so you need to set
|
||||
* the variable that this object is assigned to equal to itself to force an update.
|
||||
* Example: `states = states;`.
|
||||
*/
|
||||
addWin(guesses: number, mode: Mode) {
|
||||
++this.guesses[guesses];
|
||||
++this.played;
|
||||
if (this.#hasStreak) {
|
||||
this.streak = mode.seed - this.lastGame > mode.unit ? 1 : this.streak + 1;
|
||||
this.maxStreak = Math.max(this.streak, this.maxStreak);
|
||||
}
|
||||
this.lastGame = mode.seed;
|
||||
}
|
||||
/**
|
||||
* IMPORTANT: When this method is called svelte will not register the update, so you need to set
|
||||
* the variable that this object is assigned to equal to itself to force an update.
|
||||
* Example: `states = states;`.
|
||||
*/
|
||||
addLoss(mode: Mode) {
|
||||
++this.guesses.fail;
|
||||
++this.played;
|
||||
if (this.#hasStreak) this.streak = 0;
|
||||
this.lastGame = mode.seed;
|
||||
}
|
||||
get hasStreak() { return this.#hasStreak; }
|
||||
}
|
||||
|
||||
export class LetterStates {
|
||||
public a: LetterState = "🔳";
|
||||
public b: LetterState = "🔳";
|
||||
public c: LetterState = "🔳";
|
||||
public d: LetterState = "🔳";
|
||||
public e: LetterState = "🔳";
|
||||
public f: LetterState = "🔳";
|
||||
public g: LetterState = "🔳";
|
||||
public h: LetterState = "🔳";
|
||||
public i: LetterState = "🔳";
|
||||
public j: LetterState = "🔳";
|
||||
public k: LetterState = "🔳";
|
||||
public l: LetterState = "🔳";
|
||||
public m: LetterState = "🔳";
|
||||
public n: LetterState = "🔳";
|
||||
public o: LetterState = "🔳";
|
||||
public p: LetterState = "🔳";
|
||||
public q: LetterState = "🔳";
|
||||
public r: LetterState = "🔳";
|
||||
public s: LetterState = "🔳";
|
||||
public t: LetterState = "🔳";
|
||||
public u: LetterState = "🔳";
|
||||
public v: LetterState = "🔳";
|
||||
public w: LetterState = "🔳";
|
||||
public x: LetterState = "🔳";
|
||||
public y: LetterState = "🔳";
|
||||
public z: LetterState = "🔳";
|
||||
|
||||
constructor(board?: GameBoard) {
|
||||
if (board) {
|
||||
for (let row = 0; row < ROWS; ++row) {
|
||||
for (let col = 0; col < board.words[row].length; ++col) {
|
||||
if (this[board.words[row][col]] === "🔳" || board.state[row][col] === "🟩") {
|
||||
this[board.words[row][col]] = board.state[row][col];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* IMPORTANT: When this method is called svelte will not register the update, so you need to set
|
||||
* the variable that this object is assigned to equal to itself to force an update.
|
||||
* Example: `states = states;`.
|
||||
*/
|
||||
update(state: LetterState[], word: string) {
|
||||
state.forEach((e, i) => {
|
||||
const ls = this[word[i]];
|
||||
if (ls === "🔳" || e === "🟩") {
|
||||
this[word[i]] = e;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export function timeRemaining(m: Mode) {
|
||||
if (m.useTimeZone) {
|
||||
return m.unit - (Date.now() - (m.seed + new Date().getTimezoneOffset() * ms.MINUTE));
|
||||
}
|
||||
return m.unit - (Date.now() - m.seed);
|
||||
}
|
||||
|
||||
export function failed(s: GameState) {
|
||||
return !(s.active || (s.guesses > 0 && s.board.state[s.guesses - 1].join("") === "🟩".repeat(COLS)));
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
/// <reference types="svelte" />
|
||||
/// <reference types="vite/client" />
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"resolveJsonModule": true,
|
||||
/**
|
||||
* Typecheck JS in `.svelte` and `.js` files by default.
|
||||
* Disable checkJs if you'd like to use dynamic types in JS.
|
||||
* Note that setting allowJs false does not prevent the use
|
||||
* of JS in `.svelte` files.
|
||||
*/
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"isolatedModules": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.d.ts",
|
||||
"src/**/*.ts",
|
||||
"src/**/*.js",
|
||||
"src/**/*.svelte"
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { svelte, vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||
import { version } from "./package.json";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
base: "/wordle/",
|
||||
plugins: [svelte({
|
||||
preprocess: vitePreprocess()
|
||||
})],
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
assetFileNames: `[name]-v${version}.[ext]`,
|
||||
entryFileNames: `[name]-v${version}.js`,
|
||||
dir: "./dist",
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -342,10 +342,10 @@
|
||||
<a href="/WebGames-master/WebGames-master/games/SuperScratchBros41.html"><img src="assets/Super-Scratch-Bros-Beta.jpeg" alt="Super Scratch Bros" width="150" height="150"></a>
|
||||
</div>
|
||||
<div class="game">
|
||||
<a href="/WebGames-master/WebGames-master/games2/game/rooftop-snipers/index.html"><img src="assets/Super-Scratch-Bros-Beta.jpeg" alt="Roof Top Snipers" width="150" height="150"></a>
|
||||
<a href="/WebGames-master/WebGames-master/games2/game/rooftop-snipers/index.html"><img src="/image-robert-added/top.jpeg" alt="Roof Top Snipers" width="150" height="150"></a>
|
||||
</div>
|
||||
<div class="game">
|
||||
<a href=""><img src="" alt="" width="150" height="150"></a>
|
||||
<a href="/WebGames-master/WebGames-master/games/wordle/wordle-main.zip_unzipped/wordle-main/index.html"><img src="/WebGames-master/WebGames-master/games/wordle/wordle-main.zip_unzipped/wordle-main/image.png" alt="wordle" width="150" height="150"></a>
|
||||
</div>
|
||||
<div class="game">
|
||||
<a href=""><img src="" alt="" width="150" height="150"></a>
|
||||
|
||||
@@ -14,6 +14,7 @@ html {
|
||||
background-size: cover;
|
||||
z-index: 2;
|
||||
text-align: center;
|
||||
rotate: 15;
|
||||
}
|
||||
|
||||
div.one {
|
||||
|
||||
|
After Width: | Height: | Size: 12 KiB |