- tryChangeVariant: async function(vname) {
- if (vname == "_unknown")
- return;
- if (this.st.variants.length > 0)
- {
- const idxOfVar = this.st.variants.findIndex(e => e.name == vname);
- this.variant = this.st.variants[idxOfVar];
- }
- else
- this.variant.name = vname;
- const vModule = await import("@/variants/" + vname + ".js");
- window.V = vModule.VariantRules;
+ clickReadRules: function() {
+ if (this.display != "rules") this.display = "rules";
+ else if (this.gameInProgress) this.display = "computer";
+ },
+ re_setVariant: async function(vname) {
+ const key = "rr_" + vname;
+ if (!localStorage.getItem(key))
+ // Mark rules as "read"
+ localStorage.setItem(key, '1');
+ await import("@/variants/" + vname + ".js")
+ .then((vModule) => {
+ this.V = window.V = vModule[vname + "Rules"];
+ this.gameInfo.vname = vname;
+ })
+ .catch((err) => {
+ // Soon after component creation, st.tr might be uninitialized.
+ // Set a timeout to let a chance for the message to show translated.
+ const text = "Mispelled variant name";
+ setTimeout(() => {
+ alert(this.st.tr[text] || text);
+ this.$router.replace("/variants");
+ }, 500);
+ });