-
Notifications
You must be signed in to change notification settings - Fork 0
/
_board.html.slim
54 lines (51 loc) · 1.74 KB
/
_board.html.slim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
- request_id = SecureRandom.uuid
- board = room.board
- attackable = board.movable_role == player.role
// TODO: 見た目をマシにする
p
ruby:
def role_i18n(my_role, evaluate_role)
if my_role == 'watcher'
case evaluate_role
when 'first_attacker'
'先手'
when 'second_attacker'
'後手'
else
raise "unexpected role #{evaluate_role}"
end
else
my_role == evaluate_role ? 'あなた' : '相手'
end
end
.board-info-container
- if board.finished? && board.winner
.alert.alert-primary.board-warning
b= role_i18n(player.role, board.winner)
| の勝ちです
- elsif board.finished? && board.winner.nil?
.alert.alert-primary.board-warning
| 引き分けです
- else
.alert.alert-primary.board-info
b= role_i18n(player.role, board.movable_role)
| の手番です
- if attackable && !board.finished? && board.passable?
p
.board-info-container
= link_to room_player_moves_path(room_id: player.room_id, player_id: player.id, pass: true, request_id: request_id), method: :post do
.btn.btn-primary
| パスする
.board-view
.board
- movable_squares = attackable ? board.calculate_movable_squares.to_set : Set.new
- board.squares.each.with_index do |rows, y|
- rows.each.with_index do |row, x|
.board-square
- if row == 'first_attacker'
.first
- elsif row == 'second_attacker'
.second
- elsif movable_squares.include?([x, y])
= link_to room_player_moves_path(room_id: player.room_id, player_id: player.id, x: x, y: y, request_id: request_id), method: :post do
.movable