reorder function
This commit is contained in:
		
							parent
							
								
									3ceff90f98
								
							
						
					
					
						commit
						009f0ef470
					
				| @ -73,6 +73,27 @@ fn add_floor_item_to_inventory(character: &CharacterEntity) | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| pub async fn pick_up_item<EG>( | ||||
|     item_state: &mut ItemState, | ||||
|     entity_gateway: &mut EG, | ||||
|     character: &CharacterEntity, | ||||
|     item_id: &ClientItemId) | ||||
|     -> Result<TriggerCreateItem, ItemStateError> | ||||
| where | ||||
|     EG: EntityGateway, | ||||
| { | ||||
|     entity_gateway.with_transaction(|transaction| async move { | ||||
|         let item_state_proxy = ItemStateProxy::new(item_state); | ||||
|         let ((item_state_proxy, transaction), result) = ItemStateAction::default() | ||||
|             .act(take_item_from_floor(character.id, *item_id)) | ||||
|             .act(add_floor_item_to_inventory(character)) | ||||
|             .commit((item_state_proxy, transaction)) | ||||
|             .await?; | ||||
|         item_state_proxy.commit(); | ||||
|         Ok((transaction, result)) | ||||
|     }).await | ||||
| } | ||||
| 
 | ||||
| fn take_item_from_inventory(character_id: CharacterEntityId, item_id: ClientItemId) | ||||
|                             -> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()) | ||||
|                                                -> Pin<Box<dyn Future<Output=Result<((ItemStateProxy, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>> | ||||
| @ -119,28 +140,6 @@ fn add_inventory_item_to_shared_floor(character_id: CharacterEntityId, item_id: | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| pub async fn pick_up_item<EG>( | ||||
|     item_state: &mut ItemState, | ||||
|     entity_gateway: &mut EG, | ||||
|     character: &CharacterEntity, | ||||
|     item_id: &ClientItemId) | ||||
|     -> Result<TriggerCreateItem, ItemStateError> | ||||
| where | ||||
|     EG: EntityGateway, | ||||
| { | ||||
|     entity_gateway.with_transaction(|transaction| async move { | ||||
|         let item_state_proxy = ItemStateProxy::new(item_state); | ||||
|         let ((item_state_proxy, transaction), result) = ItemStateAction::default() | ||||
|             .act(take_item_from_floor(character.id, *item_id)) | ||||
|             .act(add_floor_item_to_inventory(character)) | ||||
|             .commit((item_state_proxy, transaction)) | ||||
|             .await?; | ||||
|         item_state_proxy.commit(); | ||||
|         Ok((transaction, result)) | ||||
|     }).await | ||||
| } | ||||
| 
 | ||||
| pub async fn drop_item<EG>( | ||||
|     item_state: &mut ItemState, | ||||
|     entity_gateway: &mut EG, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user