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

[GH-1027] Add game mode params per map #1032

Merged
merged 12 commits into from
Jan 9, 2025
Merged

Conversation

Nico-Sanchez
Copy link
Collaborator

@Nico-Sanchez Nico-Sanchez commented Jan 6, 2025

Motivation

We can't support multiple configs for multiple game modes and/or maps.
Closes #1027

Summary of changes

How to test it?

Open the configurator (localhost:4100) and interact with every game mode form.

Disclaimer ⚠️

This is the 1st step to achieve the game modes - maps configurations. This just adds the CRUD and forms, in a next iteration this will be used to serve the config to the client.

Checklist

  • Tested the changes locally.
  • Reviewed the changes on GitHub, line by line.
  • This change requires new documentation.
    • Documentation has been added/updated.

@Nico-Sanchez Nico-Sanchez force-pushed the gh-1027-add-game-mode-params branch from ad64d9a to 373afb5 Compare January 6, 2025 16:09
@Nico-Sanchez Nico-Sanchez changed the title Gh 1027 add game mode params [GH-1027] Add game mode params per map Jan 6, 2025
Base automatically changed from create-new-settings-version-table to main January 6, 2025 18:35
@Nico-Sanchez Nico-Sanchez force-pushed the gh-1027-add-game-mode-params branch from 7989201 to a3ea317 Compare January 6, 2025 22:43
@Nico-Sanchez Nico-Sanchez marked this pull request as ready for review January 6, 2025 22:44
tvillegas98
tvillegas98 previously approved these changes Jan 7, 2025
Copy link
Contributor

@tvillegas98 tvillegas98 left a comment

Choose a reason for hiding this comment

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

Great work! I've left some comments to take into account in the future

@derive {Jason.Encoder, only: [:name, :zone_enabled, :bots_enabled, :match_duration_ms, :respawn_time_ms]}

schema "game_mode_configurations" do
field(:name, Ecto.Enum, values: [:battle_royale, :deathmatch])
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this restriction here; maybe we could have another field for this (like a game mode type). However, we can leave it as it is

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh the field name is debatable. But being type or name, it could be an Ecto.Enum as it is or something else. Tell me your thoughts so we improve it if it doesn't work!

schema "map_mode_params" do
field(:amount_of_players, :integer)
field(:deleted_at, :naive_datetime)
embeds_many(:solo_initial_positions, Position, on_replace: :delete)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a validation here saying that the initial positions length should be equal to the amount of players

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Noted. I'll create an issue with all your feedback ❤️

</span>
</div>

<.inputs_for :let={fp} field={f[:map_mode_params]}>
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you of think of doing this?

Screenshot 2025-01-07 at 3 57 31 pm

Although it kinda expands the form 😆 .
If you think it is better, you can encapsulate the inputs for within an div with the flex flex-row classes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will do in a separate PR. Thanks!

</span>
</div>

<div class="flex items-center justify-between gap-6">
Copy link
Contributor

Choose a reason for hiding this comment

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

We can add an X button within every nested form, so we can delete an specific configuration and not the last one

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alright. Let me know if it's done somewhere already so I can implement it faster 🚀

@manucamejo
Copy link
Collaborator

I'm getting an error when I try to create the initial positions in a new game mode
image

@Nico-Sanchez
Copy link
Collaborator Author

I'm getting an error when I try to create the initial positions in a new game mode

The error wasn't at creation, it was at editing (update) time.
Now it's fixed using the same logic as creation! 😄

@tvillegas98 tvillegas98 merged commit de0a5a7 into main Jan 9, 2025
1 check passed
@tvillegas98 tvillegas98 deleted the gh-1027-add-game-mode-params branch January 9, 2025 17:58
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.

[CONFIGURATOR] map configs per game mode
3 participants