diff --git a/lib/alternis/engines/dictionary_engine_impl.ex b/lib/alternis/engines/dictionary_engine_impl.ex index 1870765..5a271e7 100644 --- a/lib/alternis/engines/dictionary_engine_impl.ex +++ b/lib/alternis/engines/dictionary_engine_impl.ex @@ -32,7 +32,7 @@ defmodule Alternis.Engines.DictionaryEngine.Impl do where: ^condition, where: d.language == ^language, select_merge: %{language: d.language}, - order_by: w.frequency, + order_by: fragment("RANDOM()"), limit: 1 ) end diff --git a/lib/alternis/guess.ex b/lib/alternis/guess.ex index b87fbcc..09b440b 100644 --- a/lib/alternis/guess.ex +++ b/lib/alternis/guess.ex @@ -31,6 +31,10 @@ defmodule Alternis.Guess do |> validate_required([:word, :bulls, :cows, :exact?]) end + def priority(guess) do + length(guess.bulls) * 10 + length(guess.cows) + end + def validate_word(attrs \\ %{}) do %Guess{} |> cast(attrs, [:word]) diff --git a/lib/alternis_web/live/game_live/game_component.ex b/lib/alternis_web/live/game_live/game_component.ex index 1085348..20e66a3 100644 --- a/lib/alternis_web/live/game_live/game_component.ex +++ b/lib/alternis_web/live/game_live/game_component.ex @@ -2,6 +2,7 @@ defmodule AlternisWeb.GameLive.GameComponent do use Phoenix.Component attr :guesses, :list, required: true + attr :update, :string, default: "append" slot :header slot :footer @@ -9,7 +10,7 @@ defmodule AlternisWeb.GameLive.GameComponent do ~H"""
<%= render_slot(@header) %> -