diff --git a/character-service/src/character_db_client.rs b/character-service/src/character_db_client.rs index bb4e2bc..e2d7d56 100644 --- a/character-service/src/character_db_client.rs +++ b/character-service/src/character_db_client.rs @@ -12,6 +12,11 @@ pub struct CharacterDbClient { client: CharacterDbServiceClient, } +#[derive(Debug, Deserialize, Serialize)] +struct Skill { + id: i32, +} + #[derive(Debug, Deserialize, Serialize)] struct Item { item_id: i32, @@ -155,6 +160,24 @@ impl CharacterDbClient { }, ]; + let skills = vec![ + Skill { id: 11 }, + Skill { id: 12 }, + Skill { id: 16 }, + Skill { id: 19 }, + Skill { id: 20 }, + Skill { id: 21 }, + Skill { id: 26 }, + Skill { id: 41 }, + Skill { id: 42 }, + Skill { id: 43 }, + Skill { id: 46 }, + Skill { id: 47 }, + Skill { id: 48 }, + Skill { id: 49 }, + Skill { id: 60 }, + ]; + let stats = Stats { job: 0, str: 10, @@ -197,6 +220,7 @@ impl CharacterDbClient { user_id: user_id.parse().unwrap(), name: name.to_string(), inventory: serde_json::to_value(inventory)?.to_string(), + skills: serde_json::to_value(skills)?.to_string(), stats: serde_json::to_value(stats)?.to_string(), looks: serde_json::to_value(looks)?.to_string(), position: serde_json::to_value(position)?.to_string(), diff --git a/database-service/src/characters.rs b/database-service/src/characters.rs index 51abd39..02934b9 100644 --- a/database-service/src/characters.rs +++ b/database-service/src/characters.rs @@ -72,21 +72,20 @@ impl CharacterRepository { user_id: i32, name: &str, inventory: serde_json::Value, + skills: serde_json::Value, stats: serde_json::Value, looks: serde_json::Value, position: serde_json::Value, ) -> Result { - let default_skills = "[{\"id\": 11, \"level\": 1}, {\"id\": 12, \"level\": 1}, {\"id\": 16, \"level\": 1}, {\"id\": 19, \"level\": 1}, {\"id\": 20, \"level\": 1}, {\"id\": 21, \"level\": 1}, {\"id\": 26, \"level\": 1}, {\"id\": 41, \"level\": 1}, {\"id\": 42, \"level\": 1}, {\"id\": 43, \"level\": 1}, {\"id\": 46, \"level\": 1}, {\"id\": 47, \"level\": 1}, {\"id\": 48, \"level\": 1}, {\"id\": 49, \"level\": 1}, {\"id\": 50, \"level\": 1}]"; let result = sqlx::query( - "INSERT INTO characters (user_id, name, money, inventory, stats, skills, looks, position, created_at, updated_at, is_active) \ - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, NOW(), NOW(), true) RETURNING id", + "INSERT INTO characters (user_id, name, inventory, stats, skills, looks, position, created_at, updated_at, is_active) \ + VALUES ($1, $2, $3, $4, $5, $6, $7, NOW(), NOW(), true) RETURNING id", ) .bind(user_id) .bind(name) - .bind(0) .bind(inventory) .bind(stats) - .bind(default_skills) + .bind(skills) .bind(looks) .bind(position) .fetch_one(&self.pool) diff --git a/database-service/src/grpc/character_service.rs b/database-service/src/grpc/character_service.rs index 1096f5d..2ae5312 100644 --- a/database-service/src/grpc/character_service.rs +++ b/database-service/src/grpc/character_service.rs @@ -103,6 +103,7 @@ impl CharacterDbService for MyDatabaseService { req.user_id, &req.name, serde_json::from_str(&req.inventory).unwrap_or_default(), + serde_json::from_str(&req.skills).unwrap_or_default(), serde_json::from_str(&req.stats).unwrap_or_default(), serde_json::from_str(&req.looks).unwrap_or_default(), serde_json::from_str(&req.position).unwrap_or_default(), diff --git a/proto/character_db_api.proto b/proto/character_db_api.proto index 611446d..c2f85f6 100644 --- a/proto/character_db_api.proto +++ b/proto/character_db_api.proto @@ -26,9 +26,10 @@ message CreateCharacterRequest { int32 user_id = 1; string name = 2; string inventory = 3; // JSON serialized - string stats = 4; // JSON serialized - string looks = 5; // JSON serialized - string position = 6; // JSON serialized + string skills = 4; // JSON serialized + string stats = 5; // JSON serialized + string looks = 6; // JSON serialized + string position = 7; // JSON serialized } message CreateCharacterResponse {