Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ compose-down:
compose-test:
docker-compose run --rm exercises make test

compose-lint:
compose-code-lint:
docker-compose run --rm exercises make code-lint

code-lint-fix:
Expand Down
2 changes: 1 addition & 1 deletion modules/30-flow/20-case/lib/solution.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule Solution do
def move_allowed?(current_color, figure) do
case figure do
{:pawn, ^current_color} -> true
{:rock, ^current_color} -> true
{:rook, ^current_color} -> true
_ -> false
end
end
Expand Down
3 changes: 1 addition & 2 deletions modules/30-flow/20-case/ru/EXERCISE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

Реализовать функцию `join_game(user)`, которая принимает игрока в виде кортежа `{:user, name, age, role}` и определяет, разрешено ли данному игроку подключиться к игре. Если игроку уже исполнилось 18 лет, то он может войти в игру. Если роль игрока `:admin` или `:moderator`, то он может войти в игру независимо от возраста. Функция должна вернуть `:ok` или `:error`.

Реализовать функцию `move_allowed?(current_color, figure)` которая определяет, разрешено ли данной шахматной фигуре сделать ход. Параметр `current_color` может быть либо `:white` либо `:black`, и он указывает, фигурам какого цвета разрешено сделать ход. Параметр `figure` представлен кортежем `{type, color}`, где `type` может быть один из: `:pawn`, `:rock`, `:bishop`, `:knight`, `:queen`, `:king`, а color может быть `:white` или `:black`. Фигура может сделать ход если её тип `:pawn` или `:rock` и её цвет совпадает с `current_color`. Функция должна вернуть `true` или `false`.
Реализовать функцию `move_allowed?(current_color, figure)` которая определяет, разрешено ли данной шахматной фигуре сделать ход. Параметр `current_color` может быть либо `:white` либо `:black`, и он указывает, фигурам какого цвета разрешено сделать ход. Параметр `figure` представлен кортежем `{type, color}`, где `type` может быть один из: `:pawn`, `:rook`, `:bishop`, `:knight`, `:queen`, `:king`, а color может быть `:white` или `:black`. Фигура может сделать ход если её тип `:pawn` или `:rook` и её цвет совпадает с `current_color`. Функция должна вернуть `true` или `false`.

```elixir
Solution.join_game({:user, "Bob", 17, :admin})
Expand Down
4 changes: 2 additions & 2 deletions modules/30-flow/20-case/test/solution_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ defmodule Test do
test "move_allowed? test" do
assert move_allowed?(:white, {:pawn, :white})
assert not move_allowed?(:black, {:pawn, :white})
assert move_allowed?(:white, {:rock, :white})
assert not move_allowed?(:black, {:rock, :white})
assert move_allowed?(:white, {:rook, :white})
assert not move_allowed?(:black, {:rook, :white})
assert not move_allowed?(:white, {:queen, :white})
assert not move_allowed?(:black, {:queen, :white})
end
Expand Down