allow casual hook elo range

pull/83/head
Thibault Duplessis 2013-07-24 15:53:04 +02:00
parent 634fd470d4
commit e901dee7b1
10 changed files with 36 additions and 30 deletions

View File

@ -4,7 +4,7 @@
<div class="clock_config optional_config">
<div class="clock_choice">
<label class="required" for="clock">@trans.timeControl()</label>
<label class="required pointer" for="clock">@trans.timeControl()</label>
@setup.checkbox(form("clock"))
</div>
<div class="time_choice">

View File

@ -12,22 +12,24 @@
<div class="mode_choice buttons">
@setup.radios(form("mode"), translatedModeChoices)
</div>
<div class="elo_range_config optional_config">
@trans.eloRange(): <span class="range">? - ?</span>
<div class="elo_range">
@setup.input(
form("eloRange"),
Symbol("type") -> "hidden",
Symbol("data-min") -> EloRange.min,
Symbol("data-max") -> EloRange.max)
<div class="range_and_members optional_config">
@if(ctx.isAuth) {
<div class="members_only">
<label class="required pointer" for="@form("membersOnly").name">@trans.membersOnly()</label>
@setup.checkbox(form("membersOnly"))
</div>
}
<div class="elo_range_config">
@trans.eloRange(): <span class="range">? - ?</span>
<div class="elo_range">
@setup.input(
form("eloRange"),
Symbol("type") -> "hidden",
Symbol("data-min") -> EloRange.min,
Symbol("data-max") -> EloRange.max)
</div>
</div>
</div>
@if(ctx.isAuth) {
<div class="allow_anon_config optional_config">
<label class="required" for="@form("allowAnon").name">@trans.anonymousCanJoin()</label>
@setup.checkbox(form("allowAnon"))
</div>
}
}
}

View File

@ -239,7 +239,7 @@ createdBy=Created by
waitingForNbPlayers=Waiting for %s players
tournamentIsStarting=Tournament is starting
nbMinutesPerSidePlusNbSecondsPerMove=%s minutes/side + %s seconds/move
anonymousCanJoin=Anonymous can join
membersOnly=Members only
boardEditor=Board editor
startPosition=Start position
clearBoard=Clear board

View File

@ -263,11 +263,11 @@ final class I18nKeys(translator: Translator) {
val waitingForNbPlayers = new Key("waitingForNbPlayers")
val tournamentIsStarting = new Key("tournamentIsStarting")
val nbMinutesPerSidePlusNbSecondsPerMove = new Key("nbMinutesPerSidePlusNbSecondsPerMove")
val anonymousCanJoin = new Key("anonymousCanJoin")
val membersOnly = new Key("membersOnly")
val boardEditor = new Key("boardEditor")
val startPosition = new Key("startPosition")
val clearBoard = new Key("clearBoard")
val savePosition = new Key("savePosition")
def keys = List(playWithAFriend, inviteAFriendToPlayWithYou, playWithTheMachine, challengeTheArtificialIntelligence, toInviteSomeoneToPlayGiveThisUrl, gameOver, waitingForOpponent, waiting, yourTurn, aiNameLevelAiLevel, level, toggleTheChat, toggleSound, chat, resign, checkmate, stalemate, white, black, createAGame, noGameAvailableRightNowCreateOne, whiteIsVictorious, blackIsVictorious, playWithTheSameOpponentAgain, newOpponent, playWithAnotherOpponent, yourOpponentWantsToPlayANewGameWithYou, joinTheGame, whitePlays, blackPlays, theOtherPlayerHasLeftTheGameYouCanForceResignationOrWaitForHim, makeYourOpponentResign, forceResignation, talkInChat, theFirstPersonToComeOnThisUrlWillPlayWithYou, whiteCreatesTheGame, blackCreatesTheGame, whiteJoinsTheGame, blackJoinsTheGame, whiteResigned, blackResigned, whiteLeftTheGame, blackLeftTheGame, shareThisUrlToLetSpectatorsSeeTheGame, youAreViewingThisGameAsASpectator, replayAndAnalyse, computerAnalysisInProgress, theComputerAnalysisYouRequestedIsNowAvailable, theComputerAnalysisHasFailed, viewTheComputerAnalysis, requestAComputerAnalysis, blunders, mistakes, inaccuracies, viewGameStats, flipBoard, threefoldRepetition, claimADraw, offerDraw, draw, nbConnectedPlayers, talkAboutChessAndDiscussLichessFeaturesInTheForum, seeTheGamesBeingPlayedInRealTime, gamesBeingPlayedRightNow, viewAllNbGames, viewNbCheckmates, nbBookmarks, nbPopularGames, nbAnalysedGames, bookmarkedByNbPlayers, viewInFullSize, logOut, signIn, newToLichess, youNeedAnAccountToDoThat, signUp, people, games, forum, xPostedInForumY, chessPlayers, minutesPerSide, variant, timeControl, time, start, username, password, haveAnAccount, allYouNeedIsAUsernameAndAPassword, learnMoreAboutLichess, rank, gamesPlayed, nbGamesWithYou, declineInvitation, cancel, timeOut, drawOfferSent, drawOfferDeclined, drawOfferAccepted, drawOfferCanceled, yourOpponentOffersADraw, accept, decline, playingRightNow, finished, abortGame, gameAborted, standard, unlimited, mode, casual, rated, thisGameIsRated, rematch, rematchOfferSent, rematchOfferAccepted, rematchOfferCanceled, rematchOfferDeclined, cancelRematchOffer, viewRematch, play, inbox, chatRoom, spectatorRoom, composeMessage, sentMessages, noNewMessages, subject, recipient, send, incrementInSeconds, freeOnlineChess, spectators, nbWins, nbLosses, nbDraws, exportGames, color, eloRange, giveNbSeconds, whoIsOnline, allPlayers, premoveEnabledClickAnywhereToCancel, thisPlayerUsesChessComputerAssistance, opening, takeback, proposeATakeback, takebackPropositionSent, takebackPropositionDeclined, takebackPropositionAccepted, takebackPropositionCanceled, yourOpponentProposesATakeback, bookmarkThisGame, toggleBackground, search, advancedSearch, tournament, tournaments, tournamentPoints, viewTournament, freeOnlineChessGamePlayChessNowInACleanInterfaceNoRegistrationNoAdsNoPluginRequiredPlayChessWithComputerFriendsOrRandomOpponents, teams, nbMembers, allTeams, newTeam, myTeams, noTeamFound, joinTeam, quitTeam, anyoneCanJoin, aConfirmationIsRequiredToJoin, joiningPolicy, teamLeader, teamBestPlayers, teamRecentMembers, xJoinedTeamY, xCreatedTeamY, averageElo, location, settings, filterGames, reset, apply, leaderboard, pasteTheFenStringHere, pasteThePgnStringHere, fromPosition, continueFromHere, importGame, nbImportedGames, thisIsAChessCaptcha, clickOnTheBoardToMakeYourMove, notACheckmate, colorPlaysCheckmateInOne, retry, reconnecting, onlineFriends, noFriendsOnline, findFriends, favoriteOpponents, follow, following, unfollow, block, blocked, unblock, followsYou, xStartedFollowingY, nbFollowers, nbFollowing, profile, more, memberSince, lastLogin, challengeToPlay, player, list, graph, all, lessThanNbMinutes, xToYMinutes, textIsTooShort, textIsTooLong, required, addToChrome, openTournaments, duration, winner, standing, createANewTournament, join, withdraw, points, wins, losses, winStreak, createdBy, waitingForNbPlayers, tournamentIsStarting, nbMinutesPerSidePlusNbSecondsPerMove, anonymousCanJoin, boardEditor, startPosition, clearBoard, savePosition)
def keys = List(playWithAFriend, inviteAFriendToPlayWithYou, playWithTheMachine, challengeTheArtificialIntelligence, toInviteSomeoneToPlayGiveThisUrl, gameOver, waitingForOpponent, waiting, yourTurn, aiNameLevelAiLevel, level, toggleTheChat, toggleSound, chat, resign, checkmate, stalemate, white, black, createAGame, noGameAvailableRightNowCreateOne, whiteIsVictorious, blackIsVictorious, playWithTheSameOpponentAgain, newOpponent, playWithAnotherOpponent, yourOpponentWantsToPlayANewGameWithYou, joinTheGame, whitePlays, blackPlays, theOtherPlayerHasLeftTheGameYouCanForceResignationOrWaitForHim, makeYourOpponentResign, forceResignation, talkInChat, theFirstPersonToComeOnThisUrlWillPlayWithYou, whiteCreatesTheGame, blackCreatesTheGame, whiteJoinsTheGame, blackJoinsTheGame, whiteResigned, blackResigned, whiteLeftTheGame, blackLeftTheGame, shareThisUrlToLetSpectatorsSeeTheGame, youAreViewingThisGameAsASpectator, replayAndAnalyse, computerAnalysisInProgress, theComputerAnalysisYouRequestedIsNowAvailable, theComputerAnalysisHasFailed, viewTheComputerAnalysis, requestAComputerAnalysis, blunders, mistakes, inaccuracies, viewGameStats, flipBoard, threefoldRepetition, claimADraw, offerDraw, draw, nbConnectedPlayers, talkAboutChessAndDiscussLichessFeaturesInTheForum, seeTheGamesBeingPlayedInRealTime, gamesBeingPlayedRightNow, viewAllNbGames, viewNbCheckmates, nbBookmarks, nbPopularGames, nbAnalysedGames, bookmarkedByNbPlayers, viewInFullSize, logOut, signIn, newToLichess, youNeedAnAccountToDoThat, signUp, people, games, forum, xPostedInForumY, chessPlayers, minutesPerSide, variant, timeControl, time, start, username, password, haveAnAccount, allYouNeedIsAUsernameAndAPassword, learnMoreAboutLichess, rank, gamesPlayed, nbGamesWithYou, declineInvitation, cancel, timeOut, drawOfferSent, drawOfferDeclined, drawOfferAccepted, drawOfferCanceled, yourOpponentOffersADraw, accept, decline, playingRightNow, finished, abortGame, gameAborted, standard, unlimited, mode, casual, rated, thisGameIsRated, rematch, rematchOfferSent, rematchOfferAccepted, rematchOfferCanceled, rematchOfferDeclined, cancelRematchOffer, viewRematch, play, inbox, chatRoom, spectatorRoom, composeMessage, sentMessages, noNewMessages, subject, recipient, send, incrementInSeconds, freeOnlineChess, spectators, nbWins, nbLosses, nbDraws, exportGames, color, eloRange, giveNbSeconds, whoIsOnline, allPlayers, premoveEnabledClickAnywhereToCancel, thisPlayerUsesChessComputerAssistance, opening, takeback, proposeATakeback, takebackPropositionSent, takebackPropositionDeclined, takebackPropositionAccepted, takebackPropositionCanceled, yourOpponentProposesATakeback, bookmarkThisGame, toggleBackground, search, advancedSearch, tournament, tournaments, tournamentPoints, viewTournament, freeOnlineChessGamePlayChessNowInACleanInterfaceNoRegistrationNoAdsNoPluginRequiredPlayChessWithComputerFriendsOrRandomOpponents, teams, nbMembers, allTeams, newTeam, myTeams, noTeamFound, joinTeam, quitTeam, anyoneCanJoin, aConfirmationIsRequiredToJoin, joiningPolicy, teamLeader, teamBestPlayers, teamRecentMembers, xJoinedTeamY, xCreatedTeamY, averageElo, location, settings, filterGames, reset, apply, leaderboard, pasteTheFenStringHere, pasteThePgnStringHere, fromPosition, continueFromHere, importGame, nbImportedGames, thisIsAChessCaptcha, clickOnTheBoardToMakeYourMove, notACheckmate, colorPlaysCheckmateInOne, retry, reconnecting, onlineFriends, noFriendsOnline, findFriends, favoriteOpponents, follow, following, unfollow, block, blocked, unblock, followsYou, xStartedFollowingY, nbFollowers, nbFollowing, profile, more, memberSince, lastLogin, challengeToPlay, player, list, graph, all, lessThanNbMinutes, xToYMinutes, textIsTooShort, textIsTooLong, required, addToChrome, openTournaments, duration, winner, standing, createANewTournament, join, withdraw, points, wins, losses, winStreak, createdBy, waitingForNbPlayers, tournamentIsStarting, nbMinutesPerSidePlusNbSecondsPerMove, membersOnly, boardEditor, startPosition, clearBoard, savePosition)
}

View File

@ -46,6 +46,8 @@ private[i18n] case class JsDump(
keys.addToChrome,
keys.createANewTournament,
keys.join,
keys.joinTheGame,
keys.cancel,
keys.withdraw,
keys.tournamentIsStarting)

View File

@ -80,7 +80,7 @@ private[setup] final class FormFactory {
"time" -> time,
"increment" -> increment,
"mode" -> mode(ctx.isAuth),
"allowAnon" -> boolean,
"membersOnly" -> boolean,
"eloRange" -> eloRange,
"color" -> nonEmptyText.verifying(Color.names contains _)
)(HookConfig.<<)(_.>>)

View File

@ -16,7 +16,8 @@ case class HookConfig(
color: Color,
eloRange: EloRange) extends HumanConfig {
def >> = (variant.id, clock, time, increment, mode.id.some, allowAnon, eloRange.toString.some, color.name).some
// allowAnons -> membersOnly
def >> = (variant.id, clock, time, increment, mode.id.some, !allowAnon, eloRange.toString.some, color.name).some
def hook(uid: String, user: Option[User], sid: Option[String]) = Hook.make(
uid = uid,
@ -43,16 +44,17 @@ case class HookConfig(
object HookConfig extends BaseHumanConfig {
def <<(v: Int, k: Boolean, t: Int, i: Int, m: Option[Int], a: Boolean, e: Option[String], c: String) = {
def <<(v: Int, k: Boolean, t: Int, i: Int, m: Option[Int], membersOnly: Boolean, e: Option[String], c: String) = {
val realMode = m.fold(Mode.default)(Mode.orDefault)
val useEloRange = realMode.rated || membersOnly
new HookConfig(
variant = Variant(v) err "Invalid game variant " + v,
clock = k,
time = t,
increment = i,
mode = realMode,
allowAnon = a,
eloRange = e.filter(_ realMode.rated).fold(EloRange.default)(EloRange.orDefault),
allowAnon = !membersOnly, // membersOnly
eloRange = e.filter(_ useEloRange).fold(EloRange.default)(EloRange.orDefault),
color = Color(c) err "Invalid color " + c)
}

View File

@ -1864,13 +1864,14 @@ var storage = {
}
});
var $eloRangeConfig = $this.parent();
$modeChoices.on('change', function() {
$modeChoices.add($form.find('.members_only input')).on('change', function() {
var rated = $rated.prop('checked');
$eloRangeConfig.toggle(rated);
var membersOnly = $form.find('.members_only input').prop('checked');
$eloRangeConfig.toggle(rated || membersOnly);
if (isHook && rated && !$clockCheckbox.prop('checked')) {
$clockCheckbox.click();
}
$form.find('.allow_anon_config').toggle(!rated);
$form.find('.members_only').toggle(!rated);
$.centerOverboard();
}).trigger('change');
});
@ -2275,7 +2276,8 @@ var storage = {
}
function renderTr(hook) {
return '<tr data-id="' + hook.id + '" class="' + hook.id + ' ' + hook.action + '">' + _.map([
var title = (hook.action == "join") ? $.trans('Join the game') : $.trans('cancel');
return '<tr title="' + title + '" data-id="' + hook.id + '" class="' + hook.id + ' ' + hook.action + '">' + _.map([
['', '<span class="s16 ' + (hook.color || 'random') + '"></span>'],
[hook.username, hook.elo ? '<a href="/@/' + hook.username + '" class="ulink">' + hook.username + '</a>' : 'Anonymous'],
[hook.elo || 0, hook.elo || ''],

View File

@ -1358,8 +1358,7 @@ div.game_config .time_choice, div.game_config .increment_choice, div.game_config
div.game_config .time_choice span {
font-weight: bold;
}
div.game_config .allow_anon_config label,
div.game_config .clock_config label {
div.game_config label.pointer {
cursor: pointer;
}
div.game_config button.submit {

1
todo
View File

@ -59,4 +59,3 @@ embedded games links http://2ls.ru/chessonline/
filter ranges http://en.lichess.org/forum/lichess-feedback/my-proposed-changes-with-filter-window#1
hooks resync (chrome does not remove them all)
casual games elo range
change own hook color