simul mini-games
parent
a77bd9a348
commit
ee19d20fca
|
@ -15,7 +15,7 @@ object bits {
|
|||
private val dataState = attr("data-state")
|
||||
|
||||
def mini(pov: Pov): Tag => Tag =
|
||||
mini(FEN(Forsyth.exportBoard(pov.game.board)), pov.color, ~pov.game.lastMoveKeys) _
|
||||
mini(FEN(Forsyth.boardAndColor(pov.game.situation)), pov.color, ~pov.game.lastMoveKeys) _
|
||||
|
||||
def mini(fen: chess.format.FEN, color: chess.Color = chess.White, lastMove: String = "")(tag: Tag): Tag =
|
||||
tag(
|
||||
|
|
|
@ -55,7 +55,7 @@ object mini {
|
|||
}
|
||||
|
||||
private def renderState(pov: Pov) =
|
||||
dataState := s"${Forsyth.exportBoard(pov.game.board)},${pov.color.name},${~pov.game.lastMoveKeys}"
|
||||
dataState := s"${Forsyth boardAndColor pov.game.situation},${pov.color.name},${~pov.game.lastMoveKeys}"
|
||||
|
||||
private def renderPlayer(pov: Pov) =
|
||||
span(cls := "mini-game__player")(
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package lila.blog
|
||||
|
||||
import java.util
|
||||
|
||||
import com.github.blemale.scaffeine.LoadingCache
|
||||
import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension
|
||||
import com.vladsch.flexmark.ext.tables.TablesExtension
|
||||
import com.vladsch.flexmark.html.HtmlRenderer
|
||||
import com.vladsch.flexmark.parser.Parser
|
||||
import com.vladsch.flexmark.util.data.MutableDataSet
|
||||
import java.util.Arrays
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import scala.util.matching.Regex
|
||||
|
@ -30,7 +27,7 @@ object BlogTransform {
|
|||
private val options = new MutableDataSet()
|
||||
options.set(
|
||||
Parser.EXTENSIONS,
|
||||
util.Arrays.asList(TablesExtension.create(), StrikethroughExtension.create())
|
||||
java.util.Arrays.asList(TablesExtension.create(), StrikethroughExtension.create())
|
||||
)
|
||||
options.set(HtmlRenderer.SOFT_BREAK, "<br>\n")
|
||||
options.set(TablesExtension.CLASS_NAME, "slist")
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package lila.clas
|
||||
|
||||
import java.util
|
||||
|
||||
import com.github.blemale.scaffeine.LoadingCache
|
||||
import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension
|
||||
import com.vladsch.flexmark.ext.tables.TablesExtension
|
||||
|
@ -9,7 +7,6 @@ import com.vladsch.flexmark.ext.autolink.AutolinkExtension
|
|||
import com.vladsch.flexmark.html.HtmlRenderer
|
||||
import com.vladsch.flexmark.parser.Parser
|
||||
import com.vladsch.flexmark.util.data.MutableDataSet
|
||||
import java.util.Arrays
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
|
@ -21,7 +18,7 @@ final class ClasMarkup {
|
|||
private val options = new MutableDataSet()
|
||||
options.set(
|
||||
Parser.EXTENSIONS,
|
||||
util.Arrays.asList(
|
||||
java.util.Arrays.asList(
|
||||
TablesExtension.create(),
|
||||
StrikethroughExtension.create(),
|
||||
AutolinkExtension.create()
|
||||
|
|
|
@ -2,7 +2,6 @@ package lila.evalCache
|
|||
|
||||
import play.api.libs.json.{ JsObject, JsString }
|
||||
|
||||
import scala.collection.mutable.AnyRefMap
|
||||
import scala.concurrent.duration._
|
||||
import chess.format.FEN
|
||||
import chess.variant.Variant
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package lila.relay
|
||||
|
||||
import java.util
|
||||
|
||||
import com.github.blemale.scaffeine.LoadingCache
|
||||
import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension
|
||||
import com.vladsch.flexmark.ext.tables.TablesExtension
|
||||
import com.vladsch.flexmark.html.HtmlRenderer
|
||||
import com.vladsch.flexmark.parser.Parser
|
||||
import com.vladsch.flexmark.util.data.MutableDataSet
|
||||
import java.util.Arrays
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
|
@ -20,7 +17,7 @@ final private class RelayMarkup {
|
|||
private val options = new MutableDataSet()
|
||||
options.set(
|
||||
Parser.EXTENSIONS,
|
||||
util.Arrays.asList(TablesExtension.create(), StrikethroughExtension.create())
|
||||
java.util.Arrays.asList(TablesExtension.create(), StrikethroughExtension.create())
|
||||
)
|
||||
options.set(HtmlRenderer.SOFT_BREAK, "<br>\n")
|
||||
options.set(TablesExtension.CLASS_NAME, "slist")
|
||||
|
|
|
@ -123,13 +123,23 @@ final class JsonView(
|
|||
}
|
||||
|
||||
private def gameJson(hostId: User.ID, g: Game) =
|
||||
Json.obj(
|
||||
"id" -> g.id,
|
||||
"status" -> g.status.id,
|
||||
"fen" -> (chess.format.Forsyth exportBoard g.board),
|
||||
"lastMove" -> ~g.lastMoveKeys,
|
||||
"orient" -> g.playerByUserId(hostId).map(_.color)
|
||||
)
|
||||
Json
|
||||
.obj(
|
||||
"id" -> g.id,
|
||||
"status" -> g.status.id,
|
||||
"fen" -> (chess.format.Forsyth boardAndColor g.situation),
|
||||
"lastMove" -> ~g.lastMoveKeys,
|
||||
"orient" -> g.playerByUserId(hostId).map(_.color)
|
||||
)
|
||||
.add(
|
||||
"clock" -> g.clock.ifTrue(g.isBeingPlayed).map { c =>
|
||||
Json.obj(
|
||||
"white" -> c.remainingTime(chess.White).roundSeconds,
|
||||
"black" -> c.remainingTime(chess.Black).roundSeconds
|
||||
)
|
||||
}
|
||||
)
|
||||
.add("winner" -> g.winnerColor.map(_.name))
|
||||
|
||||
private def pairingJson(games: List[Game], hostId: String)(p: SimulPairing): Fu[Option[JsObject]] =
|
||||
games.find(_.id == p.gameId) ?? { game =>
|
||||
|
|
|
@ -260,7 +260,7 @@ object SwissJson {
|
|||
Json
|
||||
.obj(
|
||||
"id" -> b.game.id,
|
||||
"fen" -> (chess.format.Forsyth exportBoard b.game.board),
|
||||
"fen" -> chess.format.Forsyth.boardAndColor(b.game.situation),
|
||||
"lastMove" -> ~b.game.lastMoveKeys,
|
||||
"orientation" -> b.game.naturalOrientation.name,
|
||||
"white" -> boardPlayerJson(b.board.white),
|
||||
|
|
|
@ -276,7 +276,7 @@ final class JsonView(
|
|||
Json
|
||||
.obj(
|
||||
"id" -> game.id,
|
||||
"fen" -> (chess.format.Forsyth exportBoard game.board),
|
||||
"fen" -> chess.format.Forsyth.boardAndColor(game.situation),
|
||||
"orientation" -> game.naturalOrientation.name,
|
||||
"lastMove" -> ~game.lastMoveKeys,
|
||||
"white" -> ofPlayer(featured.white, game player chess.White),
|
||||
|
|
|
@ -8,7 +8,7 @@ object Dependencies {
|
|||
val scalalib = "com.github.ornicar" %% "scalalib" % "7.0.1"
|
||||
val hasher = "com.roundeights" %% "hasher" % "1.2.1"
|
||||
val jodaTime = "joda-time" % "joda-time" % "2.10.6"
|
||||
val chess = "org.lichess" %% "scalachess" % "10.0.1"
|
||||
val chess = "org.lichess" %% "scalachess" % "10.0.2"
|
||||
val compression = "org.lichess" %% "compression" % "1.6"
|
||||
val maxmind = "com.sanoma.cda" %% "maxmind-geoip2-scala" % "1.3.1-THIB"
|
||||
val prismic = "io.prismic" %% "scala-kit" % "1.2.19-THIB213"
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
.mini-game {
|
||||
@extend %nowrap-hidden, %box-neat;
|
||||
@extend %nowrap-hidden;
|
||||
|
||||
display: block;
|
||||
font-size: .9em;
|
||||
background: $c-bg-box;
|
||||
padding: .3em .6em;
|
||||
|
||||
&, &:hover {
|
||||
color: $c-font;
|
||||
|
|
|
@ -9,26 +9,14 @@
|
|||
|
||||
grid-template-columns: repeat(auto-fill, minmax(var(--np-min-width), 1fr));
|
||||
|
||||
> a {
|
||||
.mini-game {
|
||||
@extend %box-radius;
|
||||
|
||||
color: $c-font;
|
||||
padding: .3em;
|
||||
|
||||
@include transition(background);
|
||||
|
||||
background: fade-out($c-bg-box, 0.6);
|
||||
|
||||
&:hover {
|
||||
background: fade-out($c-link, 0.6);
|
||||
color: $c-font-clear;
|
||||
}
|
||||
}
|
||||
|
||||
.meta {
|
||||
display: block;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
a {
|
||||
color: $c-font;
|
||||
}
|
||||
|
||||
.indicator {
|
||||
|
|
|
@ -24,12 +24,10 @@
|
|||
.host {
|
||||
@extend %box-radius;
|
||||
|
||||
background: $c-accent;
|
||||
box-shadow: 0 0 0 7px fade-out($c-accent, 0.7);
|
||||
}
|
||||
|
||||
.vstext {
|
||||
@extend %metal;
|
||||
background: fade-out($c-accent, 0.7);
|
||||
&, a, .mini-game__clock {
|
||||
color: $c-accent-over;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +1,48 @@
|
|||
var m = require('mithril');
|
||||
var util = require('./util');
|
||||
var status = require('game/status');
|
||||
const m = require('mithril');
|
||||
const util = require('./util');
|
||||
const status = require('game/status');
|
||||
const opposite = require('chessground/util').opposite;
|
||||
|
||||
function miniPairing(ctrl) {
|
||||
return function(pairing) {
|
||||
var game = pairing.game;
|
||||
var player = pairing.player;
|
||||
var result = pairing.game.status >= status.ids.mate ? (
|
||||
pairing.winnerColor === 'white' ? '1-0' : (pairing.winnerColor === 'black' ? '0-1' : '½/½')
|
||||
) : '*';
|
||||
return m('a', {
|
||||
href: '/' + game.id + '/' + game.orient,
|
||||
class: ctrl.data.host.gameId === game.id ? 'host' : ''
|
||||
}, [
|
||||
m('span', {
|
||||
class: 'mini-board mini-board-' + game.id + ' parse-fen is2d',
|
||||
'data-color': game.orient,
|
||||
'data-fen': game.fen,
|
||||
'data-lastmove': game.lastMove,
|
||||
config: function(el, isUpdate) {
|
||||
if (!isUpdate) lichess.parseFen($(el));
|
||||
const game = pairing.game,
|
||||
player = pairing.player;
|
||||
return m(`a.mini-game.mini-game--init.mini-game-${game.id} is2d`, {
|
||||
class: ctrl.data.host.gameId === game.id ? 'host' : '',
|
||||
'data-live': game.clock ? game.id : '',
|
||||
config(el, isUpdate) {
|
||||
if (!isUpdate) {
|
||||
window.lichess.miniGame.init(el, `${game.fen},${game.orient},${game.lastMove}`)
|
||||
window.lichess.powertip.manualUserIn(el);
|
||||
}
|
||||
}, m('div.cg-wrap')),
|
||||
m('span.vstext', [
|
||||
m('span.vstext__pl', [
|
||||
util.playerVariant(ctrl, player).name,
|
||||
m('br'),
|
||||
result
|
||||
}
|
||||
}, [
|
||||
m('span.mini-game__player', [
|
||||
m('a.mini-game__user.ulpt', {
|
||||
href: `/@/${player.name}`
|
||||
}, [
|
||||
m('span.name', player.title ? [m('span.title', player.title), ' ', player.name] : [player.name]),
|
||||
' ',
|
||||
m('span.rating', player.rating)
|
||||
]),
|
||||
m('div.vstext__op', [
|
||||
player.name,
|
||||
m('br'),
|
||||
player.title ? player.title + ' ' : '',
|
||||
player.rating
|
||||
])
|
||||
])
|
||||
]);
|
||||
game.clock ?
|
||||
m(`span.mini-game__clock.mini-game__clock--${opposite(game.orient)}`, {
|
||||
'data-time': game.clock[opposite(game.orient)]
|
||||
}) :
|
||||
m('span.mini-game__result', game.winner ? (game.winner == game.orient ? 0 : 1) : '½'),
|
||||
]),
|
||||
m('a.cg-wrap', {
|
||||
href: `/${game.id}/${game.orient}`
|
||||
}),
|
||||
m('span.mini-game__player', [
|
||||
m('span'),
|
||||
game.clock ?
|
||||
m(`span.mini-game__clock.mini-game__clock--${game.orient}`, {
|
||||
'data-time': game.clock[game.orient]
|
||||
}) :
|
||||
m('span.mini-game__result', game.winner ? (game.winner == game.orient ? 1 : 0) : '½'),
|
||||
]),
|
||||
])
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,5 @@ module.exports = {
|
|||
player: function(p) {
|
||||
return m.trust(playerHtml(p));
|
||||
},
|
||||
playerVariant: function(ctrl, p) {
|
||||
return ctrl.data.variants.find(function(v) {
|
||||
return v.key === p.variant;
|
||||
});
|
||||
}
|
||||
playerVariant: (ctrl, p) => ctrl.data.variants.find(v => v.key === p.variant)
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue