Skip to content

Conversation

@weebao
Copy link
Member

@weebao weebao commented Apr 30, 2025

No description provided.

Copilot AI review requested due to automatic review settings April 30, 2025 05:09
@weebao weebao merged commit baae19a into main Apr 30, 2025
1 check passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the room configuration by reverting the problem distribution settings and updating log messages. The key changes include:

  • Updating the RoomSettingsSchema to use chained z.object() with refined probability criteria.
  • Changing probability constraints from integer ranges to decimal ranges and adding a refinement to ensure they sum to 1.
  • Adjusting the default configuration values to align with the new fractional probability model.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/lib/models/room.ts Updated schema for room settings with modified probability fields and added refinement.
src/lib/assets/config/room.ts Changed default probability values to decimals.
docs/changes.md Added changelog documentation entries.
Files not reviewed (1)
  • src/routes/+page.svelte: Language not supported

hp_multiplier_easy: z.number().min(1).default(DefaultRoomSettings.hp_multiplier_easy),
hp_multiplier_medium: z.number().min(1).default(DefaultRoomSettings.hp_multiplier_medium),
hp_multiplier_hard: z.number().int().min(1).default(DefaultRoomSettings.hp_multiplier_hard),
distribution_mode: z.enum(["auto", "fixed"]).default(DefaultRoomSettings.distribution_mode),
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

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

[nitpick] The updated probability fields now allow fractional values. If fractional probabilities are intended, consider adding a clarifying comment to explain the removal of the .int() constraint.

Suggested change
distribution_mode: z.enum(["auto", "fixed"]).default(DefaultRoomSettings.distribution_mode),
distribution_mode: z.enum(["auto", "fixed"]).default(DefaultRoomSettings.distribution_mode),
// Fractional probabilities are allowed for prob_easy, prob_medium, and prob_hard.
// The .int() constraint was removed to support values like 0.3 or 0.5.

Copilot uses AI. Check for mistakes.
starting_mp: z.number().int().min(1).max(1000).default(DefaultRoomSettings.starting_mp),
mana_recharge: z.number().int().min(1).max(1000).default(DefaultRoomSettings.mana_recharge)
})
.refine((data) => data.prob_easy + data.prob_medium + data.prob_hard === 1, {
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

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

Using an exact equality check for floating-point numbers may cause precision issues. Consider using an approximation (e.g., Math.abs(sum - 1) < ε) to ensure robust validation.

Suggested change
.refine((data) => data.prob_easy + data.prob_medium + data.prob_hard === 1, {
.refine((data) => {
const EPSILON = 1e-9;
return Math.abs(data.prob_easy + data.prob_medium + data.prob_hard - 1) < EPSILON;
}, {

Copilot uses AI. Check for mistakes.
@weebao weebao deleted the docs-config-update branch May 30, 2025 03:13
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