Skip to content

Commit

Permalink
fix tournament langs picker (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReDBrother committed Feb 24, 2020
1 parent 9eace74 commit 244bfb4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
defmodule Codebattle.GameProcess.Engine.Tournament do
alias Codebattle.Bot.PlaybookAsyncRunner

alias Codebattle.Languages

alias Codebattle.GameProcess.{
GlobalSupervisor,
Engine,
Expand All @@ -27,7 +29,7 @@ defmodule Codebattle.GameProcess.Engine.Tournament do
task_id: task.id
})

new_players = Enum.map(players, &Player.build/1)
new_players = Enum.map(players, &Player.build(&1, %{task: task}))

fsm =
build_fsm(%{
Expand All @@ -39,6 +41,7 @@ defmodule Codebattle.GameProcess.Engine.Tournament do
type: "tournament",
inserted_at: game.inserted_at,
task: task,
langs: Languages.get_langs_with_solutions(task),
tournament_id: params.tournament.id,
timeout_seconds: timeout_seconds,
starts_at: TimeHelper.utc_now()
Expand Down
10 changes: 8 additions & 2 deletions services/app/lib/codebattle/game_process/player.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defmodule Codebattle.GameProcess.Player do
end

def build(%Tournament.Types.Player{} = player, params) do
new_player = %__MODULE__{
init_player = %__MODULE__{
id: player.id,
public_id: player.public_id,
is_bot: player.is_bot,
Expand All @@ -82,7 +82,13 @@ defmodule Codebattle.GameProcess.Player do
lang: player.lang || "js"
}

Map.merge(new_player, params)
player =
case params[:task] do
nil -> init_player
task -> setup_editor_params(init_player, %{task: task})
end

Map.merge(player, params)
end

def build(user, params) do
Expand Down

0 comments on commit 244bfb4

Please sign in to comment.