fieldset
label(for="cadence") {{ st.tr["Cadence"] }} *
div#predefinedCadences
- button 3+2
- button 5+3
- button 15+5
+ button(type="button") 3+2
+ button(type="button") 5+3
+ button(type="button") 15+5
input#cadence(
type="text"
v-model="newchallenge.cadence"
)
span {{ people[sid].name }}
button.player-action(
- v-if="sid!=st.user.sid || isGamer(sid)"
+ v-if="isGamer(sid) || (st.user.id > 0 && sid!=st.user.sid)"
@click="challOrWatch(sid)"
)
| {{ getActionLabel(sid) }}
.col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
.button-group
button#peopleBtn(onClick="window.doClick('modalPeople')")
- | {{ st.tr["Social"] }}
+ | {{ st.tr["Who's there?"] }}
button(onClick="window.doClick('modalNewgame')")
| {{ st.tr["New game"] }}
.row
this.newchallenge.cadence = b.innerHTML;
});
});
- const showCtype = localStorage.getItem("type-challenges") || "live";
- const showGtype = localStorage.getItem("type-games") || "live";
+ const dispCorr = this.$route.query["disp"];
+ const showCtype =
+ dispCorr || localStorage.getItem("type-challenges") || "live";
+ const showGtype =
+ dispCorr || localStorage.getItem("type-games") || "live";
this.setDisplay("c", showCtype);
this.setDisplay("g", showGtype);
},
},
// Challenge lifecycle:
newChallenge: async function() {
+ if (this.newchallenge.cadence.match(/^[0-9]+$/))
+ this.newchallenge.cadence += "+0"; //assume minutes, no increment
+ const ctype = this.classifyObject(this.newchallenge);
+ // TODO: cadence still unchecked so ctype could be wrong...
let error = "";
- if (this.newchallenge.vid == "")
+ if (!this.newchallenge.vid)
error = this.st.tr["Please select a variant"];
- else if (!!this.newchallenge.to && this.newchallenge.to == this.st.user.name)
- error = this.st.tr["Self-challenge is forbidden"];
+ else if (ctype == "corr" && this.st.user.id <= 0)
+ error = this.st.tr["Please log in to play correspondance games"];
+ else if (this.newchallenge.to) {
+ if (this.newchallenge.to == this.st.user.name)
+ error = this.st.tr["Self-challenge is forbidden"];
+ else if (
+ ctype == "live" &&
+ Object.values(this.people).every(p => p.name != this.newchallenge.to)
+ )
+ error = this.newchallenge.to + " " + this.st.tr["is not online"];
+ }
if (error) {
alert(error);
return;
const vname = this.getVname(this.newchallenge.vid);
const vModule = await import("@/variants/" + vname + ".js");
window.V = vModule.VariantRules;
- if (this.newchallenge.cadence.match(/^[0-9]+$/))
- this.newchallenge.cadence += "+0"; //assume minutes, no increment
- const ctype = this.classifyObject(this.newchallenge);
error = checkChallenge(this.newchallenge);
- if (!error && ctype == "corr" && this.st.user.id <= 0)
- error = this.st.tr["Please log in to play correspondance games"];
if (error) {
alert(error);
return;
initime: [0, 0], //initialized later
score: "*"
});
- GameStorage.add(game);
- if (this.st.settings.sound >= 1)
- new Audio("/sounds/newgame.mp3").play().catch(() => {});
- this.$router.push("/game/" + gameInfo.id);
+ GameStorage.add(game, (err) => {
+ // If an error occurred, game is not added: abort
+ if (!err) {
+ if (this.st.settings.sound >= 1)
+ new Audio("/sounds/newgame.mp3").play().catch(() => {});
+ this.$router.push("/game/" + gameInfo.id);
+ }
+ });
}
}
};