@ -66,6 +66,11 @@ function playWord(rawWord, context) {
functionstop(context,aborted){
constgame=games.get(context.room.id);
if(!game){
context.sendMessage(`There is no letters game going on, ${context.user.prefixedUsername}. You can start one with ${config.prefix}letters!`,context.room.id);
return;
}
game.ac.abort();
games.delete(context.room.id);
@ -124,7 +129,7 @@ function pickLetters(type, context) {
functionstart(context,letters){
if(games.has(context.room.id)){
context.sendMessage(`${getBoard(context)}This is the current board. Use ${config.prefix}letters:stop to reset.`,context.room.id);
context.sendMessage(`${getBoard(context)}is the current board. Use ${config.prefix}letters:stop to reset.`,context.room.id);
context.sendMessage(`There is no numbers game going on, ${context.user.prefixedUsername}. You can start one with ${config.prefix}numbers!`,context.room.id);
?`The target ${getTarget(game)}${game.points[game.winner?.username]===10?'was':'could be'} solved as follows: ${style.bold(style.code(game.winner?.solution||game.solution.solution))}.`
:`The target ${getTarget(game)} was impossible, the closest answer is ${style.bold(game.solution.answer)} as follows: ${style.bold(style.code(game.solution.solution))}.`;
context.sendMessage(`${getBoard(context)}. You have ${style.bold(style.green(settings.timeout))} seconds, let's start!`,context.room.id);
context.logger.info(`Numbers game started by ${context.user.username}, numbers ${game.numbers.join('|')}, target ${game.target}, ${game.solution.answer===game.target?'exact':'closest'} solution for ${game.solution.answer} is: ${game.solution.solution}`);
context.sendMessage(`You are using ${imagined.map((number)=>style.bold(number)).join(' and ')} not on the board, ${context.user.prefixedUsername}`,context.room.id);
return;
}
if(overused.length>0){
context.sendMessage(`You are using ${overused.map((number)=>style.bold(number)).join(' and ')} too often, ${context.user.prefixedUsername}`,context.room.id);
?`Your solution ${style.bold(style.code(parsed))} results in ${style.bold(answer)}, which is ${style.bold('exactly on target')}`
:`Your solution ${style.bold(style.code(parsed))} results in ${style.bold(answer)}, which is ${style.bold(distance)} away from target ${style.bold(game.target)}`;
if(points&&points>lastScore){
game.points[context.user.username]=points;
}
if(points&&points>highestScore){
game.winner={
...context.user,
solution:parsed,
};
context.sendMessage(`${summary} for ${style.bold(points)} points, the current winner, ${context.user.prefixedUsername}`,context.room.id);
return;
}
if(points&&points>lastScore){
context.sendMessage(`${summary} for ${style.bold(points)} points, your personal best, but not beating the winning ${style.bold(highestScore)} points, ${context.user.prefixedUsername}`,context.room.id);
return;
}
if(points){
context.sendMessage(`${summary} for ${style.bold(points)} points, but does not beat your personal best of ${style.bold(lastScore)} points, ${context.user.prefixedUsername}`,context.room.id);
return;
}
context.sendMessage(`${summary} for ${style.bold('no')} points, ${context.user.prefixedUsername}`,context.room.id);
}catch(error){
// invalid answer
context.logger.error(error);
}
}
functionstart(context){
functionstart(context, numbers) {
if(games.has(context.room.id)){
context.sendMessage(`${getBoard(context)} This is the current board. Use ${config.prefix}numbers:stop to reset.`);
context.sendMessage(`${getBoard(context)}is the current board. Use ${config.prefix}numbers:stop to reset.`,context.room.id);