Skip to content

Commit 7d761dc

Browse files
committed
Showing the Past Moves
1 parent e0572f2 commit 7d761dc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

react_learn/src/main/scala/tutorial/webapp/TutorialApp.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ object Game {
9797
case Some(s) => "Winner is " + s
9898
case None => "Next player: " + {if (state.xIsNext) "X" else "O"}
9999
}
100+
val moves = state.history.zipWithIndex.map{
101+
case (step, move) => {
102+
val desc = if (move > 0) "Go to move #%s".format(move) else "Go to game start"
103+
<.li(
104+
<.button(
105+
^.onClick --> Callback{/* TODO */},
106+
desc
107+
)
108+
)
109+
}
110+
}
100111
<.div(
101112
^.cls := "game",
102113
<.div(
@@ -106,7 +117,7 @@ object Game {
106117
<.div(
107118
^.cls := "game-info",
108119
<.div(status),
109-
<.ol(/* TODO */),
120+
<.ol(moves.toTagMod),
110121
),
111122
)
112123
}

0 commit comments

Comments
 (0)