|
|
@ -224,10 +224,21 @@ async fn save_user_settings(conn: &mut sqlx::PgConnection, settings: &UserSettin |
|
|
|
async fn create_character(conn: &mut sqlx::PgConnection, char: NewCharacterEntity) -> Result<CharacterEntity, GatewayError>
|
|
|
|
{
|
|
|
|
let q = r#"insert into player_character
|
|
|
|
(user_account, slot, name, exp, class, section_id, costume, skin, face, head, hair, hair_r, hair_g, hair_b, prop_x, prop_y, techs,
|
|
|
|
config, infoboard, guildcard, power, mind, def, evade, luck, hp, tp, tech_menu, option_flags)
|
|
|
|
(user_account, slot, name, exp, class,
|
|
|
|
section_id, costume, skin, face, head,
|
|
|
|
hair, hair_r, hair_g, hair_b, prop_x,
|
|
|
|
prop_y, techs, config, infoboard, guildcard,
|
|
|
|
power, mind, def, evade, luck,
|
|
|
|
hp, tp, tech_menu, option_flags, keyboard_config,
|
|
|
|
gamepad_config, playtime)
|
|
|
|
values
|
|
|
|
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31)
|
|
|
|
($1, $2, $3, $4, $5,
|
|
|
|
$6, $7, $8, $9, $10,
|
|
|
|
$11, $12, $13, $14, $15,
|
|
|
|
$16, $17, $18, $19, $20,
|
|
|
|
$21, $22, $23, $24, $25,
|
|
|
|
$26, $27, $28, $29, $30,
|
|
|
|
$31, $32)
|
|
|
|
returning *;"#;
|
|
|
|
let character = sqlx::query_as::<_, PgCharacter>(q)
|
|
|
|
.bind(char.user_id.0)
|
|
|
@ -259,6 +270,9 @@ async fn create_character(conn: &mut sqlx::PgConnection, char: NewCharacterEntit |
|
|
|
.bind(char.materials.tp as i16)
|
|
|
|
.bind(char.tech_menu.tech_menu.to_vec())
|
|
|
|
.bind(char.option_flags as i32)
|
|
|
|
.bind(&char.keyboard_config.keyboard_config.to_vec())
|
|
|
|
.bind(&char.gamepad_config.gamepad_config.to_vec())
|
|
|
|
.bind(0)
|
|
|
|
.fetch_one(conn).await?;
|
|
|
|
|
|
|
|
Ok(character.into())
|
|
|
@ -284,8 +298,8 @@ async fn save_character(conn: &mut sqlx::PgConnection, char: &CharacterEntity) - |
|
|
|
let q = r#"update player_character set
|
|
|
|
user_account=$1, slot=$2, name=$3, exp=$4, class=$5, section_id=$6, costume=$7, skin=$8, face=$9, head=$10, hair=$11, hair_r=$12,
|
|
|
|
hair_g=$13, hair_b=$14, prop_x=$15, prop_y=$16, techs=$17, config=$18, infoboard=$19, guildcard=$20, power=$21, mind=$22, def=$23,
|
|
|
|
evade=$24, luck=$25, hp=$26, tp=$27, tech_menu=$28, option_flags=$29, playtime=$30
|
|
|
|
where id=$31;"#;
|
|
|
|
evade=$24, luck=$25, hp=$26, tp=$27, tech_menu=$28, option_flags=$29, keyboard_config=$30, gamepad_config=$31, playtime=$32,
|
|
|
|
where id=$33;"#;
|
|
|
|
sqlx::query(q)
|
|
|
|
.bind(char.user_id.0) // $1
|
|
|
|
.bind(char.slot as i16) // $2
|
|
|
@ -316,8 +330,10 @@ async fn save_character(conn: &mut sqlx::PgConnection, char: &CharacterEntity) - |
|
|
|
.bind(char.materials.tp as i16) // $27
|
|
|
|
.bind(char.tech_menu.tech_menu.to_vec()) // $28
|
|
|
|
.bind(char.option_flags as i32) // $29
|
|
|
|
.bind(char.playtime as i32) // $20
|
|
|
|
.bind(char.id.0 as i32) // $31
|
|
|
|
.bind(&char.keyboard_config.keyboard_config.to_vec()) // $30
|
|
|
|
.bind(&char.gamepad_config.gamepad_config.to_vec()) // $31
|
|
|
|
.bind(char.playtime as i32) // $32
|
|
|
|
.bind(char.id.0 as i32) // $33
|
|
|
|
.execute(conn).await?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
@ -530,7 +546,7 @@ async fn set_character_equips(conn: &mut sqlx::PgConnection, char_id: &Character |
|
|
|
|
|
|
|
async fn set_character_meseta(conn: &mut sqlx::PgConnection, char_id: &CharacterEntityId, meseta: Meseta) -> Result<(), GatewayError>
|
|
|
|
{
|
|
|
|
sqlx::query("insert into character_meseta values ($1, $2) on conflict (pchar) do update set items = $2")
|
|
|
|
sqlx::query("insert into character_meseta values ($1, $2) on conflict (pchar) do update set meseta = $2")
|
|
|
|
.bind(char_id.0)
|
|
|
|
.bind(meseta.0 as i32)
|
|
|
|
.execute(conn)
|
|
|
@ -542,7 +558,7 @@ async fn get_character_meseta(conn: &mut sqlx::PgConnection, char_id: &Character |
|
|
|
{
|
|
|
|
#[derive(sqlx::FromRow)]
|
|
|
|
struct PgMeseta(i32);
|
|
|
|
let meseta = sqlx::query_as::<_, PgMeseta>(r#"select meseta from character_meseta where id = $1"#)
|
|
|
|
let meseta = sqlx::query_as::<_, PgMeseta>(r#"select meseta from character_meseta where pchar = $1"#)
|
|
|
|
.bind(char_id.0)
|
|
|
|
.fetch_one(conn)
|
|
|
|
.await?;
|
|
|
@ -551,10 +567,10 @@ async fn get_character_meseta(conn: &mut sqlx::PgConnection, char_id: &Character |
|
|
|
|
|
|
|
async fn set_bank_meseta(conn: &mut sqlx::PgConnection, char_id: &CharacterEntityId, bank: &BankName, meseta: Meseta) -> Result<(), GatewayError>
|
|
|
|
{
|
|
|
|
sqlx::query("insert into bank_meseta values ($1, $2, $3) on conflict (pchar, bank) do update set items = $2")
|
|
|
|
sqlx::query("insert into bank_meseta values ($1, $2, $3) on conflict (pchar, bank) do update set meseta = $3")
|
|
|
|
.bind(char_id.0)
|
|
|
|
.bind(meseta.0 as i32)
|
|
|
|
.bind(bank.0.clone())
|
|
|
|
.bind(meseta.0 as i32)
|
|
|
|
.execute(conn)
|
|
|
|
.await?;
|
|
|
|
Ok(())
|
|
|
@ -564,7 +580,7 @@ async fn get_bank_meseta(conn: &mut sqlx::PgConnection, char_id: &CharacterEntit |
|
|
|
{
|
|
|
|
#[derive(sqlx::FromRow)]
|
|
|
|
struct PgMeseta(i32);
|
|
|
|
let meseta = sqlx::query_as::<_, PgMeseta>(r#"select meseta from character_meseta where id = $1 and bank = $2"#)
|
|
|
|
let meseta = sqlx::query_as::<_, PgMeseta>(r#"select meseta from bank_meseta where pchar = $1 and bank = $2"#)
|
|
|
|
.bind(char_id.0)
|
|
|
|
.bind(bank.0.clone())
|
|
|
|
.fetch_one(conn)
|
|
|
@ -584,10 +600,10 @@ async fn create_trade(conn: &mut sqlx::PgConnection, char_id1: &CharacterEntityI |
|
|
|
|
|
|
|
async fn set_character_playtime(conn: &mut sqlx::PgConnection, char_id: &CharacterEntityId, playtime: u32) -> Result<(), GatewayError>
|
|
|
|
{
|
|
|
|
sqlx::query_as::<_, PgTradeEntity>(r#"update player_character set playtime=$2 where id=$1;"#)
|
|
|
|
sqlx::query(r#"update player_character set playtime=$2 where id=$1;"#)
|
|
|
|
.bind(char_id.0)
|
|
|
|
.bind(playtime)
|
|
|
|
.fetch_one(conn)
|
|
|
|
.execute(conn)
|
|
|
|
.await?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|