Compare commits

..

86 Commits

Author SHA1 Message Date
ef6bf9862e feat: add FriendsTodaySection component for displaying friends' results
All checks were successful
Build Docker Image / build (push) Successful in 2m4s
2026-04-14 22:08:49 +02:00
d75c74ac3c Refactor character affiliations to singular form
- Updated character data structure to replace 'affiliations' and 'frAffiliations' with 'affiliation' and 'frAffiliation'.
- Modified related functions and components to accommodate the new structure.
- Adjusted database schema and server-side logic to reflect the changes in character affiliation handling.
- Ensured all references in the UI components and data import/export scripts are updated accordingly.
2026-04-14 21:56:26 +02:00
fa14156d82 feat: remove overrides
Some checks failed
Build Docker Image / build (push) Has been cancelled
2026-04-12 02:01:01 +02:00
29297d3773 fix: include 'Four Emperors' in character exclusion logic
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
2026-03-18 22:42:32 +01:00
28bb8f526b fix: include Kuja in female character categorization
All checks were successful
Build Docker Image / build (push) Successful in 1m13s
2026-03-18 22:40:39 +01:00
288271fb04 fix: include Queens Regnant in female character categorization
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
2026-03-18 22:22:54 +01:00
fb64c84a17 fix: include Gorgon Sisters in female character categorization
All checks were successful
Build Docker Image / build (push) Successful in 1m11s
2026-03-18 22:19:46 +01:00
81e205dd4e fix: expand gender categorization in character fetch logic
All checks were successful
Build Docker Image / build (push) Successful in 1m23s
2026-03-18 22:07:28 +01:00
ded1c8313d fix: update character link URLs to remove language prefix
All checks were successful
Build Docker Image / build (push) Successful in 1m11s
2026-03-16 23:15:02 +01:00
4426b5d28a fix: correct href interpolation for character links in admin page
Some checks failed
Build Docker Image / build (push) Has been cancelled
2026-03-16 23:14:21 +01:00
5ad0428420 feat: enhance character scrape validation and management
All checks were successful
Build Docker Image / build (push) Successful in 1m14s
- Added a new entry for "fuzzy_talisman" in the journal.
- Updated import-json script to handle character deletion and mark absent characters as deleted in the scrape validation.
- Modified schema to include an `isDeleted` field in the characterScrapeValidation table.
- Renamed function `upsertCharacterFromScrapeValidation` to `applyCharacterChangeFromScrapeValidation` for clarity.
- Enhanced character change loading to include deleted characters and updated UI to display them.
- Improved character change handling in the Svelte component to reflect new, modified, and deleted states.
2026-03-16 23:12:06 +01:00
7760570365 feat: exclude characters with 'family' in their name from fetch results
All checks were successful
Build Docker Image / build (push) Successful in 1m14s
2026-03-16 22:31:40 +01:00
5fde54a2a7 feat: add age filter functionality and localization support in guess history
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
2026-03-16 22:05:09 +01:00
2a3c82f777 feat: add age attribute to character history and localization support
All checks were successful
Build Docker Image / build (push) Successful in 1m13s
2026-03-16 22:00:49 +01:00
835163f5bb feat: add tried characters tracking and display in daily game profile
All checks were successful
Build Docker Image / build (push) Successful in 1m10s
2026-03-16 21:39:44 +01:00
5020393b22 fix: normalize character status text to lowercase for consistency
All checks were successful
Build Docker Image / build (push) Successful in 1m22s
2026-03-16 21:17:01 +01:00
94393851c8 feat: support French epithets in character extraction logic
All checks were successful
Build Docker Image / build (push) Successful in 1m14s
2026-03-15 22:44:45 +01:00
997b2f1781 feat: add French localization support for character attributes and improve character display logic
All checks were successful
Build Docker Image / build (push) Successful in 1m18s
- Added optional French names, affiliations, origins, and epithets to character records.
- Updated character import logic to handle new French fields.
- Enhanced character search and display components to show French names and epithets based on selected language.
- Modified database schema to include French fields for characters.
- Improved error handling in daily character setup to check for existing characters.
- Refactored components to utilize helper functions for displaying names and attributes based on language.
2026-03-15 22:00:19 +01:00
bd121b7d85 feat(i18n): integrate internationalization for game pages
- Added translation support for various game-related texts in the home, daily, infinite, login, and profile pages.
- Replaced hardcoded French strings with translation keys using the `$t` function.
- Updated titles, descriptions, and button texts to enhance localization.
2026-03-15 20:19:26 +01:00
6d2dccd47f refactor: update link generation to use resolve for consistent path handling 2026-03-15 19:53:47 +01:00
5fdde9d177 refactor: remove unused fandomUrl and getDifferenceColor functions, simplify character link generation 2026-03-14 18:34:03 +01:00
b1cc691422 refactor: enhance character data transformation and improve fetching logic in character-related scripts 2026-03-14 18:32:43 +01:00
8b08950719 refactor: streamline character selection and improve rendering logic in +page.svelte 2026-03-14 17:29:57 +01:00
fd83ac911a refactor: improve type definitions for selectedCharacter and selectedCharacters in WinPanel component 2026-03-14 17:22:44 +01:00
eeccf812cf refactor: improve type definitions for dailyCharacter and selectedCharacters in HintsPanel component 2026-03-14 17:20:26 +01:00
9485d9841c refactor: improve type definitions and event handling in CharacterSearchInput component 2026-03-14 17:18:58 +01:00
31308ef126 refactor: enhance affiliation handling and improve type definitions in GuessHistoryTable component 2026-03-14 17:13:13 +01:00
57a0427e77 refactor: improve bounty extraction logic and enhance character selection in infinite mode 2026-03-14 17:09:33 +01:00
3bd2506c2f refactor: enhance type safety and improve layout structure in GuessHistoryTable component 2026-03-14 16:33:43 +01:00
e5a21cb0af refactor: improve type definitions and enhance state management in profile and daily components 2026-03-14 16:31:16 +01:00
4e95abf09f fix: update devil fruit extraction to handle redirects and ensure correct title retrieval
Some checks failed
Build Docker Image / build (push) Has been cancelled
2026-03-14 15:41:20 +01:00
66afda5101 Refactor code structure for improved readability and maintainability 2026-03-14 15:34:30 +01:00
a041a8caf5 Refactor database schema and update scraping logic for One Piece characters and arcs
- Updated database schema to include French names and adjusted field names for consistency.
- Modified scraping script to fetch and store French names for arcs and characters.
- Improved API calls to handle redirects and fetch additional data for characters.
- Enhanced data extraction methods for character attributes and devil fruits.
- Cleaned up code for better readability and maintainability.
2026-03-14 01:23:29 +01:00
a91b298ee5 fix: unify fetch concurrency constant for character and devil fruit fetching
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
2026-03-06 21:57:09 +01:00
d3e36e486f feat: display GuessHistoryTable after winning condition and friends' results
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
2026-03-06 20:26:04 +01:00
249da5ad2e feat(auth): add username field to user schema and authentication process
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
- Updated user schema to include a unique username field.
- Modified authentication logic to support sign-in using either email or username.
- Enhanced sign-up process to require a username and validate its uniqueness.
- Updated login and profile routes to reflect changes in user identification.
- Adjusted frontend forms to accommodate username input alongside email.
2026-03-06 20:16:05 +01:00
ce08329b2d feat: add friends' results display for today's game
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
2026-03-06 19:34:46 +01:00
f35f4565b6 feat: implement friendship system with requests and management features
All checks were successful
Build Docker Image / build (push) Successful in 1m15s
- Added a new friendship table schema to manage friend requests and relationships.
- Updated profile page to include tabs for managing friends, incoming requests, and outgoing requests.
- Implemented functionality to send, accept, decline, cancel, and remove friend requests.
- Enhanced user experience with feedback messages for friend request actions.
2026-03-06 19:28:42 +01:00
5cd989b098 fix: normalize character status filtering logic to handle unknown and null values 2026-03-06 19:05:02 +01:00
edab42fd26 fix: improve status display logic in GuessHistoryTable for unknown and null values 2026-03-06 19:03:03 +01:00
a78473b5ff fix: correct height extraction logic to convert centimeters to meters
All checks were successful
Build Docker Image / build (push) Successful in 1m11s
2026-03-06 00:05:21 +01:00
2ddcd548a2 fix: enhance affiliation comparison logic in GuessHistoryTable
All checks were successful
Build Docker Image / build (push) Successful in 1m11s
2026-03-05 23:42:48 +01:00
0b2797440e feat: add arc filter functionality to character selection
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
2026-03-05 23:25:03 +01:00
c268cd5301 feat: implement character filters for gender, status, haki, devil fruit, height, and origin
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
2026-03-05 23:09:49 +01:00
5978963939 feat: add reveal answer functionality to reset score and update selected characters
All checks were successful
Build Docker Image / build (push) Successful in 1m10s
2026-03-05 22:57:09 +01:00
1035a98eca refactor: simplify tries display by removing win/loss status
All checks were successful
Build Docker Image / build (push) Successful in 1m10s
2026-03-05 22:51:39 +01:00
df224d97bb fix: correct win count message grammar for singular and plural cases 2026-03-05 22:10:54 +01:00
08f5d620be feat: add daily history tab and fetch daily character history for user profile
All checks were successful
Build Docker Image / build (push) Successful in 1m11s
2026-03-05 22:08:36 +01:00
b4601a5caf feat: create new character table and migrate data from existing character table
All checks were successful
Build Docker Image / build (push) Successful in 1m17s
2026-03-05 22:03:09 +01:00
a7775783af feat: add filtering for characters with null origin data
All checks were successful
Build Docker Image / build (push) Successful in 1m24s
2026-03-04 13:11:53 +01:00
e6bfc1e413 feat: refactor character loading to use let for mutable characters and improve filtering logic
All checks were successful
Build Docker Image / build (push) Successful in 1m37s
2026-03-04 12:45:55 +01:00
7c9aef1aee feat: add scrape import functionality with status messages and logs
All checks were successful
Build Docker Image / build (push) Successful in 1m22s
2026-03-03 23:44:03 +01:00
de2c8cdc77 feat: improve search functionality by normalizing input and character names
All checks were successful
Build Docker Image / build (push) Successful in 1m23s
2026-03-03 23:38:07 +01:00
b5816e6c28 feat: enhance character status extraction and update schema for nullable status
All checks were successful
Build Docker Image / build (push) Successful in 1m22s
2026-03-03 23:26:53 +01:00
70de84f3ab feat: update DevilFruitType to include 'Smile' for enhanced categorization
All checks were successful
Build Docker Image / build (push) Successful in 1m28s
2026-03-03 23:12:17 +01:00
6402c378dd feat: implement character changes page with new and modified character listings
All checks were successful
Build Docker Image / build (push) Successful in 1m23s
2026-03-03 19:58:02 +01:00
085dae6765 feat: add new snapshot for version 6 with updated schema and relationships
All checks were successful
Build Docker Image / build (push) Successful in 1m23s
- Created a new snapshot file for version 6 of the database schema.
- Added tables for arc, character, characterHistory, characterOverride, characterScrapeValidation, config, devilFruit, userCharacterHistory, account, session, user, and verification with appropriate columns and constraints.
- Updated the journal to include new entries for version 6.
- Modified the userCharacterHistory table to enforce unique constraints on userId and characterHistoryId.
- Enhanced daily game logic to track user attempts and prevent duplicate entries for the same day.
2026-03-03 19:31:10 +01:00
bfc6d76dfe feat: add win count display for today's character in the UI
All checks were successful
Build Docker Image / build (push) Successful in 1m24s
2026-03-03 19:13:45 +01:00
4ee7445b68 feat: refactor WinPanel to use selectedCharacter prop for improved clarity and consistency 2026-03-03 19:11:08 +01:00
7ecc46b5a6 feat: enhance character data loading with distinct statuses and genders, optimize epithets handling
All checks were successful
Build Docker Image / build (push) Successful in 1m42s
2026-03-03 18:52:58 +01:00
8010ddf00e feat: replace SVG favicon with PNG and update layout reference
All checks were successful
Build Docker Image / build (push) Successful in 1m20s
2026-03-02 23:48:54 +01:00
91400f9910 feat: simplify uploads directory path assignment by removing redundant process.cwd() call
All checks were successful
Build Docker Image / build (push) Successful in 1m20s
2026-03-02 23:32:26 +01:00
2b4a55636e feat: use environment variable for uploads directory path
All checks were successful
Build Docker Image / build (push) Successful in 1m26s
2026-03-02 23:21:05 +01:00
6cd18992f6 feat: enhance WinPanel with dynamic attempt messages based on user performance
Some checks failed
Build Docker Image / build (push) Has been cancelled
2026-03-02 23:19:51 +01:00
26d3734e7e feat: update .env.example with body size limit and uploads directory
All checks were successful
Build Docker Image / build (push) Successful in 1m20s
2026-03-02 23:05:33 +01:00
33efee0707 feat: add lazy loading to character images in admin character list
All checks were successful
Build Docker Image / build (push) Successful in 1m19s
2026-03-02 22:37:42 +01:00
73593f99a6 feat: add lazy loading to character images in CharacterSearchInput component
All checks were successful
Build Docker Image / build (push) Successful in 1m19s
2026-03-02 22:35:54 +01:00
74d051cbfe feat: implement file upload functionality and create file serving endpoint
All checks were successful
Build Docker Image / build (push) Successful in 1m20s
2026-03-02 22:25:33 +01:00
bf963ee3fd feat: update GuessHistoryTable styles for improved layout and readability
All checks were successful
Build Docker Image / build (push) Successful in 1m23s
2026-03-02 22:00:25 +01:00
1ba853771e feat: add userCharacterHistory table schema and update journal with new version 2026-03-02 22:00:25 +01:00
949d9596a6 feat: add deployment webhook call to build image workflow 2026-03-02 22:00:25 +01:00
040a8963b0 feat: update Docker image build workflow to lowercase repository name in output 2026-03-02 22:00:25 +01:00
d78a70c473 feat: remove daily character seed from environment and implement random seed generation for selection 2026-03-02 22:00:25 +01:00
b70e47b0d6 feat: implement daily character seed from environment variable and enhance selection logic with hashing 2026-03-02 22:00:25 +01:00
60d2474f51 feat: refactor character history schema and related logic for improved date handling and data integrity 2026-03-02 22:00:25 +01:00
ef7ef4dd6c feat: refactor daily character logic to improve win count retrieval and streamline character selection 2026-03-02 22:00:25 +01:00
02c2ff2684 feat: enhance column visibility toggle with localized display names and improve layout 2026-03-02 22:00:25 +01:00
b245ee984a feat: implement infinite mode with character selection and scoring; refactor daily character storage logic 2026-03-02 22:00:25 +01:00
cf25a96719 feat: add WinPanel and YesterdayCharacter components; refactor daily game page
- Introduced WinPanel component to display win/loss messages based on game outcome.
- Added YesterdayCharacter component to show the character from the previous day.
- Refactored daily game page to utilize new components for better code organization and readability.
- Updated server-side logic to fetch daily character ID and count wins more efficiently.
- Cleaned up character selection logic and hint availability tracking.
2026-03-02 22:00:25 +01:00
4d059d45ef feat: add promote admin script to manage user roles 2026-03-02 22:00:25 +01:00
a6a5055f3a feat: improve character update logic and handle haki fields more effectively 2026-03-02 22:00:25 +01:00
6c2e0886af fix: adjust main component height for consistent layout across game, login, and profile pages 2026-03-02 22:00:25 +01:00
18ac6220f1 feat: enhance admin layout with navigation and return link; add name field for sign-up in login 2026-03-02 22:00:25 +01:00
114f6cde7a feat: add daily win recording endpoint, user authentication, and profile management
- Implemented a POST endpoint for recording daily wins in the game.
- Created login and signup functionality with email and password.
- Developed a profile page allowing users to update their profile information, change passwords, and manage active sessions.
- Added a toggle feature for switching between login and signup forms.
- Enhanced the layout by removing the profile button and adjusting the header structure.
2026-03-02 22:00:24 +01:00
e45dfb9832 fix: update @types/node version and improve type handling in daily character affiliations 2026-03-02 22:00:24 +01:00
b45909f86e feat: add user admin status and profile management
- Updated user schema to include isAdmin field.
- Enhanced authentication hooks to fetch and set user admin status.
- Created ProfileButton component for user profile actions.
- Implemented profile and password update functionality.
- Added session management for user accounts.
- Developed login and signup pages with form handling.
- Introduced layout server for user session data.
- Updated daily page to reflect character changes.
2026-03-02 22:00:24 +01:00
62 changed files with 7074 additions and 2962 deletions

View File

@@ -7,3 +7,10 @@ ORIGIN=""
# For production use 32 characters and generated with high entropy # For production use 32 characters and generated with high entropy
# https://www.better-auth.com/docs/installation # https://www.better-auth.com/docs/installation
BETTER_AUTH_SECRET="" BETTER_AUTH_SECRET=""
# SvelteKit request body limit (default is 512K)
# Increase this for image uploads (e.g. 5M, 10M)
BODY_SIZE_LIMIT="10M"
# Uploaded files directory (relative to project root)
UPLOADS_DIR="uploads"

View File

@@ -0,0 +1,70 @@
name: Build Docker Image
on:
push:
branches:
- main
tags:
- '*'
env:
GITEA_REGISTRY: ${{ gitea.server_url }}
GITEA_USERNAME: ${{ gitea.actor }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Determine image tag
id: tag
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG=${GITHUB_REF#refs/tags/}
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
TAG=main
else
echo "Not on main branch or a tag, skipping build"
exit 1
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
# Remove protocol from registry URL
REGISTRY="${{ env.GITEA_REGISTRY }}"
REGISTRY="${REGISTRY#https://}"
REGISTRY="${REGISTRY#http://}"
echo "registry=$REGISTRY" >> $GITHUB_OUTPUT
# Lowercase repository name
REPO="${{ gitea.repository }}"
REPO="${REPO,,}"
echo "repository=$REPO" >> $GITHUB_OUTPUT
- name: Login to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ steps.tag.outputs.registry }}
username: ${{ vars.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ steps.tag.outputs.registry }}/${{ steps.tag.outputs.repository }}:${{ steps.tag.outputs.tag }}
${{ steps.tag.outputs.registry }}/${{ steps.tag.outputs.repository }}:latest
- name: Call deployment webhook
if: ${{ secrets.DEPLOYMENT_WEBHOOK != '' }}
run: |
curl -k -X POST ${{ secrets.DEPLOYMENT_WEBHOOK }} \
-H 'Content-Type: application/json'

3
.gitignore vendored
View File

@@ -27,3 +27,6 @@ vite.config.ts.timestamp-*
# Script outputs # Script outputs
/scraped-data /scraped-data
# Uploads
/uploads

View File

@@ -1,156 +0,0 @@
CREATE TABLE `arc` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`startChapter` integer NOT NULL,
`endChapter` integer,
`url` text
);
--> statement-breakpoint
CREATE TABLE `character` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`gender` text,
`age` integer,
`affiliations` text,
`devilFruitId` text,
`hakiObservation` integer DEFAULT false,
`hakiArmament` integer DEFAULT false,
`hakiConqueror` integer DEFAULT false,
`bounty` integer DEFAULT 0,
`height` real,
`origin` text,
`firstAppearance` integer NOT NULL,
`pictureUrl` text,
`epithets` text,
`status` text,
`arcId` text,
`url` text,
`isInDailyMode` integer DEFAULT true,
FOREIGN KEY (`devilFruitId`) REFERENCES `devilFruit`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`arcId`) REFERENCES `arc`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `characterHistory` (
`id` text PRIMARY KEY NOT NULL,
`characterId` text,
`date` text,
`won` integer DEFAULT 0 NOT NULL,
`createdAt` integer NOT NULL,
`updatedAt` integer NOT NULL,
FOREIGN KEY (`characterId`) REFERENCES `character`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `characterOverride` (
`characterId` text PRIMARY KEY NOT NULL,
`name` text,
`gender` text,
`age` integer,
`affiliations` text,
`devilFruitId` text,
`hakiObservation` integer,
`hakiArmament` integer,
`hakiConqueror` integer,
`bounty` integer,
`height` real,
`origin` text,
`firstAppearance` integer NOT NULL,
`pictureUrl` text,
`epithets` text,
`status` text,
`arcId` text,
`url` text,
`notes` text,
FOREIGN KEY (`characterId`) REFERENCES `character`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`devilFruitId`) REFERENCES `devilFruit`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`arcId`) REFERENCES `arc`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `characterScrapeValidation` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`gender` text,
`age` integer,
`affiliations` text,
`devilFruitId` text,
`hakiObservation` integer DEFAULT false,
`hakiArmament` integer DEFAULT false,
`hakiConqueror` integer DEFAULT false,
`bounty` integer,
`height` real,
`origin` text,
`firstAppearance` integer NOT NULL,
`pictureUrl` text,
`epithets` text,
`status` text,
`arcId` text,
`url` text,
FOREIGN KEY (`devilFruitId`) REFERENCES `devilFruit`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`arcId`) REFERENCES `arc`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `config` (
`key` text PRIMARY KEY NOT NULL,
`value` text
);
--> statement-breakpoint
CREATE TABLE `devilFruit` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`type` text,
`url` text
);
--> statement-breakpoint
CREATE UNIQUE INDEX `devilFruit_name_unique` ON `devilFruit` (`name`);--> statement-breakpoint
CREATE TABLE `account` (
`id` text PRIMARY KEY NOT NULL,
`account_id` text NOT NULL,
`provider_id` text NOT NULL,
`user_id` text NOT NULL,
`access_token` text,
`refresh_token` text,
`id_token` text,
`access_token_expires_at` integer,
`refresh_token_expires_at` integer,
`scope` text,
`password` text,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE INDEX `account_userId_idx` ON `account` (`user_id`);--> statement-breakpoint
CREATE TABLE `session` (
`id` text PRIMARY KEY NOT NULL,
`expires_at` integer NOT NULL,
`token` text NOT NULL,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
`updated_at` integer NOT NULL,
`ip_address` text,
`user_agent` text,
`user_id` text NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `session_token_unique` ON `session` (`token`);--> statement-breakpoint
CREATE INDEX `session_userId_idx` ON `session` (`user_id`);--> statement-breakpoint
CREATE TABLE `user` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`email` text NOT NULL,
`email_verified` integer DEFAULT false NOT NULL,
`image` text,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);--> statement-breakpoint
CREATE TABLE `verification` (
`id` text PRIMARY KEY NOT NULL,
`identifier` text NOT NULL,
`value` text NOT NULL,
`expires_at` integer NOT NULL,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
);
--> statement-breakpoint
CREATE INDEX `verification_identifier_idx` ON `verification` (`identifier`);

View File

@@ -0,0 +1,199 @@
CREATE TABLE `arc` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`fr_name` text,
`start_chapter` integer NOT NULL,
`end_chapter` integer,
`url` text
);
--> statement-breakpoint
CREATE TABLE `character` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`fr_name` text,
`gender` text,
`age` integer,
`affiliations` text,
`fr_affiliations` text,
`devil_fruit_id` text,
`haki_observation` integer DEFAULT false,
`haki_armament` integer DEFAULT false,
`haki_conqueror` integer DEFAULT false,
`bounty` integer DEFAULT 0,
`height` real,
`origin` text,
`fr_origin` text,
`first_appearance` integer NOT NULL,
`picture_url` text,
`epithets` text,
`fr_epithets` text,
`status` text,
`arc_id` text,
`url` text,
`fr_url` text,
`is_in_daily_mode` integer DEFAULT false,
FOREIGN KEY (`devil_fruit_id`) REFERENCES `devil_fruit`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`arc_id`) REFERENCES `arc`(`id`) ON UPDATE no action ON DELETE set null
);
--> statement-breakpoint
CREATE TABLE `character_history` (
`id` text PRIMARY KEY NOT NULL,
`character_id` text,
`date` integer NOT NULL,
`won` integer DEFAULT 0 NOT NULL,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`character_id`) REFERENCES `character`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `character_history_date_unique` ON `character_history` (`date`);--> statement-breakpoint
CREATE TABLE `character_override` (
`character_id` text PRIMARY KEY NOT NULL,
`name` text,
`gender` text,
`age` integer,
`affiliations` text,
`fr_affiliations` text,
`devil_fruit_id` text,
`haki_observation` integer,
`haki_armament` integer,
`haki_conqueror` integer,
`bounty` integer,
`height` real,
`origin` text,
`fr_origin` text,
`first_appearance` integer,
`picture_url` text,
`epithets` text,
`fr_epithets` text,
`status` text,
`arc_id` text,
`url` text,
`fr_url` text,
`notes` text,
FOREIGN KEY (`character_id`) REFERENCES `character`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`devil_fruit_id`) REFERENCES `devil_fruit`(`id`) ON UPDATE no action ON DELETE set null,
FOREIGN KEY (`arc_id`) REFERENCES `arc`(`id`) ON UPDATE no action ON DELETE set null
);
--> statement-breakpoint
CREATE TABLE `character_scrape_validation` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`fr_name` text,
`gender` text,
`age` integer,
`affiliations` text,
`fr_affiliations` text,
`devil_fruit_id` text,
`haki_observation` integer DEFAULT false,
`haki_armament` integer DEFAULT false,
`haki_conqueror` integer DEFAULT false,
`bounty` integer,
`height` real,
`origin` text,
`fr_origin` text,
`first_appearance` integer NOT NULL,
`picture_url` text,
`epithets` text,
`fr_epithets` text,
`status` text,
`arc_id` text,
`url` text,
`fr_url` text,
FOREIGN KEY (`devil_fruit_id`) REFERENCES `devil_fruit`(`id`) ON UPDATE no action ON DELETE set null,
FOREIGN KEY (`arc_id`) REFERENCES `arc`(`id`) ON UPDATE no action ON DELETE set null
);
--> statement-breakpoint
CREATE TABLE `config` (
`key` text PRIMARY KEY NOT NULL,
`value` text
);
--> statement-breakpoint
CREATE TABLE `devil_fruit` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`type` text,
`url` text
);
--> statement-breakpoint
CREATE UNIQUE INDEX `devil_fruit_name_unique` ON `devil_fruit` (`name`);--> statement-breakpoint
CREATE TABLE `friendship` (
`id` text PRIMARY KEY NOT NULL,
`requester_id` text NOT NULL,
`addressee_id` text NOT NULL,
`status` text DEFAULT 'pending' NOT NULL,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`requester_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`addressee_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `friendship_requester_id_addressee_id_unique` ON `friendship` (`requester_id`,`addressee_id`);--> statement-breakpoint
CREATE TABLE `user_character_history` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text,
`character_history_id` text,
`try_count` integer NOT NULL,
`tried_character_ids` text,
`created_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`character_history_id`) REFERENCES `character_history`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `user_character_history_user_id_character_history_id_unique` ON `user_character_history` (`user_id`,`character_history_id`);--> statement-breakpoint
CREATE TABLE `account` (
`id` text PRIMARY KEY NOT NULL,
`account_id` text NOT NULL,
`provider_id` text NOT NULL,
`user_id` text NOT NULL,
`access_token` text,
`refresh_token` text,
`id_token` text,
`access_token_expires_at` integer,
`refresh_token_expires_at` integer,
`scope` text,
`password` text,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE INDEX `account_userId_idx` ON `account` (`user_id`);--> statement-breakpoint
CREATE TABLE `session` (
`id` text PRIMARY KEY NOT NULL,
`expires_at` integer NOT NULL,
`token` text NOT NULL,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
`updated_at` integer NOT NULL,
`ip_address` text,
`user_agent` text,
`user_id` text NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `session_token_unique` ON `session` (`token`);--> statement-breakpoint
CREATE INDEX `session_userId_idx` ON `session` (`user_id`);--> statement-breakpoint
CREATE TABLE `user` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`username` text NOT NULL,
`email` text NOT NULL,
`email_verified` integer DEFAULT false NOT NULL,
`image` text,
`is_admin` integer DEFAULT false NOT NULL,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `user_username_unique` ON `user` (`username`);--> statement-breakpoint
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);--> statement-breakpoint
CREATE TABLE `verification` (
`id` text PRIMARY KEY NOT NULL,
`identifier` text NOT NULL,
`value` text NOT NULL,
`expires_at` integer NOT NULL,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
);
--> statement-breakpoint
CREATE INDEX `verification_identifier_idx` ON `verification` (`identifier`);

View File

@@ -0,0 +1 @@
ALTER TABLE `character_scrape_validation` ADD `is_deleted` integer DEFAULT false;

View File

@@ -1,30 +0,0 @@
PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_characterOverride` (
`characterId` text PRIMARY KEY NOT NULL,
`name` text,
`gender` text,
`age` integer,
`affiliations` text,
`devilFruitId` text,
`hakiObservation` integer,
`hakiArmament` integer,
`hakiConqueror` integer,
`bounty` integer,
`height` real,
`origin` text,
`firstAppearance` integer,
`pictureUrl` text,
`epithets` text,
`status` text,
`arcId` text,
`url` text,
`notes` text,
FOREIGN KEY (`characterId`) REFERENCES `character`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`devilFruitId`) REFERENCES `devilFruit`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`arcId`) REFERENCES `arc`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
INSERT INTO `__new_characterOverride`("characterId", "name", "gender", "age", "affiliations", "devilFruitId", "hakiObservation", "hakiArmament", "hakiConqueror", "bounty", "height", "origin", "firstAppearance", "pictureUrl", "epithets", "status", "arcId", "url", "notes") SELECT "characterId", "name", "gender", "age", "affiliations", "devilFruitId", "hakiObservation", "hakiArmament", "hakiConqueror", "bounty", "height", "origin", "firstAppearance", "pictureUrl", "epithets", "status", "arcId", "url", "notes" FROM `characterOverride`;--> statement-breakpoint
DROP TABLE `characterOverride`;--> statement-breakpoint
ALTER TABLE `__new_characterOverride` RENAME TO `characterOverride`;--> statement-breakpoint
PRAGMA foreign_keys=ON;

View File

@@ -1 +0,0 @@
ALTER TABLE `user` ADD `is_admin` integer DEFAULT false NOT NULL;

View File

@@ -0,0 +1 @@
DROP TABLE `character_override`;

View File

@@ -0,0 +1,8 @@
ALTER TABLE `character` ADD `affiliation` text;--> statement-breakpoint
ALTER TABLE `character` ADD `fr_affiliation` text;--> statement-breakpoint
ALTER TABLE `character` DROP COLUMN `affiliations`;--> statement-breakpoint
ALTER TABLE `character` DROP COLUMN `fr_affiliations`;--> statement-breakpoint
ALTER TABLE `character_scrape_validation` ADD `affiliation` text;--> statement-breakpoint
ALTER TABLE `character_scrape_validation` ADD `fr_affiliation` text;--> statement-breakpoint
ALTER TABLE `character_scrape_validation` DROP COLUMN `affiliations`;--> statement-breakpoint
ALTER TABLE `character_scrape_validation` DROP COLUMN `fr_affiliations`;

View File

@@ -1,16 +0,0 @@
PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_characterHistory` (
`id` text PRIMARY KEY NOT NULL,
`characterId` text,
`date` integer NOT NULL,
`won` integer DEFAULT 0 NOT NULL,
`createdAt` integer NOT NULL,
`updatedAt` integer NOT NULL,
FOREIGN KEY (`characterId`) REFERENCES `character`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
INSERT INTO `__new_characterHistory`("id", "characterId", "date", "won", "createdAt", "updatedAt") SELECT "id", "characterId", "date", "won", "createdAt", "updatedAt" FROM `characterHistory`;--> statement-breakpoint
DROP TABLE `characterHistory`;--> statement-breakpoint
ALTER TABLE `__new_characterHistory` RENAME TO `characterHistory`;--> statement-breakpoint
PRAGMA foreign_keys=ON;--> statement-breakpoint
CREATE UNIQUE INDEX `characterHistory_date_unique` ON `characterHistory` (`date`);

View File

@@ -1,7 +1,7 @@
{ {
"version": "6", "version": "6",
"dialect": "sqlite", "dialect": "sqlite",
"id": "d1237d76-8f1c-4721-b8dd-d31082ed7b9a", "id": "4b4f14a1-b37b-44f4-aed3-7289bd8cb6a0",
"prevId": "00000000-0000-0000-0000-000000000000", "prevId": "00000000-0000-0000-0000-000000000000",
"tables": { "tables": {
"arc": { "arc": {
@@ -21,15 +21,22 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"startChapter": { "fr_name": {
"name": "startChapter", "name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"start_chapter": {
"name": "start_chapter",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"endChapter": { "end_chapter": {
"name": "endChapter", "name": "end_chapter",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -66,6 +73,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"fr_name": {
"name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"gender": { "gender": {
"name": "gender", "name": "gender",
"type": "text", "type": "text",
@@ -87,31 +101,38 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"devilFruitId": { "fr_affiliations": {
"name": "devilFruitId", "name": "fr_affiliations",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiObservation": { "devil_fruit_id": {
"name": "hakiObservation", "name": "devil_fruit_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"haki_observation": {
"name": "haki_observation",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiArmament": { "haki_armament": {
"name": "hakiArmament", "name": "haki_armament",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiConqueror": { "haki_conqueror": {
"name": "hakiConqueror", "name": "haki_conqueror",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -140,15 +161,22 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"firstAppearance": { "fr_origin": {
"name": "firstAppearance", "name": "fr_origin",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"first_appearance": {
"name": "first_appearance",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"pictureUrl": { "picture_url": {
"name": "pictureUrl", "name": "picture_url",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -161,6 +189,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_epithets": {
"name": "fr_epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": { "status": {
"name": "status", "name": "status",
"type": "text", "type": "text",
@@ -168,8 +203,8 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"arcId": { "arc_id": {
"name": "arcId", "name": "arc_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -182,23 +217,30 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"isInDailyMode": { "fr_url": {
"name": "isInDailyMode", "name": "fr_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"is_in_daily_mode": {
"name": "is_in_daily_mode",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": true "default": false
} }
}, },
"indexes": {}, "indexes": {},
"foreignKeys": { "foreignKeys": {
"character_devilFruitId_devilFruit_id_fk": { "character_devil_fruit_id_devil_fruit_id_fk": {
"name": "character_devilFruitId_devilFruit_id_fk", "name": "character_devil_fruit_id_devil_fruit_id_fk",
"tableFrom": "character", "tableFrom": "character",
"tableTo": "devilFruit", "tableTo": "devil_fruit",
"columnsFrom": [ "columnsFrom": [
"devilFruitId" "devil_fruit_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
@@ -206,17 +248,17 @@
"onDelete": "no action", "onDelete": "no action",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"character_arcId_arc_id_fk": { "character_arc_id_arc_id_fk": {
"name": "character_arcId_arc_id_fk", "name": "character_arc_id_arc_id_fk",
"tableFrom": "character", "tableFrom": "character",
"tableTo": "arc", "tableTo": "arc",
"columnsFrom": [ "columnsFrom": [
"arcId" "arc_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -224,8 +266,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"characterHistory": { "character_history": {
"name": "characterHistory", "name": "character_history",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -234,8 +276,8 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"characterId": { "character_id": {
"name": "characterId", "name": "character_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -243,9 +285,9 @@
}, },
"date": { "date": {
"name": "date", "name": "date",
"type": "text", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"won": { "won": {
@@ -256,34 +298,42 @@
"autoincrement": false, "autoincrement": false,
"default": 0 "default": 0
}, },
"createdAt": { "created_at": {
"name": "createdAt", "name": "created_at",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"updatedAt": { "updated_at": {
"name": "updatedAt", "name": "updated_at",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
} }
}, },
"indexes": {}, "indexes": {
"character_history_date_unique": {
"name": "character_history_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": { "foreignKeys": {
"characterHistory_characterId_character_id_fk": { "character_history_character_id_character_id_fk": {
"name": "characterHistory_characterId_character_id_fk", "name": "character_history_character_id_character_id_fk",
"tableFrom": "characterHistory", "tableFrom": "character_history",
"tableTo": "character", "tableTo": "character",
"columnsFrom": [ "columnsFrom": [
"characterId" "character_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "cascade",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -291,11 +341,11 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"characterOverride": { "character_override": {
"name": "characterOverride", "name": "character_override",
"columns": { "columns": {
"characterId": { "character_id": {
"name": "characterId", "name": "character_id",
"type": "text", "type": "text",
"primaryKey": true, "primaryKey": true,
"notNull": true, "notNull": true,
@@ -329,29 +379,36 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"devilFruitId": { "fr_affiliations": {
"name": "devilFruitId", "name": "fr_affiliations",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiObservation": { "devil_fruit_id": {
"name": "hakiObservation", "name": "devil_fruit_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"haki_observation": {
"name": "haki_observation",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiArmament": { "haki_armament": {
"name": "hakiArmament", "name": "haki_armament",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiConqueror": { "haki_conqueror": {
"name": "hakiConqueror", "name": "haki_conqueror",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -378,15 +435,22 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"firstAppearance": { "fr_origin": {
"name": "firstAppearance", "name": "fr_origin",
"type": "integer", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"pictureUrl": { "first_appearance": {
"name": "pictureUrl", "name": "first_appearance",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"picture_url": {
"name": "picture_url",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -399,6 +463,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_epithets": {
"name": "fr_epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": { "status": {
"name": "status", "name": "status",
"type": "text", "type": "text",
@@ -406,8 +477,8 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"arcId": { "arc_id": {
"name": "arcId", "name": "arc_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -420,6 +491,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_url": {
"name": "fr_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"notes": { "notes": {
"name": "notes", "name": "notes",
"type": "text", "type": "text",
@@ -430,43 +508,43 @@
}, },
"indexes": {}, "indexes": {},
"foreignKeys": { "foreignKeys": {
"characterOverride_characterId_character_id_fk": { "character_override_character_id_character_id_fk": {
"name": "characterOverride_characterId_character_id_fk", "name": "character_override_character_id_character_id_fk",
"tableFrom": "characterOverride", "tableFrom": "character_override",
"tableTo": "character", "tableTo": "character",
"columnsFrom": [ "columnsFrom": [
"characterId" "character_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "cascade",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"characterOverride_devilFruitId_devilFruit_id_fk": { "character_override_devil_fruit_id_devil_fruit_id_fk": {
"name": "characterOverride_devilFruitId_devilFruit_id_fk", "name": "character_override_devil_fruit_id_devil_fruit_id_fk",
"tableFrom": "characterOverride", "tableFrom": "character_override",
"tableTo": "devilFruit", "tableTo": "devil_fruit",
"columnsFrom": [ "columnsFrom": [
"devilFruitId" "devil_fruit_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"characterOverride_arcId_arc_id_fk": { "character_override_arc_id_arc_id_fk": {
"name": "characterOverride_arcId_arc_id_fk", "name": "character_override_arc_id_arc_id_fk",
"tableFrom": "characterOverride", "tableFrom": "character_override",
"tableTo": "arc", "tableTo": "arc",
"columnsFrom": [ "columnsFrom": [
"arcId" "arc_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -474,8 +552,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"characterScrapeValidation": { "character_scrape_validation": {
"name": "characterScrapeValidation", "name": "character_scrape_validation",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -491,6 +569,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"fr_name": {
"name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"gender": { "gender": {
"name": "gender", "name": "gender",
"type": "text", "type": "text",
@@ -512,31 +597,38 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"devilFruitId": { "fr_affiliations": {
"name": "devilFruitId", "name": "fr_affiliations",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiObservation": { "devil_fruit_id": {
"name": "hakiObservation", "name": "devil_fruit_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"haki_observation": {
"name": "haki_observation",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiArmament": { "haki_armament": {
"name": "hakiArmament", "name": "haki_armament",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiConqueror": { "haki_conqueror": {
"name": "hakiConqueror", "name": "haki_conqueror",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -564,15 +656,22 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"firstAppearance": { "fr_origin": {
"name": "firstAppearance", "name": "fr_origin",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"first_appearance": {
"name": "first_appearance",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"pictureUrl": { "picture_url": {
"name": "pictureUrl", "name": "picture_url",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -585,6 +684,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_epithets": {
"name": "fr_epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": { "status": {
"name": "status", "name": "status",
"type": "text", "type": "text",
@@ -592,8 +698,8 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"arcId": { "arc_id": {
"name": "arcId", "name": "arc_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -605,34 +711,41 @@
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
},
"fr_url": {
"name": "fr_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
} }
}, },
"indexes": {}, "indexes": {},
"foreignKeys": { "foreignKeys": {
"characterScrapeValidation_devilFruitId_devilFruit_id_fk": { "character_scrape_validation_devil_fruit_id_devil_fruit_id_fk": {
"name": "characterScrapeValidation_devilFruitId_devilFruit_id_fk", "name": "character_scrape_validation_devil_fruit_id_devil_fruit_id_fk",
"tableFrom": "characterScrapeValidation", "tableFrom": "character_scrape_validation",
"tableTo": "devilFruit", "tableTo": "devil_fruit",
"columnsFrom": [ "columnsFrom": [
"devilFruitId" "devil_fruit_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"characterScrapeValidation_arcId_arc_id_fk": { "character_scrape_validation_arc_id_arc_id_fk": {
"name": "characterScrapeValidation_arcId_arc_id_fk", "name": "character_scrape_validation_arc_id_arc_id_fk",
"tableFrom": "characterScrapeValidation", "tableFrom": "character_scrape_validation",
"tableTo": "arc", "tableTo": "arc",
"columnsFrom": [ "columnsFrom": [
"arcId" "arc_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -664,8 +777,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"devilFruit": { "devil_fruit": {
"name": "devilFruit", "name": "devil_fruit",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -697,8 +810,8 @@
} }
}, },
"indexes": { "indexes": {
"devilFruit_name_unique": { "devil_fruit_name_unique": {
"name": "devilFruit_name_unique", "name": "devil_fruit_name_unique",
"columns": [ "columns": [
"name" "name"
], ],
@@ -710,6 +823,183 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"friendship": {
"name": "friendship",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"requester_id": {
"name": "requester_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"addressee_id": {
"name": "addressee_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'pending'"
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"friendship_requester_id_addressee_id_unique": {
"name": "friendship_requester_id_addressee_id_unique",
"columns": [
"requester_id",
"addressee_id"
],
"isUnique": true
}
},
"foreignKeys": {
"friendship_requester_id_user_id_fk": {
"name": "friendship_requester_id_user_id_fk",
"tableFrom": "friendship",
"tableTo": "user",
"columnsFrom": [
"requester_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"friendship_addressee_id_user_id_fk": {
"name": "friendship_addressee_id_user_id_fk",
"tableFrom": "friendship",
"tableTo": "user",
"columnsFrom": [
"addressee_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"user_character_history": {
"name": "user_character_history",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"character_history_id": {
"name": "character_history_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"try_count": {
"name": "try_count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"tried_character_ids": {
"name": "tried_character_ids",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"user_character_history_user_id_character_history_id_unique": {
"name": "user_character_history_user_id_character_history_id_unique",
"columns": [
"user_id",
"character_history_id"
],
"isUnique": true
}
},
"foreignKeys": {
"user_character_history_user_id_user_id_fk": {
"name": "user_character_history_user_id_user_id_fk",
"tableFrom": "user_character_history",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"user_character_history_character_history_id_character_history_id_fk": {
"name": "user_character_history_character_history_id_character_history_id_fk",
"tableFrom": "user_character_history",
"tableTo": "character_history",
"columnsFrom": [
"character_history_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"account": { "account": {
"name": "account", "name": "account",
"columns": { "columns": {
@@ -947,6 +1237,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"username": {
"name": "username",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": { "email": {
"name": "email", "name": "email",
"type": "text", "type": "text",
@@ -969,6 +1266,14 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"is_admin": {
"name": "is_admin",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": false
},
"created_at": { "created_at": {
"name": "created_at", "name": "created_at",
"type": "integer", "type": "integer",
@@ -987,6 +1292,13 @@
} }
}, },
"indexes": { "indexes": {
"user_username_unique": {
"name": "user_username_unique",
"columns": [
"username"
],
"isUnique": true
},
"user_email_unique": { "user_email_unique": {
"name": "user_email_unique", "name": "user_email_unique",
"columns": [ "columns": [

View File

@@ -1,8 +1,8 @@
{ {
"version": "6", "version": "6",
"dialect": "sqlite", "dialect": "sqlite",
"id": "23b693a1-eebd-499e-9755-27a732e1afc1", "id": "9a965dd1-d97c-4142-a795-0558214180a4",
"prevId": "d1237d76-8f1c-4721-b8dd-d31082ed7b9a", "prevId": "4b4f14a1-b37b-44f4-aed3-7289bd8cb6a0",
"tables": { "tables": {
"arc": { "arc": {
"name": "arc", "name": "arc",
@@ -21,15 +21,22 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"startChapter": { "fr_name": {
"name": "startChapter", "name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"start_chapter": {
"name": "start_chapter",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"endChapter": { "end_chapter": {
"name": "endChapter", "name": "end_chapter",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -66,6 +73,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"fr_name": {
"name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"gender": { "gender": {
"name": "gender", "name": "gender",
"type": "text", "type": "text",
@@ -87,31 +101,38 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"devilFruitId": { "fr_affiliations": {
"name": "devilFruitId", "name": "fr_affiliations",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiObservation": { "devil_fruit_id": {
"name": "hakiObservation", "name": "devil_fruit_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"haki_observation": {
"name": "haki_observation",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiArmament": { "haki_armament": {
"name": "hakiArmament", "name": "haki_armament",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiConqueror": { "haki_conqueror": {
"name": "hakiConqueror", "name": "haki_conqueror",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -140,15 +161,22 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"firstAppearance": { "fr_origin": {
"name": "firstAppearance", "name": "fr_origin",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"first_appearance": {
"name": "first_appearance",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"pictureUrl": { "picture_url": {
"name": "pictureUrl", "name": "picture_url",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -161,6 +189,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_epithets": {
"name": "fr_epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": { "status": {
"name": "status", "name": "status",
"type": "text", "type": "text",
@@ -168,8 +203,8 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"arcId": { "arc_id": {
"name": "arcId", "name": "arc_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -182,23 +217,30 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"isInDailyMode": { "fr_url": {
"name": "isInDailyMode", "name": "fr_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"is_in_daily_mode": {
"name": "is_in_daily_mode",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": true "default": false
} }
}, },
"indexes": {}, "indexes": {},
"foreignKeys": { "foreignKeys": {
"character_devilFruitId_devilFruit_id_fk": { "character_devil_fruit_id_devil_fruit_id_fk": {
"name": "character_devilFruitId_devilFruit_id_fk", "name": "character_devil_fruit_id_devil_fruit_id_fk",
"tableFrom": "character", "tableFrom": "character",
"tableTo": "devilFruit", "tableTo": "devil_fruit",
"columnsFrom": [ "columnsFrom": [
"devilFruitId" "devil_fruit_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
@@ -206,17 +248,17 @@
"onDelete": "no action", "onDelete": "no action",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"character_arcId_arc_id_fk": { "character_arc_id_arc_id_fk": {
"name": "character_arcId_arc_id_fk", "name": "character_arc_id_arc_id_fk",
"tableFrom": "character", "tableFrom": "character",
"tableTo": "arc", "tableTo": "arc",
"columnsFrom": [ "columnsFrom": [
"arcId" "arc_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -224,8 +266,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"characterHistory": { "character_history": {
"name": "characterHistory", "name": "character_history",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -234,8 +276,8 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"characterId": { "character_id": {
"name": "characterId", "name": "character_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -243,9 +285,9 @@
}, },
"date": { "date": {
"name": "date", "name": "date",
"type": "text", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"won": { "won": {
@@ -256,34 +298,42 @@
"autoincrement": false, "autoincrement": false,
"default": 0 "default": 0
}, },
"createdAt": { "created_at": {
"name": "createdAt", "name": "created_at",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"updatedAt": { "updated_at": {
"name": "updatedAt", "name": "updated_at",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
} }
}, },
"indexes": {}, "indexes": {
"character_history_date_unique": {
"name": "character_history_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": { "foreignKeys": {
"characterHistory_characterId_character_id_fk": { "character_history_character_id_character_id_fk": {
"name": "characterHistory_characterId_character_id_fk", "name": "character_history_character_id_character_id_fk",
"tableFrom": "characterHistory", "tableFrom": "character_history",
"tableTo": "character", "tableTo": "character",
"columnsFrom": [ "columnsFrom": [
"characterId" "character_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "cascade",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -291,11 +341,11 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"characterOverride": { "character_override": {
"name": "characterOverride", "name": "character_override",
"columns": { "columns": {
"characterId": { "character_id": {
"name": "characterId", "name": "character_id",
"type": "text", "type": "text",
"primaryKey": true, "primaryKey": true,
"notNull": true, "notNull": true,
@@ -329,29 +379,36 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"devilFruitId": { "fr_affiliations": {
"name": "devilFruitId", "name": "fr_affiliations",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiObservation": { "devil_fruit_id": {
"name": "hakiObservation", "name": "devil_fruit_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"haki_observation": {
"name": "haki_observation",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiArmament": { "haki_armament": {
"name": "hakiArmament", "name": "haki_armament",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiConqueror": { "haki_conqueror": {
"name": "hakiConqueror", "name": "haki_conqueror",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -378,15 +435,22 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"firstAppearance": { "fr_origin": {
"name": "firstAppearance", "name": "fr_origin",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"first_appearance": {
"name": "first_appearance",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"pictureUrl": { "picture_url": {
"name": "pictureUrl", "name": "picture_url",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -399,6 +463,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_epithets": {
"name": "fr_epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": { "status": {
"name": "status", "name": "status",
"type": "text", "type": "text",
@@ -406,8 +477,8 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"arcId": { "arc_id": {
"name": "arcId", "name": "arc_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -420,6 +491,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_url": {
"name": "fr_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"notes": { "notes": {
"name": "notes", "name": "notes",
"type": "text", "type": "text",
@@ -430,43 +508,43 @@
}, },
"indexes": {}, "indexes": {},
"foreignKeys": { "foreignKeys": {
"characterOverride_characterId_character_id_fk": { "character_override_character_id_character_id_fk": {
"name": "characterOverride_characterId_character_id_fk", "name": "character_override_character_id_character_id_fk",
"tableFrom": "characterOverride", "tableFrom": "character_override",
"tableTo": "character", "tableTo": "character",
"columnsFrom": [ "columnsFrom": [
"characterId" "character_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "cascade",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"characterOverride_devilFruitId_devilFruit_id_fk": { "character_override_devil_fruit_id_devil_fruit_id_fk": {
"name": "characterOverride_devilFruitId_devilFruit_id_fk", "name": "character_override_devil_fruit_id_devil_fruit_id_fk",
"tableFrom": "characterOverride", "tableFrom": "character_override",
"tableTo": "devilFruit", "tableTo": "devil_fruit",
"columnsFrom": [ "columnsFrom": [
"devilFruitId" "devil_fruit_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"characterOverride_arcId_arc_id_fk": { "character_override_arc_id_arc_id_fk": {
"name": "characterOverride_arcId_arc_id_fk", "name": "character_override_arc_id_arc_id_fk",
"tableFrom": "characterOverride", "tableFrom": "character_override",
"tableTo": "arc", "tableTo": "arc",
"columnsFrom": [ "columnsFrom": [
"arcId" "arc_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -474,8 +552,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"characterScrapeValidation": { "character_scrape_validation": {
"name": "characterScrapeValidation", "name": "character_scrape_validation",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -491,6 +569,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"fr_name": {
"name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"gender": { "gender": {
"name": "gender", "name": "gender",
"type": "text", "type": "text",
@@ -512,31 +597,38 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"devilFruitId": { "fr_affiliations": {
"name": "devilFruitId", "name": "fr_affiliations",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiObservation": { "devil_fruit_id": {
"name": "hakiObservation", "name": "devil_fruit_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"haki_observation": {
"name": "haki_observation",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiArmament": { "haki_armament": {
"name": "hakiArmament", "name": "haki_armament",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiConqueror": { "haki_conqueror": {
"name": "hakiConqueror", "name": "haki_conqueror",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -564,15 +656,22 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"firstAppearance": { "fr_origin": {
"name": "firstAppearance", "name": "fr_origin",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"first_appearance": {
"name": "first_appearance",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"pictureUrl": { "picture_url": {
"name": "pictureUrl", "name": "picture_url",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -585,6 +684,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_epithets": {
"name": "fr_epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": { "status": {
"name": "status", "name": "status",
"type": "text", "type": "text",
@@ -592,8 +698,8 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"arcId": { "arc_id": {
"name": "arcId", "name": "arc_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -605,34 +711,49 @@
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
},
"fr_url": {
"name": "fr_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"is_deleted": {
"name": "is_deleted",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": false
} }
}, },
"indexes": {}, "indexes": {},
"foreignKeys": { "foreignKeys": {
"characterScrapeValidation_devilFruitId_devilFruit_id_fk": { "character_scrape_validation_devil_fruit_id_devil_fruit_id_fk": {
"name": "characterScrapeValidation_devilFruitId_devilFruit_id_fk", "name": "character_scrape_validation_devil_fruit_id_devil_fruit_id_fk",
"tableFrom": "characterScrapeValidation", "tableFrom": "character_scrape_validation",
"tableTo": "devilFruit", "tableTo": "devil_fruit",
"columnsFrom": [ "columnsFrom": [
"devilFruitId" "devil_fruit_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"characterScrapeValidation_arcId_arc_id_fk": { "character_scrape_validation_arc_id_arc_id_fk": {
"name": "characterScrapeValidation_arcId_arc_id_fk", "name": "character_scrape_validation_arc_id_arc_id_fk",
"tableFrom": "characterScrapeValidation", "tableFrom": "character_scrape_validation",
"tableTo": "arc", "tableTo": "arc",
"columnsFrom": [ "columnsFrom": [
"arcId" "arc_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -664,8 +785,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"devilFruit": { "devil_fruit": {
"name": "devilFruit", "name": "devil_fruit",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -697,8 +818,8 @@
} }
}, },
"indexes": { "indexes": {
"devilFruit_name_unique": { "devil_fruit_name_unique": {
"name": "devilFruit_name_unique", "name": "devil_fruit_name_unique",
"columns": [ "columns": [
"name" "name"
], ],
@@ -710,6 +831,183 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"friendship": {
"name": "friendship",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"requester_id": {
"name": "requester_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"addressee_id": {
"name": "addressee_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'pending'"
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"friendship_requester_id_addressee_id_unique": {
"name": "friendship_requester_id_addressee_id_unique",
"columns": [
"requester_id",
"addressee_id"
],
"isUnique": true
}
},
"foreignKeys": {
"friendship_requester_id_user_id_fk": {
"name": "friendship_requester_id_user_id_fk",
"tableFrom": "friendship",
"tableTo": "user",
"columnsFrom": [
"requester_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"friendship_addressee_id_user_id_fk": {
"name": "friendship_addressee_id_user_id_fk",
"tableFrom": "friendship",
"tableTo": "user",
"columnsFrom": [
"addressee_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"user_character_history": {
"name": "user_character_history",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"character_history_id": {
"name": "character_history_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"try_count": {
"name": "try_count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"tried_character_ids": {
"name": "tried_character_ids",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"user_character_history_user_id_character_history_id_unique": {
"name": "user_character_history_user_id_character_history_id_unique",
"columns": [
"user_id",
"character_history_id"
],
"isUnique": true
}
},
"foreignKeys": {
"user_character_history_user_id_user_id_fk": {
"name": "user_character_history_user_id_user_id_fk",
"tableFrom": "user_character_history",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"user_character_history_character_history_id_character_history_id_fk": {
"name": "user_character_history_character_history_id_character_history_id_fk",
"tableFrom": "user_character_history",
"tableTo": "character_history",
"columnsFrom": [
"character_history_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"account": { "account": {
"name": "account", "name": "account",
"columns": { "columns": {
@@ -947,6 +1245,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"username": {
"name": "username",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": { "email": {
"name": "email", "name": "email",
"type": "text", "type": "text",
@@ -969,6 +1274,14 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"is_admin": {
"name": "is_admin",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": false
},
"created_at": { "created_at": {
"name": "created_at", "name": "created_at",
"type": "integer", "type": "integer",
@@ -987,6 +1300,13 @@
} }
}, },
"indexes": { "indexes": {
"user_username_unique": {
"name": "user_username_unique",
"columns": [
"username"
],
"isUnique": true
},
"user_email_unique": { "user_email_unique": {
"name": "user_email_unique", "name": "user_email_unique",
"columns": [ "columns": [

View File

@@ -1,8 +1,8 @@
{ {
"version": "6", "version": "6",
"dialect": "sqlite", "dialect": "sqlite",
"id": "4fa96ce4-93c4-4d2d-9f9a-5badf47dfb05", "id": "f3540f13-a6c4-4c52-ac29-6330ffce33fd",
"prevId": "23b693a1-eebd-499e-9755-27a732e1afc1", "prevId": "9a965dd1-d97c-4142-a795-0558214180a4",
"tables": { "tables": {
"arc": { "arc": {
"name": "arc", "name": "arc",
@@ -21,15 +21,22 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"startChapter": { "fr_name": {
"name": "startChapter", "name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"start_chapter": {
"name": "start_chapter",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"endChapter": { "end_chapter": {
"name": "endChapter", "name": "end_chapter",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -66,6 +73,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"fr_name": {
"name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"gender": { "gender": {
"name": "gender", "name": "gender",
"type": "text", "type": "text",
@@ -87,31 +101,38 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"devilFruitId": { "fr_affiliations": {
"name": "devilFruitId", "name": "fr_affiliations",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiObservation": { "devil_fruit_id": {
"name": "hakiObservation", "name": "devil_fruit_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"haki_observation": {
"name": "haki_observation",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiArmament": { "haki_armament": {
"name": "hakiArmament", "name": "haki_armament",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiConqueror": { "haki_conqueror": {
"name": "hakiConqueror", "name": "haki_conqueror",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -140,15 +161,22 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"firstAppearance": { "fr_origin": {
"name": "firstAppearance", "name": "fr_origin",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"first_appearance": {
"name": "first_appearance",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"pictureUrl": { "picture_url": {
"name": "pictureUrl", "name": "picture_url",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -161,6 +189,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_epithets": {
"name": "fr_epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": { "status": {
"name": "status", "name": "status",
"type": "text", "type": "text",
@@ -168,8 +203,8 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"arcId": { "arc_id": {
"name": "arcId", "name": "arc_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -182,23 +217,30 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"isInDailyMode": { "fr_url": {
"name": "isInDailyMode", "name": "fr_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"is_in_daily_mode": {
"name": "is_in_daily_mode",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": true "default": false
} }
}, },
"indexes": {}, "indexes": {},
"foreignKeys": { "foreignKeys": {
"character_devilFruitId_devilFruit_id_fk": { "character_devil_fruit_id_devil_fruit_id_fk": {
"name": "character_devilFruitId_devilFruit_id_fk", "name": "character_devil_fruit_id_devil_fruit_id_fk",
"tableFrom": "character", "tableFrom": "character",
"tableTo": "devilFruit", "tableTo": "devil_fruit",
"columnsFrom": [ "columnsFrom": [
"devilFruitId" "devil_fruit_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
@@ -206,17 +248,17 @@
"onDelete": "no action", "onDelete": "no action",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"character_arcId_arc_id_fk": { "character_arc_id_arc_id_fk": {
"name": "character_arcId_arc_id_fk", "name": "character_arc_id_arc_id_fk",
"tableFrom": "character", "tableFrom": "character",
"tableTo": "arc", "tableTo": "arc",
"columnsFrom": [ "columnsFrom": [
"arcId" "arc_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -224,8 +266,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"characterHistory": { "character_history": {
"name": "characterHistory", "name": "character_history",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -234,8 +276,8 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"characterId": { "character_id": {
"name": "characterId", "name": "character_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -243,9 +285,9 @@
}, },
"date": { "date": {
"name": "date", "name": "date",
"type": "text", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"won": { "won": {
@@ -256,34 +298,42 @@
"autoincrement": false, "autoincrement": false,
"default": 0 "default": 0
}, },
"createdAt": { "created_at": {
"name": "createdAt", "name": "created_at",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"updatedAt": { "updated_at": {
"name": "updatedAt", "name": "updated_at",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
} }
}, },
"indexes": {}, "indexes": {
"character_history_date_unique": {
"name": "character_history_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": { "foreignKeys": {
"characterHistory_characterId_character_id_fk": { "character_history_character_id_character_id_fk": {
"name": "characterHistory_characterId_character_id_fk", "name": "character_history_character_id_character_id_fk",
"tableFrom": "characterHistory", "tableFrom": "character_history",
"tableTo": "character", "tableTo": "character",
"columnsFrom": [ "columnsFrom": [
"characterId" "character_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "cascade",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -291,191 +341,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"characterOverride": { "character_scrape_validation": {
"name": "characterOverride", "name": "character_scrape_validation",
"columns": {
"characterId": {
"name": "characterId",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"gender": {
"name": "gender",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"age": {
"name": "age",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"affiliations": {
"name": "affiliations",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"devilFruitId": {
"name": "devilFruitId",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"hakiObservation": {
"name": "hakiObservation",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"hakiArmament": {
"name": "hakiArmament",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"hakiConqueror": {
"name": "hakiConqueror",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"bounty": {
"name": "bounty",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"height": {
"name": "height",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"origin": {
"name": "origin",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"firstAppearance": {
"name": "firstAppearance",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"pictureUrl": {
"name": "pictureUrl",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"epithets": {
"name": "epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"arcId": {
"name": "arcId",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"characterOverride_characterId_character_id_fk": {
"name": "characterOverride_characterId_character_id_fk",
"tableFrom": "characterOverride",
"tableTo": "character",
"columnsFrom": [
"characterId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"characterOverride_devilFruitId_devilFruit_id_fk": {
"name": "characterOverride_devilFruitId_devilFruit_id_fk",
"tableFrom": "characterOverride",
"tableTo": "devilFruit",
"columnsFrom": [
"devilFruitId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"characterOverride_arcId_arc_id_fk": {
"name": "characterOverride_arcId_arc_id_fk",
"tableFrom": "characterOverride",
"tableTo": "arc",
"columnsFrom": [
"arcId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"characterScrapeValidation": {
"name": "characterScrapeValidation",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -491,6 +358,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"fr_name": {
"name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"gender": { "gender": {
"name": "gender", "name": "gender",
"type": "text", "type": "text",
@@ -512,31 +386,38 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"devilFruitId": { "fr_affiliations": {
"name": "devilFruitId", "name": "fr_affiliations",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiObservation": { "devil_fruit_id": {
"name": "hakiObservation", "name": "devil_fruit_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"haki_observation": {
"name": "haki_observation",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiArmament": { "haki_armament": {
"name": "hakiArmament", "name": "haki_armament",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiConqueror": { "haki_conqueror": {
"name": "hakiConqueror", "name": "haki_conqueror",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -564,15 +445,22 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"firstAppearance": { "fr_origin": {
"name": "firstAppearance", "name": "fr_origin",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"first_appearance": {
"name": "first_appearance",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"pictureUrl": { "picture_url": {
"name": "pictureUrl", "name": "picture_url",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -585,6 +473,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_epithets": {
"name": "fr_epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": { "status": {
"name": "status", "name": "status",
"type": "text", "type": "text",
@@ -592,8 +487,8 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"arcId": { "arc_id": {
"name": "arcId", "name": "arc_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -605,34 +500,49 @@
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
},
"fr_url": {
"name": "fr_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"is_deleted": {
"name": "is_deleted",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": false
} }
}, },
"indexes": {}, "indexes": {},
"foreignKeys": { "foreignKeys": {
"characterScrapeValidation_devilFruitId_devilFruit_id_fk": { "character_scrape_validation_devil_fruit_id_devil_fruit_id_fk": {
"name": "characterScrapeValidation_devilFruitId_devilFruit_id_fk", "name": "character_scrape_validation_devil_fruit_id_devil_fruit_id_fk",
"tableFrom": "characterScrapeValidation", "tableFrom": "character_scrape_validation",
"tableTo": "devilFruit", "tableTo": "devil_fruit",
"columnsFrom": [ "columnsFrom": [
"devilFruitId" "devil_fruit_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"characterScrapeValidation_arcId_arc_id_fk": { "character_scrape_validation_arc_id_arc_id_fk": {
"name": "characterScrapeValidation_arcId_arc_id_fk", "name": "character_scrape_validation_arc_id_arc_id_fk",
"tableFrom": "characterScrapeValidation", "tableFrom": "character_scrape_validation",
"tableTo": "arc", "tableTo": "arc",
"columnsFrom": [ "columnsFrom": [
"arcId" "arc_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -664,8 +574,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"devilFruit": { "devil_fruit": {
"name": "devilFruit", "name": "devil_fruit",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -697,8 +607,8 @@
} }
}, },
"indexes": { "indexes": {
"devilFruit_name_unique": { "devil_fruit_name_unique": {
"name": "devilFruit_name_unique", "name": "devil_fruit_name_unique",
"columns": [ "columns": [
"name" "name"
], ],
@@ -710,6 +620,183 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"friendship": {
"name": "friendship",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"requester_id": {
"name": "requester_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"addressee_id": {
"name": "addressee_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'pending'"
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"friendship_requester_id_addressee_id_unique": {
"name": "friendship_requester_id_addressee_id_unique",
"columns": [
"requester_id",
"addressee_id"
],
"isUnique": true
}
},
"foreignKeys": {
"friendship_requester_id_user_id_fk": {
"name": "friendship_requester_id_user_id_fk",
"tableFrom": "friendship",
"tableTo": "user",
"columnsFrom": [
"requester_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"friendship_addressee_id_user_id_fk": {
"name": "friendship_addressee_id_user_id_fk",
"tableFrom": "friendship",
"tableTo": "user",
"columnsFrom": [
"addressee_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"user_character_history": {
"name": "user_character_history",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"character_history_id": {
"name": "character_history_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"try_count": {
"name": "try_count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"tried_character_ids": {
"name": "tried_character_ids",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"user_character_history_user_id_character_history_id_unique": {
"name": "user_character_history_user_id_character_history_id_unique",
"columns": [
"user_id",
"character_history_id"
],
"isUnique": true
}
},
"foreignKeys": {
"user_character_history_user_id_user_id_fk": {
"name": "user_character_history_user_id_user_id_fk",
"tableFrom": "user_character_history",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"user_character_history_character_history_id_character_history_id_fk": {
"name": "user_character_history_character_history_id_character_history_id_fk",
"tableFrom": "user_character_history",
"tableTo": "character_history",
"columnsFrom": [
"character_history_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"account": { "account": {
"name": "account", "name": "account",
"columns": { "columns": {
@@ -947,6 +1034,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"username": {
"name": "username",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": { "email": {
"name": "email", "name": "email",
"type": "text", "type": "text",
@@ -995,6 +1089,13 @@
} }
}, },
"indexes": { "indexes": {
"user_username_unique": {
"name": "user_username_unique",
"columns": [
"username"
],
"isUnique": true
},
"user_email_unique": { "user_email_unique": {
"name": "user_email_unique", "name": "user_email_unique",
"columns": [ "columns": [

View File

@@ -1,8 +1,8 @@
{ {
"version": "6", "version": "6",
"dialect": "sqlite", "dialect": "sqlite",
"id": "8a8486cf-5e1c-4fcb-94ce-b6967ae10290", "id": "736137e1-d840-4f5b-a1b4-d50648839073",
"prevId": "4fa96ce4-93c4-4d2d-9f9a-5badf47dfb05", "prevId": "f3540f13-a6c4-4c52-ac29-6330ffce33fd",
"tables": { "tables": {
"arc": { "arc": {
"name": "arc", "name": "arc",
@@ -21,15 +21,22 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"startChapter": { "fr_name": {
"name": "startChapter", "name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"start_chapter": {
"name": "start_chapter",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"endChapter": { "end_chapter": {
"name": "endChapter", "name": "end_chapter",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -66,6 +73,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"fr_name": {
"name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"gender": { "gender": {
"name": "gender", "name": "gender",
"type": "text", "type": "text",
@@ -80,38 +94,45 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"affiliations": { "affiliation": {
"name": "affiliations", "name": "affiliation",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"devilFruitId": { "fr_affiliation": {
"name": "devilFruitId", "name": "fr_affiliation",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiObservation": { "devil_fruit_id": {
"name": "hakiObservation", "name": "devil_fruit_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"haki_observation": {
"name": "haki_observation",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiArmament": { "haki_armament": {
"name": "hakiArmament", "name": "haki_armament",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiConqueror": { "haki_conqueror": {
"name": "hakiConqueror", "name": "haki_conqueror",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -140,15 +161,22 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"firstAppearance": { "fr_origin": {
"name": "firstAppearance", "name": "fr_origin",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"first_appearance": {
"name": "first_appearance",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"pictureUrl": { "picture_url": {
"name": "pictureUrl", "name": "picture_url",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -161,6 +189,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_epithets": {
"name": "fr_epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": { "status": {
"name": "status", "name": "status",
"type": "text", "type": "text",
@@ -168,8 +203,8 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"arcId": { "arc_id": {
"name": "arcId", "name": "arc_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -182,23 +217,30 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"isInDailyMode": { "fr_url": {
"name": "isInDailyMode", "name": "fr_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"is_in_daily_mode": {
"name": "is_in_daily_mode",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": true "default": false
} }
}, },
"indexes": {}, "indexes": {},
"foreignKeys": { "foreignKeys": {
"character_devilFruitId_devilFruit_id_fk": { "character_devil_fruit_id_devil_fruit_id_fk": {
"name": "character_devilFruitId_devilFruit_id_fk", "name": "character_devil_fruit_id_devil_fruit_id_fk",
"tableFrom": "character", "tableFrom": "character",
"tableTo": "devilFruit", "tableTo": "devil_fruit",
"columnsFrom": [ "columnsFrom": [
"devilFruitId" "devil_fruit_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
@@ -206,17 +248,17 @@
"onDelete": "no action", "onDelete": "no action",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"character_arcId_arc_id_fk": { "character_arc_id_arc_id_fk": {
"name": "character_arcId_arc_id_fk", "name": "character_arc_id_arc_id_fk",
"tableFrom": "character", "tableFrom": "character",
"tableTo": "arc", "tableTo": "arc",
"columnsFrom": [ "columnsFrom": [
"arcId" "arc_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -224,8 +266,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"characterHistory": { "character_history": {
"name": "characterHistory", "name": "character_history",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -234,8 +276,8 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"characterId": { "character_id": {
"name": "characterId", "name": "character_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -256,15 +298,15 @@
"autoincrement": false, "autoincrement": false,
"default": 0 "default": 0
}, },
"createdAt": { "created_at": {
"name": "createdAt", "name": "created_at",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"updatedAt": { "updated_at": {
"name": "updatedAt", "name": "updated_at",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
@@ -272,8 +314,8 @@
} }
}, },
"indexes": { "indexes": {
"characterHistory_date_unique": { "character_history_date_unique": {
"name": "characterHistory_date_unique", "name": "character_history_date_unique",
"columns": [ "columns": [
"date" "date"
], ],
@@ -281,17 +323,17 @@
} }
}, },
"foreignKeys": { "foreignKeys": {
"characterHistory_characterId_character_id_fk": { "character_history_character_id_character_id_fk": {
"name": "characterHistory_characterId_character_id_fk", "name": "character_history_character_id_character_id_fk",
"tableFrom": "characterHistory", "tableFrom": "character_history",
"tableTo": "character", "tableTo": "character",
"columnsFrom": [ "columnsFrom": [
"characterId" "character_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "cascade",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -299,191 +341,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"characterOverride": { "character_scrape_validation": {
"name": "characterOverride", "name": "character_scrape_validation",
"columns": {
"characterId": {
"name": "characterId",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"gender": {
"name": "gender",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"age": {
"name": "age",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"affiliations": {
"name": "affiliations",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"devilFruitId": {
"name": "devilFruitId",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"hakiObservation": {
"name": "hakiObservation",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"hakiArmament": {
"name": "hakiArmament",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"hakiConqueror": {
"name": "hakiConqueror",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"bounty": {
"name": "bounty",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"height": {
"name": "height",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"origin": {
"name": "origin",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"firstAppearance": {
"name": "firstAppearance",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"pictureUrl": {
"name": "pictureUrl",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"epithets": {
"name": "epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"arcId": {
"name": "arcId",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"characterOverride_characterId_character_id_fk": {
"name": "characterOverride_characterId_character_id_fk",
"tableFrom": "characterOverride",
"tableTo": "character",
"columnsFrom": [
"characterId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"characterOverride_devilFruitId_devilFruit_id_fk": {
"name": "characterOverride_devilFruitId_devilFruit_id_fk",
"tableFrom": "characterOverride",
"tableTo": "devilFruit",
"columnsFrom": [
"devilFruitId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"characterOverride_arcId_arc_id_fk": {
"name": "characterOverride_arcId_arc_id_fk",
"tableFrom": "characterOverride",
"tableTo": "arc",
"columnsFrom": [
"arcId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"characterScrapeValidation": {
"name": "characterScrapeValidation",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -499,6 +358,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"fr_name": {
"name": "fr_name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"gender": { "gender": {
"name": "gender", "name": "gender",
"type": "text", "type": "text",
@@ -513,38 +379,45 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"affiliations": { "affiliation": {
"name": "affiliations", "name": "affiliation",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"devilFruitId": { "fr_affiliation": {
"name": "devilFruitId", "name": "fr_affiliation",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"hakiObservation": { "devil_fruit_id": {
"name": "hakiObservation", "name": "devil_fruit_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"haki_observation": {
"name": "haki_observation",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiArmament": { "haki_armament": {
"name": "hakiArmament", "name": "haki_armament",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false, "autoincrement": false,
"default": false "default": false
}, },
"hakiConqueror": { "haki_conqueror": {
"name": "hakiConqueror", "name": "haki_conqueror",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -572,15 +445,22 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"firstAppearance": { "fr_origin": {
"name": "firstAppearance", "name": "fr_origin",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"first_appearance": {
"name": "first_appearance",
"type": "integer", "type": "integer",
"primaryKey": false, "primaryKey": false,
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"pictureUrl": { "picture_url": {
"name": "pictureUrl", "name": "picture_url",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -593,6 +473,13 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"fr_epithets": {
"name": "fr_epithets",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": { "status": {
"name": "status", "name": "status",
"type": "text", "type": "text",
@@ -600,8 +487,8 @@
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
}, },
"arcId": { "arc_id": {
"name": "arcId", "name": "arc_id",
"type": "text", "type": "text",
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
@@ -613,34 +500,49 @@
"primaryKey": false, "primaryKey": false,
"notNull": false, "notNull": false,
"autoincrement": false "autoincrement": false
},
"fr_url": {
"name": "fr_url",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"is_deleted": {
"name": "is_deleted",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": false
} }
}, },
"indexes": {}, "indexes": {},
"foreignKeys": { "foreignKeys": {
"characterScrapeValidation_devilFruitId_devilFruit_id_fk": { "character_scrape_validation_devil_fruit_id_devil_fruit_id_fk": {
"name": "characterScrapeValidation_devilFruitId_devilFruit_id_fk", "name": "character_scrape_validation_devil_fruit_id_devil_fruit_id_fk",
"tableFrom": "characterScrapeValidation", "tableFrom": "character_scrape_validation",
"tableTo": "devilFruit", "tableTo": "devil_fruit",
"columnsFrom": [ "columnsFrom": [
"devilFruitId" "devil_fruit_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
}, },
"characterScrapeValidation_arcId_arc_id_fk": { "character_scrape_validation_arc_id_arc_id_fk": {
"name": "characterScrapeValidation_arcId_arc_id_fk", "name": "character_scrape_validation_arc_id_arc_id_fk",
"tableFrom": "characterScrapeValidation", "tableFrom": "character_scrape_validation",
"tableTo": "arc", "tableTo": "arc",
"columnsFrom": [ "columnsFrom": [
"arcId" "arc_id"
], ],
"columnsTo": [ "columnsTo": [
"id" "id"
], ],
"onDelete": "no action", "onDelete": "set null",
"onUpdate": "no action" "onUpdate": "no action"
} }
}, },
@@ -672,8 +574,8 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"devilFruit": { "devil_fruit": {
"name": "devilFruit", "name": "devil_fruit",
"columns": { "columns": {
"id": { "id": {
"name": "id", "name": "id",
@@ -705,8 +607,8 @@
} }
}, },
"indexes": { "indexes": {
"devilFruit_name_unique": { "devil_fruit_name_unique": {
"name": "devilFruit_name_unique", "name": "devil_fruit_name_unique",
"columns": [ "columns": [
"name" "name"
], ],
@@ -718,6 +620,183 @@
"uniqueConstraints": {}, "uniqueConstraints": {},
"checkConstraints": {} "checkConstraints": {}
}, },
"friendship": {
"name": "friendship",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"requester_id": {
"name": "requester_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"addressee_id": {
"name": "addressee_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'pending'"
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"friendship_requester_id_addressee_id_unique": {
"name": "friendship_requester_id_addressee_id_unique",
"columns": [
"requester_id",
"addressee_id"
],
"isUnique": true
}
},
"foreignKeys": {
"friendship_requester_id_user_id_fk": {
"name": "friendship_requester_id_user_id_fk",
"tableFrom": "friendship",
"tableTo": "user",
"columnsFrom": [
"requester_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"friendship_addressee_id_user_id_fk": {
"name": "friendship_addressee_id_user_id_fk",
"tableFrom": "friendship",
"tableTo": "user",
"columnsFrom": [
"addressee_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"user_character_history": {
"name": "user_character_history",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"character_history_id": {
"name": "character_history_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"try_count": {
"name": "try_count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"tried_character_ids": {
"name": "tried_character_ids",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"user_character_history_user_id_character_history_id_unique": {
"name": "user_character_history_user_id_character_history_id_unique",
"columns": [
"user_id",
"character_history_id"
],
"isUnique": true
}
},
"foreignKeys": {
"user_character_history_user_id_user_id_fk": {
"name": "user_character_history_user_id_user_id_fk",
"tableFrom": "user_character_history",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"user_character_history_character_history_id_character_history_id_fk": {
"name": "user_character_history_character_history_id_character_history_id_fk",
"tableFrom": "user_character_history",
"tableTo": "character_history",
"columnsFrom": [
"character_history_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"account": { "account": {
"name": "account", "name": "account",
"columns": { "columns": {
@@ -955,6 +1034,13 @@
"notNull": true, "notNull": true,
"autoincrement": false "autoincrement": false
}, },
"username": {
"name": "username",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": { "email": {
"name": "email", "name": "email",
"type": "text", "type": "text",
@@ -1003,6 +1089,13 @@
} }
}, },
"indexes": { "indexes": {
"user_username_unique": {
"name": "user_username_unique",
"columns": [
"username"
],
"isUnique": true
},
"user_email_unique": { "user_email_unique": {
"name": "user_email_unique", "name": "user_email_unique",
"columns": [ "columns": [

View File

@@ -5,29 +5,29 @@
{ {
"idx": 0, "idx": 0,
"version": "6", "version": "6",
"when": 1772325597983, "when": 1773602933375,
"tag": "0000_graceful_master_mold", "tag": "0000_huge_doctor_octopus",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 1, "idx": 1,
"version": "6", "version": "6",
"when": 1772383366179, "when": 1773697753818,
"tag": "0001_nostalgic_hercules", "tag": "0001_fuzzy_talisman",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 2, "idx": 2,
"version": "6", "version": "6",
"when": 1772390182445, "when": 1775950314114,
"tag": "0002_large_gwen_stacy", "tag": "0002_old_earthquake",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 3, "idx": 3,
"version": "6", "version": "6",
"when": 1772449624450, "when": 1776195681488,
"tag": "0003_wise_blonde_phantom", "tag": "0003_mixed_ben_grimm",
"breakpoints": true "breakpoints": true
} }
] ]

1
package-lock.json generated
View File

@@ -6,7 +6,6 @@
"packages": { "packages": {
"": { "": {
"name": "onepiecedle", "name": "onepiecedle",
"version": "0.0.1",
"dependencies": { "dependencies": {
"@libsql/client": "^0.17.0", "@libsql/client": "^0.17.0",
"@sveltejs/adapter-node": "^5.5.4", "@sveltejs/adapter-node": "^5.5.4",

View File

@@ -1,7 +1,6 @@
{ {
"name": "onepiecedle", "name": "onepiecedle",
"private": true, "private": true,
"version": "0.0.1",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",

View File

@@ -1,50 +1,65 @@
[ [
"aladdin_aladdin", "absalom_absalom",
"king_king",
"alvida_alvida", "alvida_alvida",
"aramaki_aramaki", "aramaki_aramaki",
"arlong_arlong", "arlong_arlong",
"ashura_doji_ashura_doji", "ashura_doji_ashura_doji",
"vegapunk/atlas_atlas",
"avalo_pizarro_avalo_pizarro",
"baby_5_baby_5", "baby_5_baby_5",
"baggy_baggy", "buggy_buggy",
"bartholomew_kuma_bartholomew_kuma", "bartholomew_kuma_bartholomew_kuma",
"bartolomeo_bartolomeo", "bartolomeo_bartolomeo",
"basil_hawkins_basil_hawkins", "basil_hawkins_basil_hawkins",
"batman_batman", "bell-mère_bell-mère",
"bellamy_bellamy", "bellamy_bellamy",
"belo_betty_belo_betty", "belo_betty_belo_betty",
"ben_beckman_ben_beckman", "benn_beckman_ben_beckman",
"bentham_bentham", "bentham_bentham",
"bepo_bepo", "bepo_bepo",
"black_maria_black_maria", "black_maria_black_maria",
"blueno_blueno",
"boa_hancock_boa_hancock", "boa_hancock_boa_hancock",
"boa_marigold_boa_marigold", "boa_marigold_boa_marigold",
"boa_sandersonia_boa_sandersonia", "boa_sandersonia_boa_sandersonia",
"borsalino_borsalino", "borsalino_borsalino",
"brogy_brogy", "brogy_brogy",
"brook_brook", "brook_brook",
"buckingham_stussy_buckingham_stussy",
"buffalo_buffalo",
"camie_camie", "camie_camie",
"capone_bege_capone_bege", "capone_bege_capone_bege",
"carmel_carmel",
"caribou_caribou", "caribou_caribou",
"carrot_carrot", "carrot_carrot",
"catarina_devon_catarina_devon", "catarina_devon_catarina_devon",
"cavendish_cavendish", "cavendish_cavendish",
"cesar_clown_cesar_clown", "caesar_clown_caesar_clown",
"charlotte_brûlée_charlotte_brûlée",
"charlotte_cracker_charlotte_cracker",
"charlotte_katakuri_charlotte_katakuri",
"charlotte_linlin_charlotte_linlin",
"charlotte_mont-d'or_charlotte_mont-d'or",
"charlotte_oven_charlotte_oven",
"charlotte_perospero_charlotte_perospero",
"charlotte_pudding_charlotte_pudding",
"charlotte_smoothie_charlotte_smoothie",
"chinjao_chinjao", "chinjao_chinjao",
"coby_coby", "clou_d_clover_clou_d_clover",
"corazon_corazon",
"crocodile_crocodile", "crocodile_crocodile",
"crocus_crocus", "crocus_crocus",
"curly_dadan_curly_dadan", "curly_dadan_curly_dadan",
"dalton_dalton", "dalton_dalton",
"daz_bones_daz_bones", "daz_bonez_daz_bonez",
"denjiro_denjiro", "denjiro_denjiro",
"diamante_diamante", "diamante_diamante",
"doc_q_doc_q", "doc_q_doc_q",
"don_quichotte_doflamingo_don_quichotte_doflamingo", "donquixote_doflamingo_donquixote_doflamingo",
"don_quichotte_rossinante_don_quichotte_rossinante", "donquixote_rosinante_donquixote_rosinante",
"dorry_dorry", "dorry_dorry",
"dracule_mihawk_dracule_mihawk", "dracule_mihawk_dracule_mihawk",
"duval_duval", "vegapunk/edison_edison",
"edward_newgate_edward_newgate", "edward_newgate_edward_newgate",
"edward_weevil_edward_weevil", "edward_weevil_edward_weevil",
"emporio_ivankov_emporio_ivankov", "emporio_ivankov_emporio_ivankov",
@@ -53,30 +68,47 @@
"fisher_tiger_fisher_tiger", "fisher_tiger_fisher_tiger",
"foxy_foxy", "foxy_foxy",
"franky_franky", "franky_franky",
"fujitora_fujitora", "fukaboshi_fukaboshi",
"gan_forr_gan_forr", "fukurou_fukurou",
"galdino_galdino",
"gan_fall_gan_fall",
"gecko_moria_gecko_moria", "gecko_moria_gecko_moria",
"gem_gem",
"genzo_genzo",
"gin_gin", "gin_gin",
"ginny_ginny",
"gol_d_roger_gol_d_roger", "gol_d_roger_gol_d_roger",
"haguar_d_sauro_haguar_d_sauro", "guernika_guernika",
"hack_hack",
"jaguar_d_saul_jaguar_d_saul",
"hajrudin_hajrudin", "hajrudin_hajrudin",
"hannyabal_hannyabal", "hannyabal_hannyabal",
"hatchan_hatchan", "harald_harald",
"haredas_haredas",
"heracles_heracles",
"helmeppo_helmeppo",
"hibari_hibari",
"hiriluk_hiriluk",
"hina_hina", "hina_hina",
"hody_jones_hody_jones", "hody_jones_hody_jones",
"hyogoro_hyogoro", "hogback_hogback",
"hyougoro_hyougoro",
"iceburg_iceburg", "iceburg_iceburg",
"igaram_igaram",
"imu_imu", "imu_imu",
"inazuma_inazuma", "inazuma_inazuma",
"inuarashi_inuarashi", "inuarashi_inuarashi",
"issho_issho", "issho_issho",
"izo_izo", "izou_izou",
"jabra_jabra", "jabra_jabra",
"jack_jack", "jack_jack",
"jango_jango",
"jesus_burgess_jesus_burgess", "jesus_burgess_jesus_burgess",
"jewelry_bonney_jewelry_bonney", "jewelry_bonney_jewelry_bonney",
"jinbei_jinbei", "jinbe_jinbe",
"giolla_giolla",
"joy_boy_joy_boy", "joy_boy_joy_boy",
"jozu_jozu",
"kaidou_kaidou", "kaidou_kaidou",
"kaku_kaku", "kaku_kaku",
"kalgara_kalgara", "kalgara_kalgara",
@@ -85,60 +117,139 @@
"karoo_karoo", "karoo_karoo",
"kawamatsu_kawamatsu", "kawamatsu_kawamatsu",
"kaya_kaya", "kaya_kaya",
"kelly_funk_kelly_funk",
"kikunojo_kikunojo",
"killer_killer", "killer_killer",
"kinemon_kinemon", "kin'emon_kin'emon",
"koala_koala", "koala_koala",
"koby_koby", "koby_koby",
"kong_kong", "kokoro_kokoro",
"kozuki_hiyori_kozuki_hiyori", "kouzuki_hiyori_kouzuki_hiyori",
"kozuki_momonosuke_kozuki_momonosuke", "kouzuki_momonosuke_kouzuki_momonosuke",
"kozuki_oden_kozuki_oden", "kouzuki_oden_kouzuki_oden",
"kouzuki_sukiyaki_kouzuki_sukiyaki",
"kouzuki_toki_kouzuki_toki",
"krieg_krieg", "krieg_krieg",
"kumadori_kumadori",
"kureha_kureha", "kureha_kureha",
"kuro_kuro", "kuro_kuro",
"kurozumi_kanjuro_kurozumi_kanjuro",
"kurozumi_orochi_kurozumi_orochi", "kurozumi_orochi_kurozumi_orochi",
"kurozumi_tama_kurozumi_tama",
"kuzan_kuzan", "kuzan_kuzan",
"kyros_kyros", "kyros_kyros",
"laboon_laboon", "laboon_laboon",
"laffitte_laffitte", "laffitte_laffitte",
"lao_g_lao_g", "lao_g_lao_g",
"leo_leo", "leo_leo",
"vegapunk/lilith_lilith",
"lindbergh_lindbergh", "lindbergh_lindbergh",
"loki_loki", "loki_loki",
"lucky_roux_lucky_roux", "lucky_roux_lucky_roux",
"magellan_magellan", "magellan_magellan",
"makino_makino", "makino_makino",
"mansherry_mansherry",
"marco_marco", "marco_marco",
"marshall_d_teach_marshall_d_teach", "marshall_d_teach_marshall_d_teach",
"merry_merry",
"momoo_momoo",
"mocha_mocha",
"monet_monet",
"monkey_d_dragon_monkey_d_dragon", "monkey_d_dragon_monkey_d_dragon",
"monkey_d_garp_monkey_d_garp", "monkey_d_garp_monkey_d_garp",
"monkey_d_luffy_monkey_d_luffy", "monkey_d_luffy_monkey_d_luffy",
"montblanc_norland_montblanc_norland", "mont_blanc_cricket_mont_blanc_cricket",
"mont_blanc_noland_mont_blanc_noland",
"morgans_morgans", "morgans_morgans",
"morgan_morgan",
"morley_morley", "morley_morley",
"mr_3_mr_3",
"nami_nami", "nami_nami",
"nefertari_cobra_nefertari_cobra", "nefertari_cobra_nefertari_cobra",
"nefertari_vivi_nefertari_vivi", "nefertari_vivi_nefertari_vivi",
"nekomamushi_nekomamushi", "nekomamushi_nekomamushi",
"neptune_neptune", "neptune_neptune",
"nico_olvia_nico_olvia",
"nico_robin_nico_robin", "nico_robin_nico_robin",
"oars_oars", "nojiko_nojiko",
"hatchan_hatchan",
"otohime_otohime", "otohime_otohime",
"oars_oars",
"page_one_page_one", "page_one_page_one",
"pandaman_pandaman", "pandaman_pandaman",
"paulie_paulie",
"pedro_pedro",
"pekoms_pekoms", "pekoms_pekoms",
"pell_pell", "pell_pell",
"perona_perona", "perona_perona",
"pica_pica", "pica_pica",
"portgas_d_ace_portgas_d_ace", "portgas_d_ace_portgas_d_ace",
"vegapunk/pythagoras_pythagoras",
"queen_queen", "queen_queen",
"raizo_raizo", "raizo_raizo",
"rebecca_rebecca", "rebecca_rebecca",
"riku_doldo_iii_riku_doldo_iii",
"rob_lucci_rob_lucci", "rob_lucci_rob_lucci",
"rocks_d_xebec_rocks_d_xebec", "rocks_d_xebec_rocks_d_xebec",
"roronoa_zoro_roronoa_zoro", "roronoa_zoro_roronoa_zoro",
"s-bear_s-bear",
"s-hawk_s-hawk",
"s-snake_s-snake",
"sabo_sabo", "sabo_sabo",
"sadi_sadi",
"donquixote_mjosgard_donquixote_mjosgard",
"rimoshifu_killingham_rimoshifu_killingham",
"manmayer_gunko_manmayer_gunko",
"shepherd_sommers_shepherd_sommers",
"sakazuki_sakazuki",
"sanjuan_wolf_sanjuan_wolf",
"sasaki_sasaki",
"scratchmen_apoo_scratchmen_apoo",
"sengoku_sengoku",
"senor_pink_senor_pink",
"sentomaru_sentomaru",
"vegapunk/shaka_shaka",
"shakuyaku_shakuyaku",
"shanks_shanks",
"shiryu_shiryu",
"shimotsuki_kuina_shimotsuki_kuina",
"shimotsuki_yasuie_shimotsuki_yasuie",
"shinobu_shinobu",
"shirahoshi_shirahoshi",
"silvers_rayleigh_silvers_rayleigh",
"smoker_smoker",
"spandam_spandam",
"speed_speed",
"stussy_stussy",
"sugar_sugar",
"tamago_tamago",
"tashigi_tashigi",
"toko_toko",
"tom_tom",
"tony_tony_chopper_tony_tony_chopper",
"trafalgar_d_water_law_trafalgar_d_water_law",
"trebol_trebol",
"tsuru_tsuru",
"ulti_ulti",
"urouge_urouge",
"usopp_usopp",
"uta_uta",
"van_augur_van_augur",
"vander_decken_ix_vander_decken_ix",
"vegapunk_vegapunk", "vegapunk_vegapunk",
"yamato_yamato" "vergo_vergo",
"vinsmoke_ichiji_vinsmoke_ichiji",
"vinsmoke_judge_vinsmoke_judge",
"vinsmoke_niji_vinsmoke_niji",
"vinsmoke_reiju_vinsmoke_reiju",
"sanji_sanji",
"vinsmoke_yonji_vinsmoke_yonji",
"viola_viola",
"wadatsumi_wadatsumi",
"wapol_wapol",
"wyper_wyper",
"x_drake_x_drake",
"yamato_yamato",
"yasopp_yasopp",
"vegapunk/york_york",
"zeff_zeff"
] ]

View File

@@ -1,12 +1,15 @@
import { createClient } from '@libsql/client'; import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql'; import { drizzle } from 'drizzle-orm/libsql';
import { sql, eq } from 'drizzle-orm'; import { sql, eq, inArray } from 'drizzle-orm';
import fs from 'fs'; import fs from 'fs';
import { arc, character, devilFruit, characterScrapeValidation, type DevilFruitType } from '../src/lib/server/db/schema'; import { arc, character, devilFruit, characterScrapeValidation, type DevilFruitType } from '../src/lib/server/db/schema';
type Status = 'Alive' | 'Dead' | 'Unknown';
type ArcRecord = { type ArcRecord = {
id: string; id: string;
name: string; name: string;
frName?: string | null;
startChapter: number; startChapter: number;
endChapter?: number | null; endChapter?: number | null;
url?: string | null; url?: string | null;
@@ -22,9 +25,11 @@ type DevilFruitRecord = {
type CharacterRecord = { type CharacterRecord = {
id: string; id: string;
name: string; name: string;
frName?: string | null;
gender?: string | null; gender?: string | null;
age?: number | null; age?: number | null;
affiliations?: string[] | string | null; affiliation?: string | null;
frAffiliation?: string | null;
devilFruitId?: string | null; devilFruitId?: string | null;
hakiObservation?: boolean; hakiObservation?: boolean;
hakiArmament?: boolean; hakiArmament?: boolean;
@@ -32,12 +37,15 @@ type CharacterRecord = {
bounty?: number | null; bounty?: number | null;
height?: number | null; height?: number | null;
origin?: string | null; origin?: string | null;
frOrigin?: string | null;
firstAppearance?: number; firstAppearance?: number;
pictureUrl?: string | null; pictureUrl?: string | null;
epithets?: string[] | string | null; epithets?: string[] | string | null;
status?: string | null; frEpithets?: string[] | string | null;
status?: Status | null;
arcId?: string | null; arcId?: string | null;
url?: string | null; url?: string | null;
frUrl?: string | null;
}; };
const DATABASE_URL = process.env.DATABASE_URL || 'file:local.db'; const DATABASE_URL = process.env.DATABASE_URL || 'file:local.db';
@@ -86,7 +94,7 @@ function toJsonArray(value: string[] | string | null | undefined): string[] | nu
function toDevilFruitType(value: DevilFruitType | string | null | undefined): DevilFruitType | null { function toDevilFruitType(value: DevilFruitType | string | null | undefined): DevilFruitType | null {
if (!value) return null; if (!value) return null;
if (value === 'Paramecia' || value === 'Zoan' || value === 'Logia' || value === 'Unknown') { if (value === 'Paramecia' || value === 'Zoan' || value === 'Logia' || value === 'Smile' || value === 'Unknown') {
return value; return value;
} }
return 'Unknown'; return 'Unknown';
@@ -112,62 +120,31 @@ function transformCharacterData(item: CharacterRecord) {
return { return {
id: item.id, id: item.id,
name: item.name, name: item.name,
frName: toNullable(item.frName),
gender: toNullable(item.gender), gender: toNullable(item.gender),
age: toNullable(item.age), age: toNullable(item.age),
affiliations: toJsonArray(item.affiliations), affiliation: toNullable(item.affiliation),
frAffiliation: toNullable(item.frAffiliation),
devilFruitId: toNullable(item.devilFruitId), devilFruitId: toNullable(item.devilFruitId),
hakiObservation: !!item.hakiObservation, hakiObservation: !!item.hakiObservation,
hakiArmament: !!item.hakiArmament, hakiArmament: !!item.hakiArmament,
hakiConqueror: !!item.hakiConqueror, hakiConqueror: !!item.hakiConqueror,
bounty: item.bounty ?? 0, bounty: item.bounty ?? 0,
height: toNumber(item.height as any), height: toNumber(item.height as string | number | null),
origin: toNullable(item.origin), origin: toNullable(item.origin),
frOrigin: toNullable(item.frOrigin),
firstAppearance: item.firstAppearance ?? 0, firstAppearance: item.firstAppearance ?? 0,
pictureUrl: toNullable(item.pictureUrl), pictureUrl: toNullable(item.pictureUrl),
epithets: toJsonArray(item.epithets), epithets: toJsonArray(item.epithets),
frEpithets: toJsonArray(item.frEpithets),
status: toNullable(item.status), status: toNullable(item.status),
arcId: toNullable(item.arcId), arcId: toNullable(item.arcId),
url: toNullable(item.url) url: toNullable(item.url),
frUrl: toNullable(item.frUrl),
isDeleted: false
}; };
} }
function hasChanged(jsonData: any, dbData: any): boolean {
if (!dbData) return true;
// Print any differences for debugging
for (const key in jsonData) {
const jsonValue = jsonData[key];
const dbValue = dbData[key];
const jsonString = typeof jsonValue === 'object' ? JSON.stringify(jsonValue) : String(jsonValue);
const dbString = typeof dbValue === 'object' ? JSON.stringify(dbValue) : String(dbValue);
if (jsonString !== dbString) {
console.log(`\nField "${key}" changed for character ID ${jsonData.id}:`);
console.log(` JSON: ${jsonString}`);
console.log(` DB: ${dbString}`);
} }
// Compare each field
return (
jsonData.name != dbData.name ||
jsonData.gender != dbData.gender ||
jsonData.age != dbData.age ||
JSON.stringify(jsonData.affiliations) != JSON.stringify(dbData.affiliations) ||
jsonData.devilFruitId != dbData.devilFruitId ||
jsonData.hakiObservation != dbData.hakiObservation ||
jsonData.hakiArmament != dbData.hakiArmament ||
jsonData.hakiConqueror != dbData.hakiConqueror ||
jsonData.bounty != dbData.bounty ||
jsonData.height != dbData.height ||
jsonData.origin != dbData.origin ||
jsonData.firstAppearance != dbData.firstAppearance ||
jsonData.pictureUrl != dbData.pictureUrl ||
JSON.stringify(jsonData.epithets) != JSON.stringify(dbData.epithets) ||
jsonData.status != dbData.status ||
jsonData.arcId != dbData.arcId ||
jsonData.url != dbData.url
);
}
async function isCharacterTableEmpty(): Promise<boolean> { async function isCharacterTableEmpty(): Promise<boolean> {
const result = await db.select({ count: sql<number>`COUNT(*)` }).from(character); const result = await db.select({ count: sql<number>`COUNT(*)` }).from(character);
return result[0]?.count === 0; return result[0]?.count === 0;
@@ -195,6 +172,7 @@ async function importFromJson(): Promise<void> {
.values({ .values({
id: item.id, id: item.id,
name: item.name, name: item.name,
frName: toNullable(item.frName),
startChapter: item.startChapter, startChapter: item.startChapter,
endChapter: toNullable(item.endChapter), endChapter: toNullable(item.endChapter),
url: toNullable(item.url) url: toNullable(item.url)
@@ -203,6 +181,7 @@ async function importFromJson(): Promise<void> {
target: arc.id, target: arc.id,
set: { set: {
name: item.name, name: item.name,
frName: toNullable(item.frName),
startChapter: item.startChapter, startChapter: item.startChapter,
endChapter: toNullable(item.endChapter), endChapter: toNullable(item.endChapter),
url: toNullable(item.url) url: toNullable(item.url)
@@ -327,8 +306,9 @@ async function importFromJson(): Promise<void> {
} }
} }
} else { } else {
// Check for changes and update scrapeValidation table // Update scrapeValidation table
console.log('Characters table not empty, checking for changes...\n'); console.log('Characters table not empty, updating scrapeValidation table for changes...\n');
const scrapedCharacterIds: string[] = [];
for (let i = 0; i < characters.length; i++) { for (let i = 0; i < characters.length; i++) {
const item = characters[i]; const item = characters[i];
@@ -340,13 +320,10 @@ async function importFromJson(): Promise<void> {
.where(eq(character.id, item.id)); .where(eq(character.id, item.id));
lastSql = selectQuery.toSQL(); lastSql = selectQuery.toSQL();
const [dbCharacter] = await selectQuery;
scrapedCharacterIds.push(item.id);
const jsonData = transformCharacterData(item); const jsonData = transformCharacterData(item);
const changed = hasChanged(jsonData, dbCharacter);
if (changed) {
// Update scrapeValidation table with changes
const upsertQuery = db const upsertQuery = db
.insert(characterScrapeValidation) .insert(characterScrapeValidation)
.values(jsonData) .values(jsonData)
@@ -357,16 +334,6 @@ async function importFromJson(): Promise<void> {
lastSql = upsertQuery.toSQL(); lastSql = upsertQuery.toSQL();
await upsertQuery; await upsertQuery;
} else {
// No changes, delete from scrapeValidation if it exists
const deleteQuery = db
.delete(characterScrapeValidation)
.where(eq(characterScrapeValidation.id, item.id));
lastSql = deleteQuery.toSQL();
await deleteQuery;
}
successCount++; successCount++;
process.stdout.write(`\rProcessed: ${successCount}/${characters.length}`); process.stdout.write(`\rProcessed: ${successCount}/${characters.length}`);
} catch (error) { } catch (error) {
@@ -377,6 +344,57 @@ async function importFromJson(): Promise<void> {
logSqlOnError(lastSql); logSqlOnError(lastSql);
} }
} }
// Fetch all characters from the character table and mark those absent from the
// scrape as deleted in scrape validation.
const allCharacters = await db.select({ id: character.id }).from(character);
const scrapedSet = new Set(scrapedCharacterIds);
const idsToMarkDeleted = allCharacters
.map((c) => c.id)
.filter((id) => !scrapedSet.has(id));
if (idsToMarkDeleted.length > 0) {
console.log(`\n⚠ Marking ${idsToMarkDeleted.length} character(s) as deleted in scrape validation...`);
const deletedCharacterRows = await db
.select()
.from(character)
.where(inArray(character.id, idsToMarkDeleted));
for (const row of deletedCharacterRows) {
await db
.insert(characterScrapeValidation)
.values({
id: row.id,
name: row.name,
frName: row.frName,
gender: row.gender,
age: row.age,
affiliation: row.affiliation,
frAffiliation: row.frAffiliation,
devilFruitId: row.devilFruitId,
hakiObservation: row.hakiObservation,
hakiArmament: row.hakiArmament,
hakiConqueror: row.hakiConqueror,
bounty: row.bounty,
height: row.height,
origin: row.origin,
frOrigin: row.frOrigin,
firstAppearance: row.firstAppearance,
pictureUrl: row.pictureUrl,
epithets: row.epithets,
frEpithets: row.frEpithets,
status: row.status,
arcId: row.arcId,
url: row.url,
frUrl: row.frUrl,
isDeleted: true
})
.onConflictDoUpdate({
target: characterScrapeValidation.id,
set: { isDeleted: true }
});
}
}
} }
console.log(`\n\n✓ Characters imported!`); console.log(`\n\n✓ Characters imported!`);

View File

@@ -23,7 +23,8 @@ const columns = [
'origin', 'origin',
'devilFruitType', 'devilFruitType',
'arc', 'arc',
'status' 'status',
'age'
] as const; ] as const;
async function initColumnConfig(): Promise<void> { async function initColumnConfig(): Promise<void> {

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
import { createClient } from '@libsql/client'; import { createClient } from '@libsql/client';
import { drizzle } from 'drizzle-orm/libsql'; import { drizzle } from 'drizzle-orm/libsql';
import { eq } from 'drizzle-orm'; import { eq, inArray } from 'drizzle-orm';
import fs from 'fs'; import fs from 'fs';
import { character, characterHistory } from '../src/lib/server/db/schema'; import { character, characterHistory } from '../src/lib/server/db/schema';
@@ -24,13 +24,14 @@ function getErrorMessage(error: unknown): string {
async function setDailyCharacters(): Promise<void> { async function setDailyCharacters(): Promise<void> {
try { try {
const dailyCharacterIds = readJsonFile('./scripts/daily-characters.json'); const dailyCharacterIdsRaw = readJsonFile('./scripts/daily-characters.json');
if (!dailyCharacterIds || dailyCharacterIds.length === 0) { if (!dailyCharacterIdsRaw || dailyCharacterIdsRaw.length === 0) {
console.error('No daily characters found in daily-characters.json'); throw new Error('No daily characters found in daily-characters.json');
process.exit(1);
} }
const dailyCharacterIds = dailyCharacterIdsRaw;
console.log(`\n=== Setting Daily Mode Characters ===\n`); console.log(`\n=== Setting Daily Mode Characters ===\n`);
console.log(`Found ${dailyCharacterIds.length} characters to set as daily\n`); console.log(`Found ${dailyCharacterIds.length} characters to set as daily\n`);
@@ -45,16 +46,36 @@ async function setDailyCharacters(): Promise<void> {
let successCount = 0; let successCount = 0;
let errorCount = 0; let errorCount = 0;
const existingCharacters = await db
.select({ id: character.id })
.from(character)
.where(inArray(character.id, dailyCharacterIds));
const existingIdSet = new Set(existingCharacters.map((c) => c.id));
const missingIds = dailyCharacterIds.filter((id) => !existingIdSet.has(id));
if (missingIds.length > 0) {
errorCount += missingIds.length;
console.error(`${missingIds.length} character ID(s) were not found in database:`);
for (const missingId of missingIds) {
console.error(` - ${missingId}`);
}
console.error('');
}
for (let i = 0; i < dailyCharacterIds.length; i++) { for (let i = 0; i < dailyCharacterIds.length; i++) {
const charId = dailyCharacterIds[i]; const charId = dailyCharacterIds[i];
if (!existingIdSet.has(charId)) {
continue;
}
try { try {
const result = await db await db
.update(character) .update(character)
.set({ isInDailyMode: true }) .set({ isInDailyMode: true })
.where(eq(character.id, charId)); .where(eq(character.id, charId));
successCount++; successCount++;
process.stdout.write(`\rUpdated: ${successCount}/${dailyCharacterIds.length}`);
} catch (error) { } catch (error) {
errorCount++; errorCount++;
console.error(`\n✗ Error updating character ${i + 1}:`); console.error(`\n✗ Error updating character ${i + 1}:`);

BIN
src/lib/assets/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="107" height="128" viewBox="0 0 107 128"><title>svelte-logo</title><path d="M94.157 22.819c-10.4-14.885-30.94-19.297-45.792-9.835L22.282 29.608A29.92 29.92 0 0 0 8.764 49.65a31.5 31.5 0 0 0 3.108 20.231 30 30 0 0 0-4.477 11.183 31.9 31.9 0 0 0 5.448 24.116c10.402 14.887 30.942 19.297 45.791 9.835l26.083-16.624A29.92 29.92 0 0 0 98.235 78.35a31.53 31.53 0 0 0-3.105-20.232 30 30 0 0 0 4.474-11.182 31.88 31.88 0 0 0-5.447-24.116" style="fill:#ff3e00"/><path d="M45.817 106.582a20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.503 18 18 0 0 1 .624-2.435l.49-1.498 1.337.981a33.6 33.6 0 0 0 10.203 5.098l.97.294-.09.968a5.85 5.85 0 0 0 1.052 3.878 6.24 6.24 0 0 0 6.695 2.485 5.8 5.8 0 0 0 1.603-.704L69.27 76.28a5.43 5.43 0 0 0 2.45-3.631 5.8 5.8 0 0 0-.987-4.371 6.24 6.24 0 0 0-6.698-2.487 5.7 5.7 0 0 0-1.6.704l-9.953 6.345a19 19 0 0 1-5.296 2.326 20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.502 17.99 17.99 0 0 1 8.13-12.052l26.081-16.623a19 19 0 0 1 5.3-2.329 20.72 20.72 0 0 1 22.237 8.243 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-.624 2.435l-.49 1.498-1.337-.98a33.6 33.6 0 0 0-10.203-5.1l-.97-.294.09-.968a5.86 5.86 0 0 0-1.052-3.878 6.24 6.24 0 0 0-6.696-2.485 5.8 5.8 0 0 0-1.602.704L37.73 51.72a5.42 5.42 0 0 0-2.449 3.63 5.79 5.79 0 0 0 .986 4.372 6.24 6.24 0 0 0 6.698 2.486 5.8 5.8 0 0 0 1.602-.704l9.952-6.342a19 19 0 0 1 5.295-2.328 20.72 20.72 0 0 1 22.237 8.242 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-8.13 12.053l-26.081 16.622a19 19 0 0 1-5.3 2.328" style="fill:#fff"/></svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,16 +1,71 @@
<script lang="ts"> <script lang="ts">
import type { CharacterWithRelations } from '$lib/server/daily-character';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { createEventDispatcher } from 'svelte'; import { language, t } from '$lib/i18n';
export let characters: any[]; let {
export let selectedCharacters: any[]; characters,
selectedCharacters,
onSelect
}: {
characters: CharacterWithRelations[];
selectedCharacters: CharacterWithRelations[];
onSelect: (character: CharacterWithRelations) => void;
} = $props();
const dispatch = createEventDispatcher(); const state = $state({
searchInput: '',
highlightedIndex: 0,
dropdownContainer: null as HTMLDivElement | null,
searchContainer: null as HTMLDivElement | null
});
let searchInput = ''; const isFrench = $derived($language === 'fr');
let highlightedIndex = 0;
let dropdownContainer: HTMLDivElement; function parseEpithets(value: unknown): string[] {
let searchContainer: HTMLDivElement; if (Array.isArray(value)) {
return value.filter((entry): entry is string => typeof entry === 'string' && entry.length > 0);
}
if (typeof value === 'string') {
try {
const parsed = JSON.parse(value);
if (Array.isArray(parsed)) {
return parsed.filter((entry): entry is string => typeof entry === 'string' && entry.length > 0);
}
} catch {
if (value.length > 0) {
return [value];
}
}
}
return [];
}
function getDisplayName(character: CharacterWithRelations): string {
if (isFrench && typeof character.frName === 'string' && character.frName.length > 0) {
return character.frName;
}
return character.name;
}
function getDisplayEpithets(character: CharacterWithRelations): string[] {
const frenchEpithets = parseEpithets(character.frEpithets);
if (isFrench && frenchEpithets.length > 0) {
return frenchEpithets;
}
return parseEpithets(character.epithets);
}
function normalizeSearchText(value: string): string {
return value
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase();
}
onMount(() => { onMount(() => {
// Add click outside listener // Add click outside listener
@@ -21,52 +76,54 @@
}; };
}); });
$: filteredCharacters = characters.filter(char => { const filteredCharacters = $derived.by(() => {
const searchTerm = searchInput.toLowerCase(); const searchTerm = normalizeSearchText(state.searchInput);
const nameMatches = char.name.toLowerCase().includes(searchTerm);
let epithetsMatches = false; return characters.filter((char) => {
if (char.epithets) { const displayName = getDisplayName(char);
try { const displayEpithets = getDisplayEpithets(char);
const parsedEpithets = typeof char.epithets === 'string' const nameMatches = normalizeSearchText(displayName).includes(searchTerm);
? JSON.parse(char.epithets) const epithetsMatches = displayEpithets.some((epithet) =>
: char.epithets; normalizeSearchText(epithet).includes(searchTerm)
if (Array.isArray(parsedEpithets)) {
epithetsMatches = parsedEpithets.some((epithet: string) =>
epithet.toLowerCase().includes(searchTerm)
); );
} else if (typeof parsedEpithets === 'string') {
epithetsMatches = parsedEpithets.toLowerCase().includes(searchTerm);
}
} catch {
epithetsMatches = String(char.epithets).toLowerCase().includes(searchTerm);
}
}
return (nameMatches || epithetsMatches) && return (nameMatches || epithetsMatches) &&
!selectedCharacters.some(selected => selected.id === char.id); !selectedCharacters.some((selected) => selected.id === char.id);
});
}); });
// Reset highlighted index when filtered list changes // Reset highlighted index when filtered list changes.
$: if (filteredCharacters) { $effect(() => {
highlightedIndex = 0; const nextFilteredCharacters = filteredCharacters;
if (!nextFilteredCharacters) {
return;
}
state.highlightedIndex = 0;
});
// Scroll highlighted item into view.
$effect(() => {
const nextFilteredCharacters = filteredCharacters;
if (!state.dropdownContainer || state.highlightedIndex < 0) {
return;
} }
// Scroll highlighted item into view if (state.highlightedIndex >= nextFilteredCharacters.length) {
$: if (dropdownContainer && highlightedIndex >= 0) { return;
const highlightedButton = dropdownContainer.querySelector(
`button:nth-child(${highlightedIndex + 1})`
) as HTMLElement;
if (highlightedButton) {
highlightedButton.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
}
} }
function selectCharacter(character: any) { const highlightedButton = state.dropdownContainer.querySelector(
dispatch('select', character); `button:nth-child(${state.highlightedIndex + 1})`
searchInput = ''; ) as HTMLElement | null;
highlightedIndex = 0;
highlightedButton?.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
});
function selectCharacter(character: CharacterWithRelations) {
onSelect(character);
state.searchInput = '';
state.highlightedIndex = 0;
} }
function handleKeydown(event: KeyboardEvent) { function handleKeydown(event: KeyboardEvent) {
@@ -75,16 +132,19 @@
switch (event.key) { switch (event.key) {
case 'ArrowDown': case 'ArrowDown':
event.preventDefault(); event.preventDefault();
highlightedIndex = Math.min(highlightedIndex + 1, filteredCharacters.length - 1); state.highlightedIndex = Math.min(
state.highlightedIndex + 1,
filteredCharacters.length - 1
);
break; break;
case 'ArrowUp': case 'ArrowUp':
event.preventDefault(); event.preventDefault();
highlightedIndex = Math.max(highlightedIndex - 1, 0); state.highlightedIndex = Math.max(state.highlightedIndex - 1, 0);
break; break;
case 'Enter': case 'Enter':
event.preventDefault(); event.preventDefault();
if (filteredCharacters[highlightedIndex]) { if (filteredCharacters[state.highlightedIndex]) {
selectCharacter(filteredCharacters[highlightedIndex]); selectCharacter(filteredCharacters[state.highlightedIndex]);
} }
break; break;
} }
@@ -92,44 +152,44 @@
function submitGuess() { function submitGuess() {
if (filteredCharacters.length === 0) return; if (filteredCharacters.length === 0) return;
const characterToSelect = const characterToSelect = filteredCharacters[state.highlightedIndex] ?? filteredCharacters[0];
filteredCharacters[highlightedIndex] ?? filteredCharacters[0];
if (characterToSelect) { if (characterToSelect) {
selectCharacter(characterToSelect); selectCharacter(characterToSelect);
} }
} }
function handleClickOutside(event: MouseEvent) { function handleClickOutside(event: MouseEvent) {
if (searchContainer && !searchContainer.contains(event.target as Node)) { if (state.searchContainer && !state.searchContainer.contains(event.target as Node)) {
searchInput = ''; state.searchInput = '';
} }
} }
</script> </script>
<div class="rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur z-10"> <div class="rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur z-10">
<h2 class="text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">Entrer une supposition</h2> <h2 class="text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">{$t.game.components.searchInput.title}</h2>
<div class="mt-4 flex flex-col gap-3 sm:flex-row"> <div class="mt-4 flex flex-col gap-3 sm:flex-row">
<div bind:this={searchContainer} class="relative w-full"> <div bind:this={state.searchContainer} class="relative w-full">
<input <input
bind:value={searchInput} bind:value={state.searchInput}
class="w-full rounded-full border border-amber-200/30 bg-slate-900/60 px-5 py-3 text-sm text-slate-100 placeholder:text-slate-400 focus:border-amber-200/70 focus:outline-none" class="w-full rounded-full border border-amber-200/30 bg-slate-900/60 px-5 py-3 text-sm text-slate-100 placeholder:text-slate-400 focus:border-amber-200/70 focus:outline-none"
placeholder="Nom du personnage" placeholder={$t.game.components.searchInput.placeholder}
type="text" type="text"
onkeydown={handleKeydown} onkeydown={handleKeydown}
/> />
{#if searchInput.length > 0 && filteredCharacters.length > 0} {#if state.searchInput.length > 0 && filteredCharacters.length > 0}
<div bind:this={dropdownContainer} class="absolute top-full left-0 right-0 mt-2 max-h-96 overflow-y-auto rounded-2xl border border-amber-200/30 bg-slate-900/90 backdrop-blur z-10"> <div bind:this={state.dropdownContainer} class="absolute top-full left-0 right-0 mt-2 max-h-96 overflow-y-auto rounded-2xl border border-amber-200/30 bg-slate-900/90 backdrop-blur z-10">
{#each filteredCharacters as character, index (character.id)} {#each filteredCharacters as character, index (character.id)}
<button <button
class="w-full px-5 py-4 text-left text-base text-slate-100 transition border-b border-slate-800/50 last:border-b-0 flex items-center gap-4 {index === highlightedIndex ? 'bg-slate-700' : 'hover:bg-slate-800/70'}" class="w-full px-5 py-4 text-left text-base text-slate-100 transition border-b border-slate-800/50 last:border-b-0 flex items-center gap-4 {index === state.highlightedIndex ? 'bg-slate-700' : 'hover:bg-slate-800/70'}"
type="button" type="button"
onmouseenter={() => highlightedIndex = index} onmouseenter={() => (state.highlightedIndex = index)}
onclick={() => selectCharacter(character)} onclick={() => selectCharacter(character)}
> >
{#if character.pictureUrl} {#if character.pictureUrl}
<img <img
src={character.pictureUrl} src={character.pictureUrl}
alt={character.name} alt={getDisplayName(character)}
loading="lazy"
class="w-12 h-12 rounded-full object-cover border border-amber-200/30" class="w-12 h-12 rounded-full object-cover border border-amber-200/30"
/> />
{:else} {:else}
@@ -138,17 +198,12 @@
</div> </div>
{/if} {/if}
<div class="flex-1"> <div class="flex-1">
<span class="font-semibold text-amber-100">{character.name}</span> <span class="font-semibold text-amber-100">{getDisplayName(character)}</span>
{#if character.epithets} {#if getDisplayEpithets(character).length > 0}
{@const parsedEpithets = typeof character.epithets === 'string'
? JSON.parse(character.epithets)
: character.epithets}
{#if Array.isArray(parsedEpithets) && parsedEpithets.length > 0}
<span class="ml-2 text-xs text-slate-400"> <span class="ml-2 text-xs text-slate-400">
{parsedEpithets.join(', ')} {getDisplayEpithets(character).join(', ')}
</span> </span>
{/if} {/if}
{/if}
</div> </div>
</button> </button>
{/each} {/each}
@@ -158,10 +213,10 @@
<button <button
type="button" type="button"
onclick={submitGuess} onclick={submitGuess}
disabled={searchInput.length === 0 || filteredCharacters.length === 0} disabled={state.searchInput.length === 0 || filteredCharacters.length === 0}
class="rounded-full bg-amber-300 px-6 py-3 text-sm font-semibold text-slate-900 transition hover:bg-amber-200 disabled:cursor-not-allowed disabled:opacity-50" class="rounded-full bg-amber-300 px-6 py-3 text-sm font-semibold text-slate-900 transition hover:bg-amber-200 disabled:cursor-not-allowed disabled:opacity-50"
> >
Valider {$t.game.components.searchInput.submit}
</button> </button>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,73 @@
<script lang="ts">
import { t } from '$lib/i18n';
type TriedCharacter = {
id: string;
name: string;
pictureUrl: string | null;
};
type FriendTodayResult = {
userId: string;
name: string;
image: string | null;
tryCount: number;
triedCharacters: TriedCharacter[];
};
export let friendsTodayResults: FriendTodayResult[] = [];
</script>
{#if friendsTodayResults.length > 0}
<section class="mt-6 rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur">
<p class="text-xs font-semibold uppercase tracking-[0.28em] text-amber-100 text-center">{$t.game.daily.friendsToday}</p>
<div class="mt-4 space-y-2">
{#each friendsTodayResults as friendResult (friendResult.userId)}
<div class="rounded-lg border border-white/10 bg-slate-950/50 px-4 py-3">
<div class="flex items-center justify-between gap-4">
<div class="flex items-center gap-3">
{#if friendResult.image}
<img
src={friendResult.image}
alt={friendResult.name}
class="h-8 w-8 rounded-full border border-white/20 object-cover"
/>
{:else}
<div class="flex h-8 w-8 items-center justify-center rounded-full bg-amber-300/20 text-xs font-semibold text-amber-100">
{friendResult.name?.charAt(0).toUpperCase() || 'U'}
</div>
{/if}
<p class="text-sm font-semibold text-slate-100">{friendResult.name}</p>
</div>
<p class="text-sm text-amber-300">
{friendResult.tryCount} {friendResult.tryCount > 1 ? $t.game.daily.friendTryPlural : $t.game.daily.friendTrySingular}
</p>
</div>
<div class="mt-3 border-t border-white/10 pt-2">
<p class="text-[11px] font-semibold uppercase tracking-[0.2em] text-amber-100">
{$t.game.daily.friendsTriedCharacters}
</p>
{#if friendResult.triedCharacters && friendResult.triedCharacters.length > 0}
<div class="mt-2 flex flex-wrap gap-2">
{#each friendResult.triedCharacters as triedCharacter (triedCharacter.id)}
<span class="inline-flex items-center gap-2 rounded-full border border-white/15 bg-white/5 px-2.5 py-1 text-xs text-slate-200">
{#if triedCharacter.pictureUrl}
<img
src={triedCharacter.pictureUrl}
alt={triedCharacter.name}
class="h-4 w-4 rounded-full object-cover"
/>
{/if}
{triedCharacter.name}
</span>
{/each}
</div>
{:else}
<p class="mt-1 text-xs text-slate-500">{$t.game.daily.friendsNoTriedCharacters}</p>
{/if}
</div>
</div>
{/each}
</div>
</section>
{/if}

View File

@@ -1,178 +1,346 @@
<script lang="ts"> <script lang="ts">
import { formatBounty } from '$lib'; import { formatBounty } from '$lib';
import type { CharacterWithRelations } from '$lib/server/daily-character';
import { language, t } from '$lib/i18n';
export let selectedCharacters: any[]; export let selectedCharacters: CharacterWithRelations[];
export let dailyCharacter: any; export let dailyCharacter: CharacterWithRelations;
export let columnVisibility: any; export let columnVisibility: {
status?: boolean;
gender?: boolean;
affiliation?: boolean;
devilFruitType?: boolean;
haki?: boolean;
bounty?: boolean;
height?: boolean;
age?: boolean;
origin?: boolean;
arc?: boolean;
};
$: isFrench = $language === 'fr';
function getDisplayName(character: CharacterWithRelations): string {
if (isFrench && typeof character.frName === 'string' && character.frName.length > 0) {
return character.frName;
}
return character.name;
}
function getWikiUrl(character: CharacterWithRelations): string {
if (isFrench && typeof character.frUrl === 'string' && character.frUrl.length > 0) {
return character.frUrl;
}
return character.url || '';
}
function getWikiBaseUrl(): string {
return isFrench ? 'https://onepiece.fandom.com/fr/wiki/' : 'https://onepiece.fandom.com/wiki/';
}
function getDisplayOrigin(character: CharacterWithRelations): string | null {
if (isFrench && typeof character.frOrigin === 'string' && character.frOrigin.length > 0) {
return character.frOrigin;
}
return character.origin;
}
function hasMatchingOrigin(characterEntry: CharacterWithRelations, dailyEntry: CharacterWithRelations): boolean {
return getDisplayOrigin(characterEntry) === getDisplayOrigin(dailyEntry);
}
function getDisplayArcName(character: CharacterWithRelations): string | null {
if (isFrench && typeof character.frArcName === 'string' && character.frArcName.length > 0) {
return character.frArcName;
}
return character.arcName;
}
function getDislayAffiliation(character: CharacterWithRelations): string | null {
if (isFrench && typeof character.frAffiliation === 'string' && character.frAffiliation.length > 0) {
return character.frAffiliation;
}
return character.affiliation;
}
function hasMatchingArc(characterEntry: CharacterWithRelations, dailyEntry: CharacterWithRelations): boolean {
return getDisplayArcName(characterEntry) === getDisplayArcName(dailyEntry);
}
</script> </script>
<section class="mt-8 rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur"> <section
class="mt-8 rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur"
>
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
<div class="flex flex-col items-center gap-4 text-center"> <div class="flex flex-col items-center gap-4 text-center">
<p class="text-xs font-semibold uppercase tracking-[0.28em] text-amber-100">Historique</p> <p class="text-xs font-semibold tracking-[0.28em] text-amber-100 uppercase">{$t.game.components.guessHistory.title}</p>
</div> </div>
{#if selectedCharacters.length === 0} {#if selectedCharacters.length === 0}
<p class="text-sm text-slate-200 text-center">Aucune tentative pour le moment.</p> <p class="text-center text-sm text-slate-200">{$t.game.components.guessHistory.empty}</p>
{:else} {:else}
<div class="overflow-x-auto pb-2 -mx-6 px-6 sm:mx-0 sm:px-0"> <div class="-mx-6 overflow-x-auto px-6 pb-2 sm:mx-0 sm:px-0">
<div class="w-max min-w-max mx-auto"> <div class="mx-auto w-max min-w-max">
<!-- Header --> <!-- Header -->
<div class="flex gap-2 mb-2"> <div class="mb-2 flex gap-1 sm:gap-2">
<div class="w-24 shrink-0 rounded-lg border border-amber-200/30 bg-amber-900/30 p-2 text-center flex items-center justify-center"> <div
<p class="text-xs font-semibold uppercase tracking-wider text-amber-100">Personnage</p> class="flex w-16 shrink-0 items-center justify-center rounded-lg border border-amber-200/30 bg-amber-900/30 p-1 text-center sm:w-20 sm:p-2 md:w-24"
>
<p
class="text-[9px] font-semibold tracking-wider text-amber-100 uppercase sm:text-xs"
>
{$t.game.components.guessHistory.character}
</p>
</div> </div>
{#if columnVisibility.status !== false} {#if columnVisibility.status !== false}
<div class="w-24 shrink-0 rounded-lg border border-amber-200/30 bg-amber-900/30 p-2 text-center flex items-center justify-center"> <div
<p class="text-xs font-semibold uppercase tracking-wider text-amber-100">Statut</p> class="flex w-16 shrink-0 items-center justify-center rounded-lg border border-amber-200/30 bg-amber-900/30 p-1 text-center sm:w-20 sm:p-2 md:w-24"
>
<p
class="text-[9px] font-semibold tracking-wider text-amber-100 uppercase sm:text-xs"
>
{$t.game.components.guessHistory.status}
</p>
</div> </div>
{/if} {/if}
{#if columnVisibility.gender !== false} {#if columnVisibility.gender !== false}
<div class="w-24 shrink-0 rounded-lg border border-amber-200/30 bg-amber-900/30 p-2 text-center flex items-center justify-center"> <div
<p class="text-xs font-semibold uppercase tracking-wider text-amber-100">Genre</p> class="flex w-16 shrink-0 items-center justify-center rounded-lg border border-amber-200/30 bg-amber-900/30 p-1 text-center sm:w-20 sm:p-2 md:w-24"
>
<p
class="text-[9px] font-semibold tracking-wider text-amber-100 uppercase sm:text-xs"
>
{$t.game.components.guessHistory.gender}
</p>
</div> </div>
{/if} {/if}
{#if columnVisibility.affiliations !== false} {#if columnVisibility.affiliation !== false}
<div class="w-24 shrink-0 rounded-lg border border-amber-200/30 bg-amber-900/30 p-2 text-center flex items-center justify-center"> <div
<p class="text-xs font-semibold uppercase tracking-wider text-amber-100">Affiliations</p> class="flex w-16 shrink-0 items-center justify-center rounded-lg border border-amber-200/30 bg-amber-900/30 p-1 text-center sm:w-20 sm:p-2 md:w-24"
>
<p
class="text-[9px] font-semibold tracking-wider text-amber-100 uppercase sm:text-xs"
>
{$t.game.components.guessHistory.affiliations}
</p>
</div> </div>
{/if} {/if}
{#if columnVisibility.devilFruitType !== false} {#if columnVisibility.devilFruitType !== false}
<div class="w-24 shrink-0 rounded-lg border border-amber-200/30 bg-amber-900/30 p-2 text-center flex items-center justify-center"> <div
<p class="text-xs font-semibold uppercase tracking-wider text-amber-100">Fruit</p> class="flex w-16 shrink-0 items-center justify-center rounded-lg border border-amber-200/30 bg-amber-900/30 p-1 text-center sm:w-20 sm:p-2 md:w-24"
>
<p
class="text-[9px] font-semibold tracking-wider text-amber-100 uppercase sm:text-xs"
>
{$t.game.components.guessHistory.fruit}
</p>
</div> </div>
{/if} {/if}
{#if columnVisibility.haki !== false} {#if columnVisibility.haki !== false}
<div class="w-24 shrink-0 rounded-lg border border-amber-200/30 bg-amber-900/30 p-2 text-center flex items-center justify-center"> <div
<p class="text-xs font-semibold uppercase tracking-wider text-amber-100">Haki</p> class="flex w-16 shrink-0 items-center justify-center rounded-lg border border-amber-200/30 bg-amber-900/30 p-1 text-center sm:w-20 sm:p-2 md:w-24"
>
<p
class="text-[9px] font-semibold tracking-wider text-amber-100 uppercase sm:text-xs"
>
{$t.game.components.guessHistory.haki}
</p>
</div> </div>
{/if} {/if}
{#if columnVisibility.bounty !== false} {#if columnVisibility.bounty !== false}
<div class="w-24 shrink-0 rounded-lg border border-amber-200/30 bg-amber-900/30 p-2 text-center flex items-center justify-center"> <div
<p class="text-xs font-semibold uppercase tracking-wider text-amber-100">Prime</p> class="flex w-16 shrink-0 items-center justify-center rounded-lg border border-amber-200/30 bg-amber-900/30 p-1 text-center sm:w-20 sm:p-2 md:w-24"
>
<p
class="text-[9px] font-semibold tracking-wider text-amber-100 uppercase sm:text-xs"
>
{$t.game.components.guessHistory.bounty}
</p>
</div> </div>
{/if} {/if}
{#if columnVisibility.height !== false} {#if columnVisibility.height !== false}
<div class="w-24 shrink-0 rounded-lg border border-amber-200/30 bg-amber-900/30 p-2 text-center flex items-center justify-center"> <div
<p class="text-xs font-semibold uppercase tracking-wider text-amber-100">Taille</p> class="flex w-16 shrink-0 items-center justify-center rounded-lg border border-amber-200/30 bg-amber-900/30 p-1 text-center sm:w-20 sm:p-2 md:w-24"
>
<p
class="text-[9px] font-semibold tracking-wider text-amber-100 uppercase sm:text-xs"
>
{$t.game.components.guessHistory.height}
</p>
</div>
{/if}
{#if columnVisibility.age !== false}
<div
class="flex w-16 shrink-0 items-center justify-center rounded-lg border border-amber-200/30 bg-amber-900/30 p-1 text-center sm:w-20 sm:p-2 md:w-24"
>
<p
class="text-[9px] font-semibold tracking-wider text-amber-100 uppercase sm:text-xs"
>
{$t.game.components.guessHistory.age}
</p>
</div> </div>
{/if} {/if}
{#if columnVisibility.origin !== false} {#if columnVisibility.origin !== false}
<div class="w-24 shrink-0 rounded-lg border border-amber-200/30 bg-amber-900/30 p-2 text-center flex items-center justify-center"> <div
<p class="text-xs font-semibold uppercase tracking-wider text-amber-100">Origine</p> class="flex w-16 shrink-0 items-center justify-center rounded-lg border border-amber-200/30 bg-amber-900/30 p-1 text-center sm:w-20 sm:p-2 md:w-24"
>
<p
class="text-[9px] font-semibold tracking-wider text-amber-100 uppercase sm:text-xs"
>
{$t.game.components.guessHistory.origin}
</p>
</div> </div>
{/if} {/if}
{#if columnVisibility.arc !== false} {#if columnVisibility.arc !== false}
<div class="w-24 shrink-0 rounded-lg border border-amber-200/30 bg-amber-900/30 p-2 text-center flex items-center justify-center"> <div
<p class="text-xs font-semibold uppercase tracking-wider text-amber-100">Arc</p> class="flex w-16 shrink-0 items-center justify-center rounded-lg border border-amber-200/30 bg-amber-900/30 p-1 text-center sm:w-20 sm:p-2 md:w-24"
>
<p
class="text-[9px] font-semibold tracking-wider text-amber-100 uppercase sm:text-xs"
>
{$t.game.components.guessHistory.arc}
</p>
</div> </div>
{/if} {/if}
</div> </div>
<!-- Rows --> <!-- Rows -->
{#each selectedCharacters as character (character.id)} {#each selectedCharacters as character (character.id)}
<div class="flex gap-2 mb-2"> <div class="mb-2 flex gap-1 sm:gap-2">
<!-- Personnage --> <!-- Personnage -->
<div class="w-24 h-24 shrink-0 rounded-lg border border-white/10 bg-slate-950/60 overflow-hidden"> <div
class="h-16 w-16 shrink-0 overflow-hidden rounded-lg border border-white/10 bg-slate-950/60 sm:h-20 sm:w-20 md:h-24 md:w-24"
>
{#if character.pictureUrl} {#if character.pictureUrl}
<a <a
href={"https://onepiece.fandom.com/fr/wiki/" + character.url} href={getWikiBaseUrl() + getWikiUrl(character)}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
class="block w-full h-full" class="block h-full w-full"
> >
<img <img
src={character.pictureUrl} src={character.pictureUrl}
alt={character.name} alt={getDisplayName(character)}
class="w-full h-full object-cover hover:opacity-80 transition-opacity cursor-pointer" class="h-full w-full cursor-pointer object-cover transition-opacity hover:opacity-80"
/> />
</a> </a>
{:else} {:else}
<div class="w-full h-full bg-slate-800 flex items-center justify-center p-2"> <div
<span class="text-xl text-center font-semibold line-clamp-3">{character.name}</span> class="flex h-full w-full items-center justify-center bg-slate-800 p-1 sm:p-2"
>
<span
class="line-clamp-3 text-center text-xs font-semibold sm:text-sm md:text-xl"
>{getDisplayName(character)}</span
>
</div> </div>
{/if} {/if}
</div> </div>
<!-- Vivant / Mort --> <!-- Vivant / Mort -->
{#if columnVisibility.status !== false} {#if columnVisibility.status !== false}
<div class="w-24 h-24 shrink-0 rounded-lg border border-white/10 {character.status === dailyCharacter.status ? 'bg-emerald-600/90' : 'bg-red-900/60'} p-2 flex items-center justify-center"> <div
<p class="text-sm font-bold text-white text-center"> class="h-16 w-16 shrink-0 rounded-lg border border-white/10 sm:h-20 sm:w-20 md:h-24 md:w-24 {character.status ===
{character.status === 'Alive' ? 'Vivant' : character.status === 'Deceased' || character.status === 'Dead' ? 'Mort' : character.status || 'Inconnu'} dailyCharacter.status
? 'bg-emerald-600/90'
: 'bg-red-900/60'} flex items-center justify-center p-1 sm:p-2"
>
<p class="text-center text-[10px] font-bold text-white sm:text-xs md:text-sm">
{character.status === 'Alive'
? $t.game.components.guessHistory.alive
: character.status === 'Dead'
? $t.game.components.guessHistory.dead
: character.status === 'Unknown'
? $t.game.components.guessHistory.unknown
: character.status === null
? '-'
: character.status || $t.game.components.guessHistory.unknown}
</p> </p>
</div> </div>
{/if} {/if}
<!-- Genre --> <!-- Genre -->
{#if columnVisibility.gender !== false} {#if columnVisibility.gender !== false}
<div class="w-24 h-24 shrink-0 rounded-lg border border-white/10 {character.gender === dailyCharacter.gender ? 'bg-emerald-600/90' : 'bg-red-900/60'} p-2 flex items-center justify-center"> <div
<p class="text-base font-bold text-white text-center"> class="h-16 w-16 shrink-0 rounded-lg border border-white/10 sm:h-20 sm:w-20 md:h-24 md:w-24 {character.gender ===
{character.gender === 'Male' ? 'Homme' : character.gender === 'Female' ? 'Femme' : character.gender || 'Inconnu'} dailyCharacter.gender
? 'bg-emerald-600/90'
: 'bg-red-900/60'} flex items-center justify-center p-1 sm:p-2"
>
<p class="text-center text-xs font-bold text-white sm:text-sm md:text-base">
{character.gender === 'Male'
? $t.game.components.guessHistory.male
: character.gender === 'Female'
? $t.game.components.guessHistory.female
: character.gender || $t.game.components.guessHistory.unknown}
</p> </p>
</div> </div>
{/if} {/if}
<!-- Affiliations --> <!-- Affiliations -->
{#if columnVisibility.affiliations !== false} {#if columnVisibility.affiliation !== false}
<div class="w-24 h-24 shrink-0 rounded-lg border border-white/10 {(() => { <div
try { class="h-16 w-16 shrink-0 rounded-lg border border-white/10 sm:h-20 sm:w-20 md:h-24 md:w-24 {getDislayAffiliation(character) === getDislayAffiliation(dailyCharacter)
const charAff = typeof character.affiliations === 'string' ? 'bg-emerald-600/90'
? ((character.affiliations as string).includes('[') ? JSON.parse(character.affiliations) : (character.affiliations as string).split(',').map((a: string) => a.trim())) : 'bg-red-900/60'} flex items-center justify-center p-1 sm:p-2"
: character.affiliations; >
const dailyAff = typeof dailyCharacter.affiliations === 'string' <p class="text-center text-[10px] font-bold text-white sm:text-xs md:text-sm">
? ((dailyCharacter.affiliations as string).includes('[') ? JSON.parse(dailyCharacter.affiliations) : (dailyCharacter.affiliations as string).split(',').map((a: string) => a.trim())) {getDislayAffiliation(character) || $t.game.components.guessHistory.unknown}
: dailyCharacter.affiliations; </p>
const charFirstAff = Array.isArray(charAff) ? charAff[0] : charAff;
const dailyFirstAff = Array.isArray(dailyAff) ? dailyAff[0] : dailyAff;
return charFirstAff && dailyFirstAff && charFirstAff === dailyFirstAff ? 'bg-emerald-600/90' : 'bg-red-900/60';
} catch (e) {
return 'bg-slate-950/60';
}
})()} p-2 flex items-center justify-center overflow-hidden">
{#if character.affiliations}
{@const parsedAffiliations = typeof character.affiliations === 'string'
? (character.affiliations.includes('[') ? JSON.parse(character.affiliations) : character.affiliations.split(',').map((a: string) => a.trim()))
: character.affiliations}
{#if Array.isArray(parsedAffiliations) && parsedAffiliations.length > 0}
<p class="w-full text-sm font-bold text-white text-center whitespace-normal break-words leading-tight">{parsedAffiliations[0]}</p>
{:else}
<p class="w-full text-sm font-bold text-white text-center whitespace-normal break-words leading-tight">{parsedAffiliations}</p>
{/if}
{:else}
<p class="text-base font-bold text-slate-400 text-center">-</p>
{/if}
</div> </div>
{/if} {/if}
<!-- Fruit --> <!-- Fruit -->
{#if columnVisibility.devilFruitType !== false} {#if columnVisibility.devilFruitType !== false}
<div class="w-24 h-24 shrink-0 rounded-lg border border-white/10 {character.devilFruitType === dailyCharacter.devilFruitType ? 'bg-emerald-600/90' : 'bg-red-900/60'} p-2 flex items-center justify-center"> <div
class="h-16 w-16 shrink-0 rounded-lg border border-white/10 sm:h-20 sm:w-20 md:h-24 md:w-24 {character.devilFruitType ===
dailyCharacter.devilFruitType
? 'bg-emerald-600/90'
: 'bg-red-900/60'} flex items-center justify-center p-1 sm:p-2"
>
{#if character.devilFruitType} {#if character.devilFruitType}
<p class="text-sm font-bold text-white text-center">{character.devilFruitType}</p> <p class="text-center text-[10px] font-bold text-white sm:text-xs md:text-sm">
{character.devilFruitType}
</p>
{:else} {:else}
<p class="text-5xl font-bold text-white text-center"></p> <p class="text-center text-2xl font-bold text-white sm:text-3xl md:text-5xl">
</p>
{/if} {/if}
</div> </div>
{/if} {/if}
<!-- Haki --> <!-- Haki -->
{#if columnVisibility.haki !== false} {#if columnVisibility.haki !== false}
<div class="w-24 h-24 shrink-0 rounded-lg border border-white/10 {(() => { <div
if (character.hakiObservation === dailyCharacter.hakiObservation && character.hakiArmament === dailyCharacter.hakiArmament && character.hakiConqueror === dailyCharacter.hakiConqueror) { class="h-16 w-16 shrink-0 rounded-lg border border-white/10 sm:h-20 sm:w-20 md:h-24 md:w-24 {(() => {
if (
character.hakiObservation === dailyCharacter.hakiObservation &&
character.hakiArmament === dailyCharacter.hakiArmament &&
character.hakiConqueror === dailyCharacter.hakiConqueror
) {
return 'bg-emerald-600/90'; return 'bg-emerald-600/90';
} else if ((character.hakiObservation && dailyCharacter.hakiObservation) || } else if (
(character.hakiObservation && dailyCharacter.hakiObservation) ||
(character.hakiArmament && dailyCharacter.hakiArmament) || (character.hakiArmament && dailyCharacter.hakiArmament) ||
(character.hakiConqueror && dailyCharacter.hakiConqueror)) { (character.hakiConqueror && dailyCharacter.hakiConqueror)
) {
return 'bg-yellow-600/80'; return 'bg-yellow-600/80';
} else { } else {
return 'bg-red-900/60'; return 'bg-red-900/60';
} }
})()} p-2 flex items-center justify-center"> })()} flex items-center justify-center p-1 sm:p-2"
<p class="text-2xl font-bold text-white text-center"> >
{#if character.hakiObservation}<span title="Haki de l'Observation">👁️</span>{/if} <p class="text-center text-sm font-bold text-white sm:text-lg md:text-2xl">
{#if character.hakiArmament}<span title="Haki de l'Armement">🦾</span>{/if} {#if character.hakiObservation}<span title={$t.game.components.guessHistory.obsHakiTitle}>👁️</span
{#if character.hakiConqueror}<span title="Haki des Rois">👑</span>{/if} >{/if}
{#if character.hakiArmament}<span title={$t.game.components.guessHistory.armHakiTitle}>🦾</span>{/if}
{#if character.hakiConqueror}<span title={$t.game.components.guessHistory.kingHakiTitle}>👑</span>{/if}
{#if !character.hakiObservation && !character.hakiArmament && !character.hakiConqueror} {#if !character.hakiObservation && !character.hakiArmament && !character.hakiConqueror}
<span class="text-5xl"></span> <span class="text-2xl sm:text-3xl md:text-5xl"></span>
{/if} {/if}
</p> </p>
</div> </div>
@@ -180,61 +348,145 @@
<!-- Prime --> <!-- Prime -->
{#if columnVisibility.bounty !== false} {#if columnVisibility.bounty !== false}
<div class="w-24 h-24 shrink-0 rounded-lg border border-white/10 {character.bounty === dailyCharacter.bounty ? 'bg-emerald-600/90' : 'bg-red-900/60'} p-2 flex items-center justify-center relative overflow-hidden"> <div
class="h-16 w-16 shrink-0 rounded-lg border border-white/10 sm:h-20 sm:w-20 md:h-24 md:w-24 {character.bounty ===
dailyCharacter.bounty
? 'bg-emerald-600/90'
: 'bg-red-900/60'} relative flex items-center justify-center overflow-hidden p-1 sm:p-2"
>
{#if character.bounty != null && dailyCharacter.bounty != null && character.bounty !== dailyCharacter.bounty} {#if character.bounty != null && dailyCharacter.bounty != null && character.bounty !== dailyCharacter.bounty}
<div class="absolute w-full h-full opacity-30 pointer-events-none" style=" <div
class="pointer-events-none absolute h-full w-full opacity-30"
style="
background-color: rgb(203, 213, 225); background-color: rgb(203, 213, 225);
clip-path: {character.bounty > dailyCharacter.bounty clip-path: {character.bounty > dailyCharacter.bounty
? 'polygon(97% 60%,80% 60%,80% 5%,20% 5%,20% 60%,3% 60%,50% 95%)' ? 'polygon(97% 60%,80% 60%,80% 5%,20% 5%,20% 60%,3% 60%,50% 95%)'
: 'polygon(97% 40%,80% 40%,80% 95%,20% 95%,20% 40%,3% 40%,50% 5%)'}; : 'polygon(97% 40%,80% 40%,80% 95%,20% 95%,20% 40%,3% 40%,50% 5%)'};
"></div> "
></div>
{/if} {/if}
{#if character.bounty != null} {#if character.bounty != null}
<p class="text-sm font-bold text-white text-center relative z-10">{formatBounty(character.bounty)} ฿</p> <p
class="relative z-10 text-center text-[10px] font-bold text-white sm:text-xs md:text-sm"
>
{formatBounty(character.bounty)} ฿
</p>
{:else} {:else}
<p class="text-sm font-bold text-white text-center relative z-10">Inconnue</p> <p
class="relative z-10 text-center text-[10px] font-bold text-white sm:text-xs md:text-sm"
>
{$t.game.components.guessHistory.unknown}
</p>
{/if} {/if}
</div> </div>
{/if} {/if}
<!-- Taille --> <!-- Taille -->
{#if columnVisibility.height !== false} {#if columnVisibility.height !== false}
<div class="w-24 h-24 shrink-0 rounded-lg border border-white/10 {character.height === dailyCharacter.height ? 'bg-emerald-600/90' : 'bg-red-900/60'} p-2 flex items-center justify-center relative overflow-hidden"> <div
class="h-16 w-16 shrink-0 rounded-lg border border-white/10 sm:h-20 sm:w-20 md:h-24 md:w-24 {character.height ===
dailyCharacter.height
? 'bg-emerald-600/90'
: 'bg-red-900/60'} relative flex items-center justify-center overflow-hidden p-1 sm:p-2"
>
{#if character.height && dailyCharacter.height && character.height !== dailyCharacter.height} {#if character.height && dailyCharacter.height && character.height !== dailyCharacter.height}
<div class="absolute w-full h-full opacity-30 pointer-events-none" style=" <div
class="pointer-events-none absolute h-full w-full opacity-30"
style="
background-color: rgb(203, 213, 225); background-color: rgb(203, 213, 225);
clip-path: {character.height > dailyCharacter.height clip-path: {character.height > dailyCharacter.height
? 'polygon(97% 60%,80% 60%,80% 5%,20% 5%,20% 60%,3% 60%,50% 95%)' ? 'polygon(97% 60%,80% 60%,80% 5%,20% 5%,20% 60%,3% 60%,50% 95%)'
: 'polygon(97% 40%,80% 40%,80% 95%,20% 95%,20% 40%,3% 40%,50% 5%)'}; : 'polygon(97% 40%,80% 40%,80% 95%,20% 95%,20% 40%,3% 40%,50% 5%)'};
"></div> "
></div>
{/if} {/if}
{#if character.height} {#if character.height}
<p class="text-sm font-bold text-white text-center relative z-10">{character.height} m</p> <p
class="relative z-10 text-center text-[10px] font-bold text-white sm:text-xs md:text-sm"
>
{character.height} m
</p>
{:else} {:else}
<p class="text-sm font-bold text-white text-center relative z-10">Inconnue</p> <p
class="relative z-10 text-center text-[10px] font-bold text-white sm:text-xs md:text-sm"
>
{$t.game.components.guessHistory.unknown}
</p>
{/if}
</div>
{/if}
<!-- Age -->
{#if columnVisibility.age !== false}
<div
class="h-16 w-16 shrink-0 rounded-lg border border-white/10 sm:h-20 sm:w-20 md:h-24 md:w-24 {character.age ===
dailyCharacter.age
? 'bg-emerald-600/90'
: 'bg-red-900/60'} relative flex items-center justify-center overflow-hidden p-1 sm:p-2"
>
{#if character.age != null && dailyCharacter.age != null && character.age !== dailyCharacter.age}
<div
class="pointer-events-none absolute h-full w-full opacity-30"
style="
background-color: rgb(203, 213, 225);
clip-path: {character.age > dailyCharacter.age
? 'polygon(97% 60%,80% 60%,80% 5%,20% 5%,20% 60%,3% 60%,50% 95%)'
: 'polygon(97% 40%,80% 40%,80% 95%,20% 95%,20% 40%,3% 40%,50% 5%)'};
"
></div>
{/if}
{#if character.age != null}
<p
class="relative z-10 text-center text-[10px] font-bold text-white sm:text-xs md:text-sm"
>
{character.age}
</p>
{:else}
<p
class="relative z-10 text-center text-[10px] font-bold text-white sm:text-xs md:text-sm"
>
{$t.game.components.guessHistory.unknown}
</p>
{/if} {/if}
</div> </div>
{/if} {/if}
<!-- Origine --> <!-- Origine -->
{#if columnVisibility.origin !== false} {#if columnVisibility.origin !== false}
<div class="w-24 h-24 shrink-0 rounded-lg border border-white/10 {character.origin === dailyCharacter.origin ? 'bg-emerald-600/90' : 'bg-red-900/60'} p-2 flex items-center justify-center"> <div
<p class="text-sm font-bold text-white text-center">{character.origin || 'Inconnue'}</p> class="h-16 w-16 shrink-0 rounded-lg border border-white/10 sm:h-20 sm:w-20 md:h-24 md:w-24 {hasMatchingOrigin(character, dailyCharacter)
? 'bg-emerald-600/90'
: 'bg-red-900/60'} flex items-center justify-center p-1 sm:p-2"
>
<p class="text-center text-[10px] font-bold text-white sm:text-xs md:text-sm">
{getDisplayOrigin(character) || $t.game.components.guessHistory.unknown}
</p>
</div> </div>
{/if} {/if}
<!-- Arc --> <!-- Arc -->
{#if columnVisibility.arc !== false} {#if columnVisibility.arc !== false}
<div class="w-24 h-24 shrink-0 rounded-lg border border-white/10 {character.arcName === dailyCharacter.arcName ? 'bg-emerald-600/90' : 'bg-red-900/60'} p-2 flex items-center justify-center relative overflow-hidden"> <div
{#if character.arcName !== dailyCharacter.arcName && character.firstAppearance && dailyCharacter.firstAppearance && character.firstAppearance !== dailyCharacter.firstAppearance} class="h-16 w-16 shrink-0 rounded-lg border border-white/10 sm:h-20 sm:w-20 md:h-24 md:w-24 {hasMatchingArc(character, dailyCharacter)
<div class="absolute w-full h-full opacity-30 pointer-events-none" style=" ? 'bg-emerald-600/90'
: 'bg-red-900/60'} relative flex items-center justify-center overflow-hidden p-1 sm:p-2"
>
{#if !hasMatchingArc(character, dailyCharacter) && character.firstAppearance && dailyCharacter.firstAppearance && character.firstAppearance !== dailyCharacter.firstAppearance}
<div
class="pointer-events-none absolute h-full w-full opacity-30"
style="
background-color: rgb(203, 213, 225); background-color: rgb(203, 213, 225);
clip-path: {character.firstAppearance > dailyCharacter.firstAppearance clip-path: {character.firstAppearance > dailyCharacter.firstAppearance
? 'polygon(97% 60%,80% 60%,80% 5%,20% 5%,20% 60%,3% 60%,50% 95%)' ? 'polygon(97% 60%,80% 60%,80% 5%,20% 5%,20% 60%,3% 60%,50% 95%)'
: 'polygon(97% 40%,80% 40%,80% 95%,20% 95%,20% 40%,3% 40%,50% 5%)'}; : 'polygon(97% 40%,80% 40%,80% 95%,20% 95%,20% 40%,3% 40%,50% 5%)'};
"></div> "
></div>
{/if} {/if}
<p class="text-sm font-bold text-white text-center relative z-10">{character.arcName || 'Inconnu'}</p> <p
class="relative z-10 text-center text-[10px] font-bold text-white sm:text-xs md:text-sm"
>
{getDisplayArcName(character) || $t.game.components.guessHistory.unknown}
</p>
</div> </div>
{/if} {/if}
</div> </div>

View File

@@ -1,6 +1,9 @@
<script lang="ts"> <script lang="ts">
export let dailyCharacter: any; import type { CharacterWithRelations } from "$lib/server/daily-character";
export let selectedCharacters: any[]; import { language, t } from '$lib/i18n';
export let dailyCharacter: CharacterWithRelations;
export let selectedCharacters: CharacterWithRelations[];
export let showOriginUnlock: boolean = false; export let showOriginUnlock: boolean = false;
export let showFruitUnlock: boolean = false; export let showFruitUnlock: boolean = false;
export let showAffiliationUnlock: boolean = false; export let showAffiliationUnlock: boolean = false;
@@ -13,6 +16,15 @@
$: isOriginAvailable = selectedCharacters.length >= 5; $: isOriginAvailable = selectedCharacters.length >= 5;
$: isFruitAvailable = selectedCharacters.length >= 10; $: isFruitAvailable = selectedCharacters.length >= 10;
$: isAffiliationAvailable = selectedCharacters.length >= 15; $: isAffiliationAvailable = selectedCharacters.length >= 15;
$: isFrench = $language === 'fr';
function getDisplayOrigin(character: CharacterWithRelations): string | null {
if (isFrench && typeof character.frOrigin === 'string' && character.frOrigin.length > 0) {
return character.frOrigin;
}
return character.origin;
}
</script> </script>
<svelte:head> <svelte:head>
@@ -42,13 +54,13 @@
disabled={!isOriginAvailable} disabled={!isOriginAvailable}
onclick={() => showHintOrigin = !showHintOrigin} onclick={() => showHintOrigin = !showHintOrigin}
> >
<p class="text-sm font-medium text-amber-100">Origine</p> <p class="text-sm font-medium text-amber-100">{$t.game.components.hints.origin}</p>
{#if showHintOrigin} {#if showHintOrigin}
<p class="mt-2 text-xs text-white font-semibold">{dailyCharacter.origin || 'Inconnue'}</p> <p class="mt-2 text-xs text-white font-semibold">{getDisplayOrigin(dailyCharacter) || $t.game.components.hints.unknown}</p>
{:else if Math.max(0, 5 - selectedCharacters.length) > 0} {:else if Math.max(0, 5 - selectedCharacters.length) > 0}
<p class="mt-2 text-xs text-slate-400">{Math.max(0, 5 - selectedCharacters.length)} essais avant déblocage</p> <p class="mt-2 text-xs text-slate-400">{Math.max(0, 5 - selectedCharacters.length)} {$t.game.components.hints.beforeUnlock}</p>
{:else} {:else}
<p class="mt-2 text-xs text-slate-400">Indice disponible !</p> <p class="mt-2 text-xs text-slate-400">{$t.game.components.hints.available}</p>
{/if} {/if}
</button> </button>
<button <button
@@ -57,13 +69,13 @@
disabled={!isFruitAvailable} disabled={!isFruitAvailable}
onclick={() => showHintFruit = !showHintFruit} onclick={() => showHintFruit = !showHintFruit}
> >
<p class="text-sm font-medium text-amber-100">Fruit du démon</p> <p class="text-sm font-medium text-amber-100">{$t.game.components.hints.devilFruit}</p>
{#if showHintFruit} {#if showHintFruit}
<p class="mt-2 text-xs text-white font-semibold">{dailyCharacter.devilFruitName || 'Aucun'}</p> <p class="mt-2 text-xs text-white font-semibold">{dailyCharacter.devilFruitName || $t.game.components.hints.none}</p>
{:else if Math.max(0, 10 - selectedCharacters.length) > 0} {:else if Math.max(0, 10 - selectedCharacters.length) > 0}
<p class="mt-2 text-xs text-slate-400">{Math.max(0, 10 - selectedCharacters.length)} essais avant déblocage</p> <p class="mt-2 text-xs text-slate-400">{Math.max(0, 10 - selectedCharacters.length)} {$t.game.components.hints.beforeUnlock}</p>
{:else} {:else}
<p class="mt-2 text-xs text-slate-400">Indice disponible !</p> <p class="mt-2 text-xs text-slate-400">{$t.game.components.hints.available}</p>
{/if} {/if}
</button> </button>
<button <button
@@ -72,16 +84,13 @@
disabled={!isAffiliationAvailable} disabled={!isAffiliationAvailable}
onclick={() => showHintAffiliation = !showHintAffiliation} onclick={() => showHintAffiliation = !showHintAffiliation}
> >
<p class="text-sm font-medium text-amber-100">Affiliation</p> <p class="text-sm font-medium text-amber-100">{$t.game.components.hints.affiliation}</p>
{#if showHintAffiliation} {#if showHintAffiliation}
{@const affiliations = typeof dailyCharacter.affiliations === 'string' <p class="mt-2 text-xs text-white font-semibold">{isFrench && dailyCharacter.frAffiliation ? dailyCharacter.frAffiliation : dailyCharacter.affiliation || $t.game.components.hints.unknown}</p>
? ((dailyCharacter.affiliations as string).includes('[') ? JSON.parse(dailyCharacter.affiliations) : (dailyCharacter.affiliations as string).split(',').map((a: string) => a.trim()))
: dailyCharacter.affiliations}
<p class="mt-2 text-xs text-white font-semibold">{Array.isArray(affiliations) ? affiliations[0] : affiliations || 'Inconnue'}</p>
{:else if Math.max(0, 15 - selectedCharacters.length) > 0} {:else if Math.max(0, 15 - selectedCharacters.length) > 0}
<p class="mt-2 text-xs text-slate-400">{Math.max(0, 15 - selectedCharacters.length)} essais avant déblocage</p> <p class="mt-2 text-xs text-slate-400">{Math.max(0, 15 - selectedCharacters.length)} {$t.game.components.hints.beforeUnlock}</p>
{:else} {:else}
<p class="mt-2 text-xs text-slate-400">Indice disponible !</p> <p class="mt-2 text-xs text-slate-400">{$t.game.components.hints.available}</p>
{/if} {/if}
</button> </button>
</div> </div>

View File

@@ -0,0 +1,104 @@
<script lang="ts">
import { onMount } from 'svelte';
import { availableLanguages, language, setLanguage } from '$lib/i18n';
let isOpen = false;
let rootElement: HTMLDivElement | undefined;
const languageLabels: Record<string, string> = {
en: 'English',
fr: 'Francais'
};
const languageFlags: Record<string, string> = {
en: 'GB',
fr: 'FR'
};
function getLanguageLabel(lang: string): string {
return languageLabels[lang] || lang.toUpperCase();
}
function getFlagCode(lang: string): string {
return languageFlags[lang] || 'UN';
}
function toFlagEmoji(code: string): string {
const normalized = code.toUpperCase();
if (normalized.length !== 2) {
return 'UN';
}
const first = normalized.codePointAt(0);
const second = normalized.codePointAt(1);
if (!first || !second) {
return 'UN';
}
return String.fromCodePoint(127397 + first, 127397 + second);
}
function toggleMenu() {
isOpen = !isOpen;
}
function selectLanguage(lang: string) {
setLanguage(lang);
isOpen = false;
}
onMount(() => {
const onDocumentClick = (event: MouseEvent) => {
if (!rootElement) {
return;
}
if (!rootElement.contains(event.target as Node)) {
isOpen = false;
}
};
document.addEventListener('click', onDocumentClick);
return () => document.removeEventListener('click', onDocumentClick);
});
</script>
<div bind:this={rootElement} class="relative">
<button
type="button"
onclick={toggleMenu}
class="flex items-center gap-2 rounded-full border border-white/10 bg-white/5 px-3 py-2 text-sm font-semibold text-slate-100 transition hover:border-amber-300/50 hover:bg-white/10"
aria-haspopup="true"
aria-expanded={isOpen}
aria-label="Change language"
>
<span class="text-base" aria-hidden="true">{toFlagEmoji(getFlagCode($language))}</span>
<span class="uppercase text-xs tracking-wider">{$language}</span>
<svg
class="h-3.5 w-3.5 transition-transform {isOpen ? 'rotate-180' : ''}"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</button>
{#if isOpen}
<div class="absolute right-0 top-full z-20 mt-2 w-44 rounded-xl border border-white/10 bg-slate-900/95 p-1 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur">
{#each availableLanguages as lang (lang)}
<button
type="button"
onclick={() => selectLanguage(lang)}
class="flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-sm transition {lang === $language ? 'bg-amber-300 text-slate-900' : 'text-slate-100 hover:bg-white/5'}"
>
<span class="flex items-center gap-2">
<span class="text-base" aria-hidden="true">{toFlagEmoji(getFlagCode(lang))}</span>
<span>{getLanguageLabel(lang)}</span>
</span>
<span class="text-xs uppercase tracking-wide opacity-70">{lang}</span>
</button>
{/each}
</div>
{/if}
</div>

View File

@@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import type { User } from 'better-auth/types'; import type { User } from 'better-auth/types';
import { resolve } from '$app/paths';
interface Props { interface Props {
user: (User & { isAdmin?: boolean }) | null; user: (User & { isAdmin?: boolean }) | null;
@@ -59,7 +60,7 @@
{user.name?.charAt(0).toUpperCase() || 'U'} {user.name?.charAt(0).toUpperCase() || 'U'}
</div> </div>
{/if} {/if}
<span class="max-w-[150px] truncate text-sm font-semibold text-slate-100"> <span class="max-w-37.5 truncate text-sm font-semibold text-slate-100">
{user.name || 'Utilisateur'} {user.name || 'Utilisateur'}
</span> </span>
<svg <svg
@@ -77,15 +78,15 @@
class="absolute right-0 top-full mt-2 w-48 rounded-xl border border-white/10 bg-slate-900/95 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur" class="absolute right-0 top-full mt-2 w-48 rounded-xl border border-white/10 bg-slate-900/95 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur"
> >
<a <a
href="/profile" href={resolve("/profile")}
onclick={closeMenu} onclick={closeMenu}
class="block border-b border-white/5 px-4 py-3 text-sm font-semibold text-slate-100 transition hover:bg-white/5 hover:text-amber-100 first:rounded-t-xl" class="block border-b border-white/5 px-4 py-3 text-sm font-semibold text-slate-100 transition hover:bg-white/5 hover:text-amber-100 first:rounded-t-xl"
> >
Voir mon profil Voir mon profil
</a> </a>
{#if (user as any).isAdmin} {#if (user).isAdmin}
<a <a
href="/admin" href={resolve("/admin")}
onclick={closeMenu} onclick={closeMenu}
class="block border-b border-white/5 px-4 py-3 text-sm font-semibold text-amber-300 transition hover:bg-white/5 hover:text-amber-200" class="block border-b border-white/5 px-4 py-3 text-sm font-semibold text-amber-300 transition hover:bg-white/5 hover:text-amber-200"
> >
@@ -102,7 +103,7 @@
{/if} {/if}
{:else} {:else}
<a <a
href="/login" href={resolve("/login")}
class="rounded-full bg-amber-300 px-5 py-2.5 text-sm font-semibold text-slate-900 transition hover:bg-amber-200" class="rounded-full bg-amber-300 px-5 py-2.5 text-sm font-semibold text-slate-900 transition hover:bg-amber-200"
> >
Se connecter Se connecter

View File

@@ -1,31 +1,88 @@
<script lang="ts"> <script lang="ts">
export let dailyCharacter: any; import type { CharacterWithRelations } from "$lib/server/daily-character";
export let selectedCharacters: any[]; import { language, t } from '$lib/i18n';
export let selectedCharacter: CharacterWithRelations;
export let selectedCharacters: CharacterWithRelations[];
export let isGeckoMoriaWin: boolean = false; export let isGeckoMoriaWin: boolean = false;
$: isFrench = $language === 'fr';
function getDisplayName(character: CharacterWithRelations): string {
if (isFrench && typeof character.frName === 'string' && character.frName.length > 0) {
return character.frName;
}
return character.name;
}
function getWikiUrl(character: CharacterWithRelations): string {
if (isFrench && typeof character.frUrl === 'string' && character.frUrl.length > 0) {
return character.frUrl;
}
return character.url || '';
}
function getWikiBaseUrl(): string {
return isFrench ? 'https://onepiece.fandom.com/fr/wiki/' : 'https://onepiece.fandom.com/wiki/';
}
const pickMessage = (messages: readonly string[]) => messages[Math.floor(Math.random() * messages.length)];
const getAttemptMessage = (attempts: number): string => {
if (attempts <= 0) return '';
const oneTryMessages = $t.game.components.winPanel.oneTryMessages;
const twoTryMessages = $t.game.components.winPanel.twoTryMessages;
const tenPlusMessages = $t.game.components.winPanel.tenPlusMessages;
const fivePlusMessages = $t.game.components.winPanel.fivePlusMessages;
const defaultMessages = $t.game.components.winPanel.defaultMessages;
if (attempts === 1) {
return pickMessage(oneTryMessages);
}
if (attempts === 2) {
return pickMessage(twoTryMessages);
}
if (attempts >= 10) {
return pickMessage(tenPlusMessages).replace('${attempts}', String(attempts));
}
if (attempts >= 5) {
return pickMessage(fivePlusMessages).replace('${attempts}', String(attempts));
}
return pickMessage(defaultMessages);
};
$: attempts = selectedCharacters.length;
$: attemptMessage = getAttemptMessage(attempts);
$: attemptWord = selectedCharacters.length > 1
? $t.game.components.winPanel.attemptPlural
: $t.game.components.winPanel.attemptSingular;
</script> </script>
{#if isGeckoMoriaWin} {#if isGeckoMoriaWin}
<div class="rounded-3xl border border-slate-700/80 bg-slate-950/80 p-4 shadow-[0_24px_60px_rgba(0,0,0,0.8)] backdrop-blur gecko-moria-effect"> <div class="rounded-3xl border border-slate-700/80 bg-slate-950/80 p-4 shadow-[0_24px_60px_rgba(0,0,0,0.8)] backdrop-blur gecko-moria-effect">
<div class="text-center"> <div class="text-center">
<div class="text-3xl mb-2">🌑</div> <div class="text-3xl mb-2">🌑</div>
<h2 class="text-xl font-bold text-slate-300 mb-1">Moria vous contrôle...</h2> <h2 class="text-xl font-bold text-slate-300 mb-1">{$t.game.components.winPanel.moriaTitle}</h2>
<p class="text-sm text-slate-400">Vous avez succombé à l'ombre en {selectedCharacters.length} {selectedCharacters.length > 1 ? 'tentatives' : 'tentative'} !</p> <p class="text-sm text-slate-400">{$t.game.components.winPanel.moriaPrefix} {selectedCharacters.length} {attemptWord} !</p>
<p class="text-xs text-slate-300 mt-1">{attemptMessage}</p>
<div class="mt-3"> <div class="mt-3">
{#if dailyCharacter.pictureUrl} {#if selectedCharacter.pictureUrl}
<a <a
href={"https://onepiece.fandom.com/fr/wiki/" + dailyCharacter.url} href={getWikiBaseUrl() + getWikiUrl(selectedCharacter)}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
class="inline-block" class="inline-block"
> >
<img <img
src={dailyCharacter.pictureUrl} src={selectedCharacter.pictureUrl}
alt={dailyCharacter.name} alt={getDisplayName(selectedCharacter)}
class="w-20 h-20 mx-auto rounded-full border-2 border-slate-600 shadow-lg object-cover hover:border-slate-500 transition-colors cursor-pointer opacity-80" class="w-20 h-20 mx-auto rounded-full border-2 border-slate-600 shadow-lg object-cover hover:border-slate-500 transition-colors cursor-pointer opacity-80"
/> />
</a> </a>
{/if} {/if}
<p class="mt-2 text-lg font-bold text-slate-200">{dailyCharacter.name}</p> <p class="mt-2 text-lg font-bold text-slate-200">{getDisplayName(selectedCharacter)}</p>
</div> </div>
</div> </div>
</div> </div>
@@ -33,24 +90,25 @@
<div class="rounded-3xl border border-emerald-500/50 bg-emerald-500/10 p-4 shadow-[0_24px_60px_rgba(16,185,129,0.3)] backdrop-blur"> <div class="rounded-3xl border border-emerald-500/50 bg-emerald-500/10 p-4 shadow-[0_24px_60px_rgba(16,185,129,0.3)] backdrop-blur">
<div class="text-center"> <div class="text-center">
<div class="text-3xl mb-2">🎉</div> <div class="text-3xl mb-2">🎉</div>
<h2 class="text-xl font-bold text-emerald-400 mb-1">Félicitations !</h2> <h2 class="text-xl font-bold text-emerald-400 mb-1">{$t.game.components.winPanel.winTitle}</h2>
<p class="text-sm text-emerald-300">Vous avez trouvé le personnage en {selectedCharacters.length} {selectedCharacters.length > 1 ? 'tentatives' : 'tentative'} !</p> <p class="text-sm text-emerald-300">{$t.game.components.winPanel.winPrefix} {selectedCharacters.length} {attemptWord} !</p>
<p class="text-xs text-emerald-200 mt-1">{attemptMessage}</p>
<div class="mt-3"> <div class="mt-3">
{#if dailyCharacter.pictureUrl} {#if selectedCharacter.pictureUrl}
<a <a
href={"https://onepiece.fandom.com/fr/wiki/" + dailyCharacter.url} href={getWikiBaseUrl() + getWikiUrl(selectedCharacter)}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
class="inline-block" class="inline-block"
> >
<img <img
src={dailyCharacter.pictureUrl} src={selectedCharacter.pictureUrl}
alt={dailyCharacter.name} alt={getDisplayName(selectedCharacter)}
class="w-20 h-20 mx-auto rounded-full border-2 border-emerald-400 shadow-lg object-cover hover:border-emerald-300 transition-colors cursor-pointer" class="w-20 h-20 mx-auto rounded-full border-2 border-emerald-400 shadow-lg object-cover hover:border-emerald-300 transition-colors cursor-pointer"
/> />
</a> </a>
{/if} {/if}
<p class="mt-2 text-lg font-bold text-white">{dailyCharacter.name}</p> <p class="mt-2 text-lg font-bold text-white">{getDisplayName(selectedCharacter)}</p>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,5 +1,57 @@
<script lang="ts"> <script lang="ts">
export let yesterdayCharacter: any; import type { CharacterWithRelations } from "$lib/server/daily-character";
import { language, t } from '$lib/i18n';
export let yesterdayCharacter: CharacterWithRelations | null;
$: isFrench = $language === 'fr';
function parseEpithets(value: unknown): string[] {
if (Array.isArray(value)) {
return value.filter((entry): entry is string => typeof entry === 'string' && entry.length > 0);
}
if (typeof value === 'string') {
try {
const parsed = JSON.parse(value);
if (Array.isArray(parsed)) {
return parsed.filter((entry): entry is string => typeof entry === 'string' && entry.length > 0);
}
} catch {
if (value.length > 0) {
return [value];
}
}
}
return [];
}
function getDisplayName(character: CharacterWithRelations): string {
if (isFrench && typeof character.frName === 'string' && character.frName.length > 0) {
return character.frName;
}
return character.name;
}
function getDisplayEpithets(character: CharacterWithRelations): string[] {
const frenchEpithets = parseEpithets(character.frEpithets);
if (isFrench && frenchEpithets.length > 0) {
return frenchEpithets;
}
return parseEpithets(character.epithets);
}
function getWikiUrl(character: CharacterWithRelations): string {
if (isFrench && typeof character.frUrl === 'string' && character.frUrl.length > 0) {
return character.frUrl;
}
return character.url || '';
}
</script> </script>
<section class="mt-8 rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur"> <section class="mt-8 rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur">
@@ -8,43 +60,52 @@
{#if yesterdayCharacter.pictureUrl} {#if yesterdayCharacter.pictureUrl}
<img <img
src={yesterdayCharacter.pictureUrl} src={yesterdayCharacter.pictureUrl}
alt={yesterdayCharacter.name} alt={getDisplayName(yesterdayCharacter)}
class="h-20 w-20 rounded-full border border-amber-200/40 object-cover" class="h-20 w-20 rounded-full border border-amber-200/40 object-cover"
/> />
{:else} {:else}
<div class="flex h-20 w-20 items-center justify-center rounded-full border border-amber-200/40 bg-slate-900/70 text-xs uppercase tracking-[0.25em] text-amber-100"> <div class="flex h-20 w-20 items-center justify-center rounded-full border border-amber-200/40 bg-slate-900/70 text-xs uppercase tracking-[0.25em] text-amber-100">
Photo {$t.game.components.yesterdayCharacter.photo}
</div> </div>
{/if} {/if}
<div class="flex-1"> <div class="flex-1">
<p class="text-xs font-semibold uppercase tracking-[0.28em] text-amber-100">Personnage d'hier</p> <p class="text-xs font-semibold uppercase tracking-[0.28em] text-amber-100">{$t.game.components.yesterdayCharacter.title}</p>
<p class="mt-2 text-lg font-semibold text-white">{yesterdayCharacter.name}</p> <p class="mt-2 text-lg font-semibold text-white">{getDisplayName(yesterdayCharacter)}</p>
{#if yesterdayCharacter.epithets} {#if getDisplayEpithets(yesterdayCharacter).length > 0}
<p class="mt-1 text-sm text-slate-400"> <p class="mt-1 text-sm text-slate-400">
{typeof yesterdayCharacter.epithets === 'string' {getDisplayEpithets(yesterdayCharacter).join(', ')}
? JSON.parse(yesterdayCharacter.epithets).join(', ')
: (yesterdayCharacter.epithets as string[]).join(', ')}
</p> </p>
{/if} {/if}
</div> </div>
{#if isFrench}
<a <a
href={"https://onepiece.fandom.com/fr/wiki/" + yesterdayCharacter.url} href="https://onepiece.fandom.com/fr/wiki/{getWikiUrl(yesterdayCharacter)}"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
class="w-full rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50 sm:w-auto" class="w-full rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50 sm:w-auto"
> >
Voir la page {$t.game.components.yesterdayCharacter.openPage}
</a> </a>
{:else}
<a
href="https://onepiece.fandom.com/wiki/{getWikiUrl(yesterdayCharacter)}"
target="_blank"
rel="noopener noreferrer"
class="w-full rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50 sm:w-auto"
>
{$t.game.components.yesterdayCharacter.openPage}
</a>
{/if}
</div> </div>
{:else} {:else}
<div class="flex flex-col items-center gap-5 text-center sm:flex-row sm:text-left"> <div class="flex flex-col items-center gap-5 text-center sm:flex-row sm:text-left">
<div class="flex h-20 w-20 items-center justify-center rounded-full border border-amber-200/40 bg-slate-900/70 text-xs uppercase tracking-[0.25em] text-amber-100"> <div class="flex h-20 w-20 items-center justify-center rounded-full border border-amber-200/40 bg-slate-900/70 text-xs uppercase tracking-[0.25em] text-amber-100">
Photo {$t.game.components.yesterdayCharacter.photo}
</div> </div>
<div class="flex-1"> <div class="flex-1">
<p class="text-xs font-semibold uppercase tracking-[0.28em] text-amber-100">Personnage d'hier</p> <p class="text-xs font-semibold uppercase tracking-[0.28em] text-amber-100">{$t.game.components.yesterdayCharacter.title}</p>
<p class="mt-2 text-lg font-semibold text-white">Aucun personnage</p> <p class="mt-2 text-lg font-semibold text-white">{$t.game.components.yesterdayCharacter.none}</p>
<p class="mt-1 text-sm text-slate-200">Aucun personnage d'hier disponible</p> <p class="mt-1 text-sm text-slate-200">{$t.game.components.yesterdayCharacter.noneAvailable}</p>
</div> </div>
</div> </div>
{/if} {/if}

233
src/lib/i18n/en.json Normal file
View File

@@ -0,0 +1,233 @@
{
"common": {
"language": "Language",
"selectLanguage": "Select Language",
"english": "English",
"french": "Français",
"german": "Deutsch",
"spanish": "Español"
},
"game": {
"home": {
"heroDescription": "Guess the character from pirate crews, marines, or the wider world. Every hint brings you closer to the treasure.",
"dailyTitle": "Daily Character",
"dailySubtitle": "A new mystery every 24 hours",
"dailyDescription": "Compare your guesses, unlock hints, and keep your streak alive.",
"dailyCta": "Start",
"infiniteTitle": "Infinite Mode",
"infiniteSubtitle": "Endless challenges",
"infiniteDescription": "Chain characters and chase your score. No limits, only fun.",
"infiniteCta": "Play",
"photoFallback": "Photo",
"yesterdayCharacter": "Yesterday's character",
"openPage": "Open page",
"noCharacter": "No character",
"noYesterdayCharacter": "No character from yesterday available"
},
"login": {
"titleSignUp": "Sign Up",
"titleSignIn": "Sign In",
"headerSignUp": "Create your account",
"headerSignIn": "Welcome, pirate",
"nameLabel": "Name",
"namePlaceholder": "Your name",
"usernameLabel": "Username",
"usernamePlaceholder": "e.g. luffy_gear5",
"identifierLabelSignUp": "Email",
"identifierLabelSignIn": "Email or username",
"identifierPlaceholderSignUp": "yourmail@email.com",
"identifierPlaceholderSignIn": "yourmail@email.com or luffy_gear5",
"passwordLabel": "Password",
"confirmPasswordLabel": "Confirm password",
"loading": "Loading...",
"submitSignUp": "Create an account",
"submitSignIn": "Log in",
"togglePromptSignUp": "Already have an account?",
"togglePromptSignIn": "Don't have an account?",
"toggleActionSignUp": "Log in",
"toggleActionSignIn": "Sign up",
"backHome": "Back to home"
},
"profile": {
"pageTitle": "My Profile",
"headerTitle": "My Profile",
"headerSubtitle": "Edit your profile information",
"tabProfile": "Profile",
"tabPassword": "Password",
"tabDaily": "Daily History",
"tabSessions": "Sessions",
"tabFriends": "Friends",
"avatarFallbackAlt": "Profile",
"email": "Email",
"displayName": "Display name",
"displayNamePlaceholder": "Your name",
"profileUpdateSuccess": "Profile updated successfully!",
"updating": "Updating...",
"saveChanges": "Save changes",
"friendsTitle": "Friends System",
"addFriendByUsername": "Add a friend by username",
"friendUsernamePlaceholder": "e.g. luffy_gear5",
"sending": "Sending...",
"send": "Send",
"incomingRequests": "Incoming requests",
"noIncomingRequests": "No incoming requests.",
"accept": "Accept",
"decline": "Decline",
"outgoingRequests": "Outgoing requests",
"noOutgoingRequests": "No outgoing requests.",
"cancel": "Cancel",
"myFriends": "My friends",
"noFriends": "You don't have any friends yet.",
"remove": "Remove",
"changePasswordTitle": "Change password",
"currentPassword": "Current password",
"newPassword": "New password",
"confirmPassword": "Confirm password",
"passwordChangeSuccess": "Password changed successfully!",
"changing": "Changing...",
"changePassword": "Change password",
"dailyHistoryTitle": "Daily history",
"noDailyHistory": "No history available",
"triedCharactersTitle": "Tried characters",
"noTriedCharacters": "No characters recorded",
"noImage": "N/A",
"trySingular": "try",
"tryPlural": "tries",
"activeSessionsTitle": "Active sessions",
"noActiveSessions": "No active session",
"unknownDevice": "Unknown device",
"unknown": "Unknown",
"ip": "IP",
"created": "Created",
"terminate": "Terminate",
"backHome": "Back to home"
},
"daily": {
"metaTitle": "OnePieceDle - Daily Mode",
"title": "Daily Character",
"winsPeopleSingular": "person",
"winsPeoplePlural": "people",
"winsVerbSingular": "has",
"winsVerbPlural": "have",
"winsSuffix": "found it today 🎉",
"reset": "Play again",
"description": "Guess the character. Each hint unlocks after a certain number of guesses. Good luck!",
"friendsToday": "Your friends today",
"friendsTriedCharacters": "Tried characters",
"friendsNoTriedCharacters": "No characters recorded",
"friendTrySingular": "try",
"friendTryPlural": "tries"
},
"infinite": {
"metaTitle": "OnePieceDle - Infinite Mode",
"title": "Infinite Mode",
"score": "Score",
"resetScore": "Reset",
"description": "Guess characters endlessly. Each hint unlocks after a certain number of guesses. Good luck!",
"nextCharacter": "Play again",
"revealAnswer": "Reveal answer",
"loadingCharacter": "Loading character...",
"filtersTitle": "Character filters",
"clearFilters": "Reset",
"filterGender": "Gender",
"filterStatus": "Status",
"filterAbilities": "Abilities",
"filterInformation": "Information",
"filterArcs": "Arcs",
"male": "Male",
"female": "Female",
"alive": "Alive",
"dead": "Dead",
"unknown": "Unknown",
"hasHaki": "Has Haki",
"fruitAll": "Fruit (All)",
"withFruit": "With Fruit",
"withoutFruit": "Without Fruit",
"heightDefined": "Height defined",
"ageDefined": "Age defined",
"originDefined": "Origin defined",
"availableCharactersSingular": "character available",
"availableCharactersPlural": "characters available",
"columnsTitle": "Columns"
},
"components": {
"searchInput": {
"title": "Enter a guess",
"placeholder": "Character name",
"submit": "Submit"
},
"hints": {
"origin": "Origin",
"devilFruit": "Devil fruit",
"affiliation": "Affiliation",
"unknown": "Unknown",
"none": "None",
"beforeUnlock": "guesses before unlock",
"available": "Hint available!"
},
"guessHistory": {
"title": "History",
"empty": "No guesses yet.",
"character": "Character",
"status": "Status",
"gender": "Gender",
"affiliations": "Affiliations",
"fruit": "Fruit",
"haki": "Haki",
"bounty": "Bounty",
"height": "Height",
"age": "Age",
"origin": "Origin",
"arc": "Arc",
"alive": "Alive",
"dead": "Dead",
"unknown": "Unknown",
"male": "Male",
"female": "Female",
"obsHakiTitle": "Observation Haki",
"armHakiTitle": "Armament Haki",
"kingHakiTitle": "Conqueror's Haki"
},
"winPanel": {
"attemptSingular": "attempt",
"attemptPlural": "attempts",
"moriaTitle": "Moria controls you...",
"moriaPrefix": "You succumbed to the shadows in",
"winTitle": "Congratulations!",
"winPrefix": "You found the character in",
"oneTryMessages": [
"Cheater 👀",
"1 guess? Admit it, you already knew 😏",
"First try... suspicious 🤨"
],
"twoTryMessages": [
"Well played! ⚡",
"Two guesses, clean! 👏",
"You warmed up fast, nice 🔥"
],
"tenPlusMessages": [
"${attempts} guesses... even a transponder snail would be faster 📞",
"${attempts} attempts? The Grand Line is shorter than that 😵",
"${attempts} guesses: legendary performance... in the wrong direction 🫠"
],
"fivePlusMessages": [
"${attempts} guesses? Let's say it was for suspense 😅",
"That is a lot of guesses... but you made it 😬",
"You never give up, even after several guesses 😂"
],
"defaultMessages": [
"Not bad at all!",
"Nice try, good pace 👍",
"Things are going well, keep it up ✨"
]
},
"yesterdayCharacter": {
"photo": "Photo",
"title": "Yesterday's character",
"openPage": "Open page",
"none": "No character",
"noneAvailable": "No character from yesterday available"
}
}
}
}

233
src/lib/i18n/fr.json Normal file
View File

@@ -0,0 +1,233 @@
{
"common": {
"language": "Langue",
"selectLanguage": "Sélectionnez la Langue",
"english": "English",
"french": "Français",
"german": "Deutsch",
"spanish": "Español"
},
"game": {
"home": {
"heroDescription": "Devine le personnage de l'equipage, des marines ou du vaste monde. Chaque indice te rapproche du tresor.",
"dailyTitle": "Personnage du jour",
"dailySubtitle": "Nouveau mystere toutes les 24 heures",
"dailyDescription": "Compare tes essais, debloque des indices et garde ta serie.",
"dailyCta": "Commencer",
"infiniteTitle": "Mode Infini",
"infiniteSubtitle": "Des defis sans fin",
"infiniteDescription": "Enchaine les personnages et croise ton score. Pas de limite, que du plaisir.",
"infiniteCta": "Jouer",
"photoFallback": "Photo",
"yesterdayCharacter": "Personnage d'hier",
"openPage": "Voir la page",
"noCharacter": "Aucun personnage",
"noYesterdayCharacter": "Aucun personnage d'hier disponible"
},
"login": {
"titleSignUp": "Inscription",
"titleSignIn": "Connexion",
"headerSignUp": "Creer votre compte",
"headerSignIn": "Bienvenue, pirate",
"nameLabel": "Nom",
"namePlaceholder": "Votre nom",
"usernameLabel": "Nom d'utilisateur",
"usernamePlaceholder": "ex: luffy_gear5",
"identifierLabelSignUp": "E-mail",
"identifierLabelSignIn": "E-mail ou nom d'utilisateur",
"identifierPlaceholderSignUp": "votremail@email.com",
"identifierPlaceholderSignIn": "votremail@email.com ou luffy_gear5",
"passwordLabel": "Mot de passe",
"confirmPasswordLabel": "Confirmer le mot de passe",
"loading": "Chargement...",
"submitSignUp": "Creer un compte",
"submitSignIn": "Se connecter",
"togglePromptSignUp": "Vous avez deja un compte ?",
"togglePromptSignIn": "Vous n'avez pas de compte ?",
"toggleActionSignUp": "Se connecter",
"toggleActionSignIn": "S'inscrire",
"backHome": "Retour a l'accueil"
},
"profile": {
"pageTitle": "Mon Profil",
"headerTitle": "Mon Profil",
"headerSubtitle": "Modifie les informations de ton profil",
"tabProfile": "Profil",
"tabPassword": "Mot de passe",
"tabDaily": "Historique Daily",
"tabSessions": "Sessions",
"tabFriends": "Amis",
"avatarFallbackAlt": "Profil",
"email": "Email",
"displayName": "Nom d'affichage",
"displayNamePlaceholder": "Ton nom",
"profileUpdateSuccess": "Profil mis a jour avec succes !",
"updating": "Mise a jour...",
"saveChanges": "Enregistrer les modifications",
"friendsTitle": "Systeme d'amis",
"addFriendByUsername": "Ajouter un ami par nom d'utilisateur",
"friendUsernamePlaceholder": "ex: luffy_gear5",
"sending": "Envoi...",
"send": "Envoyer",
"incomingRequests": "Demandes recues",
"noIncomingRequests": "Aucune demande recue.",
"accept": "Accepter",
"decline": "Refuser",
"outgoingRequests": "Demandes envoyees",
"noOutgoingRequests": "Aucune demande envoyee.",
"cancel": "Annuler",
"myFriends": "Mes amis",
"noFriends": "Tu n'as pas encore d'amis.",
"remove": "Supprimer",
"changePasswordTitle": "Changer le mot de passe",
"currentPassword": "Mot de passe actuel",
"newPassword": "Nouveau mot de passe",
"confirmPassword": "Confirmer le mot de passe",
"passwordChangeSuccess": "Mot de passe change avec succes !",
"changing": "Changement en cours...",
"changePassword": "Changer le mot de passe",
"dailyHistoryTitle": "Historique des Daily",
"noDailyHistory": "Aucun historique disponible",
"triedCharactersTitle": "Personnages essayes",
"noTriedCharacters": "Aucun personnage enregistre",
"noImage": "N/A",
"trySingular": "tentative",
"tryPlural": "tentatives",
"activeSessionsTitle": "Sessions actives",
"noActiveSessions": "Aucune session active",
"unknownDevice": "Appareil inconnu",
"unknown": "Inconnue",
"ip": "IP",
"created": "Creee",
"terminate": "Terminer",
"backHome": "Retour a l'accueil"
},
"daily": {
"metaTitle": "OnePieceDle - Mode du jour",
"title": "Personnage du jour",
"winsPeopleSingular": "personne",
"winsPeoplePlural": "personnes",
"winsVerbSingular": "a",
"winsVerbPlural": "ont",
"winsSuffix": "trouve aujourd'hui 🎉",
"reset": "Recommencer",
"description": "Devine le personnage. Chaque indice se debloque apres un certain nombre de tentatives. Bonne chance !",
"friendsToday": "Tes amis aujourd'hui",
"friendsTriedCharacters": "Personnages essayes",
"friendsNoTriedCharacters": "Aucun personnage enregistre",
"friendTrySingular": "coup",
"friendTryPlural": "coups"
},
"infinite": {
"metaTitle": "OnePieceDle - Mode Infini",
"title": "Mode Infini",
"score": "Score",
"resetScore": "Reinitialiser",
"description": "Devine des personnages a l'infini ! Chaque indice se debloque apres un certain nombre de tentatives. Bonne chance !",
"nextCharacter": "Recommencer",
"revealAnswer": "Reveler la reponse",
"loadingCharacter": "Chargement du personnage...",
"filtersTitle": "Filtres de personnages",
"clearFilters": "Reinitialiser",
"filterGender": "Genre",
"filterStatus": "Statut",
"filterAbilities": "Capacites",
"filterInformation": "Informations",
"filterArcs": "Arcs",
"male": "Homme",
"female": "Femme",
"alive": "Vivant",
"dead": "Mort",
"unknown": "Inconnu",
"hasHaki": "A du Haki",
"fruitAll": "Fruit (Tous)",
"withFruit": "Avec Fruit",
"withoutFruit": "Sans Fruit",
"heightDefined": "Taille definie",
"ageDefined": "Age defini",
"originDefined": "Origine definie",
"availableCharactersSingular": "personnage disponible",
"availableCharactersPlural": "personnages disponibles",
"columnsTitle": "Colonnes"
},
"components": {
"searchInput": {
"title": "Entrer une supposition",
"placeholder": "Nom du personnage",
"submit": "Valider"
},
"hints": {
"origin": "Origine",
"devilFruit": "Fruit du demon",
"affiliation": "Affiliation",
"unknown": "Inconnue",
"none": "Aucun",
"beforeUnlock": "essais avant deblocage",
"available": "Indice disponible !"
},
"guessHistory": {
"title": "Historique",
"empty": "Aucune tentative pour le moment.",
"character": "Personnage",
"status": "Statut",
"gender": "Genre",
"affiliations": "Affiliations",
"fruit": "Fruit",
"haki": "Haki",
"bounty": "Prime",
"height": "Taille",
"age": "Age",
"origin": "Origine",
"arc": "Arc",
"alive": "Vivant",
"dead": "Mort",
"unknown": "Inconnu",
"male": "Homme",
"female": "Femme",
"obsHakiTitle": "Haki de l'Observation",
"armHakiTitle": "Haki de l'Armement",
"kingHakiTitle": "Haki des Rois"
},
"winPanel": {
"attemptSingular": "tentative",
"attemptPlural": "tentatives",
"moriaTitle": "Moria vous controle...",
"moriaPrefix": "Vous avez succombe a l'ombre en",
"winTitle": "Felicitations !",
"winPrefix": "Vous avez trouve le personnage en",
"oneTryMessages": [
"Tricheur 👀",
"1 essai ? Avoue, tu avais la reponse 😏",
"Premier coup direct... suspect 🤨"
],
"twoTryMessages": [
"Bien joue ! ⚡",
"Deux essais, propre ! 👏",
"Tu chauffes vite, bien joue 🔥"
],
"tenPlusMessages": [
"${attempts} essais... meme un escargophone aurait trouve plus vite 📞",
"${attempts} tentatives ? Le Grand Line est moins long que ca 😵",
"${attempts} essais : performance legendaire... dans le mauvais sens 🫠"
],
"fivePlusMessages": [
"${attempts} essais ? On va dire que c'etait pour le suspense 😅",
"Ca en fait des essais... mais au moins tu y es arrive 😬",
"Tu ne laches rien, meme apres plusieurs essais 😂"
],
"defaultMessages": [
"Pas mal du tout !",
"Bien tente, bon rythme 👍",
"Ca se passe bien, continue comme ca ✨"
]
},
"yesterdayCharacter": {
"photo": "Photo",
"title": "Personnage d'hier",
"openPage": "Voir la page",
"none": "Aucun personnage",
"noneAvailable": "Aucun personnage d'hier disponible"
}
}
}
}

51
src/lib/i18n/index.ts Normal file
View File

@@ -0,0 +1,51 @@
import { writable, derived } from 'svelte/store';
import type { Writable, Readable } from 'svelte/store';
import en from './en.json';
import fr from './fr.json';
type Messages = typeof en;
const translations: Record<string, Messages> = { en, fr };
// Get initial language
function getInitialLanguage(): string {
if (typeof window !== 'undefined') {
const stored = localStorage.getItem('language');
if (stored && stored in translations) {
return stored;
}
const browserLang = navigator.language.split('-')[0];
if (browserLang in translations) {
return browserLang;
}
}
return 'en';
}
// Create writable store for the current language
export const language: Writable<string> = writable(getInitialLanguage());
// Create derived store for the current messages
export const t: Readable<Messages> = derived(language, ($language) => {
return translations[$language] || translations['en'];
});
export function setLanguage(lang: string) {
if (lang in translations) {
if (typeof window !== 'undefined') {
localStorage.setItem('language', lang);
}
language.set(lang);
}
}
export function getLanguage(): string {
let currentLang = 'en';
language.subscribe((lang) => {
currentLang = lang;
})();
return currentLang;
}
export const availableLanguages = Object.keys(translations);

View File

@@ -9,6 +9,15 @@ export const auth = betterAuth({
baseURL: env.ORIGIN, baseURL: env.ORIGIN,
secret: env.BETTER_AUTH_SECRET || 'secret', secret: env.BETTER_AUTH_SECRET || 'secret',
database: drizzleAdapter(db, { provider: 'sqlite' }), database: drizzleAdapter(db, { provider: 'sqlite' }),
user: {
additionalFields: {
username: {
type: 'string',
required: true,
unique: true
}
}
},
emailAndPassword: { enabled: true }, emailAndPassword: { enabled: true },
plugins: [sveltekitCookies(getRequestEvent)] // make sure this is the last plugin in the array plugins: [sveltekitCookies(getRequestEvent)] // make sure this is the last plugin in the array
}); });

View File

@@ -1,6 +1,6 @@
import { db } from '$lib/server/db'; import { db } from '$lib/server/db';
import { arc, character, characterHistory, characterOverride, devilFruit } from '$lib/server/db/schema'; import { arc, character, characterHistory, devilFruit, type Character } from '$lib/server/db/schema';
import { desc, eq, inArray, and } from 'drizzle-orm'; import { desc, eq, and } from 'drizzle-orm';
// Generate or get random seed for daily character selection // Generate or get random seed for daily character selection
const RANDOM_SEED = Math.random(); const RANDOM_SEED = Math.random();
@@ -8,9 +8,11 @@ const RANDOM_SEED = Math.random();
const characterWithRelationsSelect = { const characterWithRelationsSelect = {
id: character.id, id: character.id,
name: character.name, name: character.name,
frName: character.frName,
gender: character.gender, gender: character.gender,
age: character.age, age: character.age,
affiliations: character.affiliations, affiliation: character.affiliation,
frAffiliation: character.frAffiliation,
devilFruitId: character.devilFruitId, devilFruitId: character.devilFruitId,
devilFruitName: devilFruit.name, devilFruitName: devilFruit.name,
devilFruitType: devilFruit.type, devilFruitType: devilFruit.type,
@@ -20,23 +22,26 @@ const characterWithRelationsSelect = {
bounty: character.bounty, bounty: character.bounty,
height: character.height, height: character.height,
origin: character.origin, origin: character.origin,
frOrigin: character.frOrigin,
firstAppearance: character.firstAppearance, firstAppearance: character.firstAppearance,
pictureUrl: character.pictureUrl, pictureUrl: character.pictureUrl,
epithets: character.epithets, epithets: character.epithets,
frEpithets: character.frEpithets,
status: character.status, status: character.status,
url: character.url, url: character.url,
frUrl: character.frUrl,
arcId: character.arcId, arcId: character.arcId,
arcName: arc.name arcName: arc.name,
frArcName: arc.frName,
}; };
export type CharacterWithRelations = typeof character.$inferSelect & { export type CharacterWithRelations = Character & {
devilFruitName: string | null; devilFruitName: string | null;
devilFruitType: string | null; devilFruitType: string | null;
arcName: string | null; arcName: string | null;
frArcName: string | null;
}; };
type CharacterOverrideRow = typeof characterOverride.$inferSelect;
type RelationMaps = { type RelationMaps = {
arcNameById: Map<string, string | null>; arcNameById: Map<string, string | null>;
devilFruitById: Map<string, { name: string | null; type: string | null }>; devilFruitById: Map<string, { name: string | null; type: string | null }>;
@@ -46,102 +51,6 @@ function isNotNullish<T>(value: T | null | undefined): value is T {
return value !== null && value !== undefined; return value !== null && value !== undefined;
} }
function mergeCharacterWithOverride(
baseCharacter: CharacterWithRelations,
overrideRow?: CharacterOverrideRow,
relationMaps?: RelationMaps
): CharacterWithRelations {
if (!overrideRow) {
return baseCharacter;
}
const mergedCharacter = { ...baseCharacter } as CharacterWithRelations;
for (const [key, value] of Object.entries(overrideRow)) {
if (key === 'characterId' || key === 'notes') {
continue;
}
if (isNotNullish(value)) {
(mergedCharacter as Record<string, unknown>)[key] = value;
}
}
if (relationMaps) {
if (mergedCharacter.arcId) {
mergedCharacter.arcName = relationMaps.arcNameById.get(mergedCharacter.arcId) ?? null;
} else {
mergedCharacter.arcName = null;
}
if (mergedCharacter.devilFruitId) {
const devilFruitData = relationMaps.devilFruitById.get(mergedCharacter.devilFruitId);
mergedCharacter.devilFruitName = devilFruitData?.name ?? null;
mergedCharacter.devilFruitType = devilFruitData?.type ?? null;
} else {
mergedCharacter.devilFruitName = null;
mergedCharacter.devilFruitType = null;
}
}
return mergedCharacter;
}
async function applyCharacterOverrides(
characters: CharacterWithRelations[]
): Promise<CharacterWithRelations[]> {
if (characters.length === 0) {
return characters;
}
const characterIds = characters.map((currentCharacter) => currentCharacter.id);
const overrideRows = await db
.select()
.from(characterOverride)
.where(inArray(characterOverride.characterId, characterIds));
if (overrideRows.length === 0) {
return characters;
}
const overrideByCharacterId = new Map<string, CharacterOverrideRow>(
overrideRows.map((overrideRow) => [overrideRow.characterId, overrideRow])
);
const shouldRefreshRelations = overrideRows.some(
(overrideRow) => isNotNullish(overrideRow.arcId) || isNotNullish(overrideRow.devilFruitId)
);
let relationMaps: RelationMaps | undefined;
if (shouldRefreshRelations) {
const [allArcs, allDevilFruits] = await Promise.all([
db.select({ id: arc.id, name: arc.name }).from(arc),
db
.select({ id: devilFruit.id, name: devilFruit.name, type: devilFruit.type })
.from(devilFruit)
]);
relationMaps = {
arcNameById: new Map(allArcs.map((currentArc) => [currentArc.id, currentArc.name])),
devilFruitById: new Map(
allDevilFruits.map((currentDevilFruit) => [
currentDevilFruit.id,
{ name: currentDevilFruit.name, type: currentDevilFruit.type }
])
)
};
}
return characters.map((currentCharacter) =>
mergeCharacterWithOverride(
currentCharacter,
overrideByCharacterId.get(currentCharacter.id),
relationMaps
)
);
}
export function getDateKey(date: Date): number { export function getDateKey(date: Date): number {
return normalizeDay(date).getTime(); return normalizeDay(date).getTime();
} }
@@ -161,26 +70,22 @@ function pickDailyCharacter(characters: CharacterWithRelations[], date: Date): C
} }
export async function getDailyModeCharacters(): Promise<CharacterWithRelations[]> { export async function getDailyModeCharacters(): Promise<CharacterWithRelations[]> {
const characters = (await db return (await db
.select(characterWithRelationsSelect) .select(characterWithRelationsSelect)
.from(character) .from(character)
.leftJoin(arc, eq(character.arcId, arc.id)) .leftJoin(arc, eq(character.arcId, arc.id))
.leftJoin(devilFruit, eq(character.devilFruitId, devilFruit.id)) .leftJoin(devilFruit, eq(character.devilFruitId, devilFruit.id))
.where(eq(character.isInDailyMode, true)) .where(eq(character.isInDailyMode, true))
.all()) as CharacterWithRelations[]; .all()) as CharacterWithRelations[];
return applyCharacterOverrides(characters);
} }
export async function getAllCharacters(): Promise<CharacterWithRelations[]> { export async function getAllCharacters(): Promise<CharacterWithRelations[]> {
const characters = (await db return (await db
.select(characterWithRelationsSelect) .select(characterWithRelationsSelect)
.from(character) .from(character)
.leftJoin(arc, eq(character.arcId, arc.id)) .leftJoin(arc, eq(character.arcId, arc.id))
.leftJoin(devilFruit, eq(character.devilFruitId, devilFruit.id)) .leftJoin(devilFruit, eq(character.devilFruitId, devilFruit.id))
.all()) as CharacterWithRelations[]; .all()) as CharacterWithRelations[];
return applyCharacterOverrides(characters);
} }
export async function getCharacterById(characterId: string): Promise<CharacterWithRelations | null> { export async function getCharacterById(characterId: string): Promise<CharacterWithRelations | null> {
@@ -196,8 +101,7 @@ export async function getCharacterById(characterId: string): Promise<CharacterWi
return null; return null;
} }
const [overriddenCharacter] = await applyCharacterOverrides([found as CharacterWithRelations]); return found as CharacterWithRelations
return overriddenCharacter ?? null;
} }
export async function getOrCreateTodayCharacter( export async function getOrCreateTodayCharacter(

View File

@@ -4,6 +4,7 @@ import { sqliteTable, text, integer, index } from "drizzle-orm/sqlite-core";
export const user = sqliteTable("user", { export const user = sqliteTable("user", {
id: text("id").primaryKey(), id: text("id").primaryKey(),
name: text("name").notNull(), name: text("name").notNull(),
username: text("username").notNull().unique(),
email: text("email").notNull().unique(), email: text("email").notNull().unique(),
emailVerified: integer("email_verified", { mode: "boolean" }) emailVerified: integer("email_verified", { mode: "boolean" })
.default(false) .default(false)

View File

@@ -1,7 +1,12 @@
import { integer, sqliteTable, text, real } from 'drizzle-orm/sqlite-core'; import { integer, sqliteTable, text, real, unique } from 'drizzle-orm/sqlite-core';
import { user } from './auth.schema';
import type { InferSelectModel } from 'drizzle-orm';
// Define devil fruit types // Define devil fruit types
export type DevilFruitType = 'Paramecia' | 'Zoan' | 'Logia' | 'Unknown'; export type DevilFruitType = 'Paramecia' | 'Zoan' | 'Logia' | 'Smile' | 'Unknown';
export type Status = 'Alive' | 'Dead' | 'Unknown';
export type FriendshipStatus = 'pending' | 'accepted' | 'declined';
// Define the site config table schema // Define the site config table schema
export const config = sqliteTable('config', { export const config = sqliteTable('config', {
@@ -13,98 +18,132 @@ export const config = sqliteTable('config', {
export const arc = sqliteTable('arc', { export const arc = sqliteTable('arc', {
id: text('id').primaryKey(), id: text('id').primaryKey(),
name: text('name').notNull(), name: text('name').notNull(),
startChapter: integer('startChapter').notNull(), frName: text('fr_name'),
endChapter: integer('endChapter'), startChapter: integer('start_chapter').notNull(),
endChapter: integer('end_chapter'),
url: text('url') url: text('url')
}); });
export type Arc = InferSelectModel<typeof arc>;
// Define the devil fruit table schema // Define the devil fruit table schema
export const devilFruit = sqliteTable('devilFruit', { export const devilFruit = sqliteTable('devil_fruit', {
id: text('id').primaryKey(), id: text('id').primaryKey(),
name: text('name').notNull().unique(), name: text('name').notNull().unique(),
type: text('type').$type<DevilFruitType>(), type: text('type').$type<DevilFruitType>(),
url: text('url') url: text('url')
}); });
export type DevilFruit = InferSelectModel<typeof devilFruit>;
// Define the character table schema // Define the character table schema
export const character = sqliteTable('character', { export const character = sqliteTable('character', {
id: text('id').primaryKey(), id: text('id').primaryKey(),
name: text('name').notNull(), name: text('name').notNull(),
frName: text('fr_name'),
gender: text('gender'), gender: text('gender'),
age: integer('age'), age: integer('age'),
affiliations: text('affiliations', { mode: 'json' }).$type<string[]>(), affiliation: text('affiliation'),
devilFruitId: text('devilFruitId').references(() => devilFruit.id), frAffiliation: text('fr_affiliation'),
hakiObservation: integer('hakiObservation', { mode: 'boolean' }).default(false), devilFruitId: text('devil_fruit_id').references(() => devilFruit.id),
hakiArmament: integer('hakiArmament', { mode: 'boolean' }).default(false), hakiObservation: integer('haki_observation', { mode: 'boolean' }).default(false),
hakiConqueror: integer('hakiConqueror', { mode: 'boolean' }).default(false), hakiArmament: integer('haki_armament', { mode: 'boolean' }).default(false),
hakiConqueror: integer('haki_conqueror', { mode: 'boolean' }).default(false),
bounty: integer('bounty').default(0), bounty: integer('bounty').default(0),
height: real('height'), height: real('height'),
origin: text('origin'), origin: text('origin'),
firstAppearance: integer('firstAppearance').notNull(), frOrigin: text('fr_origin'),
pictureUrl: text('pictureUrl'), firstAppearance: integer('first_appearance').notNull(),
pictureUrl: text('picture_url'),
epithets: text('epithets', { mode: 'json' }).$type<string[]>(), epithets: text('epithets', { mode: 'json' }).$type<string[]>(),
status: text('status'), frEpithets: text('fr_epithets', { mode: 'json' }).$type<string[]>(),
arcId: text('arcId').references(() => arc.id), status: text('status').$type<Status | null>(),
arcId: text('arc_id').references(() => arc.id, { onDelete: 'set null' }),
url: text('url'), url: text('url'),
isInDailyMode: integer('isInDailyMode', { mode: 'boolean' }).default(true) frUrl: text('fr_url'),
isInDailyMode: integer('is_in_daily_mode', { mode: 'boolean' }).default(false)
}); });
// Define the character override table schema export type Character = InferSelectModel<typeof character>;
export const characterOverride = sqliteTable('characterOverride', {
characterId: text('characterId').primaryKey().references(() => character.id),
name: text('name'),
gender: text('gender'),
age: integer('age'),
affiliations: text('affiliations', { mode: 'json' }).$type<string[]>(),
devilFruitId: text('devilFruitId').references(() => devilFruit.id),
hakiObservation: integer('hakiObservation', { mode: 'boolean' }),
hakiArmament: integer('hakiArmament', { mode: 'boolean' }),
hakiConqueror: integer('hakiConqueror', { mode: 'boolean' }),
bounty: integer('bounty'),
height: real('height'),
origin: text('origin'),
firstAppearance: integer('firstAppearance'),
pictureUrl: text('pictureUrl'),
epithets: text('epithets', { mode: 'json' }).$type<string[]>(),
status: text('status'),
arcId: text('arcId').references(() => arc.id),
url: text('url'),
notes: text('notes')
});
// Define the character scrape validation table schema // Define the character scrape validation table schema
export const characterScrapeValidation = sqliteTable('characterScrapeValidation', { export const characterScrapeValidation = sqliteTable('character_scrape_validation', {
id: text('id').primaryKey(), id: text('id').primaryKey(),
name: text('name').notNull(), name: text('name').notNull(),
frName: text('fr_name'),
gender: text('gender'), gender: text('gender'),
age: integer('age'), age: integer('age'),
affiliations: text('affiliations', { mode: 'json' }).$type<string[]>(), affiliation: text('affiliation'),
devilFruitId: text('devilFruitId').references(() => devilFruit.id), frAffiliation: text('fr_affiliation'),
hakiObservation: integer('hakiObservation', { mode: 'boolean' }).default(false), devilFruitId: text('devil_fruit_id').references(() => devilFruit.id, { onDelete: 'set null' }),
hakiArmament: integer('hakiArmament', { mode: 'boolean' }).default(false), hakiObservation: integer('haki_observation', { mode: 'boolean' }).default(false),
hakiConqueror: integer('hakiConqueror', { mode: 'boolean' }).default(false), hakiArmament: integer('haki_armament', { mode: 'boolean' }).default(false),
hakiConqueror: integer('haki_conqueror', { mode: 'boolean' }).default(false),
bounty: integer('bounty'), bounty: integer('bounty'),
height: real('height'), height: real('height'),
origin: text('origin'), origin: text('origin'),
firstAppearance: integer('firstAppearance').notNull(), frOrigin: text('fr_origin'),
pictureUrl: text('pictureUrl'), firstAppearance: integer('first_appearance').notNull(),
pictureUrl: text('picture_url'),
epithets: text('epithets', { mode: 'json' }).$type<string[]>(), epithets: text('epithets', { mode: 'json' }).$type<string[]>(),
status: text('status'), frEpithets: text('fr_epithets', { mode: 'json' }).$type<string[]>(),
arcId: text('arcId').references(() => arc.id), status: text('status').$type<Status | null>(),
url: text('url') arcId: text('arc_id').references(() => arc.id, { onDelete: 'set null' }),
url: text('url'),
frUrl: text('fr_url'),
isDeleted: integer('is_deleted', { mode: 'boolean' }).default(false),
}); });
// Define the caracter history table schema export type CharacterScrapeValidation = InferSelectModel<typeof characterScrapeValidation>;
export const characterHistory = sqliteTable('characterHistory', {
// Define the character history table schema
export const characterHistory = sqliteTable('character_history', {
id: text('id') id: text('id')
.primaryKey() .primaryKey()
.$defaultFn(() => crypto.randomUUID()), .$defaultFn(() => crypto.randomUUID()),
characterId: text('characterId').references(() => character.id), characterId: text('character_id').references(() => character.id, { onDelete: 'cascade' }),
date: integer('date').notNull().unique(), date: integer('date').notNull().unique(),
won: integer('won').notNull().default(0), won: integer('won').notNull().default(0),
createdAt: integer('createdAt').notNull().$default(() => Date.now()), createdAt: integer('created_at').notNull().$default(() => Date.now()),
updatedAt: integer('updatedAt').notNull().$default(() => Date.now()), updatedAt: integer('updated_at').notNull().$default(() => Date.now()),
}); });
export type CharacterHistory = InferSelectModel<typeof characterHistory>;
// Define the user character history table schema
export const userCharacterHistory = sqliteTable('user_character_history', {
id: text('id')
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
userId: text('user_id').references(() => user.id, { onDelete: 'cascade' }),
characterHistoryId: text('character_history_id').references(() => characterHistory.id, { onDelete: 'cascade' }),
tryCount: integer('try_count').notNull(),
triedCharacterIds: text('tried_character_ids', { mode: 'json' }).$type<string[]>(),
createdAt: integer('created_at').notNull().$default(() => Date.now())
}, (table) => [
unique().on(table.userId, table.characterHistoryId)
]);
export type UserCharacterHistory = InferSelectModel<typeof userCharacterHistory>;
// Define the friendship table schema (friend requests + accepted friends)
export const friendship = sqliteTable('friendship', {
id: text('id')
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
requesterId: text('requester_id')
.notNull()
.references(() => user.id, { onDelete: 'cascade' }),
addresseeId: text('addressee_id')
.notNull()
.references(() => user.id, { onDelete: 'cascade' }),
status: text('status').$type<FriendshipStatus>().notNull().default('pending'),
createdAt: integer('created_at').notNull().$default(() => Date.now()),
updatedAt: integer('updated_at').notNull().$default(() => Date.now()),
}, (table) => [
unique().on(table.requesterId, table.addresseeId)
]);
export type Friendship = InferSelectModel<typeof friendship>;
export * from './auth.schema'; export * from './auth.schema';

View File

@@ -1,12 +1,14 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/stores'; import { page } from '$app/stores';
import ProfileButton from '$lib/components/ProfileButton.svelte'; import ProfileButton from '$lib/components/ProfileButton.svelte';
import { resolve } from '$app/paths';
let { children, data } = $props(); let { children, data } = $props();
const navItems = [ const navItems = [
{ href: '/admin', label: 'Dashboard', icon: '📊' }, { href: '/admin', label: 'Dashboard', icon: '📊' },
{ href: '/admin/characters', label: 'Characters', icon: '🗣️' }, { href: '/admin/characters', label: 'Characters', icon: '🗣️' },
{ href: '/admin/character-changes', label: 'Changes', icon: '🔄' },
{ href: '/admin/devil-fruits', label: 'Devil Fruits', icon: '🍎' }, { href: '/admin/devil-fruits', label: 'Devil Fruits', icon: '🍎' },
{ href: '/admin/arcs', label: 'Arcs', icon: '📚' }, { href: '/admin/arcs', label: 'Arcs', icon: '📚' },
{ href: '/admin/users', label: 'Users', icon: '👥' }, { href: '/admin/users', label: 'Users', icon: '👥' },
@@ -28,9 +30,9 @@
<h2 class="text-lg font-black uppercase tracking-[0.15em] text-amber-50">Admin</h2> <h2 class="text-lg font-black uppercase tracking-[0.15em] text-amber-50">Admin</h2>
</div> </div>
<nav class="flex-1 space-y-2 px-3"> <nav class="flex-1 space-y-2 px-3">
{#each navItems as item} {#each navItems as item (item.label)}
<a <a
href={item.href} href={resolve(item.href)}
class={`flex items-center gap-3 rounded-lg px-4 py-3 text-sm font-medium transition-colors ${ class={`flex items-center gap-3 rounded-lg px-4 py-3 text-sm font-medium transition-colors ${
isActive(item.href, $page.url.pathname) isActive(item.href, $page.url.pathname)
? 'bg-amber-600 text-white' ? 'bg-amber-600 text-white'
@@ -44,7 +46,7 @@
</nav> </nav>
<div class="border-t border-white/5 p-3"> <div class="border-t border-white/5 p-3">
<a <a
href="/" href={resolve('/')}
class="flex items-center gap-2 rounded-lg px-4 py-3 text-sm font-medium text-gray-300 transition-colors hover:bg-slate-800 hover:text-white" class="flex items-center gap-2 rounded-lg px-4 py-3 text-sm font-medium text-gray-300 transition-colors hover:bg-slate-800 hover:text-white"
title="Return to site" title="Return to site"
> >

View File

@@ -2,13 +2,16 @@ import { db } from '$lib/server/db';
import { character, devilFruit, arc, user } from '$lib/server/db/schema'; import { character, devilFruit, arc, user } from '$lib/server/db/schema';
import { getOrCreateTodayCharacter, getTodayCharacterWinsCount } from '$lib/server/daily-character'; import { getOrCreateTodayCharacter, getTodayCharacterWinsCount } from '$lib/server/daily-character';
import type { PageServerLoad } from './$types'; import type { PageServerLoad } from './$types';
import { count, eq } from 'drizzle-orm';
export const load: PageServerLoad = async () => { export const load: PageServerLoad = async () => {
const [characters, devilFruits, arcs, users] = await Promise.all([ const [totalCharacters, totalDevilFruits, totalArcs, totalUsers, adminUsers, charactersInDaily] = await Promise.all([
db.select().from(character), db.select({ count: count() }).from(character),
db.select().from(devilFruit), db.select({ count: count() }).from(devilFruit),
db.select().from(arc), db.select({ count: count() }).from(arc),
db.select().from(user) db.select({ count: count() }).from(user),
db.select({ count: count() }).from(user).where(eq(user.isAdmin, true)),
db.select({ count: count() }).from(character).where(eq(character.isInDailyMode, true))
]); ]);
// Get today's daily character and count wins // Get today's daily character and count wins
@@ -21,12 +24,12 @@ export const load: PageServerLoad = async () => {
return { return {
stats: { stats: {
totalCharacters: characters.length, totalCharacters: totalCharacters[0].count,
charactersInDaily: characters.filter((c) => c.isInDailyMode).length, charactersInDaily: charactersInDaily[0].count,
totalDevilFruits: devilFruits.length, totalDevilFruits: totalDevilFruits[0].count,
totalArcs: arcs.length, totalArcs: totalArcs[0].count,
totalUsers: users.length, totalUsers: totalUsers[0].count,
adminUsers: users.filter((u) => u.isAdmin).length, adminUsers: adminUsers[0].count,
dailyCharacterWins dailyCharacterWins
} }
}; };

View File

@@ -0,0 +1,272 @@
import { db } from '$lib/server/db';
import { character, characterScrapeValidation } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm';
import { exec } from 'node:child_process';
import { promisify } from 'node:util';
const execAsync = promisify(exec);
let isScrapeImportRunning = false;
const EXEC_OPTIONS = {
cwd: process.cwd(),
maxBuffer: 50 * 1024 * 1024
};
async function applyCharacterChangeFromScrapeValidation(characterId: string): Promise<boolean> {
const [scraped] = await db
.select()
.from(characterScrapeValidation)
.where(eq(characterScrapeValidation.id, characterId));
if (!scraped) {
return false;
}
if (scraped.isDeleted) {
await db.delete(character).where(eq(character.id, characterId));
return true;
}
await db
.insert(character)
.values({
id: scraped.id,
name: scraped.name,
frName: scraped.frName,
gender: scraped.gender,
age: scraped.age,
affiliation: scraped.affiliation,
frAffiliation: scraped.frAffiliation,
devilFruitId: scraped.devilFruitId,
hakiObservation: scraped.hakiObservation,
hakiArmament: scraped.hakiArmament,
hakiConqueror: scraped.hakiConqueror,
bounty: scraped.bounty,
height: scraped.height,
origin: scraped.origin,
frOrigin: scraped.frOrigin,
firstAppearance: scraped.firstAppearance,
pictureUrl: scraped.pictureUrl,
epithets: scraped.epithets,
frEpithets: scraped.frEpithets,
status: scraped.status,
arcId: scraped.arcId,
url: scraped.url,
frUrl: scraped.frUrl,
})
.onConflictDoUpdate({
target: character.id,
set: {
name: scraped.name,
frName: scraped.frName,
gender: scraped.gender,
age: scraped.age,
affiliation: scraped.affiliation,
frAffiliation: scraped.frAffiliation,
devilFruitId: scraped.devilFruitId,
hakiObservation: scraped.hakiObservation,
hakiArmament: scraped.hakiArmament,
hakiConqueror: scraped.hakiConqueror,
bounty: scraped.bounty,
height: scraped.height,
origin: scraped.origin,
frOrigin: scraped.frOrigin,
firstAppearance: scraped.firstAppearance,
pictureUrl: scraped.pictureUrl,
epithets: scraped.epithets,
frEpithets: scraped.frEpithets,
status: scraped.status,
arcId: scraped.arcId,
url: scraped.url,
frUrl: scraped.frUrl
}
});
return true;
}
export async function load() {
// Get all characters from both tables
const currentCharacters = await db.select().from(character);
const scrapedCharacters = await db.select().from(characterScrapeValidation);
// Create a map for quick lookup
const currentCharMap = new Map(currentCharacters.map(c => [c.id, c]));
// Compare and categorize changes
const changes: {
type: 'new' | 'modified' | 'deleted';
id: string;
scraped: (typeof scrapedCharacters)[0];
current?: (typeof currentCharacters)[0];
differences?: Record<string, { current: any; scraped: any }>;
}[] = [];
for (const scraped of scrapedCharacters) {
const current = currentCharMap.get(scraped.id);
if (scraped.isDeleted) {
if (current) {
changes.push({
type: 'deleted',
id: scraped.id,
scraped,
current
});
}
continue;
}
if (!current) {
// New character
changes.push({
type: 'new',
id: scraped.id,
scraped
});
} else {
// Check if different
const differences: Record<string, { current: any; scraped: any }> = {};
const fieldsToCompare = [
'name',
'frName',
'gender',
'age',
'affiliation',
'frAffiliation',
'devilFruitId',
'hakiObservation',
'hakiArmament',
'hakiConqueror',
'bounty',
'height',
'origin',
'frOrigin',
'firstAppearance',
'pictureUrl',
'epithets',
'frEpithets',
'status',
'arcId',
'url',
'frUrl'
];
for (const field of fieldsToCompare) {
const currentValue = current[field as keyof typeof current];
const scrapedValue = scraped[field as keyof typeof scraped];
// Deep comparison for JSON fields
if (JSON.stringify(currentValue) !== JSON.stringify(scrapedValue)) {
differences[field] = {
current: currentValue,
scraped: scrapedValue
};
}
}
if (Object.keys(differences).length > 0) {
changes.push({
type: 'modified',
id: scraped.id,
scraped,
current,
differences
});
}
}
}
const typeOrder: Record<'new' | 'modified' | 'deleted', number> = {
new: 0,
modified: 1,
deleted: 2
};
return {
changes: changes.sort((a, b) => {
if (a.type !== b.type) {
return typeOrder[a.type] - typeOrder[b.type];
}
return a.id.localeCompare(b.id);
})
};
}
export const actions = {
runScrapeImport: async () => {
if (isScrapeImportRunning) {
return {
success: false,
message: 'A scrape is already running. Please wait for it to finish.',
logs: ''
};
}
isScrapeImportRunning = true;
try {
const scrapeResult = await execAsync('npm run scrape', EXEC_OPTIONS);
const importResult = await execAsync('npm run db:import', EXEC_OPTIONS);
const logs = [
'=== npm run scrape ===',
scrapeResult.stdout || '',
scrapeResult.stderr ? `\n[stderr]\n${scrapeResult.stderr}` : '',
'\n=== npm run db:import ===',
importResult.stdout || '',
importResult.stderr ? `\n[stderr]\n${importResult.stderr}` : ''
]
.filter(Boolean)
.join('\n');
return {
success: true,
message: 'Scrape and import completed successfully',
logs
};
} catch (error) {
const message = error instanceof Error ? error.message : 'Failed to run scripts';
const stdout = typeof error === 'object' && error && 'stdout' in error ? String((error as any).stdout || '') : '';
const stderr = typeof error === 'object' && error && 'stderr' in error ? String((error as any).stderr || '') : '';
const logs = [stdout, stderr ? `\n[stderr]\n${stderr}` : ''].filter(Boolean).join('\n');
return {
success: false,
message,
logs
};
} finally {
isScrapeImportRunning = false;
}
},
acceptOne: async ({ request }) => {
const formData = await request.formData();
const characterId = formData.get('characterId');
if (!characterId || typeof characterId !== 'string') {
return { success: false, message: 'characterId is required' };
}
const applied = await applyCharacterChangeFromScrapeValidation(characterId);
return {
success: applied,
message: applied ? 'Character change applied successfully' : 'Character not found in scrape validation table'
};
},
acceptAll: async () => {
const scrapedCharacters = await db.select().from(characterScrapeValidation);
let appliedCount = 0;
for (const scraped of scrapedCharacters) {
const applied = await applyCharacterChangeFromScrapeValidation(scraped.id);
if (applied) {
appliedCount++;
}
}
return {
success: true,
appliedCount
};
}
};

View File

@@ -0,0 +1,251 @@
<script lang="ts">
type CharacterLike = {
name: string;
pictureUrl?: string | null;
url?: string | null;
status?: string | null;
gender?: string | null;
age?: number | null;
bounty?: number | null;
[key: string]: unknown;
};
type CharacterChange = {
type: 'new' | 'modified' | 'deleted';
id: string;
scraped: CharacterLike;
current?: CharacterLike;
differences?: Record<string, { current: unknown; scraped: unknown }>;
};
let { data, form } = $props();
const newCharacters = $derived((data.changes as CharacterChange[]).filter((c) => c.type === 'new'));
const modifiedCharacters = $derived((data.changes as CharacterChange[]).filter((c) => c.type === 'modified'));
const deletedCharacters = $derived((data.changes as CharacterChange[]).filter((c) => c.type === 'deleted'));
function formatValue(value: unknown): string {
if (value === null || value === undefined) {
return '—';
}
if (Array.isArray(value)) {
return value.join(', ');
}
if (typeof value === 'boolean') {
return value ? '✓' : '✗';
}
return String(value);
}
</script>
<svelte:head>
<title>Admin - Character Changes</title>
</svelte:head>
<div class="space-y-8">
<div>
<h1 class="text-3xl font-black uppercase tracking-[0.25em] text-amber-50 mb-2">Character Changes</h1>
<p class="text-gray-400">Total changes: {newCharacters.length} new, {modifiedCharacters.length} modified, {deletedCharacters.length} deleted</p>
<form method="POST" action="?/runScrapeImport" class="mt-4">
<button
type="submit"
class="rounded-full border border-sky-300/40 bg-sky-500/20 px-4 py-2 text-sm font-semibold text-sky-100 transition hover:bg-sky-500/30"
>
🔄 Lancer scrape + import
</button>
</form>
{#if form?.message}
<p class={`mt-3 text-sm ${form.success ? 'text-emerald-300' : 'text-rose-300'}`}>
{form.message}
</p>
{/if}
{#if form?.logs}
<pre class="mt-3 max-h-72 overflow-auto rounded-lg border border-white/10 bg-slate-900/70 p-3 text-xs text-slate-200 whitespace-pre-wrap">{form.logs}</pre>
{/if}
{#if newCharacters.length + modifiedCharacters.length + deletedCharacters.length > 0}
<form method="POST" action="?/acceptAll" class="mt-4">
<button
type="submit"
class="rounded-full border border-emerald-300/40 bg-emerald-500/20 px-4 py-2 text-sm font-semibold text-emerald-100 transition hover:bg-emerald-500/30"
>
✅ Accepter tous les changements
</button>
</form>
{/if}
</div>
<!-- New Characters Section -->
{#if newCharacters.length > 0}
<section class="space-y-4">
<h2 class="text-xl font-bold text-emerald-400 uppercase tracking-[0.15em]">
🆕 New Characters ({newCharacters.length})
</h2>
<div class="grid gap-4">
{#each newCharacters as change (change.id)}
<div class="rounded-lg border border-emerald-500/30 bg-emerald-500/5 p-4 space-y-3">
<div class="flex items-center justify-between gap-3">
<div class="flex items-center gap-3">
{#if change.scraped.pictureUrl}
<a href="https://onepiece.fandom.com/fr/wiki/{change.scraped.url}" target="_blank" rel="noopener noreferrer">
<img
src={change.scraped.pictureUrl ?? undefined}
alt={change.scraped.name}
class="w-12 h-12 rounded object-cover hover:opacity-80 transition"
/>
</a>
{/if}
<div>
<h3 class="font-bold text-emerald-300">{change.scraped.name}</h3>
<p class="text-sm text-gray-500">{change.id}</p>
</div>
</div>
<form method="POST" action="?/acceptOne">
<input type="hidden" name="characterId" value={change.id} />
<button
type="submit"
class="rounded-full border border-emerald-300/40 bg-emerald-500/20 px-3 py-1 text-xs font-semibold text-emerald-100 transition hover:bg-emerald-500/30"
>
Accepter
</button>
</form>
</div>
<div class="grid grid-cols-2 gap-2 text-sm">
<div>
<span class="text-gray-400">Status:</span>
<span class="ml-2">{formatValue(change.scraped.status)}</span>
</div>
<div>
<span class="text-gray-400">Gender:</span>
<span class="ml-2">{formatValue(change.scraped.gender)}</span>
</div>
<div>
<span class="text-gray-400">Age:</span>
<span class="ml-2">{formatValue(change.scraped.age)}</span>
</div>
<div>
<span class="text-gray-400">Bounty:</span>
<span class="ml-2">{formatValue(change.scraped.bounty)}</span>
</div>
</div>
</div>
{/each}
</div>
</section>
{/if}
<!-- Modified Characters Section -->
{#if modifiedCharacters.length > 0}
<section class="space-y-4">
<h2 class="text-xl font-bold text-amber-400 uppercase tracking-[0.15em]">
✏️ Modified Characters ({modifiedCharacters.length})
</h2>
<div class="grid gap-6">
{#each modifiedCharacters as change (change.id)}
<div class="rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 space-y-4">
<div class="flex items-center justify-between gap-3 pb-4 border-b border-amber-500/20">
<div class="flex items-center gap-3">
{#if change.current?.pictureUrl}
<a href="https://onepiece.fandom.com/fr/wiki/{change.current?.url ?? change.scraped.url}" target="_blank" rel="noopener noreferrer">
<img
src={change.current?.pictureUrl ?? undefined}
alt={change.current?.name ?? change.scraped.name}
class="w-12 h-12 rounded object-cover hover:opacity-80 transition"
/>
</a>
{/if}
<div>
<h3 class="font-bold text-amber-300">{change.current?.name ?? change.scraped.name}</h3>
<p class="text-sm text-gray-500">{change.id}</p>
</div>
</div>
<form method="POST" action="?/acceptOne">
<input type="hidden" name="characterId" value={change.id} />
<button
type="submit"
class="rounded-full border border-amber-300/40 bg-amber-500/20 px-3 py-1 text-xs font-semibold text-amber-100 transition hover:bg-amber-500/30"
>
Accepter
</button>
</form>
</div>
{#if change.differences}
<div class="space-y-3">
{#each Object.entries(change.differences) as [field, diff] (field)}
<div class="bg-slate-900/50 rounded p-3 space-y-1">
<h4 class="text-sm font-semibold text-amber-100 uppercase tracking-widest">{field}</h4>
<div class="grid grid-cols-2 gap-4 text-sm">
<div class="space-y-1">
<p class="text-gray-500">Current:</p>
<p class="font-mono text-gray-300">{formatValue(diff.current)}</p>
</div>
<div class="space-y-1">
<p class="text-gray-500">Scraped:</p>
<p class="font-mono text-emerald-300 font-semibold">{formatValue(diff.scraped)}</p>
</div>
</div>
</div>
{/each}
</div>
{/if}
</div>
{/each}
</div>
</section>
{/if}
<!-- Deleted Characters Section -->
{#if deletedCharacters.length > 0}
<section class="space-y-4">
<h2 class="text-xl font-bold text-rose-400 uppercase tracking-[0.15em]">
🗑️ Deleted Characters ({deletedCharacters.length})
</h2>
<div class="grid gap-4">
{#each deletedCharacters as change (change.id)}
<div class="rounded-lg border border-rose-500/30 bg-rose-500/5 p-4 space-y-3">
<div class="flex items-center justify-between gap-3">
<div class="flex items-center gap-3">
{#if change.current?.pictureUrl}
<a href="https://onepiece.fandom.com/fr/wiki/{change.current?.url ?? change.scraped.url}" target="_blank" rel="noopener noreferrer">
<img
src={change.current?.pictureUrl ?? undefined}
alt={change.current?.name ?? change.scraped.name}
class="w-12 h-12 rounded object-cover hover:opacity-80 transition"
/>
</a>
{/if}
<div>
<h3 class="font-bold text-rose-300">{change.current?.name ?? change.scraped.name}</h3>
<p class="text-sm text-gray-500">{change.id}</p>
</div>
</div>
<form method="POST" action="?/acceptOne">
<input type="hidden" name="characterId" value={change.id} />
<button
type="submit"
class="rounded-full border border-rose-300/40 bg-rose-500/20 px-3 py-1 text-xs font-semibold text-rose-100 transition hover:bg-rose-500/30"
>
Supprimer
</button>
</form>
</div>
<p class="text-sm text-rose-200/80">This character is no longer present in the latest scrape and will be removed if accepted.</p>
</div>
{/each}
</div>
</section>
{/if}
{#if newCharacters.length === 0 && modifiedCharacters.length === 0 && deletedCharacters.length === 0}
<div class="rounded-lg border border-white/10 bg-white/5 p-8 text-center">
<p class="text-gray-400">Aucun changement détecté. Les tables character et characterScrapeValidation sont synchronisées.</p>
</div>
{/if}
</div>
<style>
:global(body) {
background-color: rgb(15, 23, 42);
color: rgb(203, 213, 225);
}
</style>

View File

@@ -1,18 +1,32 @@
import { db } from '$lib/server/db'; import { db } from '$lib/server/db';
import { character, devilFruit, arc, characterOverride } from '$lib/server/db/schema'; import { character, devilFruit, arc, type Status } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm'; import { eq, sql } from 'drizzle-orm';
import { fail } from '@sveltejs/kit'; import { fail } from '@sveltejs/kit';
import type { PageServerLoad, Actions } from './$types'; import type { PageServerLoad, Actions } from './$types';
// Helper function to normalize data (parse JSON arrays)
const normalizeArray = (value: any): any => {
if (!value) return value;
if (Array.isArray(value)) return value;
if (typeof value === 'string' && value.includes('[')) {
try {
return JSON.parse(value);
} catch {
return value;
}
}
return value;
};
export const load: PageServerLoad = async () => { export const load: PageServerLoad = async () => {
const [charactersData, devilFruits, arcs, overrides] = await Promise.all([ let [characters, devilFruits, arcs, statusesData, gendersData] = await Promise.all([
db db
.select({ .select({
id: character.id, id: character.id,
name: character.name, name: character.name,
gender: character.gender, gender: character.gender,
age: character.age, age: character.age,
affiliations: character.affiliations, affiliation: character.affiliation,
devilFruitId: character.devilFruitId, devilFruitId: character.devilFruitId,
hakiObservation: character.hakiObservation, hakiObservation: character.hakiObservation,
hakiArmament: character.hakiArmament, hakiArmament: character.hakiArmament,
@@ -22,7 +36,7 @@ export const load: PageServerLoad = async () => {
origin: character.origin, origin: character.origin,
firstAppearance: character.firstAppearance, firstAppearance: character.firstAppearance,
pictureUrl: character.pictureUrl, pictureUrl: character.pictureUrl,
epithets: character.epithets, epithets: normalizeArray(character.epithets),
status: character.status, status: character.status,
url: character.url, url: character.url,
arcId: character.arcId, arcId: character.arcId,
@@ -37,112 +51,30 @@ export const load: PageServerLoad = async () => {
.orderBy(character.name), .orderBy(character.name),
db.select().from(devilFruit).orderBy(devilFruit.name), db.select().from(devilFruit).orderBy(devilFruit.name),
db.select().from(arc).orderBy(arc.name), db.select().from(arc).orderBy(arc.name),
db.select().from(characterOverride) db.selectDistinct({ status: character.status })
.from(character)
.where(sql`${character.status} IS NOT NULL AND ${character.status} != ''`),
db.selectDistinct({ gender: character.gender })
.from(character)
.where(sql`${character.gender} IS NOT NULL AND ${character.gender} != ''`)
]); ]);
// Create a map of overrides by characterId for easy lookup
const overridesMap = new Map(overrides.map((o) => [o.characterId, o]));
// Merge character data with overrides
const charactersWithOverrides = charactersData.map((char) => {
const override = overridesMap.get(char.id);
// Build displayValues by only applying non-null override fields
const displayValues = { ...char } as any;
if (override) {
Object.keys(override).forEach((key) => {
if (override[key as keyof typeof override] !== null && key !== 'characterId') {
displayValues[key as keyof typeof displayValues] = override[key as keyof typeof override];
}
});
}
return { return {
...char, characters,
override,
displayValues
};
});
return {
characters: charactersWithOverrides,
devilFruits, devilFruits,
arcs arcs,
availableStatuses: statusesData
.map(s => s.status)
.filter((s): s is Status => !!s)
.sort((a, b) => a.localeCompare(b)),
availableGenders: gendersData
.map(g => g.gender)
.filter((g): g is string => !!g)
.sort((a, b) => a.localeCompare(b))
}; };
}; };
export const actions: Actions = { export const actions: Actions = {
update: async ({ request, locals }) => {
if (!locals.user?.isAdmin) {
return fail(401, { error: 'Unauthorized' });
}
const formData = await request.formData();
const id = formData.get('id') as string;
if (!id) {
return fail(400, { error: 'Character ID is required' });
}
try {
const [originalCharacter] = await db
.select({
hakiObservation: character.hakiObservation,
hakiArmament: character.hakiArmament,
hakiConqueror: character.hakiConqueror
})
.from(character)
.where(eq(character.id, id))
.limit(1);
if (!originalCharacter) {
return fail(404, { error: 'Character not found' });
}
const updates: Record<string, any> = {};
formData.forEach((value, key) => {
if (key !== 'id') {
// Handle integers (age, bounty, height, devilFruitId, arcId)
if (key === 'age' || key === 'bounty' || key === 'height' || key === 'devilFruitId' || key === 'arcId') {
const strValue = value as string;
updates[key] = strValue && strValue !== '' ? parseInt(strValue) : null;
}
// Handle checkboxes (haki fields) after parsing all form data
else if (key === 'hakiObservation' || key === 'hakiArmament' || key === 'hakiConqueror') {
return;
}
// Handle strings (name, gender, status, origin, affiliations, epithets, pictureUrl, url, firstAppearance)
else {
updates[key] = value || null;
}
}
});
const submittedHakiObservation = formData.has('hakiObservation');
const submittedHakiArmament = formData.has('hakiArmament');
const submittedHakiConqueror = formData.has('hakiConqueror');
updates.hakiObservation =
submittedHakiObservation === originalCharacter.hakiObservation ? null : submittedHakiObservation;
updates.hakiArmament =
submittedHakiArmament === originalCharacter.hakiArmament ? null : submittedHakiArmament;
updates.hakiConqueror =
submittedHakiConqueror === originalCharacter.hakiConqueror ? null : submittedHakiConqueror;
// Update or insert into characterOverride table
await db
.insert(characterOverride)
.values({ characterId: id, ...updates })
.onConflictDoUpdate({ target: characterOverride.characterId, set: updates });
return { success: true };
} catch (error) {
console.error('Character update error:', error);
return fail(500, { error: 'Failed to update character' });
}
},
delete: async ({ request, locals }) => { delete: async ({ request, locals }) => {
if (!locals.user?.isAdmin) { if (!locals.user?.isAdmin) {
return fail(401, { error: 'Unauthorized' }); return fail(401, { error: 'Unauthorized' });

View File

@@ -15,13 +15,11 @@
let filterGender = $state('all'); let filterGender = $state('all');
let filterArc = $state('all'); let filterArc = $state('all');
let filterHaki = $state<'all' | 'observation' | 'armament' | 'conqueror' | 'none'>('all'); let filterHaki = $state<'all' | 'observation' | 'armament' | 'conqueror' | 'none'>('all');
let selectedCharacterId = $state<string | null>(null);
let isEditModalOpen = $state(false); let isEditModalOpen = $state(false);
let isSaving = $state(false); let isSaving = $state(false);
let saveMessage = $state<{ type: 'success' | 'error'; text: string } | null>(null); let saveMessage = $state<{ type: 'success' | 'error'; text: string } | null>(null);
let dailyModeToast = $state<{ type: 'success' | 'error'; text: string } | null>(null); let dailyModeToast = $state<{ type: 'success' | 'error'; text: string } | null>(null);
let selectedChar = $state<any>(null); let selectedChar = $state<any>(null);
let showOriginalValue = $state<Record<string, boolean>>({});
const showDailyModeToast = (type: 'success' | 'error', text: string) => { const showDailyModeToast = (type: 'success' | 'error', text: string) => {
dailyModeToast = { type, text }; dailyModeToast = { type, text };
@@ -30,10 +28,12 @@
}, 3000); }, 3000);
}; };
const getFandomUrl = (url: string | null | undefined) => { const handleFileSelect = (event: Event) => {
if (!url) return null; const target = event.target as HTMLInputElement;
if (url.startsWith('http://') || url.startsWith('https://')) return url; if (target.files && target.files.length > 0) {
return `https://onepiece.fandom.com/fr/wiki/${url}`; // Clear pictureUrl when a file is selected
editForm.pictureUrl = '';
}
}; };
let editForm = $state<any>({ let editForm = $state<any>({
@@ -44,7 +44,7 @@
bounty: 0, bounty: 0,
height: 0, height: 0,
origin: '', origin: '',
affiliations: '', affiliation: '',
epithets: '', epithets: '',
pictureUrl: '', pictureUrl: '',
url: '', url: '',
@@ -57,69 +57,28 @@
status: '' status: ''
}); });
const availableStatuses = $derived.by(() => {
const statuses = new Set<string>();
for (const char of data.characters) {
const status = char.displayValues.status;
if (status && String(status).trim() !== '') {
statuses.add(String(status));
}
}
return Array.from(statuses).sort((a, b) => a.localeCompare(b));
});
const availableGenders = $derived.by(() => {
const genders = new Set<string>();
for (const char of data.characters) {
const gender = char.displayValues.gender;
if (gender && String(gender).trim() !== '') {
genders.add(String(gender));
}
}
return Array.from(genders).sort((a, b) => a.localeCompare(b));
});
const filteredCharacters = $derived.by(() => { const filteredCharacters = $derived.by(() => {
return data.characters.filter((char) => { return data.characters.filter((char) => {
const normalizedQuery = searchQuery.toLowerCase().trim(); const normalizedQuery = searchQuery.toLowerCase().trim();
let epithetsText = '';
if (char.displayValues.epithets) {
if (typeof char.displayValues.epithets === 'string') {
if (char.displayValues.epithets.includes('[')) {
try {
const parsed = JSON.parse(char.displayValues.epithets);
epithetsText = Array.isArray(parsed) ? parsed.join(' ') : String(parsed);
} catch {
epithetsText = char.displayValues.epithets;
}
} else {
epithetsText = char.displayValues.epithets;
}
} else if (Array.isArray(char.displayValues.epithets)) {
epithetsText = char.displayValues.epithets.join(' ');
}
}
const matchesSearch = const matchesSearch =
normalizedQuery === '' || normalizedQuery === '' ||
char.displayValues.name.toLowerCase().includes(normalizedQuery) || char.name.toLowerCase().includes(normalizedQuery);
epithetsText.toLowerCase().includes(normalizedQuery);
const matchesDaily = const matchesDaily =
filterDaily === 'all' || filterDaily === 'all' ||
(filterDaily === 'daily' && char.displayValues.isInDailyMode) || (filterDaily === 'daily' && char.isInDailyMode) ||
(filterDaily === 'not-daily' && !char.displayValues.isInDailyMode); (filterDaily === 'not-daily' && !char.isInDailyMode);
const matchesStatus = filterStatus === 'all' || (char.displayValues.status || '') === filterStatus; const matchesStatus = filterStatus === 'all' || (char.status || '') === filterStatus;
const matchesGender = filterGender === 'all' || (char.displayValues.gender || '') === filterGender; const matchesGender = filterGender === 'all' || (char.gender || '') === filterGender;
const matchesArc = const matchesArc =
filterArc === 'all' || filterArc === 'all' ||
String(char.displayValues.arcId ?? '') === filterArc; String(char.arcId ?? '') === filterArc;
const matchesHaki = const matchesHaki =
filterHaki === 'all' || filterHaki === 'all' ||
(filterHaki === 'observation' && !!char.displayValues.hakiObservation) || (filterHaki === 'observation' && !!char.hakiObservation) ||
(filterHaki === 'armament' && !!char.displayValues.hakiArmament) || (filterHaki === 'armament' && !!char.hakiArmament) ||
(filterHaki === 'conqueror' && !!char.displayValues.hakiConqueror) || (filterHaki === 'conqueror' && !!char.hakiConqueror) ||
(filterHaki === 'none' && !char.displayValues.hakiObservation && !char.displayValues.hakiArmament && !char.displayValues.hakiConqueror); (filterHaki === 'none' && !char.hakiObservation && !char.hakiArmament && !char.hakiConqueror);
return matchesSearch && matchesDaily && matchesStatus && matchesGender && matchesArc && matchesHaki; return matchesSearch && matchesDaily && matchesStatus && matchesGender && matchesArc && matchesHaki;
}); });
@@ -130,7 +89,6 @@
}; };
const openEditModal = (char: any) => { const openEditModal = (char: any) => {
selectedCharacterId = char.id;
selectedChar = char; selectedChar = char;
const override = char.override || {}; const override = char.override || {};
@@ -143,25 +101,23 @@
bounty: override.bounty ?? null, bounty: override.bounty ?? null,
height: override.height ?? null, height: override.height ?? null,
origin: override.origin ?? '', origin: override.origin ?? '',
affiliations: override.affiliations ?? '', affiliation: override.affiliation ?? '',
epithets: override.epithets ?? '', epithets: override.epithets ?? '',
pictureUrl: override.pictureUrl ?? '', pictureUrl: override.pictureUrl ?? '',
url: override.url ?? '', url: override.url ?? '',
devilFruitId: override.devilFruitId !== null && override.devilFruitId !== undefined ? override.devilFruitId : '', devilFruitId: override.devilFruitId !== null && override.devilFruitId !== undefined ? override.devilFruitId : (char.devilFruitId || ''),
hakiObservation: override.hakiObservation ?? char.hakiObservation, hakiObservation: override.hakiObservation ?? char.hakiObservation,
hakiArmament: override.hakiArmament ?? char.hakiArmament, hakiArmament: override.hakiArmament ?? char.hakiArmament,
hakiConqueror: override.hakiConqueror ?? char.hakiConqueror, hakiConqueror: override.hakiConqueror ?? char.hakiConqueror,
firstAppearance: override.firstAppearance ?? '', firstAppearance: override.firstAppearance ?? '',
arcId: override.arcId !== null && override.arcId !== undefined ? override.arcId : '', arcId: override.arcId !== null && override.arcId !== undefined ? override.arcId : (char.arcId || ''),
status: override.status ?? '' status: override.status ?? ''
}; };
showOriginalValue = {};
isEditModalOpen = true; isEditModalOpen = true;
}; };
const closeModal = () => { const closeModal = () => {
isEditModalOpen = false; isEditModalOpen = false;
selectedCharacterId = null;
selectedChar = null; selectedChar = null;
editForm = { editForm = {
id: '', id: '',
@@ -171,7 +127,7 @@
bounty: 0, bounty: 0,
height: 0, height: 0,
origin: '', origin: '',
affiliations: '', affiliation: '',
epithets: '', epithets: '',
pictureUrl: '', pictureUrl: '',
url: '', url: '',
@@ -211,6 +167,7 @@
}, 3000); }, 3000);
} }
} catch (error) { } catch (error) {
console.error('Error deleting character:', error);
saveMessage = { saveMessage = {
type: 'error', type: 'error',
text: 'Error deleting character' text: 'Error deleting character'
@@ -253,7 +210,7 @@
class="rounded-lg bg-slate-700 px-4 py-2 text-sm text-white outline-none transition focus:ring-2 focus:ring-amber-600" class="rounded-lg bg-slate-700 px-4 py-2 text-sm text-white outline-none transition focus:ring-2 focus:ring-amber-600"
> >
<option value="all">All Statuses</option> <option value="all">All Statuses</option>
{#each availableStatuses as status} {#each data.availableStatuses as status (status)}
<option value={status}>{status}</option> <option value={status}>{status}</option>
{/each} {/each}
</select> </select>
@@ -262,7 +219,7 @@
class="rounded-lg bg-slate-700 px-4 py-2 text-sm text-white outline-none transition focus:ring-2 focus:ring-amber-600" class="rounded-lg bg-slate-700 px-4 py-2 text-sm text-white outline-none transition focus:ring-2 focus:ring-amber-600"
> >
<option value="all">All Genders</option> <option value="all">All Genders</option>
{#each availableGenders as gender} {#each data.availableGenders as gender (gender)}
<option value={gender}>{gender}</option> <option value={gender}>{gender}</option>
{/each} {/each}
</select> </select>
@@ -271,8 +228,8 @@
class="rounded-lg bg-slate-700 px-4 py-2 text-sm text-white outline-none transition focus:ring-2 focus:ring-amber-600" class="rounded-lg bg-slate-700 px-4 py-2 text-sm text-white outline-none transition focus:ring-2 focus:ring-amber-600"
> >
<option value="all">All Arcs</option> <option value="all">All Arcs</option>
{#each data.arcs as arc} {#each data.arcs as arc (arc.id)}
<option value={String(arc.id)}>{arc.name}</option> <option value={arc.id}>{arc.name}</option>
{/each} {/each}
</select> </select>
<select <select
@@ -316,120 +273,115 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{#each filteredCharacters as char} {#each filteredCharacters as char (char.id)}
<tr class="border-b border-white/5 hover:bg-slate-800/50"> <tr class="border-b border-white/5 hover:bg-slate-800/50">
<!-- Character --> <!-- Character -->
<td class="px-4 py-4 text-sm text-white w-64 max-w-64 {isFieldOverridden(char, 'name') || isFieldOverridden(char, 'pictureUrl') ? 'bg-amber-500/10' : ''}"> <td class="px-4 py-4 text-sm text-white w-64 max-w-64">
<div class="flex items-center gap-3 min-w-0"> <div class="flex items-center gap-3 min-w-0">
{#if getFandomUrl(char.displayValues.url)} {#if char.url}
<a <a
href={getFandomUrl(char.displayValues.url)} href={"https://onepiece.fandom.com/wiki/" + char.url}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
class="flex-shrink-0 transition-opacity hover:opacity-80" class="shrink-0 transition-opacity hover:opacity-80"
> >
{#if char.displayValues.pictureUrl} {#if char.pictureUrl}
<img <img
src={char.displayValues.pictureUrl} src={char.pictureUrl}
alt={char.displayValues.name} alt={char.name}
loading="lazy"
class="h-10 w-10 rounded-full object-cover" class="h-10 w-10 rounded-full object-cover"
/> />
{:else} {:else}
<div class="flex h-10 w-10 items-center justify-center rounded-full bg-slate-700 text-gray-400"> <div class="flex h-10 w-10 items-center justify-center rounded-full bg-slate-700 text-gray-400">
{char.displayValues.name?.charAt(0).toUpperCase() || '?'} {char.name?.charAt(0).toUpperCase() || '?'}
</div> </div>
{/if} {/if}
</a> </a>
{:else} {:else}
{#if char.displayValues.pictureUrl} {#if char.pictureUrl}
<img <img
src={char.displayValues.pictureUrl} src={char.pictureUrl}
alt={char.displayValues.name} alt={char.name}
class="h-10 w-10 flex-shrink-0 rounded-full object-cover" loading="lazy"
class="h-10 w-10 shrink-0 rounded-full object-cover"
/> />
{:else} {:else}
<div class="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full bg-slate-700 text-gray-400"> <div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-slate-700 text-gray-400">
{char.displayValues.name?.charAt(0).toUpperCase() || '?'} {char.name?.charAt(0).toUpperCase() || '?'}
</div> </div>
{/if} {/if}
{/if} {/if}
<div class="flex flex-col min-w-0"> <div class="flex flex-col min-w-0">
{#if getFandomUrl(char.displayValues.url)} {#if char.url}
<a <a
href={getFandomUrl(char.displayValues.url)} href="https://onepiece.fandom.com/wiki/{char.url}"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
class="font-medium truncate text-white hover:text-amber-200 hover:underline" class="font-medium truncate text-white hover:text-amber-200 hover:underline"
> >
{char.displayValues.name} {char.name}
</a> </a>
{:else} {:else}
<span class="font-medium truncate">{char.displayValues.name}</span> <span class="font-medium truncate">{char.name}</span>
{/if} {/if}
{#if char.displayValues.epithets} {#if char.epithets}
<span class="text-xs text-gray-500 truncate"> <span class="text-xs text-gray-500 truncate">
{typeof char.displayValues.epithets === 'string' {Array.isArray(char.epithets)
? (char.displayValues.epithets.includes('[') ? JSON.parse(char.displayValues.epithets).join(', ') : char.displayValues.epithets) ? char.epithets.join(', ')
: char.displayValues.epithets.join(', ')} : char.epithets}
</span> </span>
{/if} {/if}
</div> </div>
</div> </div>
</td> </td>
<!-- Status --> <!-- Status -->
<td class="px-4 py-4 text-sm text-gray-400 {isFieldOverridden(char, 'status') ? 'bg-amber-500/10' : ''}">{char.displayValues.status || '-'}</td> <td class="px-4 py-4 text-sm text-gray-400">{char.status || '-'}</td>
<!-- Gender --> <!-- Gender -->
<td class="px-4 py-4 text-sm text-gray-400 {isFieldOverridden(char, 'gender') ? 'bg-amber-500/10' : ''}">{char.displayValues.gender || '-'}</td> <td class="px-4 py-4 text-sm text-gray-400">{char.gender || '-'}</td>
<!-- Affiliations --> <!-- Affiliations -->
<td class="px-4 py-4 text-sm text-gray-400 {isFieldOverridden(char, 'affiliations') ? 'bg-amber-500/10' : ''}"> <td class="px-4 py-4 text-sm text-gray-400">
{#if char.displayValues.affiliations} {#if char.affiliation}
{@const parsedAffiliations = typeof char.displayValues.affiliations === 'string' {char.affiliation}
? (char.displayValues.affiliations.includes('[') ? JSON.parse(char.displayValues.affiliations) : char.displayValues.affiliations.split(',').map((a: string) => a.trim()))
: char.displayValues.affiliations}
{#if Array.isArray(parsedAffiliations) && parsedAffiliations.length > 0}
<span class="inline-block" title={parsedAffiliations.join(', ')}>{parsedAffiliations[0]}</span>
{:else}
{parsedAffiliations}
{/if}
{:else} {:else}
- -
{/if} {/if}
</td> </td>
<!-- Fruit --> <!-- Fruit -->
<td class="px-4 py-4 text-sm text-gray-400 {isFieldOverridden(char, 'devilFruitId') ? 'bg-amber-500/10' : ''}">{char.displayValues.devilFruitName || '-'}</td> <td class="px-4 py-4 text-sm text-gray-400">{char.devilFruitName || '-'}</td>
<!-- Haki --> <!-- Haki -->
<td class="px-4 py-4 text-sm {isFieldOverridden(char, 'hakiObservation') || isFieldOverridden(char, 'hakiArmament') || isFieldOverridden(char, 'hakiConqueror') ? 'bg-amber-500/10' : ''}"> <td class="px-4 py-4 text-sm">
<div class="flex gap-1"> <div class="flex gap-1">
{#if char.displayValues.hakiObservation}<span title="Haki de l'Observation">👁️</span>{/if} {#if char.hakiObservation}<span title="Haki de l'Observation">👁️</span>{/if}
{#if char.displayValues.hakiArmament}<span title="Haki de l'Armement">🦾</span>{/if} {#if char.hakiArmament}<span title="Haki de l'Armement">🦾</span>{/if}
{#if char.displayValues.hakiConqueror}<span title="Haki des Rois">👑</span>{/if} {#if char.hakiConqueror}<span title="Haki des Rois">👑</span>{/if}
{#if !char.displayValues.hakiObservation && !char.displayValues.hakiArmament && !char.displayValues.hakiConqueror} {#if !char.hakiObservation && !char.hakiArmament && !char.hakiConqueror}
<span class="text-gray-400">-</span> <span class="text-gray-400">-</span>
{/if} {/if}
</div> </div>
</td> </td>
<!-- Bounty --> <!-- Bounty -->
<td class="px-4 py-4 text-sm text-gray-400 {isFieldOverridden(char, 'bounty') ? 'bg-amber-500/10' : ''}"> <td class="px-4 py-4 text-sm text-gray-400">
{#if char.displayValues.bounty != null} {#if char.bounty != null}
{formatBounty(char.displayValues.bounty)} ฿ {formatBounty(char.bounty)} ฿
{:else} {:else}
- -
{/if} {/if}
</td> </td>
<!-- Height --> <!-- Height -->
<td class="px-4 py-4 text-sm text-gray-400 {isFieldOverridden(char, 'height') ? 'bg-amber-500/10' : ''}"> <td class="px-4 py-4 text-sm text-gray-400">
{#if char.displayValues.height} {#if char.height}
{char.displayValues.height} m {char.height} m
{:else} {:else}
- -
{/if} {/if}
</td> </td>
<!-- Origin --> <!-- Origin -->
<td class="px-4 py-4 text-sm text-gray-400 {isFieldOverridden(char, 'origin') ? 'bg-amber-500/10' : ''}">{char.displayValues.origin || '-'}</td> <td class="px-4 py-4 text-sm text-gray-400">{char.origin || '-'}</td>
<!-- Arc --> <!-- Arc -->
<td class="px-4 py-4 text-sm text-gray-400 {isFieldOverridden(char, 'arcId') || isFieldOverridden(char, 'arcName') ? 'bg-amber-500/10' : ''}">{char.displayValues.arcName || '-'}</td> <td class="px-4 py-4 text-sm text-gray-400">{char.arcName || '-'}</td>
<!-- Daily Mode --> <!-- Daily Mode -->
<td class="px-4 py-4 text-sm {isFieldOverridden(char, 'isInDailyMode') ? 'bg-amber-500/10' : ''}"> <td class="px-4 py-4 text-sm">
<form <form
method="POST" method="POST"
action="?/toggleDailyMode" action="?/toggleDailyMode"
@@ -447,11 +399,11 @@
}} }}
> >
<input type="hidden" name="id" value={char.id} /> <input type="hidden" name="id" value={char.id} />
<input type="hidden" name="isInDailyMode" value={(!char.displayValues.isInDailyMode).toString()} /> <input type="hidden" name="isInDailyMode" value={(!char.isInDailyMode).toString()} />
<label class="flex items-center justify-center cursor-pointer"> <label class="flex items-center justify-center cursor-pointer">
<input <input
type="checkbox" type="checkbox"
checked={char.displayValues.isInDailyMode} checked={char.isInDailyMode}
onchange={(e) => { onchange={(e) => {
const form = e.currentTarget.closest('form'); const form = e.currentTarget.closest('form');
if (form) form.requestSubmit(); if (form) form.requestSubmit();
@@ -494,7 +446,7 @@
{/if} {/if}
{#if dailyModeToast} {#if dailyModeToast}
<div class="fixed right-6 top-6 z-[60]"> <div class="fixed right-6 top-6 z-60">
<div <div
class={`rounded-lg border px-4 py-3 text-sm font-medium shadow-lg backdrop-blur ${ class={`rounded-lg border px-4 py-3 text-sm font-medium shadow-lg backdrop-blur ${
dailyModeToast.type === 'success' dailyModeToast.type === 'success'
@@ -516,6 +468,7 @@
class="mt-6 space-y-4" class="mt-6 space-y-4"
method="POST" method="POST"
action="?/update" action="?/update"
enctype="multipart/form-data"
use:enhance={() => { use:enhance={() => {
isSaving = true; isSaving = true;
return async ({ result }) => { return async ({ result }) => {
@@ -660,7 +613,7 @@
class="w-full rounded-lg border border-gray-500 bg-slate-800 px-3 py-2 text-white" class="w-full rounded-lg border border-gray-500 bg-slate-800 px-3 py-2 text-white"
> >
<option value="">None</option> <option value="">None</option>
{#each data.arcs as arc} {#each data.arcs as arc (arc.id)}
<option value={arc.id}>{arc.name}</option> <option value={arc.id}>{arc.name}</option>
{/each} {/each}
</select> </select>
@@ -683,7 +636,7 @@
class="w-full rounded-lg border border-gray-500 bg-slate-800 px-3 py-2 text-white" class="w-full rounded-lg border border-gray-500 bg-slate-800 px-3 py-2 text-white"
> >
<option value="">None</option> <option value="">None</option>
{#each data.devilFruits as fruit} {#each data.devilFruits as fruit (fruit.id)}
<option value={fruit.id}>{fruit.name}</option> <option value={fruit.id}>{fruit.name}</option>
{/each} {/each}
</select> </select>
@@ -780,6 +733,20 @@
/> />
</div> </div>
<div>
<label for="char-picture-file" class="block text-sm font-medium text-gray-300 mb-2">Or Upload Picture</label>
<input
type="file"
id="char-picture-file"
name="pictureFile"
accept="image/*"
onchange={handleFileSelect}
class="w-full rounded-lg border border-gray-500 bg-slate-800 px-3 py-2 text-white file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-sm file:font-semibold file:bg-amber-600 file:text-white hover:file:bg-amber-700"
/>
<p class="mt-1 text-xs text-gray-400">File will be saved as {selectedChar?.id}.jpg/png/etc</p>
</div>
<div> <div>
<label for="char-url" class="block text-sm font-medium text-gray-300 mb-2">Fandom URL</label> <label for="char-url" class="block text-sm font-medium text-gray-300 mb-2">Fandom URL</label>
<input <input

View File

@@ -13,7 +13,10 @@
let { data }: Props = $props(); let { data }: Props = $props();
let configItems = $state<ConfigItem[]>([]); let configItems = $derived(data.config.map((item) => ({
key: item.key,
value: item.value ?? ''
})));
let newKey = $state(''); let newKey = $state('');
let newValue = $state(''); let newValue = $state('');
let editingKey = $state<string | null>(null); let editingKey = $state<string | null>(null);
@@ -21,12 +24,7 @@
let isSaving = $state(false); let isSaving = $state(false);
let saveMessage = $state<{ type: 'success' | 'error'; text: string } | null>(null); let saveMessage = $state<{ type: 'success' | 'error'; text: string } | null>(null);
$effect(() => { ;
configItems = data.config.map((item) => ({
key: item.key,
value: item.value ?? ''
}));
});
const startEdit = (item: ConfigItem) => { const startEdit = (item: ConfigItem) => {
editingKey = item.key; editingKey = item.key;
@@ -70,6 +68,7 @@
saveMessage = { type: 'error', text: 'Failed to add config' }; saveMessage = { type: 'error', text: 'Failed to add config' };
} }
} catch (error) { } catch (error) {
console.error('Error adding config:', error);
saveMessage = { type: 'error', text: 'Error adding config' }; saveMessage = { type: 'error', text: 'Error adding config' };
} finally { } finally {
isSaving = false; isSaving = false;
@@ -99,6 +98,7 @@
saveMessage = { type: 'error', text: 'Failed to delete config' }; saveMessage = { type: 'error', text: 'Failed to delete config' };
} }
} catch (error) { } catch (error) {
console.error('Error deleting config:', error);
saveMessage = { type: 'error', text: 'Error deleting config' }; saveMessage = { type: 'error', text: 'Error deleting config' };
} finally { } finally {
isSaving = false; isSaving = false;
@@ -155,7 +155,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{#each configItems as item} {#each configItems as item (item.key)}
{#if editingKey === item.key} {#if editingKey === item.key}
<tr class="border-b border-white/5 bg-slate-800/50"> <tr class="border-b border-white/5 bg-slate-800/50">
<td class="px-6 py-4 text-sm text-white">{item.key}</td> <td class="px-6 py-4 text-sm text-white">{item.key}</td>

View File

@@ -11,7 +11,6 @@
let searchQuery = $state(''); let searchQuery = $state('');
let filterType = $state<'all' | 'Paramecia' | 'Zoan' | 'Logia' | 'Unknown'>('all'); let filterType = $state<'all' | 'Paramecia' | 'Zoan' | 'Logia' | 'Unknown'>('all');
let isEditModalOpen = $state(false); let isEditModalOpen = $state(false);
let selectedFruitId = $state<string | null>(null);
let isSaving = $state(false); let isSaving = $state(false);
let saveMessage = $state<{ type: 'success' | 'error'; text: string } | null>(null); let saveMessage = $state<{ type: 'success' | 'error'; text: string } | null>(null);
@@ -33,14 +32,12 @@
}); });
const openEditModal = (fruit: any) => { const openEditModal = (fruit: any) => {
selectedFruitId = fruit.id;
editForm = { ...fruit }; editForm = { ...fruit };
isEditModalOpen = true; isEditModalOpen = true;
}; };
const closeModal = () => { const closeModal = () => {
isEditModalOpen = false; isEditModalOpen = false;
selectedFruitId = null;
editForm = { editForm = {
id: '', id: '',
name: '', name: '',
@@ -88,6 +85,7 @@
}, 3000); }, 3000);
} }
} catch (error) { } catch (error) {
console.error('Error deleting devil fruit:', error);
saveMessage = { saveMessage = {
type: 'error', type: 'error',
text: 'Error deleting devil fruit' text: 'Error deleting devil fruit'
@@ -150,7 +148,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{#each filteredFruits as fruit} {#each filteredFruits as fruit (fruit.id)}
<tr class="border-b border-white/5 hover:bg-slate-800/50"> <tr class="border-b border-white/5 hover:bg-slate-800/50">
<td class="px-6 py-4 text-sm text-white">{fruit.name}</td> <td class="px-6 py-4 text-sm text-white">{fruit.name}</td>
<td class="px-6 py-4 text-sm"> <td class="px-6 py-4 text-sm">
@@ -233,7 +231,7 @@
bind:value={editForm.type} bind:value={editForm.type}
class="mt-1 w-full rounded-lg bg-slate-700 px-4 py-2 text-sm text-white outline-none transition focus:ring-2 focus:ring-amber-600" class="mt-1 w-full rounded-lg bg-slate-700 px-4 py-2 text-sm text-white outline-none transition focus:ring-2 focus:ring-amber-600"
> >
{#each fruitTypes as type} {#each fruitTypes as type (type)}
<option value={type}>{type}</option> <option value={type}>{type}</option>
{/each} {/each}
</select> </select>

View File

@@ -13,7 +13,6 @@
let isEditModalOpen = $state(false); let isEditModalOpen = $state(false);
let isSaving = $state(false); let isSaving = $state(false);
let saveMessage = $state<{ type: 'success' | 'error'; message: string } | null>(null); let saveMessage = $state<{ type: 'success' | 'error'; message: string } | null>(null);
let selectedUserId = $state<string | null>(null);
let editForm = $state<any>({ let editForm = $state<any>({
id: '', id: '',
@@ -35,7 +34,6 @@
}); });
const openEditModal = (usr: any) => { const openEditModal = (usr: any) => {
selectedUserId = usr.id;
editForm = { ...usr }; editForm = { ...usr };
isEditModalOpen = true; isEditModalOpen = true;
saveMessage = null; saveMessage = null;
@@ -43,7 +41,6 @@
const closeModal = () => { const closeModal = () => {
isEditModalOpen = false; isEditModalOpen = false;
selectedUserId = null;
editForm = { editForm = {
id: '', id: '',
name: '', name: '',
@@ -120,7 +117,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{#each filteredUsers as usr} {#each filteredUsers as usr (usr.id)}
<tr class="border-b border-white/5 hover:bg-slate-800/50"> <tr class="border-b border-white/5 hover:bg-slate-800/50">
<td class="px-6 py-4 text-sm text-white">{usr.name}</td> <td class="px-6 py-4 text-sm text-white">{usr.name}</td>
<td class="px-6 py-4 text-sm text-gray-400">{usr.email}</td> <td class="px-6 py-4 text-sm text-gray-400">{usr.email}</td>

View File

@@ -1,5 +1,7 @@
<script lang="ts"> <script lang="ts">
import ProfileButton from '$lib/components/ProfileButton.svelte'; import ProfileButton from '$lib/components/ProfileButton.svelte';
import LanguageSwitcher from '$lib/components/LanguageSwitcher.svelte';
import { resolve } from '$app/paths';
let { children, data } = $props(); let { children, data } = $props();
</script> </script>
@@ -7,11 +9,14 @@
<div class="min-h-screen bg-slate-950"> <div class="min-h-screen bg-slate-950">
<header class="fixed top-0 right-0 left-0 z-50 border-b border-white/5 bg-slate-950/95 backdrop-blur"> <header class="fixed top-0 right-0 left-0 z-50 border-b border-white/5 bg-slate-950/95 backdrop-blur">
<div class="mx-auto flex max-w-7xl items-center justify-between px-6 py-4"> <div class="mx-auto flex max-w-7xl items-center justify-between px-6 py-4">
<a href="/" class="text-lg font-black uppercase tracking-[0.15em] text-amber-50 transition hover:text-amber-100"> <a href={resolve("/")} class="text-lg font-black uppercase tracking-[0.15em] text-amber-50 transition hover:text-amber-100">
OnePieceDle OnePieceDle
</a> </a>
<div class="flex items-center gap-3">
<LanguageSwitcher />
<ProfileButton user={data.user} /> <ProfileButton user={data.user} />
</div> </div>
</div>
</header> </header>
<main class="pt-20"> <main class="pt-20">
{@render children()} {@render children()}

View File

@@ -1,7 +1,59 @@
<script lang="ts"> <script lang="ts">
export let data; export let data;
import { resolve } from '$app/paths';
import { language, t } from '$lib/i18n';
import type { CharacterWithRelations } from '$lib/server/daily-character';
$: yesterdayCharacter = data.yesterdayCharacter; $: yesterdayCharacter = data.yesterdayCharacter;
$: isFrench = $language === 'fr';
function parseEpithets(value: unknown): string[] {
if (Array.isArray(value)) {
return value.filter((entry): entry is string => typeof entry === 'string' && entry.length > 0);
}
if (typeof value === 'string') {
try {
const parsed = JSON.parse(value);
if (Array.isArray(parsed)) {
return parsed.filter((entry): entry is string => typeof entry === 'string' && entry.length > 0);
}
} catch {
if (value.length > 0) {
return [value];
}
}
}
return [];
}
function getDisplayName(character: CharacterWithRelations | null): string {
if (isFrench && typeof character?.frName === 'string' && character.frName.length > 0) {
return character.frName;
}
return character?.name || '';
}
function getDisplayEpithets(character: CharacterWithRelations | null): string[] {
const frenchEpithets = parseEpithets(character?.frEpithets);
if (isFrench && frenchEpithets.length > 0) {
return frenchEpithets;
}
return parseEpithets(character?.epithets);
}
function getWikiUrl(character: CharacterWithRelations | null): string {
if (isFrench && typeof character?.frUrl === 'string' && character.frUrl.length > 0) {
return character.frUrl;
}
return character?.url || '';
}
</script> </script>
<svelte:head> <svelte:head>
@@ -11,7 +63,7 @@
<main <main
class="relative min-h-[calc(100vh-5rem)] bg-slate-950 text-slate-100" class="relative min-h-[calc(100vh-5rem)] bg-slate-950 text-slate-100"
> >
<div class="absolute inset-0 bg-gradient-to-br from-slate-950/85 via-slate-900/60 to-slate-950/80"></div> <div class="absolute inset-0 bg-linear-to-br from-slate-950/85 via-slate-900/60 to-slate-950/80"></div>
<div class="absolute inset-0 mix-blend-screen opacity-20 bg-[radial-gradient(circle_at_top,rgba(255,215,84,0.35),transparent_55%)]"></div> <div class="absolute inset-0 mix-blend-screen opacity-20 bg-[radial-gradient(circle_at_top,rgba(255,215,84,0.35),transparent_55%)]"></div>
<div class="relative mx-auto flex w-full max-w-6xl flex-col items-center justify-center px-6 py-10"> <div class="relative mx-auto flex w-full max-w-6xl flex-col items-center justify-center px-6 py-10">
@@ -21,30 +73,30 @@
OnePieceDle OnePieceDle
</h1> </h1>
<p class="mt-4 max-w-2xl text-base text-slate-200 sm:text-lg"> <p class="mt-4 max-w-2xl text-base text-slate-200 sm:text-lg">
Devine le personnage de l'equipage, des marines ou du vaste monde. Chaque indice te rapproche du tresor. {$t.game.home.heroDescription}
</p> </p>
</div> </div>
<div class="grid w-full gap-4 sm:grid-cols-2"> <div class="grid w-full gap-4 sm:grid-cols-2">
<div class="rounded-2xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur"> <div class="rounded-2xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur">
<h2 class="text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">Personnage du jour</h2> <h2 class="text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">{$t.game.home.dailyTitle}</h2>
<p class="mt-3 text-lg font-semibold text-white">Nouveau mystere toutes les 24 heures</p> <p class="mt-3 text-lg font-semibold text-white">{$t.game.home.dailySubtitle}</p>
<p class="mt-2 text-sm text-slate-200">Compare tes essais, debloque des indices et garde ta serie.</p> <p class="mt-2 text-sm text-slate-200">{$t.game.home.dailyDescription}</p>
<a <a
href="/daily" href={resolve("/daily")}
class="mt-5 inline-flex w-full items-center justify-center rounded-full bg-amber-300 px-5 py-3 text-sm font-semibold text-slate-900 transition hover:bg-amber-200" class="mt-5 inline-flex w-full items-center justify-center rounded-full bg-amber-300 px-5 py-3 text-sm font-semibold text-slate-900 transition hover:bg-amber-200"
> >
Commencer {$t.game.home.dailyCta}
</a> </a>
</div> </div>
<div class="rounded-2xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur"> <div class="rounded-2xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur">
<h2 class="text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">Mode Infini</h2> <h2 class="text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">{$t.game.home.infiniteTitle}</h2>
<p class="mt-3 text-lg font-semibold text-white">Des defis sans fin</p> <p class="mt-3 text-lg font-semibold text-white">{$t.game.home.infiniteSubtitle}</p>
<p class="mt-2 text-sm text-slate-200">Enchaine les personnages et croise ton score. Pas de limite, que du plaisir.</p> <p class="mt-2 text-sm text-slate-200">{$t.game.home.infiniteDescription}</p>
<a <a
href="/infinite" href={resolve("/infinite")}
class="mt-5 inline-flex w-full items-center justify-center rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50" class="mt-5 inline-flex w-full items-center justify-center rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50"
> >
Jouer {$t.game.home.infiniteCta}
</a> </a>
</div> </div>
</div> </div>
@@ -54,43 +106,52 @@
{#if yesterdayCharacter.pictureUrl} {#if yesterdayCharacter.pictureUrl}
<img <img
src={yesterdayCharacter.pictureUrl} src={yesterdayCharacter.pictureUrl}
alt={yesterdayCharacter.name} alt={getDisplayName(yesterdayCharacter)}
class="h-20 w-20 rounded-full border border-amber-200/40 object-cover" class="h-20 w-20 rounded-full border border-amber-200/40 object-cover"
/> />
{:else} {:else}
<div class="flex h-20 w-20 items-center justify-center rounded-full border border-amber-200/40 bg-slate-900/70 text-xs uppercase tracking-[0.25em] text-amber-100"> <div class="flex h-20 w-20 items-center justify-center rounded-full border border-amber-200/40 bg-slate-900/70 text-xs uppercase tracking-[0.25em] text-amber-100">
Photo {$t.game.home.photoFallback}
</div> </div>
{/if} {/if}
<div class="flex-1"> <div class="flex-1">
<p class="text-xs font-semibold uppercase tracking-[0.28em] text-amber-100">Personnage d'hier</p> <p class="text-xs font-semibold uppercase tracking-[0.28em] text-amber-100">{$t.game.home.yesterdayCharacter}</p>
<p class="mt-2 text-lg font-semibold text-white">{yesterdayCharacter.name}</p> <p class="mt-2 text-lg font-semibold text-white">{getDisplayName(yesterdayCharacter)}</p>
{#if yesterdayCharacter.epithets} {#if getDisplayEpithets(yesterdayCharacter).length > 0}
<p class="mt-1 text-sm text-slate-400"> <p class="mt-1 text-sm text-slate-400">
{typeof yesterdayCharacter.epithets === 'string' {getDisplayEpithets(yesterdayCharacter).join(', ')}
? JSON.parse(yesterdayCharacter.epithets).join(', ')
: (yesterdayCharacter.epithets as string[]).join(', ')}
</p> </p>
{/if} {/if}
</div> </div>
{#if isFrench}
<a <a
href={"https://onepiece.fandom.com/fr/wiki/" + yesterdayCharacter.url} href="https://onepiece.fandom.com/fr/wiki/{getWikiUrl(yesterdayCharacter)}"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
class="w-full rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50 sm:w-auto" class="w-full rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50 sm:w-auto"
> >
Voir la page {$t.game.home.openPage}
</a> </a>
{:else}
<a
href="https://onepiece.fandom.com/wiki/{getWikiUrl(yesterdayCharacter)}"
target="_blank"
rel="noopener noreferrer"
class="w-full rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50 sm:w-auto"
>
{$t.game.home.openPage}
</a>
{/if}
</div> </div>
{:else} {:else}
<div class="flex flex-col items-center gap-5 text-center sm:flex-row sm:text-left"> <div class="flex flex-col items-center gap-5 text-center sm:flex-row sm:text-left">
<div class="flex h-20 w-20 items-center justify-center rounded-full border border-amber-200/40 bg-slate-900/70 text-xs uppercase tracking-[0.25em] text-amber-100"> <div class="flex h-20 w-20 items-center justify-center rounded-full border border-amber-200/40 bg-slate-900/70 text-xs uppercase tracking-[0.25em] text-amber-100">
Photo {$t.game.home.photoFallback}
</div> </div>
<div class="flex-1"> <div class="flex-1">
<p class="text-xs font-semibold uppercase tracking-[0.28em] text-amber-100">Personnage d'hier</p> <p class="text-xs font-semibold uppercase tracking-[0.28em] text-amber-100">{$t.game.home.yesterdayCharacter}</p>
<p class="mt-2 text-lg font-semibold text-white">Aucun personnage</p> <p class="mt-2 text-lg font-semibold text-white">{$t.game.home.noCharacter}</p>
<p class="mt-1 text-sm text-slate-200">Aucun personnage d'hier disponible</p> <p class="mt-1 text-sm text-slate-200">{$t.game.home.noYesterdayCharacter}</p>
</div> </div>
</div> </div>
{/if} {/if}

View File

@@ -1,10 +1,10 @@
import { error } from '@sveltejs/kit'; import { error } from '@sveltejs/kit';
import { db } from '$lib/server/db'; import { db } from '$lib/server/db';
import { config } from '$lib/server/db/schema'; import { character, characterHistory, config, friendship, user, userCharacterHistory } from '$lib/server/db/schema';
import { getDailyModeCharacters, getOrCreateTodayCharacter, getYesterdayCharacter } from '$lib/server/daily-character'; import { getDailyModeCharacters, getOrCreateTodayCharacter, getYesterdayCharacter, getTodayCharacterWinsCount, getDateKey } from '$lib/server/daily-character';
import { like } from 'drizzle-orm'; import { and, eq, inArray, like, or } from 'drizzle-orm';
export async function load() { export async function load(event) {
const characters = await getDailyModeCharacters(); const characters = await getDailyModeCharacters();
const dailyCharacter = await getOrCreateTodayCharacter(characters); const dailyCharacter = await getOrCreateTodayCharacter(characters);
@@ -14,6 +14,97 @@ export async function load() {
const yesterdayCharacter = await getYesterdayCharacter(new Date(), characters); const yesterdayCharacter = await getYesterdayCharacter(new Date(), characters);
// Load the win count for today
const winCount = await getTodayCharacterWinsCount(dailyCharacter.id);
let friendsTodayResults: Array<{
userId: string;
name: string;
image: string | null;
tryCount: number;
triedCharacters: Array<{ id: string; name: string; pictureUrl: string | null }>;
}> = [];
if (event.locals.user) {
const currentUserId = event.locals.user.id;
const acceptedFriendships = await db
.select({
requesterId: friendship.requesterId,
addresseeId: friendship.addresseeId
})
.from(friendship)
.where(
and(
eq(friendship.status, 'accepted'),
or(eq(friendship.requesterId, currentUserId), eq(friendship.addresseeId, currentUserId))
)
);
const friendIds = acceptedFriendships.map((relation) =>
relation.requesterId === currentUserId ? relation.addresseeId : relation.requesterId
);
if (friendIds.length > 0) {
const todayDate = getDateKey(new Date());
const [todayHistoryEntry] = await db
.select({ id: characterHistory.id })
.from(characterHistory)
.where(eq(characterHistory.date, todayDate))
.limit(1);
const todayCharacterHistoryId = todayHistoryEntry?.id;
if (todayCharacterHistoryId) {
const friendResultsRaw = await db
.select({
userId: user.id,
name: user.name,
image: user.image,
tryCount: userCharacterHistory.tryCount,
triedCharacterIds: userCharacterHistory.triedCharacterIds
})
.from(userCharacterHistory)
.innerJoin(user, eq(userCharacterHistory.userId, user.id))
.where(
and(
eq(userCharacterHistory.characterHistoryId, todayCharacterHistoryId),
inArray(userCharacterHistory.userId, friendIds)
)
)
.orderBy(userCharacterHistory.tryCount);
const uniqueTriedCharacterIds = Array.from(new Set(
friendResultsRaw.flatMap((entry) => entry.triedCharacterIds ?? [])
));
const triedCharacters = uniqueTriedCharacterIds.length > 0
? await db
.select({
id: character.id,
name: character.name,
pictureUrl: character.pictureUrl
})
.from(character)
.where(inArray(character.id, uniqueTriedCharacterIds))
: [];
const triedCharactersById = new Map(triedCharacters.map((entry) => [entry.id, entry]));
friendsTodayResults = friendResultsRaw.map((entry) => ({
userId: entry.userId,
name: entry.name,
image: entry.image,
tryCount: entry.tryCount,
triedCharacters: (entry.triedCharacterIds ?? [])
.map((characterId) => triedCharactersById.get(characterId))
.filter((triedEntry): triedEntry is (typeof triedCharacters)[number] => !!triedEntry)
}));
}
}
}
// Load column visibility config // Load column visibility config
const columnConfig = await db const columnConfig = await db
.select() .select()
@@ -33,6 +124,8 @@ export async function load() {
characters, characters,
dailyCharacter, dailyCharacter,
yesterdayCharacter, yesterdayCharacter,
columnVisibility columnVisibility,
winCount,
friendsTodayResults
}; };
} }

View File

@@ -1,23 +1,98 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onDestroy, onMount } from 'svelte';
import YesterdayCharacter from '$lib/components/YesterdayCharacter.svelte'; import YesterdayCharacter from '$lib/components/YesterdayCharacter.svelte';
import HintsPanel from '$lib/components/HintsPanel.svelte'; import HintsPanel from '$lib/components/HintsPanel.svelte';
import CharacterSearchInput from '$lib/components/CharacterSearchInput.svelte'; import CharacterSearchInput from '$lib/components/CharacterSearchInput.svelte';
import GuessHistoryTable from '$lib/components/GuessHistoryTable.svelte'; import GuessHistoryTable from '$lib/components/GuessHistoryTable.svelte';
import WinPanel from '$lib/components/WinPanel.svelte'; import WinPanel from '$lib/components/WinPanel.svelte';
import FriendsTodaySection from '$lib/components/FriendsTodaySection.svelte';
import type { CharacterWithRelations } from '$lib/server/daily-character.js';
import { t } from '$lib/i18n';
export let data; export let data;
let selectedCharacters: any[] = []; let selectedCharacters: CharacterWithRelations[] = [];
let isLoaded = false; let isLoaded = false;
let isGeckoMoriaWin = false; let isGeckoMoriaWin = false;
let wasOriginAvailable = false;
let wasFruitAvailable = false;
let wasAffiliationAvailable = false;
let showOriginUnlock = false; let showOriginUnlock = false;
let showFruitUnlock = false; let showFruitUnlock = false;
let showAffiliationUnlock = false; let showAffiliationUnlock = false;
let originUnlockTimeout: ReturnType<typeof setTimeout> | null = null;
let fruitUnlockTimeout: ReturnType<typeof setTimeout> | null = null;
let affiliationUnlockTimeout: ReturnType<typeof setTimeout> | null = null;
function clearUnlockTimeout(timeout: ReturnType<typeof setTimeout> | null) {
if (timeout) {
clearTimeout(timeout);
}
}
function pulseUnlock(type: 'origin' | 'fruit' | 'affiliation') {
if (type === 'origin') {
clearUnlockTimeout(originUnlockTimeout);
showOriginUnlock = true;
originUnlockTimeout = setTimeout(() => {
showOriginUnlock = false;
originUnlockTimeout = null;
}, 600);
return;
}
if (type === 'fruit') {
clearUnlockTimeout(fruitUnlockTimeout);
showFruitUnlock = true;
fruitUnlockTimeout = setTimeout(() => {
showFruitUnlock = false;
fruitUnlockTimeout = null;
}, 600);
return;
}
clearUnlockTimeout(affiliationUnlockTimeout);
showAffiliationUnlock = true;
affiliationUnlockTimeout = setTimeout(() => {
showAffiliationUnlock = false;
affiliationUnlockTimeout = null;
}, 600);
}
function syncHintAvailability(previousGuessCount: number, nextGuessCount: number, animateUnlocks = false) {
const nextOriginAvailable = nextGuessCount >= 5;
const nextFruitAvailable = nextGuessCount >= 10;
const nextAffiliationAvailable = nextGuessCount >= 15;
if (animateUnlocks && nextOriginAvailable && previousGuessCount < 5) {
pulseUnlock('origin');
}
if (animateUnlocks && nextFruitAvailable && previousGuessCount < 10) {
pulseUnlock('fruit');
}
if (animateUnlocks && nextAffiliationAvailable && previousGuessCount < 15) {
pulseUnlock('affiliation');
}
if (!nextOriginAvailable) {
showOriginUnlock = false;
clearUnlockTimeout(originUnlockTimeout);
originUnlockTimeout = null;
}
if (!nextFruitAvailable) {
showFruitUnlock = false;
clearUnlockTimeout(fruitUnlockTimeout);
fruitUnlockTimeout = null;
}
if (!nextAffiliationAvailable) {
showAffiliationUnlock = false;
clearUnlockTimeout(affiliationUnlockTimeout);
affiliationUnlockTimeout = null;
}
}
// Load from localStorage on mount // Load from localStorage on mount
onMount(() => { onMount(() => {
@@ -37,8 +112,8 @@
// Reconstruct character objects from IDs // Reconstruct character objects from IDs
if (Array.isArray(storedIds)) { if (Array.isArray(storedIds)) {
selectedCharacters = storedIds selectedCharacters = storedIds
.map((id: string) => data.characters.find((c: any) => c.id === id)) .map((id: string) => data.characters.find((c: CharacterWithRelations) => c.id === id))
.filter((c: any) => c !== undefined); .filter((c: CharacterWithRelations | undefined): c is CharacterWithRelations => !!c);
} }
} catch (e) { } catch (e) {
console.error('Failed to parse stored history', e); console.error('Failed to parse stored history', e);
@@ -51,9 +126,17 @@
localStorage.setItem('dailyCurrentCharacterId', dailyCurrentCharacterId); localStorage.setItem('dailyCurrentCharacterId', dailyCurrentCharacterId);
} }
syncHintAvailability(0, selectedCharacters.length);
isLoaded = true; isLoaded = true;
}); });
onDestroy(() => {
clearUnlockTimeout(originUnlockTimeout);
clearUnlockTimeout(fruitUnlockTimeout);
clearUnlockTimeout(affiliationUnlockTimeout);
});
// Save to localStorage whenever selectedCharacters changes (only store IDs) // Save to localStorage whenever selectedCharacters changes (only store IDs)
$: if (isLoaded && selectedCharacters) { $: if (isLoaded && selectedCharacters) {
const ids = selectedCharacters.map(char => char.id); const ids = selectedCharacters.map(char => char.id);
@@ -66,42 +149,19 @@
$: columnVisibility = data.columnVisibility || {}; $: columnVisibility = data.columnVisibility || {};
$: hasWon = selectedCharacters.some(char => char.id === dailyCharacter.id); $: hasWon = selectedCharacters.some(char => char.id === dailyCharacter.id);
// Hint availability tracking for unlock animations function handleCharacterSelect(character: CharacterWithRelations) {
$: isOriginAvailable = selectedCharacters.length >= 5;
$: isFruitAvailable = selectedCharacters.length >= 10;
$: isAffiliationAvailable = selectedCharacters.length >= 15;
// Track hint unlocks
$: if (isLoaded) {
if (isOriginAvailable && !wasOriginAvailable) {
showOriginUnlock = true;
setTimeout(() => showOriginUnlock = false, 600);
}
wasOriginAvailable = isOriginAvailable;
if (isFruitAvailable && !wasFruitAvailable) {
showFruitUnlock = true;
setTimeout(() => showFruitUnlock = false, 600);
}
wasFruitAvailable = isFruitAvailable;
if (isAffiliationAvailable && !wasAffiliationAvailable) {
showAffiliationUnlock = true;
setTimeout(() => showAffiliationUnlock = false, 600);
}
wasAffiliationAvailable = isAffiliationAvailable;
}
function handleCharacterSelect(event: CustomEvent) {
const character = event.detail;
selectCharacter(character); selectCharacter(character);
} }
function selectCharacter(character: any) { function selectCharacter(character: CharacterWithRelations) {
const previousGuessCount = selectedCharacters.length;
selectedCharacters = [character, ...selectedCharacters]; selectedCharacters = [character, ...selectedCharacters];
syncHintAvailability(previousGuessCount, selectedCharacters.length, isLoaded);
// Check if player won // Check if player won
if (character.id === dailyCharacter.id) { if (character.id === dailyCharacter.id) {
const triedCharacterIds = selectedCharacters.map(selected => selected.id);
// Send request to record win in database // Send request to record win in database
fetch('/daily', { fetch('/daily', {
method: 'POST', method: 'POST',
@@ -109,7 +169,9 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify({ body: JSON.stringify({
characterId: dailyCharacter.id characterId: dailyCharacter.id,
tryCount: selectedCharacters.length,
triedCharacterIds
}) })
}).catch(err => console.error('Failed to record win:', err)); }).catch(err => console.error('Failed to record win:', err));
@@ -121,13 +183,15 @@
} }
function resetHistory() { function resetHistory() {
const previousGuessCount = selectedCharacters.length;
selectedCharacters = []; selectedCharacters = [];
syncHintAvailability(previousGuessCount, 0);
localStorage.removeItem('dailyCharacterHistory'); localStorage.removeItem('dailyCharacterHistory');
} }
</script> </script>
<svelte:head> <svelte:head>
<title>OnePieceDle - Mode du jour</title> <title>{$t.game.daily.metaTitle}</title>
<style> <style>
@keyframes shadow-pulse { @keyframes shadow-pulse {
0% { 0% {
@@ -197,26 +261,31 @@
<main <main
class="relative min-h-screen overflow-hidden bg-slate-950 text-slate-100 {isGeckoMoriaWin ? 'moria-screen-chaos' : ''}" class="relative min-h-screen overflow-hidden bg-slate-950 text-slate-100 {isGeckoMoriaWin ? 'moria-screen-chaos' : ''}"
> >
<div class="absolute inset-0 bg-gradient-to-br from-slate-950/85 via-slate-900/60 to-slate-950/80"></div> <div class="absolute inset-0 bg-linear-to-br from-slate-950/85 via-slate-900/60 to-slate-950/80"></div>
<div class="absolute inset-0 mix-blend-screen opacity-20 bg-[radial-gradient(circle_at_top,rgba(255,215,84,0.35),transparent_55%)]"></div> <div class="absolute inset-0 mix-blend-screen opacity-20 bg-[radial-gradient(circle_at_top,rgba(255,215,84,0.35),transparent_55%)]"></div>
<div class="relative mx-auto flex min-h-screen w-full max-w-6xl flex-col px-6 py-8 sm:py-10"> <div class="relative mx-auto flex min-h-screen w-full max-w-6xl flex-col px-6 py-8 sm:py-10">
<header class="flex flex-col items-start gap-6 w-full"> <header class="flex flex-col items-start gap-6 w-full">
<div class="flex w-full items-center justify-between gap-4"> <div class="flex w-full items-center justify-between gap-4">
<div>
<h1 class="text-3xl font-black uppercase tracking-[0.25em] text-amber-50 sm:text-5xl"> <h1 class="text-3xl font-black uppercase tracking-[0.25em] text-amber-50 sm:text-5xl">
Personnage du jour {$t.game.daily.title}
</h1> </h1>
<p class="mt-2 text-sm text-amber-300">
{data.winCount} {data.winCount > 1 ? $t.game.daily.winsPeoplePlural : $t.game.daily.winsPeopleSingular} {data.winCount > 1 ? $t.game.daily.winsVerbPlural : $t.game.daily.winsVerbSingular} {$t.game.daily.winsSuffix}
</p>
</div>
{#if hasWon} {#if hasWon}
<button <button
class="rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50" class="rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50"
onclick={resetHistory} onclick={resetHistory}
> >
Recommencer {$t.game.daily.reset}
</button> </button>
{/if} {/if}
</div> </div>
<p class="max-w-2xl text-base text-slate-200 sm:text-lg"> <p class="max-w-2xl text-base text-slate-200 sm:text-lg">
Devine le personnage. Chaque indice se débloque après un certain nombre de tentatives. Bonne chance ! {$t.game.daily.description}
</p> </p>
</header> </header>
@@ -233,7 +302,7 @@
{#if hasWon} {#if hasWon}
<WinPanel <WinPanel
{dailyCharacter} selectedCharacter={dailyCharacter}
{selectedCharacters} {selectedCharacters}
{isGeckoMoriaWin} {isGeckoMoriaWin}
/> />
@@ -241,11 +310,16 @@
<CharacterSearchInput <CharacterSearchInput
{characters} {characters}
{selectedCharacters} {selectedCharacters}
on:select={handleCharacterSelect} onSelect={handleCharacterSelect}
/> />
{/if} {/if}
</section> </section>
{#if hasWon && data.friendsTodayResults && data.friendsTodayResults.length > 0}
<FriendsTodaySection friendsTodayResults={data.friendsTodayResults} />
{/if}
<GuessHistoryTable <GuessHistoryTable
{selectedCharacters} {selectedCharacters}
{dailyCharacter} {dailyCharacter}

View File

@@ -1,13 +1,16 @@
import { json } from '@sveltejs/kit'; import { json } from '@sveltejs/kit';
import { db } from '$lib/server/db'; import { db } from '$lib/server/db';
import { characterHistory } from '$lib/server/db/schema'; import { characterHistory, userCharacterHistory } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm'; import { eq, and } from 'drizzle-orm';
import { sql } from 'drizzle-orm'; import { sql } from 'drizzle-orm';
import { getDateKey } from '$lib/server/daily-character'; import { getDateKey } from '$lib/server/daily-character';
export async function POST({ request }) { export async function POST({ request, locals }) {
try { try {
const { characterId } = await request.json(); const { characterId, tryCount, triedCharacterIds } = await request.json();
const normalizedTriedCharacterIds = Array.isArray(triedCharacterIds)
? triedCharacterIds.filter((id): id is string => typeof id === 'string')
: [];
if (!characterId) { if (!characterId) {
return json({ error: 'Missing characterId' }, { status: 400 }); return json({ error: 'Missing characterId' }, { status: 400 });
@@ -15,6 +18,29 @@ export async function POST({ request }) {
const todayDate = getDateKey(new Date()); const todayDate = getDateKey(new Date());
// If user is logged in, check if they already played today
if (locals.user) {
// Get the characterHistoryId for today
const [todayHistoryEntry] = await db
.select({ id: characterHistory.id })
.from(characterHistory)
.where(eq(characterHistory.date, todayDate));
if (todayHistoryEntry) {
// Check if user already has a record for today
const [existingRecord] = await db
.select()
.from(userCharacterHistory)
.where(and(
eq(userCharacterHistory.userId, locals.user.id),
eq(userCharacterHistory.characterHistoryId, todayHistoryEntry.id)
));
// If user already played today, don't record again
if (existingRecord) {
return json({ success: false, message: 'Already played today' });
}
// Increment the won counter for today's entry // Increment the won counter for today's entry
await db await db
.update(characterHistory) .update(characterHistory)
@@ -24,6 +50,25 @@ export async function POST({ request }) {
}) })
.where(eq(characterHistory.date, todayDate)); .where(eq(characterHistory.date, todayDate));
// Insert into userCharacterHistory
await db.insert(userCharacterHistory).values({
userId: locals.user.id,
characterHistoryId: todayHistoryEntry.id,
tryCount: tryCount,
triedCharacterIds: normalizedTriedCharacterIds
});
}
} else {
// If user is not logged in, always increment counter
await db
.update(characterHistory)
.set({
won: sql`${characterHistory.won} + 1`,
updatedAt: Date.now()
})
.where(eq(characterHistory.date, todayDate));
}
return json({ success: true }); return json({ success: true });
} catch (error) { } catch (error) {
console.error('Error recording win:', error); console.error('Error recording win:', error);

View File

@@ -1,34 +1,117 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onDestroy, onMount } from 'svelte';
import { formatBounty } from '$lib';
import CharacterSearchInput from '$lib/components/CharacterSearchInput.svelte'; import CharacterSearchInput from '$lib/components/CharacterSearchInput.svelte';
import GuessHistoryTable from '$lib/components/GuessHistoryTable.svelte'; import GuessHistoryTable from '$lib/components/GuessHistoryTable.svelte';
import WinPanel from '$lib/components/WinPanel.svelte';
import HintsPanel from '$lib/components/HintsPanel.svelte';
import type { CharacterWithRelations } from '$lib/server/daily-character.js';
import { language, t } from '$lib/i18n';
export let data; export let data;
let selectedCharacters: any[] = []; let selectedCharacters: CharacterWithRelations[] = [];
let currentCharacter: any = null; let currentCharacter: CharacterWithRelations | null = null;
let isLoaded = false; let isLoaded = false;
let score = 0; let score = 0;
type ArcFilterOption = { id: string; name: string };
let allCharacters: CharacterWithRelations[] = [];
let characters: CharacterWithRelations[] = [];
let availableArcs: ArcFilterOption[] = [];
let hasWon = false;
let columnVisibility: Record<string, boolean> = {}; let columnVisibility: Record<string, boolean> = {};
const columnDisplayNames: Record<string, string> = { let columnDisplayNames: Record<string, string> = {};
status: 'Statut',
gender: 'Genre', // Character filters
affiliations: 'Affiliations', let characterFilters = {
devilFruitType: 'Fruit', gender: [] as string[],
haki: 'Haki', hasHaki: false,
bounty: 'Prime', hasDevilFruit: null as boolean | null, // null = all, true = with fruit, false = without fruit
height: 'Taille', status: [] as string[],
origin: 'Origine', hasHeight: false,
arc: 'Arc' hasAge: false,
hasOrigin: false,
arcs: [] as string[]
}; };
let wasOriginAvailable = false;
let wasFruitAvailable = false;
let wasAffiliationAvailable = false;
let showOriginUnlock = false; let showOriginUnlock = false;
let showFruitUnlock = false; let showFruitUnlock = false;
let showAffiliationUnlock = false; let showAffiliationUnlock = false;
let isGeckoMoriaWin = false;
let originUnlockTimeout: ReturnType<typeof setTimeout> | null = null;
let fruitUnlockTimeout: ReturnType<typeof setTimeout> | null = null;
let affiliationUnlockTimeout: ReturnType<typeof setTimeout> | null = null;
function clearUnlockTimeout(timeout: ReturnType<typeof setTimeout> | null) {
if (timeout) {
clearTimeout(timeout);
}
}
function pulseUnlock(type: 'origin' | 'fruit' | 'affiliation') {
if (type === 'origin') {
clearUnlockTimeout(originUnlockTimeout);
showOriginUnlock = true;
originUnlockTimeout = setTimeout(() => {
showOriginUnlock = false;
originUnlockTimeout = null;
}, 600);
return;
}
if (type === 'fruit') {
clearUnlockTimeout(fruitUnlockTimeout);
showFruitUnlock = true;
fruitUnlockTimeout = setTimeout(() => {
showFruitUnlock = false;
fruitUnlockTimeout = null;
}, 600);
return;
}
clearUnlockTimeout(affiliationUnlockTimeout);
showAffiliationUnlock = true;
affiliationUnlockTimeout = setTimeout(() => {
showAffiliationUnlock = false;
affiliationUnlockTimeout = null;
}, 600);
}
function syncHintAvailability(previousGuessCount: number, nextGuessCount: number, animateUnlocks = false) {
const nextOriginAvailable = nextGuessCount >= 5;
const nextFruitAvailable = nextGuessCount >= 10;
const nextAffiliationAvailable = nextGuessCount >= 15;
if (animateUnlocks && nextOriginAvailable && previousGuessCount < 5) {
pulseUnlock('origin');
}
if (animateUnlocks && nextFruitAvailable && previousGuessCount < 10) {
pulseUnlock('fruit');
}
if (animateUnlocks && nextAffiliationAvailable && previousGuessCount < 15) {
pulseUnlock('affiliation');
}
if (!nextOriginAvailable) {
showOriginUnlock = false;
clearUnlockTimeout(originUnlockTimeout);
originUnlockTimeout = null;
}
if (!nextFruitAvailable) {
showFruitUnlock = false;
clearUnlockTimeout(fruitUnlockTimeout);
fruitUnlockTimeout = null;
}
if (!nextAffiliationAvailable) {
showAffiliationUnlock = false;
clearUnlockTimeout(affiliationUnlockTimeout);
affiliationUnlockTimeout = null;
}
}
// Load from localStorage on mount // Load from localStorage on mount
onMount(() => { onMount(() => {
@@ -43,12 +126,30 @@
try { try {
columnVisibility = JSON.parse(storedColumnVisibility); columnVisibility = JSON.parse(storedColumnVisibility);
} catch (e) { } catch (e) {
console.error('Failed to parse column visibility', e);
columnVisibility = data.columnVisibility || {}; columnVisibility = data.columnVisibility || {};
} }
} else { } else {
columnVisibility = data.columnVisibility || {}; columnVisibility = data.columnVisibility || {};
} }
// Load character filters from localStorage
const storedFilters = localStorage.getItem('infiniteCharacterFilters');
if (storedFilters) {
try {
characterFilters = JSON.parse(storedFilters);
// Ensure all filter properties exist
if (!characterFilters.arcs) {
characterFilters.arcs = [];
}
if (typeof characterFilters.hasAge !== 'boolean') {
characterFilters.hasAge = false;
}
} catch (e) {
console.error('Failed to parse filters', e);
}
}
// Load current character ID and history IDs from localStorage // Load current character ID and history IDs from localStorage
const storedCharacterId = localStorage.getItem('infiniteCurrentCharacterId'); const storedCharacterId = localStorage.getItem('infiniteCurrentCharacterId');
const storedHistoryIds = localStorage.getItem('infiniteSelectedCharacterIds'); const storedHistoryIds = localStorage.getItem('infiniteSelectedCharacterIds');
@@ -59,18 +160,19 @@
const historyIds = JSON.parse(storedHistoryIds); const historyIds = JSON.parse(storedHistoryIds);
// Find the character object by ID // Find the character object by ID
currentCharacter = characters.find((c: any) => c.id === charId); currentCharacter = characters.find((c: CharacterWithRelations) => c.id === charId) || null;
// Find all character objects by their IDs // Find all character objects by their IDs
selectedCharacters = historyIds selectedCharacters = historyIds
.map((id: string) => characters.find((c: any) => c.id === id)) .map((id: string) => characters.find((c: CharacterWithRelations) => c.id === id))
.filter((c: any) => c !== undefined); .filter((c: CharacterWithRelations | undefined) => !!c) as CharacterWithRelations[];
// If character not found, generate a new one // If character not found, generate a new one
if (!currentCharacter) { if (!currentCharacter) {
generateNewCharacter(); generateNewCharacter();
} }
} catch (e) { } catch (e) {
console.error('Failed to parse character data', e);
// If parsing fails, generate a new character // If parsing fails, generate a new character
generateNewCharacter(); generateNewCharacter();
} }
@@ -78,9 +180,16 @@
generateNewCharacter(); generateNewCharacter();
} }
syncHintAvailability(0, selectedCharacters.length);
isLoaded = true; isLoaded = true;
}); });
onDestroy(() => {
clearUnlockTimeout(originUnlockTimeout);
clearUnlockTimeout(fruitUnlockTimeout);
clearUnlockTimeout(affiliationUnlockTimeout);
});
// Save score to localStorage whenever it changes // Save score to localStorage whenever it changes
$: if (isLoaded) { $: if (isLoaded) {
localStorage.setItem('infiniteScore', score.toString()); localStorage.setItem('infiniteScore', score.toString());
@@ -91,6 +200,11 @@
localStorage.setItem('infiniteColumnVisibility', JSON.stringify(columnVisibility)); localStorage.setItem('infiniteColumnVisibility', JSON.stringify(columnVisibility));
} }
// Save character filters to localStorage whenever they change
$: if (isLoaded) {
localStorage.setItem('infiniteCharacterFilters', JSON.stringify(characterFilters));
}
// Save current character ID to localStorage whenever it changes // Save current character ID to localStorage whenever it changes
$: if (isLoaded && currentCharacter) { $: if (isLoaded && currentCharacter) {
localStorage.setItem('infiniteCurrentCharacterId', JSON.stringify(currentCharacter.id)); localStorage.setItem('infiniteCurrentCharacterId', JSON.stringify(currentCharacter.id));
@@ -98,55 +212,137 @@
// Save selected character IDs to localStorage whenever it changes // Save selected character IDs to localStorage whenever it changes
$: if (isLoaded) { $: if (isLoaded) {
const selectedIds = selectedCharacters.map((c: any) => c.id); const selectedIds = selectedCharacters.map((c: CharacterWithRelations) => c.id);
localStorage.setItem('infiniteSelectedCharacterIds', JSON.stringify(selectedIds)); localStorage.setItem('infiniteSelectedCharacterIds', JSON.stringify(selectedIds));
} }
$: characters = data.characters || []; $: allCharacters = data.characters || [];
$: hasWon = currentCharacter && selectedCharacters.some(char => char.id === currentCharacter.id); $: isFrench = $language === 'fr';
// Hint availability tracking for unlock animations function getDisplayArcName(character: CharacterWithRelations, useFrench: boolean): string | null {
$: isOriginAvailable = selectedCharacters.length >= 5; if (useFrench && typeof character.frArcName === 'string' && character.frArcName.length > 0) {
$: isFruitAvailable = selectedCharacters.length >= 10; return character.frArcName;
$: isAffiliationAvailable = selectedCharacters.length >= 15; }
// Track hint unlocks return character.arcName;
$: if (isLoaded) {
if (isOriginAvailable && !wasOriginAvailable) {
showOriginUnlock = true;
setTimeout(() => (showOriginUnlock = false), 600);
} }
wasOriginAvailable = isOriginAvailable;
if (isFruitAvailable && !wasFruitAvailable) { // Extract unique arcs from all characters
showFruitUnlock = true; $: {
setTimeout(() => (showFruitUnlock = false), 600); const useFrench = isFrench;
} const arcMap = new Map<string, ArcFilterOption>(
wasFruitAvailable = isFruitAvailable; allCharacters
.filter(
(char: CharacterWithRelations): char is CharacterWithRelations & { arcId: string } =>
typeof char.arcId === 'string' &&
char.arcId.length > 0 &&
typeof getDisplayArcName(char, useFrench) === 'string' &&
getDisplayArcName(char, useFrench)!.length > 0
)
.map((char: CharacterWithRelations & { arcId: string }) => [
char.arcId,
{ id: char.arcId, name: getDisplayArcName(char, useFrench) as string }
])
);
if (isAffiliationAvailable && !wasAffiliationAvailable) { availableArcs = [...arcMap.values()].sort((a, b) => a.name.localeCompare(b.name));
showAffiliationUnlock = true;
setTimeout(() => (showAffiliationUnlock = false), 600);
} }
wasAffiliationAvailable = isAffiliationAvailable;
// Filter characters based on selected filters
$: characters = allCharacters.filter((char: CharacterWithRelations) => {
// Gender filter
if (characterFilters.gender.length > 0 && (char.gender == null || !characterFilters.gender.includes(char.gender))) {
return false;
} }
// Haki filter
if (characterFilters.hasHaki && !(char.hakiObservation || char.hakiArmament || char.hakiConqueror)) {
return false;
}
// Devil fruit filter
if (characterFilters.hasDevilFruit !== null) {
const hasDevil = char.devilFruitId !== null && char.devilFruitId !== undefined;
if (characterFilters.hasDevilFruit !== hasDevil) {
return false;
}
}
// Status filter
if (characterFilters.status.length > 0) {
const normalizedStatus = normalizeStatus(char.status);
if (!characterFilters.status.includes(normalizedStatus)) {
return false;
}
}
// Height filter
if (characterFilters.hasHeight && (char.height === null || char.height === undefined)) {
return false;
}
// Age filter
if (characterFilters.hasAge && (char.age === null || char.age === undefined)) {
return false;
}
// Origin filter
if (characterFilters.hasOrigin && (char.origin === null || char.origin === undefined || char.origin === '')) {
return false;
}
// Arc filter
if (characterFilters.arcs.length > 0 && (char.arcId == null || !characterFilters.arcs.includes(char.arcId))) {
return false;
}
return true;
});
$: {
const currentCharacterId = currentCharacter?.id;
hasWon = currentCharacterId != null && selectedCharacters.some(char => char.id === currentCharacterId);
}
$: if (hasWon && currentCharacter?.id === 'gecko_moria_gecko_moria') {
isGeckoMoriaWin = true;
} else if (!hasWon) {
isGeckoMoriaWin = false;
}
$: columnDisplayNames = {
status: $t.game.components.guessHistory.status,
gender: $t.game.components.guessHistory.gender,
affiliations: $t.game.components.guessHistory.affiliations,
devilFruitType: $t.game.components.guessHistory.fruit,
haki: $t.game.components.guessHistory.haki,
bounty: $t.game.components.guessHistory.bounty,
height: $t.game.components.guessHistory.height,
age: $t.game.components.guessHistory.age,
origin: $t.game.components.guessHistory.origin,
arc: $t.game.components.guessHistory.arc
};
function generateNewCharacter() { function generateNewCharacter() {
if (characters.length === 0) return; if (characters.length === 0) return;
currentCharacter = characters[Math.floor(Math.random() * characters.length)]; currentCharacter = characters[Math.floor(Math.random() * characters.length)];
syncHintAvailability(selectedCharacters.length, 0);
selectedCharacters = []; selectedCharacters = [];
} }
function handleCharacterSelect(event: CustomEvent) { function handleCharacterSelect(character: CharacterWithRelations) {
const character = event.detail;
selectCharacter(character); selectCharacter(character);
} }
function selectCharacter(character: any) { function selectCharacter(character: CharacterWithRelations) {
const current = currentCharacter;
if (!current) {
return;
}
const previousGuessCount = selectedCharacters.length;
selectedCharacters = [character, ...selectedCharacters]; selectedCharacters = [character, ...selectedCharacters];
syncHintAvailability(previousGuessCount, selectedCharacters.length, isLoaded);
// Check if player won // Check if player won
if (character.id === currentCharacter.id) { if (character.id === current.id) {
// Increment score (saved to localStorage via reactive statement) // Increment score (saved to localStorage via reactive statement)
score++; score++;
// Don't auto-generate next character - wait for user to click "Recommencer" // Don't auto-generate next character - wait for user to click "Recommencer"
@@ -170,195 +366,301 @@
columnVisibility[column] = !columnVisibility[column]; columnVisibility[column] = !columnVisibility[column];
columnVisibility = columnVisibility; // Trigger reactivity columnVisibility = columnVisibility; // Trigger reactivity
} }
function revealAnswer() {
if (!currentCharacter) {
return;
}
// Reset score (strike)
score = 0;
// Add the current character as the correct answer
const previousGuessCount = selectedCharacters.length;
selectedCharacters = [currentCharacter, ...selectedCharacters];
syncHintAvailability(previousGuessCount, selectedCharacters.length, isLoaded);
}
function toggleGenderFilter(gender: string) {
if (characterFilters.gender.includes(gender)) {
characterFilters.gender = characterFilters.gender.filter(g => g !== gender);
} else {
characterFilters.gender = [...characterFilters.gender, gender];
}
// Regenerate character with new filters
if (!hasWon) {
generateNewCharacter();
}
}
function toggleStatusFilter(status: string) {
if (characterFilters.status.includes(status)) {
characterFilters.status = characterFilters.status.filter(s => s !== status);
} else {
characterFilters.status = [...characterFilters.status, status];
}
// Regenerate character with new filters
if (!hasWon) {
generateNewCharacter();
}
}
function toggleHakiFilter() {
characterFilters.hasHaki = !characterFilters.hasHaki;
// Regenerate character with new filters
if (!hasWon) {
generateNewCharacter();
}
}
function toggleDevilFruitFilter() {
if (characterFilters.hasDevilFruit === null) {
characterFilters.hasDevilFruit = true;
} else if (characterFilters.hasDevilFruit === true) {
characterFilters.hasDevilFruit = false;
} else {
characterFilters.hasDevilFruit = null;
}
// Regenerate character with new filters
if (!hasWon) {
generateNewCharacter();
}
}
function toggleHeightFilter() {
characterFilters.hasHeight = !characterFilters.hasHeight;
// Regenerate character with new filters
if (!hasWon) {
generateNewCharacter();
}
}
function toggleAgeFilter() {
characterFilters.hasAge = !characterFilters.hasAge;
if (!hasWon) {
generateNewCharacter();
}
}
function toggleOriginFilter() {
characterFilters.hasOrigin = !characterFilters.hasOrigin;
// Regenerate character with new filters
if (!hasWon) {
generateNewCharacter();
}
}
function toggleArcFilter(arcId: string) {
if (characterFilters.arcs.includes(arcId)) {
characterFilters.arcs = characterFilters.arcs.filter(a => a !== arcId);
} else {
characterFilters.arcs = [...characterFilters.arcs, arcId];
}
// Regenerate character with new filters
if (!hasWon) {
generateNewCharacter();
}
}
function clearAllFilters() {
characterFilters = {
gender: [],
hasHaki: false,
hasDevilFruit: null,
status: [],
hasHeight: false,
hasAge: false,
hasOrigin: false,
arcs: []
};
// Regenerate character with new filters
if (!hasWon) {
generateNewCharacter();
}
}
function normalizeStatus(status: unknown): string {
if (status == null) {
return 'Unknown';
}
if (typeof status !== 'string') {
return String(status);
}
const value = status.trim();
if (value === '') {
return 'Unknown';
}
switch (value.toLowerCase()) {
case 'alive':
return 'Alive';
case 'dead':
case 'deceased':
return 'Dead';
case 'unknown':
case 'inconnu':
case '-':
return 'Unknown';
default:
return value;
}
}
</script> </script>
<svelte:head> <svelte:head>
<title>OnePieceDle - Mode Infini</title> <title>{$t.game.infinite.metaTitle}</title>
<style> <style>
@keyframes shadow-pulse { @keyframes shadow-pulse {
0% { 0% {
text-shadow: 0 0 20px rgba(0, 0, 0, 0.5), 0 0 40px rgba(50, 50, 50, 0.8); text-shadow:
0 0 20px rgba(0, 0, 0, 0.5),
0 0 40px rgba(50, 50, 50, 0.8);
opacity: 1; opacity: 1;
} }
50% { 50% {
text-shadow: 0 0 60px rgba(0, 0, 0, 0.9), 0 0 100px rgba(30, 30, 30, 1), text-shadow:
0 0 60px rgba(0, 0, 0, 0.9),
0 0 100px rgba(30, 30, 30, 1),
inset 0 0 50px rgba(0, 0, 0, 0.7); inset 0 0 50px rgba(0, 0, 0, 0.7);
opacity: 0.9; opacity: 0.9;
} }
100% { 100% {
text-shadow: 0 0 20px rgba(0, 0, 0, 0.5), 0 0 40px rgba(50, 50, 50, 0.8); text-shadow:
0 0 20px rgba(0, 0, 0, 0.5),
0 0 40px rgba(50, 50, 50, 0.8);
opacity: 1; opacity: 1;
} }
} }
.gecko-moria-effect { .gecko-moria-effect {
animation: shadow-pulse 1.5s ease-in-out infinite; animation: shadow-pulse 1.5s ease-in-out infinite;
} }
@keyframes moria-chaos {
0% {
transform: rotate(0deg) scale(1);
filter: invert(0%) hue-rotate(0deg) blur(0px);
}
10% {
transform: rotate(15deg) scale(1.02);
filter: invert(30%) hue-rotate(45deg) blur(2px);
}
20% {
transform: rotate(-10deg) scale(0.98);
filter: invert(60%) hue-rotate(90deg) blur(1px);
}
30% {
transform: rotate(25deg) scale(1.05);
filter: invert(100%) hue-rotate(180deg) blur(3px);
}
40% {
transform: rotate(-20deg) scale(0.95);
filter: invert(80%) hue-rotate(270deg) blur(2px);
}
50% {
transform: rotate(30deg) scale(1.08);
filter: invert(100%) hue-rotate(0deg) blur(4px);
}
60% {
transform: rotate(-25deg) scale(0.92);
filter: invert(70%) hue-rotate(90deg) blur(2px);
}
70% {
transform: rotate(20deg) scale(1.03);
filter: invert(50%) hue-rotate(180deg) blur(3px);
}
80% {
transform: rotate(-15deg) scale(1.01);
filter: invert(80%) hue-rotate(270deg) blur(1px);
}
100% {
transform: rotate(360deg) scale(1);
filter: invert(0%) hue-rotate(360deg) blur(0px);
}
}
.moria-screen-chaos {
animation: moria-chaos 4s ease-in-out;
}
</style> </style>
</svelte:head> </svelte:head>
<main <main
class="relative min-h-screen overflow-hidden bg-slate-950 text-slate-100" class="relative min-h-screen overflow-hidden bg-slate-950 text-slate-100 {isGeckoMoriaWin
? 'moria-screen-chaos'
: ''}"
> >
<div class="absolute inset-0 bg-gradient-to-br from-slate-950/85 via-slate-900/60 to-slate-950/80"></div>
<div <div
class="absolute inset-0 mix-blend-screen opacity-20 bg-[radial-gradient(circle_at_top,rgba(255,215,84,0.35),transparent_55%)]" class="absolute inset-0 bg-linear-to-br from-slate-950/85 via-slate-900/60 to-slate-950/80"
></div>
<div
class="absolute inset-0 bg-[radial-gradient(circle_at_top,rgba(255,215,84,0.35),transparent_55%)] opacity-20 mix-blend-screen"
></div> ></div>
<div class="relative mx-auto flex min-h-screen w-full max-w-6xl flex-col px-6 py-8 sm:py-10"> <div class="relative mx-auto flex min-h-screen w-full max-w-6xl flex-col px-6 py-8 sm:py-10">
<header class="flex flex-col items-start gap-6 w-full"> <header class="flex w-full flex-col items-start gap-6">
<div class="flex w-full items-center justify-between gap-4"> <div class="flex w-full items-center justify-between gap-4">
<div> <div>
<h1 class="text-3xl font-black uppercase tracking-[0.25em] text-amber-50 sm:text-5xl"> <h1 class="text-3xl font-black tracking-[0.25em] text-amber-50 uppercase sm:text-5xl">
Mode Infini {$t.game.infinite.title}
</h1> </h1>
<p class="mt-2 text-2xl font-bold text-amber-300">Score: {score}</p> <p class="mt-2 text-2xl font-bold text-amber-300">{$t.game.infinite.score}: {score}</p>
</div> </div>
{#if score > 0} {#if score > 0}
<button <button
class="rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50" class="rounded-full border border-amber-200/40 bg-transparent px-5 py-3 text-sm font-semibold text-amber-100 transition hover:border-amber-200 hover:text-amber-50"
onclick={resetScore} onclick={resetScore}
> >
Réinitialiser {$t.game.infinite.resetScore}
</button> </button>
{/if} {/if}
</div> </div>
<p class="max-w-2xl text-base text-slate-200 sm:text-lg"> <p class="max-w-2xl text-base text-slate-200 sm:text-lg">
Devine des personnages à l'infini ! Chaque indice se débloque après un certain nombre de {$t.game.infinite.description}
tentatives. Bonne chance !
</p> </p>
</header> </header>
<section class="mt-10 grid gap-6"> <section class="mt-10 grid gap-6">
{#if currentCharacter} {#if currentCharacter}
{#if hasWon} {#if hasWon}
<div <div>
class="rounded-3xl border border-emerald-500/50 bg-emerald-500/10 p-4 shadow-[0_24px_60px_rgba(16,185,129,0.3)] backdrop-blur" <WinPanel selectedCharacter={currentCharacter} {selectedCharacters} {isGeckoMoriaWin} />
>
<div class="text-center">
<div class="text-3xl mb-2">🎉</div>
<h2 class="text-xl font-bold text-emerald-400 mb-1">Bien joué !</h2>
<p class="text-sm text-emerald-300">
Vous avez trouvé le personnage en {selectedCharacters.length}
{selectedCharacters.length > 1 ? 'tentatives' : 'tentative'} !
</p>
<div class="mt-3">
{#if currentCharacter.pictureUrl}
<a
href={'https://onepiece.fandom.com/fr/wiki/' + currentCharacter.url}
target="_blank"
rel="noopener noreferrer"
class="inline-block"
>
<img
src={currentCharacter.pictureUrl}
alt={currentCharacter.name}
class="w-20 h-20 mx-auto rounded-full border-2 border-emerald-400 shadow-lg object-cover hover:border-emerald-300 transition-colors cursor-pointer"
/>
</a>
{/if}
<p class="mt-2 text-lg font-bold text-white">{currentCharacter.name}</p>
</div>
<button <button
type="button" type="button"
onclick={nextCharacter} onclick={nextCharacter}
class="mt-4 rounded-full bg-emerald-500 px-6 py-2 text-sm font-semibold text-white transition hover:bg-emerald-600" class="mt-4 w-full rounded-full bg-emerald-500 px-6 py-2 text-sm font-semibold text-white transition hover:bg-emerald-600"
> >
Recommencer {$t.game.infinite.nextCharacter}
</button> </button>
</div> </div>
{:else}
{#if selectedCharacters.length > 0}
<HintsPanel
dailyCharacter={currentCharacter}
{selectedCharacters}
{showOriginUnlock}
{showFruitUnlock}
{showAffiliationUnlock}
/>
<div class="mt-2 flex justify-center">
<button
type="button"
onclick={revealAnswer}
class="rounded-lg border border-red-600/40 bg-red-900/20 px-4 py-2 text-sm text-red-300 transition hover:border-red-500 hover:bg-red-900/40 hover:text-red-200"
>
{$t.game.infinite.revealAnswer}
</button>
</div> </div>
{/if}
<CharacterSearchInput
{characters}
{selectedCharacters}
onSelect={handleCharacterSelect}
/>
{/if}
{:else} {:else}
<div <div
class="rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur" class="rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur"
> >
<div class="grid gap-3 sm:grid-cols-3"> <p class="text-center text-slate-300">{$t.game.infinite.loadingCharacter}</p>
<button
type="button"
class="rounded-2xl border border-white/10 px-3 py-3 flex flex-col items-center justify-center cursor-pointer hover:bg-slate-900/80 transition-colors {isOriginAvailable
? 'bg-slate-950/60'
: 'bg-slate-950/30 opacity-50 cursor-not-allowed hover:bg-slate-950/30'} {showOriginUnlock
? 'hint-unlocking'
: ''}"
disabled={!isOriginAvailable}
onclick={() => (showOriginUnlock = !showOriginUnlock)}
>
<p class="text-sm font-medium text-amber-100">Origine</p>
{#if showOriginUnlock}
<p class="mt-2 text-xs text-white font-semibold">
{currentCharacter.origin || 'Inconnue'}
</p>
{:else if Math.max(0, 5 - selectedCharacters.length) > 0}
<p class="mt-2 text-xs text-slate-400">
{Math.max(0, 5 - selectedCharacters.length)} essais avant déblocage
</p>
{:else}
<p class="mt-2 text-xs text-slate-400">Indice disponible !</p>
{/if}
</button>
<button
type="button"
class="rounded-2xl border border-white/10 px-3 py-3 flex flex-col items-center justify-center cursor-pointer hover:bg-slate-900/80 transition-colors {isFruitAvailable
? 'bg-slate-950/60'
: 'bg-slate-950/30 opacity-50 cursor-not-allowed hover:bg-slate-950/30'} {showFruitUnlock
? 'hint-unlocking'
: ''}"
disabled={!isFruitAvailable}
onclick={() => (showFruitUnlock = !showFruitUnlock)}
>
<p class="text-sm font-medium text-amber-100">Fruit du démon</p>
{#if showFruitUnlock}
<p class="mt-2 text-xs text-white font-semibold">
{currentCharacter.devilFruitName || 'Aucun'}
</p>
{:else if Math.max(0, 10 - selectedCharacters.length) > 0}
<p class="mt-2 text-xs text-slate-400">
{Math.max(0, 10 - selectedCharacters.length)} essais avant déblocage
</p>
{:else}
<p class="mt-2 text-xs text-slate-400">Indice disponible !</p>
{/if}
</button>
<button
type="button"
class="rounded-2xl border border-white/10 px-3 py-3 flex flex-col items-center justify-center cursor-pointer hover:bg-slate-900/80 transition-colors {isAffiliationAvailable
? 'bg-slate-950/60'
: 'bg-slate-950/30 opacity-50 cursor-not-allowed hover:bg-slate-950/30'} {showAffiliationUnlock
? 'hint-unlocking'
: ''}"
disabled={!isAffiliationAvailable}
onclick={() => (showAffiliationUnlock = !showAffiliationUnlock)}
>
<p class="text-sm font-medium text-amber-100">Affiliation</p>
{#if showAffiliationUnlock}
{@const affiliations = typeof currentCharacter.affiliations === 'string'
? currentCharacter.affiliations.includes('[')
? JSON.parse(currentCharacter.affiliations)
: currentCharacter.affiliations
.split(',')
.map((a: string) => a.trim())
: currentCharacter.affiliations}
<p class="mt-2 text-xs text-white font-semibold">
{Array.isArray(affiliations) ? affiliations[0] : affiliations || 'Inconnue'}
</p>
{:else if Math.max(0, 15 - selectedCharacters.length) > 0}
<p class="mt-2 text-xs text-slate-400">
{Math.max(0, 15 - selectedCharacters.length)} essais avant déblocage
</p>
{:else}
<p class="mt-2 text-xs text-slate-400">Indice disponible !</p>
{/if}
</button>
</div>
</div>
<CharacterSearchInput
{characters}
{selectedCharacters}
on:select={handleCharacterSelect}
/>
{/if}
{:else}
<div class="rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur">
<p class="text-center text-slate-300">Chargement du personnage...</p>
</div> </div>
{/if} {/if}
</section> </section>
@@ -370,13 +672,169 @@
{columnVisibility} {columnVisibility}
/> />
<!-- Character Filters -->
<section class="mt-6">
<div class="rounded-2xl border border-white/10 bg-white/5 p-3 backdrop-blur sm:p-4">
<div class="mb-3 flex items-center justify-between gap-3">
<h3 class="text-xs font-semibold tracking-[0.2em] text-amber-200 uppercase">
{$t.game.infinite.filtersTitle}
</h3>
{#if characterFilters.gender.length > 0 || characterFilters.hasHaki || characterFilters.hasDevilFruit !== null || characterFilters.status.length > 0 || characterFilters.hasHeight || characterFilters.hasAge || characterFilters.hasOrigin || characterFilters.arcs.length > 0}
<button
type="button"
onclick={clearAllFilters}
class="text-xs text-red-300 transition hover:text-red-200"
>
{$t.game.infinite.clearFilters}
</button>
{/if}
</div>
<div class="space-y-3">
<!-- Gender Filter -->
<div>
<p class="mb-2 text-xs text-slate-400">{$t.game.infinite.filterGender}</p>
<div class="flex flex-wrap gap-2">
{#each ['Male', 'Female'] as gender (gender)}
<button
type="button"
onclick={() => toggleGenderFilter(gender)}
class="rounded-full border px-2.5 py-1 text-xs font-medium transition-colors {characterFilters.gender.includes(
gender
)
? 'border-amber-300/50 bg-amber-300/10 text-amber-100 hover:bg-amber-300/20'
: 'border-white/20 bg-slate-900/40 text-slate-400 hover:bg-slate-900/60'}"
>
{gender === 'Male' ? $t.game.infinite.male : $t.game.infinite.female}
</button>
{/each}
</div>
</div>
<!-- Status Filter -->
<div>
<p class="mb-2 text-xs text-slate-400">{$t.game.infinite.filterStatus}</p>
<div class="flex flex-wrap gap-2">
{#each ['Alive', 'Dead', 'Unknown'] as status (status)}
<button
type="button"
onclick={() => toggleStatusFilter(status)}
class="rounded-full border px-2.5 py-1 text-xs font-medium transition-colors {characterFilters.status.includes(
status
)
? 'border-amber-300/50 bg-amber-300/10 text-amber-100 hover:bg-amber-300/20'
: 'border-white/20 bg-slate-900/40 text-slate-400 hover:bg-slate-900/60'}"
>
{status === 'Alive' ? $t.game.infinite.alive : status === 'Dead' ? $t.game.infinite.dead : $t.game.infinite.unknown}
</button>
{/each}
</div>
</div>
<!-- Haki Filter -->
<div>
<p class="mb-2 text-xs text-slate-400">{$t.game.infinite.filterAbilities}</p>
<div class="flex flex-wrap gap-2">
<button
type="button"
onclick={toggleHakiFilter}
class="rounded-full border px-2.5 py-1 text-xs font-medium transition-colors {characterFilters.hasHaki
? 'border-amber-300/50 bg-amber-300/10 text-amber-100 hover:bg-amber-300/20'
: 'border-white/20 bg-slate-900/40 text-slate-400 hover:bg-slate-900/60'}"
>
{$t.game.infinite.hasHaki}
</button>
<button
type="button"
onclick={toggleDevilFruitFilter}
class="rounded-full border px-2.5 py-1 text-xs font-medium transition-colors {characterFilters.hasDevilFruit ===
true
? 'border-amber-300/50 bg-amber-300/10 text-amber-100 hover:bg-amber-300/20'
: characterFilters.hasDevilFruit === false
? 'border-purple-300/50 bg-purple-300/10 text-purple-100 hover:bg-purple-300/20'
: 'border-white/20 bg-slate-900/40 text-slate-400 hover:bg-slate-900/60'}"
>
{characterFilters.hasDevilFruit === null
? $t.game.infinite.fruitAll
: characterFilters.hasDevilFruit
? $t.game.infinite.withFruit
: $t.game.infinite.withoutFruit}
</button>
</div>
</div>
<!-- Informations Filter -->
<div>
<p class="mb-2 text-xs text-slate-400">{$t.game.infinite.filterInformation}</p>
<div class="flex flex-wrap gap-2">
<button
type="button"
onclick={toggleHeightFilter}
class="rounded-full border px-2.5 py-1 text-xs font-medium transition-colors {characterFilters.hasHeight
? 'border-amber-300/50 bg-amber-300/10 text-amber-100 hover:bg-amber-300/20'
: 'border-white/20 bg-slate-900/40 text-slate-400 hover:bg-slate-900/60'}"
>
{$t.game.infinite.heightDefined}
</button>
<button
type="button"
onclick={toggleAgeFilter}
class="rounded-full border px-2.5 py-1 text-xs font-medium transition-colors {characterFilters.hasAge
? 'border-amber-300/50 bg-amber-300/10 text-amber-100 hover:bg-amber-300/20'
: 'border-white/20 bg-slate-900/40 text-slate-400 hover:bg-slate-900/60'}"
>
{$t.game.infinite.ageDefined}
</button>
<button
type="button"
onclick={toggleOriginFilter}
class="rounded-full border px-2.5 py-1 text-xs font-medium transition-colors {characterFilters.hasOrigin
? 'border-amber-300/50 bg-amber-300/10 text-amber-100 hover:bg-amber-300/20'
: 'border-white/20 bg-slate-900/40 text-slate-400 hover:bg-slate-900/60'}"
>
{$t.game.infinite.originDefined}
</button>
</div>
</div>
<!-- Arc Filter -->
<div>
<p class="mb-2 text-xs text-slate-400">{$t.game.infinite.filterArcs}</p>
<div class="flex flex-wrap gap-2">
{#each availableArcs as arc (arc.id)}
<button
type="button"
onclick={() => toggleArcFilter(arc.id)}
class="rounded-full border px-2.5 py-1 text-xs font-medium transition-colors {characterFilters.arcs.includes(
arc.id
)
? 'border-amber-300/50 bg-amber-300/10 text-amber-100 hover:bg-amber-300/20'
: 'border-white/20 bg-slate-900/40 text-slate-400 hover:bg-slate-900/60'}"
>
{arc.name}
</button>
{/each}
</div>
</div>
<p class="mt-2 text-xs text-slate-500">
{characters.length} {characters.length > 1 ? $t.game.infinite.availableCharactersPlural : $t.game.infinite.availableCharactersSingular}
</p>
</div>
</div>
</section>
<!-- Column Visibility Toggle --> <!-- Column Visibility Toggle -->
<section class="mt-6"> <section class="mt-6">
<div class="rounded-2xl border border-white/10 bg-white/5 p-3 sm:p-4 backdrop-blur"> <div class="rounded-2xl border border-white/10 bg-white/5 p-3 backdrop-blur sm:p-4">
<div class="mb-3 flex items-center justify-between gap-3"> <div class="mb-3 flex items-center justify-between gap-3">
<h3 class="text-xs font-semibold uppercase tracking-[0.2em] text-amber-200">Colonnes</h3> <h3 class="text-xs font-semibold tracking-[0.2em] text-amber-200 uppercase">
{$t.game.infinite.columnsTitle}
</h3>
<p class="text-xs text-slate-400"> <p class="text-xs text-slate-400">
{Object.values(columnVisibility).filter(Boolean).length}/{Object.keys(columnVisibility).length} {Object.values(columnVisibility).filter(Boolean).length}/{Object.keys(
columnVisibility
).length}
</p> </p>
</div> </div>
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2">

View File

@@ -2,7 +2,10 @@ import { fail, redirect } from '@sveltejs/kit';
import type { Actions } from './$types'; import type { Actions } from './$types';
import type { PageServerLoad } from './$types'; import type { PageServerLoad } from './$types';
import { auth } from '$lib/server/auth'; import { auth } from '$lib/server/auth';
import { db } from '$lib/server/db';
import { user } from '$lib/server/db/schema';
import { APIError } from 'better-auth/api'; import { APIError } from 'better-auth/api';
import { sql } from 'drizzle-orm';
export const load: PageServerLoad = async (event) => { export const load: PageServerLoad = async (event) => {
if (event.locals.user) { if (event.locals.user) {
@@ -14,9 +17,28 @@ export const load: PageServerLoad = async (event) => {
export const actions: Actions = { export const actions: Actions = {
signInEmail: async (event) => { signInEmail: async (event) => {
const formData = await event.request.formData(); const formData = await event.request.formData();
const email = formData.get('email')?.toString() ?? ''; const identifier = formData.get('identifier')?.toString().trim() ?? formData.get('email')?.toString().trim() ?? '';
const password = formData.get('password')?.toString() ?? ''; const password = formData.get('password')?.toString() ?? '';
if (!identifier) {
return fail(400, { message: 'Email ou nom d\'utilisateur requis' });
}
let email = identifier;
if (!identifier.includes('@')) {
const [foundUser] = await db
.select({ email: user.email })
.from(user)
.where(sql`lower(${user.username}) = ${identifier.toLowerCase()}`)
.limit(1);
if (!foundUser) {
return fail(400, { message: 'Identifiants invalides' });
}
email = foundUser.email;
}
try { try {
await auth.api.signInEmail({ await auth.api.signInEmail({
body: { body: {
@@ -38,7 +60,33 @@ export const actions: Actions = {
const formData = await event.request.formData(); const formData = await event.request.formData();
const email = formData.get('email')?.toString() ?? ''; const email = formData.get('email')?.toString() ?? '';
const password = formData.get('password')?.toString() ?? ''; const password = formData.get('password')?.toString() ?? '';
const confirmPassword = formData.get('confirmPassword')?.toString() ?? '';
const name = formData.get('name')?.toString() ?? ''; const name = formData.get('name')?.toString() ?? '';
const username = formData.get('username')?.toString().trim() ?? '';
if (!username) {
return fail(400, { message: 'Nom d\'utilisateur requis' });
}
if (!/^[a-zA-Z0-9._-]{3,30}$/.test(username)) {
return fail(400, {
message: "Le nom d'utilisateur doit contenir 3 à 30 caractères (lettres, chiffres, ., _, -)"
});
}
const [existingUsername] = await db
.select({ id: user.id })
.from(user)
.where(sql`lower(${user.username}) = ${username.toLowerCase()}`)
.limit(1);
if (existingUsername) {
return fail(400, { message: "Ce nom d'utilisateur est déjà pris" });
}
if (password !== confirmPassword) {
return fail(400, { message: 'Les mots de passe ne correspondent pas' });
}
try { try {
await auth.api.signUpEmail({ await auth.api.signUpEmail({
@@ -46,6 +94,7 @@ export const actions: Actions = {
email, email,
password, password,
name, name,
username,
callbackURL: '/auth/verification-success' callbackURL: '/auth/verification-success'
} }
}); });

View File

@@ -1,11 +1,14 @@
<script lang="ts"> <script lang="ts">
import { enhance } from '$app/forms'; import { enhance } from '$app/forms';
import { resolve } from '$app/paths';
import { t } from '$lib/i18n';
import type { ActionData } from './$types'; import type { ActionData } from './$types';
export let form: ActionData; export let form: ActionData;
let isSignUp = false; let isSignUp = false;
let name = ''; let name = '';
let username = '';
let email = ''; let email = '';
let password = ''; let password = '';
let confirmPassword = ''; let confirmPassword = '';
@@ -14,6 +17,7 @@
const handleToggle = () => { const handleToggle = () => {
isSignUp = !isSignUp; isSignUp = !isSignUp;
name = ''; name = '';
username = '';
email = ''; email = '';
password = ''; password = '';
confirmPassword = ''; confirmPassword = '';
@@ -22,11 +26,11 @@
</script> </script>
<svelte:head> <svelte:head>
<title>OnePieceDle - {isSignUp ? 'Inscription' : 'Connexion'}</title> <title>OnePieceDle - {isSignUp ? $t.game.login.titleSignUp : $t.game.login.titleSignIn}</title>
</svelte:head> </svelte:head>
<main class="relative min-h-[calc(100vh-5rem)] bg-slate-950 text-slate-100"> <main class="relative min-h-[calc(100vh-5rem)] bg-slate-950 text-slate-100">
<div class="absolute inset-0 bg-gradient-to-br from-slate-950/85 via-slate-900/60 to-slate-950/80"></div> <div class="absolute inset-0 bg-linear-to-br from-slate-950/85 via-slate-900/60 to-slate-950/80"></div>
<div <div
class="absolute inset-0 mix-blend-screen opacity-20 bg-[radial-gradient(circle_at_top,rgba(255,215,84,0.35),transparent_55%)]" class="absolute inset-0 mix-blend-screen opacity-20 bg-[radial-gradient(circle_at_top,rgba(255,215,84,0.35),transparent_55%)]"
></div> ></div>
@@ -39,7 +43,7 @@
OnePieceDle OnePieceDle
</h1> </h1>
<p class="mt-4 text-slate-300"> <p class="mt-4 text-slate-300">
{isSignUp ? 'Créer votre compte' : 'Bienvenue, pirate'} {isSignUp ? $t.game.login.headerSignUp : $t.game.login.headerSignIn}
</p> </p>
</div> </div>
@@ -61,7 +65,7 @@
{#if isSignUp} {#if isSignUp}
<div> <div>
<label for="name" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100"> <label for="name" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">
Nom {$t.game.login.nameLabel}
</label> </label>
<input <input
id="name" id="name"
@@ -69,24 +73,42 @@
name="name" name="name"
bind:value={name} bind:value={name}
required required
placeholder="Votre nom" placeholder={$t.game.login.namePlaceholder}
class="mt-3 w-full rounded-lg border border-white/10 bg-white/5 px-4 py-3 text-white placeholder-slate-500 transition focus:border-amber-300 focus:outline-none focus:ring-2 focus:ring-amber-300/30" class="mt-3 w-full rounded-lg border border-white/10 bg-white/5 px-4 py-3 text-white placeholder-slate-500 transition focus:border-amber-300 focus:outline-none focus:ring-2 focus:ring-amber-300/30"
/> />
</div> </div>
{/if} {/if}
<!-- Email Field --> <!-- Username Field (Sign Up Only) -->
{#if isSignUp}
<div> <div>
<label for="email" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100"> <label for="username" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">
E-mail {$t.game.login.usernameLabel}
</label> </label>
<input <input
id="email" id="username"
type="email" type="text"
name="email" name="username"
bind:value={username}
required
placeholder={$t.game.login.usernamePlaceholder}
class="mt-3 w-full rounded-lg border border-white/10 bg-white/5 px-4 py-3 text-white placeholder-slate-500 transition focus:border-amber-300 focus:outline-none focus:ring-2 focus:ring-amber-300/30"
/>
</div>
{/if}
<!-- Email / Username Field -->
<div>
<label for="identifier" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">
{isSignUp ? $t.game.login.identifierLabelSignUp : $t.game.login.identifierLabelSignIn}
</label>
<input
id="identifier"
type={isSignUp ? 'email' : 'text'}
name={isSignUp ? 'email' : 'identifier'}
bind:value={email} bind:value={email}
required required
placeholder="votremail@email.com" placeholder={isSignUp ? $t.game.login.identifierPlaceholderSignUp : $t.game.login.identifierPlaceholderSignIn}
class="mt-3 w-full rounded-lg border border-white/10 bg-white/5 px-4 py-3 text-white placeholder-slate-500 transition focus:border-amber-300 focus:outline-none focus:ring-2 focus:ring-amber-300/30" class="mt-3 w-full rounded-lg border border-white/10 bg-white/5 px-4 py-3 text-white placeholder-slate-500 transition focus:border-amber-300 focus:outline-none focus:ring-2 focus:ring-amber-300/30"
/> />
</div> </div>
@@ -94,7 +116,7 @@
<!-- Password Field --> <!-- Password Field -->
<div> <div>
<label for="password" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100"> <label for="password" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">
Mot de passe {$t.game.login.passwordLabel}
</label> </label>
<input <input
id="password" id="password"
@@ -114,7 +136,7 @@
for="confirmPassword" for="confirmPassword"
class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100"
> >
Confirmer le mot de passe {$t.game.login.confirmPasswordLabel}
</label> </label>
<input <input
id="confirmPassword" id="confirmPassword"
@@ -141,20 +163,20 @@
disabled={isLoading} disabled={isLoading}
class="w-full rounded-full bg-amber-300 px-6 py-3 text-sm font-semibold text-slate-900 transition disabled:opacity-50 hover:bg-amber-200" class="w-full rounded-full bg-amber-300 px-6 py-3 text-sm font-semibold text-slate-900 transition disabled:opacity-50 hover:bg-amber-200"
> >
{isLoading ? 'Chargement...' : isSignUp ? 'Créer un compte' : 'Se connecter'} {isLoading ? $t.game.login.loading : isSignUp ? $t.game.login.submitSignUp : $t.game.login.submitSignIn}
</button> </button>
</form> </form>
<!-- Toggle Sign Up / Login --> <!-- Toggle Sign Up / Login -->
<div class="mt-6 border-t border-white/10 pt-6"> <div class="mt-6 border-t border-white/10 pt-6">
<p class="text-center text-sm text-slate-400"> <p class="text-center text-sm text-slate-400">
{isSignUp ? 'Vous avez déjà un compte ?' : "Vous n'avez pas de compte ?"} {isSignUp ? $t.game.login.togglePromptSignUp : $t.game.login.togglePromptSignIn}
<button <button
type="button" type="button"
on:click={handleToggle} on:click={handleToggle}
class="text-amber-300 transition hover:text-amber-200" class="text-amber-300 transition hover:text-amber-200"
> >
{isSignUp ? 'Se connecter' : "S'inscrire"} {isSignUp ? $t.game.login.toggleActionSignUp : $t.game.login.toggleActionSignIn}
</button> </button>
</p> </p>
</div> </div>
@@ -162,8 +184,8 @@
<!-- Back to Home --> <!-- Back to Home -->
<div class="text-center"> <div class="text-center">
<a href="/" class="text-sm text-slate-400 transition hover:text-slate-300"> <a href={resolve("/")} class="text-sm text-slate-400 transition hover:text-slate-300">
Retour à l'accueil {$t.game.login.backHome}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -2,8 +2,8 @@ import { fail, redirect } from '@sveltejs/kit';
import type { Actions, PageServerLoad } from './$types'; import type { Actions, PageServerLoad } from './$types';
import { auth } from '$lib/server/auth'; import { auth } from '$lib/server/auth';
import { db } from '$lib/server/db'; import { db } from '$lib/server/db';
import { session } from '$lib/server/db/auth.schema'; import { session, userCharacterHistory, characterHistory, character, friendship, user } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm'; import { and, desc, eq, inArray, or, sql } from 'drizzle-orm';
import { APIError } from 'better-auth/api'; import { APIError } from 'better-auth/api';
export const load: PageServerLoad = async (event) => { export const load: PageServerLoad = async (event) => {
@@ -11,15 +11,119 @@ export const load: PageServerLoad = async (event) => {
return redirect(302, '/login'); return redirect(302, '/login');
} }
const currentUserId = event.locals.user.id;
// Fetch all sessions for this user // Fetch all sessions for this user
const userSessions = await db const userSessions = await db
.select() .select()
.from(session) .from(session)
.where(eq(session.userId, event.locals.user.id)); .where(eq(session.userId, event.locals.user.id));
// Fetch daily history for this user
const dailyHistoryRaw = await db
.select({
id: userCharacterHistory.id,
characterId: characterHistory.characterId,
date: characterHistory.date,
tryCount: userCharacterHistory.tryCount,
triedCharacterIds: userCharacterHistory.triedCharacterIds,
won: characterHistory.won,
characterName: character.name,
characterImage: character.pictureUrl
})
.from(userCharacterHistory)
.innerJoin(characterHistory, eq(userCharacterHistory.characterHistoryId, characterHistory.id))
.innerJoin(character, eq(characterHistory.characterId, character.id))
.where(eq(userCharacterHistory.userId, event.locals.user.id))
.orderBy(desc(characterHistory.date));
const uniqueTriedCharacterIds = Array.from(new Set(
dailyHistoryRaw.flatMap((entry) => entry.triedCharacterIds ?? [])
));
const triedCharacters = uniqueTriedCharacterIds.length > 0
? await db
.select({
id: character.id,
name: character.name,
pictureUrl: character.pictureUrl
})
.from(character)
.where(inArray(character.id, uniqueTriedCharacterIds))
: [];
const triedCharactersById = new Map(triedCharacters.map((entry) => [entry.id, entry]));
const dailyHistory = dailyHistoryRaw.map((entry) => ({
...entry,
triedCharacters: (entry.triedCharacterIds ?? [])
.map((characterId) => triedCharactersById.get(characterId))
.filter((triedEntry): triedEntry is (typeof triedCharacters)[number] => !!triedEntry)
}));
const incomingRequests = await db
.select({
id: friendship.id,
createdAt: friendship.createdAt,
requesterId: friendship.requesterId,
requesterName: user.name,
requesterUsername: user.username,
requesterImage: user.image
})
.from(friendship)
.innerJoin(user, eq(friendship.requesterId, user.id))
.where(and(eq(friendship.addresseeId, currentUserId), eq(friendship.status, 'pending')))
.orderBy(desc(friendship.createdAt));
const outgoingRequests = await db
.select({
id: friendship.id,
createdAt: friendship.createdAt,
addresseeId: friendship.addresseeId,
addresseeName: user.name,
addresseeUsername: user.username,
addresseeImage: user.image
})
.from(friendship)
.innerJoin(user, eq(friendship.addresseeId, user.id))
.where(and(eq(friendship.requesterId, currentUserId), eq(friendship.status, 'pending')))
.orderBy(desc(friendship.createdAt));
const acceptedAsRequester = await db
.select({
id: friendship.id,
createdAt: friendship.createdAt,
friendId: friendship.addresseeId,
friendName: user.name,
friendUsername: user.username,
friendImage: user.image
})
.from(friendship)
.innerJoin(user, eq(friendship.addresseeId, user.id))
.where(and(eq(friendship.requesterId, currentUserId), eq(friendship.status, 'accepted')));
const acceptedAsAddressee = await db
.select({
id: friendship.id,
createdAt: friendship.createdAt,
friendId: friendship.requesterId,
friendName: user.name,
friendUsername: user.username,
friendImage: user.image
})
.from(friendship)
.innerJoin(user, eq(friendship.requesterId, user.id))
.where(and(eq(friendship.addresseeId, currentUserId), eq(friendship.status, 'accepted')));
const friends = [...acceptedAsRequester, ...acceptedAsAddressee].sort((a, b) => b.createdAt - a.createdAt);
return { return {
user: event.locals.user, user: event.locals.user,
sessions: userSessions sessions: userSessions,
dailyHistory: dailyHistory,
incomingRequests,
outgoingRequests,
friends
}; };
}; };
@@ -111,9 +215,214 @@ export const actions: Actions = {
// Delete the session from database // Delete the session from database
await db.delete(session).where(eq(session.id, sessionId)); await db.delete(session).where(eq(session.id, sessionId));
} catch (error) { } catch (error) {
console.error('Error revoking session:', error);
return fail(500, { message: 'Erreur lors de la révocation de la session' }); return fail(500, { message: 'Erreur lors de la révocation de la session' });
} }
return { success: true, message: 'Session révoquée avec succès' }; return { success: true, message: 'Session révoquée avec succès' };
},
sendFriendRequest: async (event) => {
if (!event.locals.user) {
return redirect(302, '/login');
}
const formData = await event.request.formData();
const friendUsername = formData.get('friendUsername')?.toString().trim() ?? '';
if (!friendUsername) {
return fail(400, { message: 'Nom d\'utilisateur requis pour envoyer une demande' });
}
const me = event.locals.user;
const myUsername = (me as { username?: string }).username;
if (myUsername && friendUsername.toLowerCase() === myUsername.toLowerCase()) {
return fail(400, { message: 'Tu ne peux pas t\'ajouter toi-même' });
}
const [targetUser] = await db
.select({ id: user.id, username: user.username })
.from(user)
.where(sql`lower(${user.username}) = ${friendUsername.toLowerCase()}`)
.limit(1);
if (!targetUser) {
return fail(404, { message: 'Aucun utilisateur trouvé avec ce nom d\'utilisateur' });
}
const [existing] = await db
.select()
.from(friendship)
.where(
or(
and(eq(friendship.requesterId, me.id), eq(friendship.addresseeId, targetUser.id)),
and(eq(friendship.requesterId, targetUser.id), eq(friendship.addresseeId, me.id))
)
)
.limit(1);
const now = Date.now();
if (!existing) {
await db.insert(friendship).values({
requesterId: me.id,
addresseeId: targetUser.id,
status: 'pending',
createdAt: now,
updatedAt: now
});
return { success: true, message: 'Demande d\'ami envoyée' };
}
if (existing.status === 'accepted') {
return fail(400, { message: 'Vous êtes déjà amis' });
}
if (existing.status === 'pending') {
if (existing.requesterId === targetUser.id && existing.addresseeId === me.id) {
await db
.update(friendship)
.set({
status: 'accepted',
updatedAt: now
})
.where(eq(friendship.id, existing.id));
return { success: true, message: 'Demande acceptée automatiquement' };
}
return fail(400, { message: 'Demande déjà envoyée' });
}
await db
.update(friendship)
.set({
requesterId: me.id,
addresseeId: targetUser.id,
status: 'pending',
updatedAt: now
})
.where(eq(friendship.id, existing.id));
return { success: true, message: 'Demande d\'ami envoyée' };
},
acceptFriendRequest: async (event) => {
if (!event.locals.user) {
return redirect(302, '/login');
}
const formData = await event.request.formData();
const friendshipId = formData.get('friendshipId')?.toString() ?? '';
if (!friendshipId) {
return fail(400, { message: 'Demande invalide' });
}
const now = Date.now();
const result = await db
.update(friendship)
.set({ status: 'accepted', updatedAt: now })
.where(
and(
eq(friendship.id, friendshipId),
eq(friendship.addresseeId, event.locals.user.id),
eq(friendship.status, 'pending')
)
)
.returning({ id: friendship.id });
if (result.length === 0) {
return fail(404, { message: 'Demande introuvable' });
}
return { success: true, message: 'Demande acceptée' };
},
declineFriendRequest: async (event) => {
if (!event.locals.user) {
return redirect(302, '/login');
}
const formData = await event.request.formData();
const friendshipId = formData.get('friendshipId')?.toString() ?? '';
if (!friendshipId) {
return fail(400, { message: 'Demande invalide' });
}
const now = Date.now();
const result = await db
.update(friendship)
.set({ status: 'declined', updatedAt: now })
.where(
and(
eq(friendship.id, friendshipId),
eq(friendship.addresseeId, event.locals.user.id),
eq(friendship.status, 'pending')
)
)
.returning({ id: friendship.id });
if (result.length === 0) {
return fail(404, { message: 'Demande introuvable' });
}
return { success: true, message: 'Demande refusée' };
},
cancelFriendRequest: async (event) => {
if (!event.locals.user) {
return redirect(302, '/login');
}
const formData = await event.request.formData();
const friendshipId = formData.get('friendshipId')?.toString() ?? '';
if (!friendshipId) {
return fail(400, { message: 'Demande invalide' });
}
const result = await db
.delete(friendship)
.where(
and(
eq(friendship.id, friendshipId),
eq(friendship.requesterId, event.locals.user.id),
eq(friendship.status, 'pending')
)
)
.returning({ id: friendship.id });
if (result.length === 0) {
return fail(404, { message: 'Demande introuvable' });
}
return { success: true, message: 'Demande annulée' };
},
removeFriend: async (event) => {
if (!event.locals.user) {
return redirect(302, '/login');
}
const formData = await event.request.formData();
const friendshipId = formData.get('friendshipId')?.toString() ?? '';
if (!friendshipId) {
return fail(400, { message: 'Relation invalide' });
}
const result = await db
.delete(friendship)
.where(
and(
eq(friendship.id, friendshipId),
eq(friendship.status, 'accepted'),
or(eq(friendship.requesterId, event.locals.user.id), eq(friendship.addresseeId, event.locals.user.id))
)
)
.returning({ id: friendship.id });
if (result.length === 0) {
return fail(404, { message: 'Relation introuvable' });
}
return { success: true, message: 'Ami supprimé' };
} }
}; };

View File

@@ -1,30 +1,56 @@
<script lang="ts"> <script lang="ts">
import { enhance } from '$app/forms'; import { enhance } from '$app/forms';
import type { PageData } from './$types'; import type { PageData } from './$types';
import { resolve } from '$app/paths';
import { t, language } from '$lib/i18n';
interface Props { interface Props {
data: PageData; data: PageData;
form?: { success?: boolean; message?: string } | null; form?: { success?: boolean; message?: string } | null;
} }
interface DailyHistoryEntry {
id: string;
characterId: string | null;
date: number;
tryCount: number;
won: number;
characterName: string;
characterImage: string | null;
triedCharacters?: Array<{
id: string;
name: string;
pictureUrl: string | null;
}>;
}
let { data, form }: Props = $props(); let { data, form }: Props = $props();
let isLoading = $state(false); let isLoading = $state(false);
let activeTab = $state<'profile' | 'password' | 'sessions'>('profile'); let activeTab = $state<'profile' | 'password' | 'sessions' | 'daily' | 'friends'>('profile');
let name = $state(''); let name = $derived(data.user?.name || '');
let friendUsername = $state('');
let showSuccess = $state(false); let showSuccess = $state(false);
let oldPassword = $state(''); let oldPassword = $state('');
let newPassword = $state(''); let newPassword = $state('');
let confirmPassword = $state(''); let confirmPassword = $state('');
let sessions = $state<any[]>([]); let sessions = $derived(data.sessions || []);
let dailyHistory = $derived((data.dailyHistory || []) as DailyHistoryEntry[]);
let friends = $derived(data.friends || []);
let incomingRequests = $derived(data.incomingRequests || []);
let outgoingRequests = $derived(data.outgoingRequests || []);
let tabsElement: HTMLDivElement | undefined; let tabsElement: HTMLDivElement | undefined;
$effect(() => { $effect(() => {
name = data.user?.name || ''; friends = data.friends || [];
}); });
$effect(() => { $effect(() => {
sessions = (data as any).sessions || []; incomingRequests = data.incomingRequests || [];
});
$effect(() => {
outgoingRequests = data.outgoingRequests || [];
}); });
$effect(() => { $effect(() => {
@@ -36,7 +62,7 @@
} }
}); });
const handleTabChange = (tab: 'profile' | 'password' | 'sessions') => { const handleTabChange = (tab: 'profile' | 'password' | 'sessions' | 'daily' | 'friends') => {
activeTab = tab; activeTab = tab;
}; };
@@ -46,11 +72,11 @@
</script> </script>
<svelte:head> <svelte:head>
<title>Mon Profil - OnePieceDle</title> <title>{$t.game.profile.pageTitle} - OnePieceDle</title>
</svelte:head> </svelte:head>
<main class="relative min-h-[calc(100vh-5rem)] bg-slate-950 text-slate-100"> <main class="relative min-h-[calc(100vh-5rem)] bg-slate-950 text-slate-100">
<div class="absolute inset-0 bg-gradient-to-br from-slate-950/85 via-slate-900/60 to-slate-950/80"></div> <div class="absolute inset-0 bg-linear-to-br from-slate-950/85 via-slate-900/60 to-slate-950/80"></div>
<div class="absolute inset-0 mix-blend-screen opacity-20 bg-[radial-gradient(circle_at_top,rgba(255,215,84,0.35),transparent_55%)]"></div> <div class="absolute inset-0 mix-blend-screen opacity-20 bg-[radial-gradient(circle_at_top,rgba(255,215,84,0.35),transparent_55%)]"></div>
<div class="relative mx-auto flex w-full max-w-2xl flex-col items-center px-6 py-4"> <div class="relative mx-auto flex w-full max-w-2xl flex-col items-center px-6 py-4">
@@ -58,10 +84,10 @@
<!-- Header --> <!-- Header -->
<div class="text-center"> <div class="text-center">
<h1 class="text-3xl font-black uppercase tracking-[0.3em] text-amber-50 sm:text-4xl"> <h1 class="text-3xl font-black uppercase tracking-[0.3em] text-amber-50 sm:text-4xl">
Mon Profil {$t.game.profile.headerTitle}
</h1> </h1>
<p class="mt-2 text-sm text-slate-300"> <p class="mt-2 text-sm text-slate-300">
Modifie les informations de ton profil {$t.game.profile.headerSubtitle}
</p> </p>
</div> </div>
@@ -69,27 +95,43 @@
<div bind:this={tabsElement} class="sticky top-20 z-10 flex gap-2 border-b border-white/10 bg-slate-950/80 backdrop-blur"> <div bind:this={tabsElement} class="sticky top-20 z-10 flex gap-2 border-b border-white/10 bg-slate-950/80 backdrop-blur">
<button <button
onclick={() => handleTabChange('profile')} onclick={() => handleTabChange('profile')}
class="px-4 py-3 font-semibold uppercase tracking-[0.1em] transition {activeTab === 'profile' class="px-4 py-3 font-semibold uppercase tracking-widest transition {activeTab === 'profile'
? 'border-b-2 border-amber-300 text-amber-100' ? 'border-b-2 border-amber-300 text-amber-100'
: 'text-slate-400 hover:text-slate-100'}" : 'text-slate-400 hover:text-slate-100'}"
> >
Profil {$t.game.profile.tabProfile}
</button> </button>
<button <button
onclick={() => handleTabChange('password')} onclick={() => handleTabChange('password')}
class="px-4 py-3 font-semibold uppercase tracking-[0.1em] transition {activeTab === 'password' class="px-4 py-3 font-semibold uppercase tracking-widest transition {activeTab === 'password'
? 'border-b-2 border-amber-300 text-amber-100' ? 'border-b-2 border-amber-300 text-amber-100'
: 'text-slate-400 hover:text-slate-100'}" : 'text-slate-400 hover:text-slate-100'}"
> >
Mot de passe {$t.game.profile.tabPassword}
</button>
<button
onclick={() => handleTabChange('daily')}
class="px-4 py-3 font-semibold uppercase tracking-widest transition {activeTab === 'daily'
? 'border-b-2 border-amber-300 text-amber-100'
: 'text-slate-400 hover:text-slate-100'}"
>
{$t.game.profile.tabDaily}
</button> </button>
<button <button
onclick={() => handleTabChange('sessions')} onclick={() => handleTabChange('sessions')}
class="px-4 py-3 font-semibold uppercase tracking-[0.1em] transition {activeTab === 'sessions' class="px-4 py-3 font-semibold uppercase tracking-widest transition {activeTab === 'sessions'
? 'border-b-2 border-amber-300 text-amber-100' ? 'border-b-2 border-amber-300 text-amber-100'
: 'text-slate-400 hover:text-slate-100'}" : 'text-slate-400 hover:text-slate-100'}"
> >
Sessions {$t.game.profile.tabSessions}
</button>
<button
onclick={() => handleTabChange('friends')}
class="px-4 py-3 font-semibold uppercase tracking-widest transition {activeTab === 'friends'
? 'border-b-2 border-amber-300 text-amber-100'
: 'text-slate-400 hover:text-slate-100'}"
>
{$t.game.profile.tabFriends}
</button> </button>
</div> </div>
@@ -101,7 +143,7 @@
{#if data.user.image} {#if data.user.image}
<img <img
src={data.user.image} src={data.user.image}
alt={data.user.name || 'Profil'} alt={data.user.name || $t.game.profile.avatarFallbackAlt}
class="h-24 w-24 rounded-full border-2 border-amber-300 object-cover" class="h-24 w-24 rounded-full border-2 border-amber-300 object-cover"
/> />
{:else} {:else}
@@ -110,7 +152,7 @@
</div> </div>
{/if} {/if}
<div class="text-center"> <div class="text-center">
<p class="text-sm text-slate-400">Email</p> <p class="text-sm text-slate-400">{$t.game.profile.email}</p>
<p class="font-semibold text-white">{data.user.email}</p> <p class="font-semibold text-white">{data.user.email}</p>
</div> </div>
</div> </div>
@@ -132,7 +174,7 @@
<!-- Name Field --> <!-- Name Field -->
<div> <div>
<label for="name" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100"> <label for="name" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">
Nom d'affichage {$t.game.profile.displayName}
</label> </label>
<input <input
id="name" id="name"
@@ -140,7 +182,7 @@
name="name" name="name"
bind:value={name} bind:value={name}
required required
placeholder="Ton nom" placeholder={$t.game.profile.displayNamePlaceholder}
class="mt-3 w-full rounded-lg border border-white/10 bg-white/5 px-4 py-3 text-white placeholder-slate-500 transition focus:border-amber-300 focus:outline-none focus:ring-2 focus:ring-amber-300/30" class="mt-3 w-full rounded-lg border border-white/10 bg-white/5 px-4 py-3 text-white placeholder-slate-500 transition focus:border-amber-300 focus:outline-none focus:ring-2 focus:ring-amber-300/30"
/> />
</div> </div>
@@ -155,7 +197,7 @@
<!-- Success Message --> <!-- Success Message -->
{#if showSuccess} {#if showSuccess}
<div class="rounded-lg border border-green-500/30 bg-green-900/20 px-4 py-3 text-sm text-green-200"> <div class="rounded-lg border border-green-500/30 bg-green-900/20 px-4 py-3 text-sm text-green-200">
Profil mis à jour avec succès ! {$t.game.profile.profileUpdateSuccess}
</div> </div>
{/if} {/if}
@@ -165,17 +207,139 @@
disabled={isLoading} disabled={isLoading}
class="w-full rounded-full bg-amber-300 px-6 py-3 text-sm font-semibold text-slate-900 transition disabled:opacity-50 hover:bg-amber-200" class="w-full rounded-full bg-amber-300 px-6 py-3 text-sm font-semibold text-slate-900 transition disabled:opacity-50 hover:bg-amber-200"
> >
{isLoading ? 'Mise à jour...' : 'Enregistrer les modifications'} {isLoading ? $t.game.profile.updating : $t.game.profile.saveChanges}
</button> </button>
</form> </form>
</div> </div>
{/if} {/if}
<!-- Friends Tab -->
{#if activeTab === 'friends'}
<div class="rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur sm:p-8">
<h2 class="mb-6 text-2xl font-bold uppercase tracking-[0.2em] text-amber-50">
{$t.game.profile.friendsTitle}
</h2>
<form
method="POST"
action="?/sendFriendRequest"
use:enhance={() => {
isLoading = true;
return async ({ update }) => {
isLoading = false;
friendUsername = '';
await update();
};
}}
class="mb-8 space-y-3"
>
<label for="friendUsername" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">
{$t.game.profile.addFriendByUsername}
</label>
<div class="flex gap-2">
<input
id="friendUsername"
type="text"
name="friendUsername"
required
bind:value={friendUsername}
placeholder={$t.game.profile.friendUsernamePlaceholder}
class="w-full rounded-lg border border-white/10 bg-white/5 px-4 py-3 text-white placeholder-slate-500 transition focus:border-amber-300 focus:outline-none focus:ring-2 focus:ring-amber-300/30"
/>
<button
type="submit"
disabled={isLoading}
class="rounded-full bg-amber-300 px-4 py-2 text-sm font-semibold text-slate-900 transition disabled:opacity-50 hover:bg-amber-200"
>
{isLoading ? $t.game.profile.sending : $t.game.profile.send}
</button>
</div>
{#if form?.message}
<p class="text-sm {form.success ? 'text-green-300' : 'text-red-300'}">{form.message}</p>
{/if}
</form>
<div class="space-y-8">
<div>
<h3 class="mb-3 text-sm font-semibold uppercase tracking-[0.15em] text-amber-100">{$t.game.profile.incomingRequests}</h3>
{#if incomingRequests.length === 0}
<p class="text-sm text-slate-400">{$t.game.profile.noIncomingRequests}</p>
{:else}
<div class="space-y-3">
{#each incomingRequests as req (req.id)}
<div class="flex flex-wrap items-center justify-between gap-3 rounded-lg border border-white/10 bg-white/5 px-4 py-3">
<div>
<p class="font-semibold text-white">{req.requesterName}</p>
<p class="text-xs text-slate-400">@{req.requesterUsername}</p>
</div>
<div class="flex gap-2">
<form method="POST" action="?/acceptFriendRequest" use:enhance>
<input type="hidden" name="friendshipId" value={req.id} />
<button type="submit" class="rounded-lg border border-emerald-400/50 bg-emerald-900/20 px-3 py-1.5 text-xs font-semibold text-emerald-300 transition hover:bg-emerald-900/40">{$t.game.profile.accept}</button>
</form>
<form method="POST" action="?/declineFriendRequest" use:enhance>
<input type="hidden" name="friendshipId" value={req.id} />
<button type="submit" class="rounded-lg border border-red-500/50 bg-red-900/20 px-3 py-1.5 text-xs font-semibold text-red-300 transition hover:bg-red-900/40">{$t.game.profile.decline}</button>
</form>
</div>
</div>
{/each}
</div>
{/if}
</div>
<div>
<h3 class="mb-3 text-sm font-semibold uppercase tracking-[0.15em] text-amber-100">{$t.game.profile.outgoingRequests}</h3>
{#if outgoingRequests.length === 0}
<p class="text-sm text-slate-400">{$t.game.profile.noOutgoingRequests}</p>
{:else}
<div class="space-y-3">
{#each outgoingRequests as req (req.id)}
<div class="flex flex-wrap items-center justify-between gap-3 rounded-lg border border-white/10 bg-white/5 px-4 py-3">
<div>
<p class="font-semibold text-white">{req.addresseeName}</p>
<p class="text-xs text-slate-400">@{req.addresseeUsername}</p>
</div>
<form method="POST" action="?/cancelFriendRequest" use:enhance>
<input type="hidden" name="friendshipId" value={req.id} />
<button type="submit" class="rounded-lg border border-red-500/50 bg-red-900/20 px-3 py-1.5 text-xs font-semibold text-red-300 transition hover:bg-red-900/40">{$t.game.profile.cancel}</button>
</form>
</div>
{/each}
</div>
{/if}
</div>
<div>
<h3 class="mb-3 text-sm font-semibold uppercase tracking-[0.15em] text-amber-100">{$t.game.profile.myFriends}</h3>
{#if friends.length === 0}
<p class="text-sm text-slate-400">{$t.game.profile.noFriends}</p>
{:else}
<div class="space-y-3">
{#each friends as friend (friend.id)}
<div class="flex flex-wrap items-center justify-between gap-3 rounded-lg border border-white/10 bg-white/5 px-4 py-3">
<div>
<p class="font-semibold text-white">{friend.friendName}</p>
<p class="text-xs text-slate-400">@{friend.friendUsername}</p>
</div>
<form method="POST" action="?/removeFriend" use:enhance>
<input type="hidden" name="friendshipId" value={friend.id} />
<button type="submit" class="rounded-lg border border-red-500/50 bg-red-900/20 px-3 py-1.5 text-xs font-semibold text-red-300 transition hover:bg-red-900/40">{$t.game.profile.remove}</button>
</form>
</div>
{/each}
</div>
{/if}
</div>
</div>
</div>
{/if}
<!-- Password Tab --> <!-- Password Tab -->
{#if activeTab === 'password'} {#if activeTab === 'password'}
<div class="rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur sm:p-8"> <div class="rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur sm:p-8">
<h2 class="mb-6 text-2xl font-bold uppercase tracking-[0.2em] text-amber-50"> <h2 class="mb-6 text-2xl font-bold uppercase tracking-[0.2em] text-amber-50">
Changer le mot de passe {$t.game.profile.changePasswordTitle}
</h2> </h2>
<!-- Form --> <!-- Form -->
@@ -197,7 +361,7 @@
<!-- Old Password Field --> <!-- Old Password Field -->
<div> <div>
<label for="oldPassword" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100"> <label for="oldPassword" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">
Mot de passe actuel {$t.game.profile.currentPassword}
</label> </label>
<input <input
id="oldPassword" id="oldPassword"
@@ -213,7 +377,7 @@
<!-- New Password Field --> <!-- New Password Field -->
<div> <div>
<label for="newPassword" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100"> <label for="newPassword" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">
Nouveau mot de passe {$t.game.profile.newPassword}
</label> </label>
<input <input
id="newPassword" id="newPassword"
@@ -229,7 +393,7 @@
<!-- Confirm Password Field --> <!-- Confirm Password Field -->
<div> <div>
<label for="confirmPassword" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100"> <label for="confirmPassword" class="block text-sm font-semibold uppercase tracking-[0.2em] text-amber-100">
Confirmer le mot de passe {$t.game.profile.confirmPassword}
</label> </label>
<input <input
id="confirmPassword" id="confirmPassword"
@@ -252,7 +416,7 @@
<!-- Success Message --> <!-- Success Message -->
{#if showSuccess} {#if showSuccess}
<div class="rounded-lg border border-green-500/30 bg-green-900/20 px-4 py-3 text-sm text-green-200"> <div class="rounded-lg border border-green-500/30 bg-green-900/20 px-4 py-3 text-sm text-green-200">
Mot de passe changé avec succès ! {$t.game.profile.passwordChangeSuccess}
</div> </div>
{/if} {/if}
@@ -262,34 +426,110 @@
disabled={isLoading} disabled={isLoading}
class="w-full rounded-full bg-amber-300 px-6 py-3 text-sm font-semibold text-slate-900 transition disabled:opacity-50 hover:bg-amber-200" class="w-full rounded-full bg-amber-300 px-6 py-3 text-sm font-semibold text-slate-900 transition disabled:opacity-50 hover:bg-amber-200"
> >
{isLoading ? 'Changement en cours...' : 'Changer le mot de passe'} {isLoading ? $t.game.profile.changing : $t.game.profile.changePassword}
</button> </button>
</form> </form>
</div> </div>
{/if} {/if}
<!-- Daily History Tab -->
{#if activeTab === 'daily'}
<div class="rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur sm:p-8">
<h2 class="mb-6 text-2xl font-bold uppercase tracking-[0.2em] text-amber-50">
{$t.game.profile.dailyHistoryTitle}
</h2>
{#if dailyHistory.length === 0}
<p class="text-center text-slate-400">{$t.game.profile.noDailyHistory}</p>
{:else}
<div class="space-y-4">
{#each dailyHistory as day (day.id)}
<div class="flex items-center gap-4 rounded-lg border border-white/10 bg-white/5 p-4">
<!-- Character Image -->
<div class="shrink-0">
{#if day.characterImage}
<img
src={day.characterImage}
alt={day.characterName}
class="h-16 w-16 rounded-lg border border-white/20 object-cover"
/>
{:else}
<div class="flex h-16 w-16 items-center justify-center rounded-lg border border-white/20 bg-slate-700">
<span class="text-xs text-slate-400">{$t.game.profile.noImage}</span>
</div>
{/if}
</div>
<!-- Character Info -->
<div class="flex-1">
<p class="font-semibold text-white">{day.characterName}</p>
<p class="text-xs text-slate-400">
{new Date(day.date).toLocaleDateString($language === 'fr' ? 'fr-FR' : 'en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
})}
</p>
<div class="mt-3">
<p class="text-[11px] font-semibold uppercase tracking-[0.2em] text-amber-100">
{$t.game.profile.triedCharactersTitle}
</p>
{#if day.triedCharacters && day.triedCharacters.length > 0}
<div class="mt-2 flex flex-wrap gap-2">
{#each day.triedCharacters as triedCharacter (triedCharacter.id)}
<span class="inline-flex items-center gap-2 rounded-full border border-white/15 bg-white/5 px-2.5 py-1 text-xs text-slate-200">
{#if triedCharacter.pictureUrl}
<img
src={triedCharacter.pictureUrl}
alt={triedCharacter.name}
class="h-4 w-4 rounded-full object-cover"
/>
{/if}
{triedCharacter.name}
</span>
{/each}
</div>
{:else}
<p class="mt-1 text-xs text-slate-500">{$t.game.profile.noTriedCharacters}</p>
{/if}
</div>
</div>
<!-- Tries -->
<div class="flex flex-col items-end">
<p class="text-xs text-slate-400">
{day.tryCount} {day.tryCount === 1 ? $t.game.profile.trySingular : $t.game.profile.tryPlural}
</p>
</div>
</div>
{/each}
</div>
{/if}
</div>
{/if}
<!-- Sessions Tab --> <!-- Sessions Tab -->
{#if activeTab === 'sessions'} {#if activeTab === 'sessions'}
<div class="rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur sm:p-8"> <div class="rounded-3xl border border-white/10 bg-white/5 p-6 shadow-[0_24px_60px_rgba(0,0,0,0.45)] backdrop-blur sm:p-8">
<h2 class="mb-6 text-2xl font-bold uppercase tracking-[0.2em] text-amber-50"> <h2 class="mb-6 text-2xl font-bold uppercase tracking-[0.2em] text-amber-50">
Sessions actives {$t.game.profile.activeSessionsTitle}
</h2> </h2>
{#if sessions.length === 0} {#if sessions.length === 0}
<p class="text-center text-slate-400">Aucune session active</p> <p class="text-center text-slate-400">{$t.game.profile.noActiveSessions}</p>
{:else} {:else}
<div class="space-y-4"> <div class="space-y-4">
{#each sessions as sess} {#each sessions as sess (sess.id)}
<div class="flex items-center justify-between rounded-lg border border-white/10 bg-white/5 px-4 py-4"> <div class="flex items-center justify-between rounded-lg border border-white/10 bg-white/5 px-4 py-4">
<div class="flex-1"> <div class="flex-1">
<p class="font-semibold text-white"> <p class="font-semibold text-white">
{sess.userAgent || 'Appareil inconnu'} {sess.userAgent || $t.game.profile.unknownDevice}
</p> </p>
<p class="text-xs text-slate-400"> <p class="text-xs text-slate-400">
IP: {sess.ipAddress || 'Inconnue'} {$t.game.profile.ip}: {sess.ipAddress || $t.game.profile.unknown}
</p> </p>
<p class="mt-1 text-xs text-slate-500"> <p class="mt-1 text-xs text-slate-500">
Créée: {new Date(sess.createdAt).toLocaleDateString('fr-FR', { {$t.game.profile.created}: {new Date(sess.createdAt).toLocaleDateString($language === 'fr' ? 'fr-FR' : 'en-US', {
year: 'numeric', year: 'numeric',
month: 'long', month: 'long',
day: 'numeric', day: 'numeric',
@@ -313,7 +553,7 @@
type="submit" type="submit"
class="rounded-lg border border-red-500/50 bg-red-900/20 px-4 py-2 text-xs font-semibold text-red-300 transition hover:border-red-500 hover:bg-red-900/40" class="rounded-lg border border-red-500/50 bg-red-900/20 px-4 py-2 text-xs font-semibold text-red-300 transition hover:border-red-500 hover:bg-red-900/40"
> >
Terminer {$t.game.profile.terminate}
</button> </button>
</form> </form>
</div> </div>
@@ -325,8 +565,8 @@
<!-- Back to Home --> <!-- Back to Home -->
<div class="text-center"> <div class="text-center">
<a href="/" class="text-sm text-slate-400 transition hover:text-slate-300"> <a href={resolve("/")} class="text-sm text-slate-400 transition hover:text-slate-300">
Retour à l'accueil {$t.game.profile.backHome}
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import './layout.css'; import './layout.css';
import favicon from '$lib/assets/favicon.svg'; import favicon from '$lib/assets/favicon.png';
let { children } = $props(); let { children } = $props();
</script> </script>

View File

@@ -0,0 +1,52 @@
import { readFile } from 'fs/promises';
import { join } from 'path';
import { existsSync } from 'fs';
import type { RequestHandler } from '@sveltejs/kit';
import { env } from '$env/dynamic/private';
export const GET: RequestHandler = async ({ params }) => {
const filename = params.filename as string;
if (!filename || typeof filename !== 'string' || filename.includes('..') || filename.includes('/')) {
return new Response('Invalid filename', { status: 400 });
}
try {
const uploadsDir = env.UPLOADS_DIR || join(process.cwd(),'uploads');
const filepath = join(uploadsDir, filename);
if (!existsSync(filepath)) {
return new Response('File not found', { status: 404 });
}
// Verify the file is within uploads directory (prevent directory traversal)
if (!filepath.startsWith(uploadsDir)) {
return new Response('Access denied', { status: 403 });
}
const fileBuffer = await readFile(filepath);
// Determine content type based on file extension
const ext = (filename as string).split('.').pop()?.toLowerCase() || '';
const contentTypes: Record<string, string> = {
'jpg': 'image/jpeg',
'jpeg': 'image/jpeg',
'png': 'image/png',
'gif': 'image/gif',
'webp': 'image/webp',
'svg': 'image/svg+xml'
};
const contentType = contentTypes[ext] || 'application/octet-stream';
return new Response(fileBuffer, {
status: 200,
headers: {
'Content-Type': contentType,
'Cache-Control': 'public, max-age=86400'
}
});
} catch (error) {
console.error('File serving error:', error);
return new Response('Internal server error', { status: 500 });
}
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB