context.sendMessage('Timeout must be a number between 10 and 300',context.room.id);
return;
}
settings.timeout=parsedTimeout;
context.sendMessage(`Timeout set to ${style.bold(settings.timeout)} by ${context.user.prefixedUsername}`,context.room.id);
}
functiongetWinnerText(game){
if(game.state==='pick'){
returnnull;
}
if(game.winner){
return`The winner is ${style.bold(game.winner.prefixedUsername)}, who was ${game.distances[game.winner.username]} away for ${style.bold(game.points[game.distances[game.winner.username]])} points.`;
return`The target ${getTarget(game)} was solved as follows: ${style.bold(style.code(game.winner.solution))}. My solution was ${style.bold(style.code(game.solution.solution))}.`;
}
if(game.distances[game.winner?.username]===0){
// the winner somehow found a solution the solver did not
return`The target ${getTarget(game)} was solved as follows: ${style.bold(style.code(game.winner.solution))}. Even I couldn't get that, well done!`;
}
if(game.solution?.answer===game.target){
return`The target ${getTarget(game)} could be solved as follows: ${style.bold(style.code(game.solution.solution))}.`;
}
if(game.solution){
return`The target ${getTarget(game)} was impossible, the closest answer is ${style.bold(game.solution.answer)} as follows: ${style.bold(style.code(game.solution.solution))}.`;
}
returnnull;
}
functionstop(context,aborted){
constgame=games.get(context.room.id);
if(!game){
context.sendMessage(`There is no numbers game going on, ${context.user.prefixedUsername}. You can start one with ${config.prefix}numbers!`,context.room.id);
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(`${getBoard(context)}. You have ${style.bold(style.green(`${Math.round((settings.timeout/3)*2)} seconds`))} left.`,context.room.id);
context.sendMessage(`${context.user.prefixedUsername}: ${imagined.map((number)=>style.bold(number)).join(' and ')} is not on the board`,context.room.id);
return;
}
if(overused.length>0){
context.sendMessage(`${context.user.prefixedUsername}: ${overused.map((number)=>style.bold(number)).join(' and ')} is used too often`,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 ${getTarget(game)}`;
*/
constsummary=distance===0
?`${style.bold(style.code(parsed))} results in ${style.bold(style.code(answer))}, that is ${style.bold('exactly on target')}`
:`${style.bold(style.code(parsed))} results in ${style.bold(style.code(answer))}, that is ${style.bold(distance)} away from target ${getTarget(game)}`;
context.sendMessage(`${context.user.prefixedUsername}: ${summary} for ${style.bold(points)} points, the current winner`,context.room.id);
return;
}
if(points&&distance<lastDistance){
context.sendMessage(`${context.user.prefixedUsername}: ${summary} for ${style.bold(points)} points, your personal best, but not closer than the winning ${style.bold(closestDistance)} away`,context.room.id);
return;
}
if(points){
context.sendMessage(`${context.user.prefixedUsername}: ${summary} for ${style.bold(points)} points, but does not beat your personal closest of ${style.bold(lastDistance)} away`,context.room.id);
return;
}
context.sendMessage(`${summary} for ${style.bold('no')} points, ${context.user.prefixedUsername}`,context.room.id);
help:`Reach the target number using only the ${config.numbers.length} numbers on the board. You can use each number only once, but do not have to use all of them. You may use addition, subtraction, multiplication and division, but each intermediate calculation must result in a whole number. You can score ${Array.from(newSet(config.numbers.points)).slice(0,-1).join(', ')} or ${config.numbers.points.at(-1)} points for solutions up to ${config.numbers.points.length-1} away, but only the first best solution gets the points. Quick-start with ${config.prefix}numsgo, or use ${config.prefix}numbers to fill the board by manually selecting a random *large* or *big* number (100, 75, 50, 25), a random *small* number (1-10), or multiple at once like LLSSSS.`,// eslint-disable-line max-len
constusername=userKey.split(':')[1]||userKey;// process the points file
if(index===0){
return`${style.bold(style.yellow(`${ping||username===user.username?config.usernamePrefix:''}${username}`))} with ${style.bold(`${score}`)}points`;
return`${style.bold(style.yellow(`${ping||username===user.username?config.usernamePrefix:''}${username}`))} with ${style.bold(`${score}`)}${pointsWord}`;
}
return`${style.bold(style.cyan(`${ping?config.usernamePrefix:''}${username}`))} with ${style.bold(`${score}`)} points`;