add gateway function set_character_meseta
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is failing
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	continuous-integration/drone/push Build is failing
				
			This commit is contained in:
		
							parent
							
								
									296d1cc0ea
								
							
						
					
					
						commit
						6ed0d838d2
					
				@ -115,4 +115,8 @@ pub trait EntityGateway: Send + Sync + Clone {
 | 
			
		||||
    async fn set_character_equips(&mut self, _char_id: &CharacterEntityId, _equips: &EquippedEntity) -> Result<(), GatewayError> {
 | 
			
		||||
        unimplemented!();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn set_character_meseta(&mut self, _char_id: &CharacterEntityId, amount: usize) -> Result<(), GatewayError> {
 | 
			
		||||
        unimplemented!();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -318,4 +318,12 @@ impl EntityGateway for InMemoryGateway {
 | 
			
		||||
        equips.insert(*char_id, equipped.clone());
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn set_character_meseta(&mut self, char_id: &CharacterEntityId, amount: usize) -> Result<(), GatewayError> {
 | 
			
		||||
        let mut characters = self.characters.lock().unwrap();
 | 
			
		||||
        if let Some(char) = characters.get_mut(&char_id) {
 | 
			
		||||
            char.meseta = amount as u32;
 | 
			
		||||
        }
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -597,4 +597,13 @@ impl EntityGateway for PostgresGateway {
 | 
			
		||||
            .await?;
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn set_character_meseta(&mut self, char_id: &CharacterEntityId, amount: usize) -> Result<(), GatewayError> {
 | 
			
		||||
        sqlx::query(r#"update player_character set meseta=$2 where id = $1"#)
 | 
			
		||||
            .bind(char_id.0)
 | 
			
		||||
            .bind(amount as i32)
 | 
			
		||||
            .execute(&self.pool)
 | 
			
		||||
            .await?;
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user