Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: slots minigame #480

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

feat: slots minigame #480

wants to merge 12 commits into from

Conversation

nunom27
Copy link
Contributor

@nunom27 nunom27 commented Jan 25, 2025

No description provided.

@nunom27 nunom27 self-assigned this Jan 25, 2025
@nunom27 nunom27 marked this pull request as ready for review February 4, 2025 01:29
Comment on lines +1206 to +1208
# If the active status is not set, set it to false by default
change_slots_active(true)
true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# If the active status is not set, set it to false by default
change_slots_active(true)
true
# If the active status is not set, set it to true by default
change_slots_active(true)
true

Comment says something and the opposite is happening.

Phoenix.PubSub.broadcast(@pubsub, slots_config_topic(config), {config, value})
end

alias Safira.Minigames.SlotsPayline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bring this to the top of the file.

Comment on lines +1326 to +1340
@doc """
Spins the wheel for the given attendee.

## Examples

iex> spin_wheel(attendee)
{:ok, :prize, %WheelDrop{}}

iex> spin_wheel(attendee)
{:ok, :tokens, %WheelDrop{}}

iex> spin_wheel(attendee)
{:ok, nil, %WheelDrop{}}
"""
def spin_slots(attendee, bet) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change docs to match what function does.

Comment on lines +1468 to +1470
if Enum.any?(paylines, fn p ->
[p.position_0, p.position_1, p.position_2] == target
end) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure, is this accounting for cases where paylines have positions with ANY (nil) ?

Comment on lines +7 to +22

schema "slots_paytables" do
field :multiplier, :integer
field :probability, :float

timestamps(type: :utc_datetime)
end

@doc false
def changeset(slots_paytable, attrs) do
slots_paytable
|> cast(attrs, [:multiplier, :probability])
|> validate_required([:multiplier, :probability])
|> validate_number(:multiplier, greater_than: 0)
|> validate_number(:probability, greater_than_or_equal_to: 0, less_than_or_equal_to: 1)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @required_fields.

<.field field={form[:multiplier]} type="number" wrapper_class="col-span-2" />
<.field field={form[:probability]} type="number" wrapper_class="col-span-2" />
<.link
phx-click={JS.push("delete-entry", value: %{id: id})}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
phx-click={JS.push("delete-entry", value: %{id: id})}
phx-click="delete-entry" phx-value={%{id: id}}}

{:noreply, assign(socket, form: to_form(changeset, action: :validate))}
end

# Update save handler to use new consume_image_data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Update save handler to use new consume_image_data

Comment on lines +188 to +192
Ecto.Multi.new()
|> update_reel_order(reel_order["reel-0"], visibility[0], :reel_0_index)
|> update_reel_order(reel_order["reel-1"], visibility[1], :reel_1_index)
|> update_reel_order(reel_order["reel-2"], visibility[2], :reel_2_index)
|> Safira.Repo.transaction()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put this logic inside the context!!

Comment on lines +263 to +267
live "/slots", MinigamesLive.Index, :edit_slots
live "/slots/reels_icons", MinigamesLive.Index, :edit_slots_reel_icons_icons
live "/slots/reels_position", MinigamesLive.Index, :edit_slots_reel_icons_position
live "/slots/paytable", MinigamesLive.Index, :edit_slots_paytable
live "/slots/payline", MinigamesLive.Index, :edit_slots_payline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
live "/slots", MinigamesLive.Index, :edit_slots
live "/slots/reels_icons", MinigamesLive.Index, :edit_slots_reel_icons_icons
live "/slots/reels_position", MinigamesLive.Index, :edit_slots_reel_icons_position
live "/slots/paytable", MinigamesLive.Index, :edit_slots_paytable
live "/slots/payline", MinigamesLive.Index, :edit_slots_payline
scope "/slots", MinigamesLive do
live "/", Index, :edit_slots
live "/reels_icons", Index, :edit_slots_reel_icons_icons
live "/reels_position", Index, :edit_slots_reel_icons_position
live "/paytable", Index, :edit_slots_paytable
live "/payline", Index, :edit_slots_payline
end

Comment on lines +4 to +11
def change do
create table(:slots_paytables, primary_key: false) do
add :id, :binary_id, primary_key: true
add :multiplier, :integer
add :probability, :float

timestamps(type: :utc_datetime)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the multiplier column should be unique, but I might be missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants