|
|
@ -31,7 +31,7 @@ async fn test_bank_items_sent_in_character_login() { |
|
|
|
),
|
|
|
|
}).await.unwrap();
|
|
|
|
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![item]), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![item]), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -69,7 +69,7 @@ async fn test_request_bank_items() { |
|
|
|
}).await.unwrap());
|
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -113,7 +113,7 @@ async fn test_request_stacked_bank_items() { |
|
|
|
}).await.unwrap());
|
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -178,7 +178,7 @@ async fn test_request_bank_items_sorted() { |
|
|
|
}).await.unwrap();
|
|
|
|
|
|
|
|
let bank = vec![item::BankItemEntity::Individual(item1), vec![monomate].into(), item2.into()];
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -275,7 +275,7 @@ async fn test_deposit_individual_item() { |
|
|
|
assert_eq!(item.id, item::ItemEntityId(1));
|
|
|
|
}).unwrap();
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
bank_items.items[0].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(2));
|
|
|
@ -335,7 +335,7 @@ async fn test_deposit_stacked_item() { |
|
|
|
&& player_no_longer_has_item.amount == 3
|
|
|
|
));
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
bank_items.items[0].with_stacked(|items| {
|
|
|
|
assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(),
|
|
|
@ -397,7 +397,7 @@ async fn test_deposit_partial_stacked_item() { |
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
bank_items.items[0].with_stacked(|items| {
|
|
|
|
assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(),
|
|
|
@ -443,7 +443,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() { |
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -477,7 +477,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() { |
|
|
|
&& player_no_longer_has_item.amount == 2
|
|
|
|
));
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
bank_items.items[0].with_stacked(|items| {
|
|
|
|
assert_eq!(items.iter().map(|i| i.id).collect::<BTreeSet<_>>(),
|
|
|
@ -516,7 +516,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() { |
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -543,7 +543,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() { |
|
|
|
|
|
|
|
assert!(packets.is_err());
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
bank_items.items[0].with_stacked(|items| {
|
|
|
|
assert_eq!(items.len(), 10);
|
|
|
@ -594,7 +594,7 @@ async fn test_deposit_individual_item_in_full_bank() { |
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inventory)).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -621,7 +621,7 @@ async fn test_deposit_individual_item_in_full_bank() { |
|
|
|
|
|
|
|
assert!(packets.is_err());
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 200);
|
|
|
|
|
|
|
|
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
|
|
@ -666,7 +666,7 @@ async fn test_deposit_stacked_item_in_full_bank() { |
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![monomates])).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(full_bank), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(full_bank), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -693,7 +693,7 @@ async fn test_deposit_stacked_item_in_full_bank() { |
|
|
|
|
|
|
|
assert!(packets.is_err());
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 200);
|
|
|
|
|
|
|
|
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
|
|
@ -752,7 +752,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() { |
|
|
|
almost_full_bank.push(bank_monomates.into());
|
|
|
|
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![monomates])).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(almost_full_bank), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(almost_full_bank), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -777,7 +777,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() { |
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 200);
|
|
|
|
bank_items.items[199].with_stacked(|items| {
|
|
|
|
assert_eq!(items.len(), 4);
|
|
|
@ -818,7 +818,7 @@ async fn test_deposit_meseta() { |
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert!(c1_meseta.0 == 277);
|
|
|
|
assert!(c1_bank_meseta.0 == 23);
|
|
|
|
}
|
|
|
@ -829,7 +829,7 @@ async fn test_deposit_too_much_meseta() { |
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(999980)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankIdentifier::Character, item::Meseta(999980)).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -857,7 +857,7 @@ async fn test_deposit_too_much_meseta() { |
|
|
|
assert!(packets.is_err());
|
|
|
|
|
|
|
|
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert!(c1_meseta.0 == 300);
|
|
|
|
assert!(c1_bank_meseta.0 == 999980);
|
|
|
|
}
|
|
|
@ -868,7 +868,7 @@ async fn test_deposit_meseta_when_bank_is_maxed() { |
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(999999)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankIdentifier::Character, item::Meseta(999999)).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -896,7 +896,7 @@ async fn test_deposit_meseta_when_bank_is_maxed() { |
|
|
|
assert!(packets.is_err());
|
|
|
|
|
|
|
|
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert!(c1_meseta.0 == 300);
|
|
|
|
assert!(c1_bank_meseta.0 == 999999);
|
|
|
|
}
|
|
|
@ -923,7 +923,7 @@ async fn test_withdraw_individual_item() { |
|
|
|
),
|
|
|
|
}).await.unwrap());
|
|
|
|
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -983,7 +983,7 @@ async fn test_withdraw_stacked_item() { |
|
|
|
}).await.unwrap());
|
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -1042,7 +1042,7 @@ async fn test_withdraw_partial_stacked_item() { |
|
|
|
),
|
|
|
|
}).await.unwrap());
|
|
|
|
}
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -1075,7 +1075,7 @@ async fn test_withdraw_partial_stacked_item() { |
|
|
|
if create_item.item_id == 0x20001
|
|
|
|
));
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
bank_items.items[0].with_stacked(|items| {
|
|
|
|
assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(),
|
|
|
@ -1120,7 +1120,7 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() { |
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -1153,7 +1153,7 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() { |
|
|
|
if create_item.item_id == 0x20000
|
|
|
|
));
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 0);
|
|
|
|
|
|
|
|
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
|
|
@ -1195,7 +1195,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() { |
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![inventory_monomates])).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_monomates]), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -1222,7 +1222,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() { |
|
|
|
|
|
|
|
assert!(packets.is_err());
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
bank_items.items[0].with_stacked(|items| {
|
|
|
|
assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(),
|
|
|
@ -1273,7 +1273,7 @@ async fn test_withdraw_individual_item_in_full_inventory() { |
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inventory)).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(bank), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -1299,7 +1299,7 @@ async fn test_withdraw_individual_item_in_full_inventory() { |
|
|
|
})))).await;
|
|
|
|
assert!(packets.is_err());
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
|
|
|
|
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
|
|
@ -1341,7 +1341,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() { |
|
|
|
}
|
|
|
|
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inventory)).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![monomates]), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -1369,7 +1369,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() { |
|
|
|
assert!(packets.is_err());
|
|
|
|
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
bank_items.items[0].with_stacked(|items| {
|
|
|
|
assert_eq!(items.iter().map(|i| i.id).collect::<Vec<_>>(),
|
|
|
@ -1397,7 +1397,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() { |
|
|
|
),
|
|
|
|
}).await.unwrap());
|
|
|
|
}
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_item]), &item::BankName("".into())).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![bank_item]), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
|
|
|
|
let mut items = Vec::new();
|
|
|
|
for _i in 0..29usize {
|
|
|
@ -1453,7 +1453,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() { |
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert!(bank_items.items.len() == 0);
|
|
|
|
|
|
|
|
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
|
|
@ -1471,7 +1471,7 @@ async fn test_withdraw_meseta() { |
|
|
|
let mut entity_gateway = InMemoryGateway::default();
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(300)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankIdentifier::Character, item::Meseta(300)).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -1497,7 +1497,7 @@ async fn test_withdraw_meseta() { |
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert!(c1_meseta.0 == 23);
|
|
|
|
assert!(c1_bank_meseta.0 == 277);
|
|
|
|
}
|
|
|
@ -1508,7 +1508,7 @@ async fn test_withdraw_too_much_meseta() { |
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999980)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(300)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankIdentifier::Character, item::Meseta(300)).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -1536,7 +1536,7 @@ async fn test_withdraw_too_much_meseta() { |
|
|
|
assert!(packet.is_err());
|
|
|
|
|
|
|
|
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert!(c1_meseta.0 == 999980);
|
|
|
|
assert!(c1_bank_meseta.0 == 300);
|
|
|
|
}
|
|
|
@ -1547,7 +1547,7 @@ async fn test_withdraw_meseta_inventory_is_maxed() { |
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
entity_gateway.set_character_meseta(&char1.id, item::Meseta(999999)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(300)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankIdentifier::Character, item::Meseta(300)).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -1575,7 +1575,7 @@ async fn test_withdraw_meseta_inventory_is_maxed() { |
|
|
|
assert!(packet.is_err());
|
|
|
|
|
|
|
|
let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert!(c1_meseta.0 == 999999);
|
|
|
|
assert!(c1_bank_meseta.0 == 300);
|
|
|
|
}
|
|
|
@ -1588,7 +1588,7 @@ async fn test_withdraw_meseta_and_buy_a_few_monomates_with_it() { |
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
entity_gateway.set_character_meseta(&char1.id, item::Meseta(100)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankName("".into()), item::Meseta(300)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankIdentifier::Character, item::Meseta(300)).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
@ -1629,7 +1629,416 @@ async fn test_withdraw_meseta_and_buy_a_few_monomates_with_it() { |
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
//let c1_meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
|
|
|
|
//let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankName("".into())).await.unwrap();
|
|
|
|
//let c1_bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
//assert!(c1_meseta.0 == 23);
|
|
|
|
//assert!(c1_bank_meseta.0 == 277);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
async fn test_deposit_items_into_shared_banks() {
|
|
|
|
let mut entity_gateway = InMemoryGateway::default();
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
|
|
|
|
let item0 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Saber).as_new()).await.unwrap();
|
|
|
|
let item1 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Buster).as_new()).await.unwrap();
|
|
|
|
let item2 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Rifle).as_new()).await.unwrap();
|
|
|
|
let item3 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Handgun).as_new()).await.unwrap();
|
|
|
|
let item4 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Autogun).as_new()).await.unwrap();
|
|
|
|
let item5 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Calibur).as_new()).await.unwrap();
|
|
|
|
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![item0, item1, item2, item3, item4, item5])).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
|
.build());
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0x10000,
|
|
|
|
action: 0,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::PlayerChat(PlayerChat::new(0, "\tE/sbank asdf".into()))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0x10001,
|
|
|
|
action: 0,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0x10002,
|
|
|
|
action: 0,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::PlayerChat(PlayerChat::new(0, "\tE/sbank qwer".into()))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0x10003,
|
|
|
|
action: 0,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::PlayerChat(PlayerChat::new(0, "\tE/bank".into()))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0x10004,
|
|
|
|
action: 0,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Shared(item::BankName("asdf".into()))).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 2);
|
|
|
|
bank_items.items[0].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(2));
|
|
|
|
}).unwrap();
|
|
|
|
|
|
|
|
bank_items.items[1].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(3));
|
|
|
|
}).unwrap();
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Shared(item::BankName("qwer".into()))).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
bank_items.items[0].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(4));
|
|
|
|
}).unwrap();
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 2);
|
|
|
|
bank_items.items[0].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(1));
|
|
|
|
}).unwrap();
|
|
|
|
|
|
|
|
bank_items.items[1].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(5));
|
|
|
|
}).unwrap();
|
|
|
|
|
|
|
|
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
|
|
|
assert_eq!(inventory_items.items.len(), 1);
|
|
|
|
inventory_items.items[0].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(6));
|
|
|
|
}).unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
async fn test_deposit_meseta_into_shared_banks() {
|
|
|
|
let mut entity_gateway = InMemoryGateway::default();
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
entity_gateway.set_character_meseta(&char1.id, item::Meseta(300)).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
|
.build());
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
|
action: 0,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 23,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::PlayerChat(PlayerChat::new(0, "\tE/sbank asdf".into()))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
|
action: 0,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 55,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::PlayerChat(PlayerChat::new(0, "\tE/sbank qwer".into()))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
|
action: 0,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 32,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
let meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
|
|
|
|
assert_eq!(meseta.0, 300-23-55-32);
|
|
|
|
|
|
|
|
let bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_meseta.0, 23);
|
|
|
|
let bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Shared(item::BankName("asdf".into()))).await.unwrap();
|
|
|
|
assert_eq!(bank_meseta.0, 55);
|
|
|
|
let bank_meseta = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Shared(item::BankName("qwer".into()))).await.unwrap();
|
|
|
|
assert_eq!(bank_meseta.0, 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
async fn test_withdraw_items_from_shared_banks() {
|
|
|
|
let mut entity_gateway = InMemoryGateway::default();
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
|
|
|
|
let item0 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Saber).as_new()).await.unwrap();
|
|
|
|
let item1 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Buster).as_new()).await.unwrap();
|
|
|
|
let item2 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Rifle).as_new()).await.unwrap();
|
|
|
|
let item3 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Handgun).as_new()).await.unwrap();
|
|
|
|
let item4 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Autogun).as_new()).await.unwrap();
|
|
|
|
let item5 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Calibur).as_new()).await.unwrap();
|
|
|
|
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![item0, item1]), &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![item2, item3]), &item::BankIdentifier::Shared(item::BankName("asdf".into()))).await.unwrap();
|
|
|
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![item4, item5]), &item::BankIdentifier::Shared(item::BankName("qwer".into()))).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
|
.build());
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0x20000, // saber (1)
|
|
|
|
action: 1,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::PlayerChat(PlayerChat::new(0, "\tE/sbank asdf".into()))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0x810003, // handgun (4)
|
|
|
|
action: 1,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0x810004, // rifle (3)
|
|
|
|
action: 1,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::PlayerChat(PlayerChat::new(0, "\tE/sbank qwer".into()))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0x810006, // autogun (5)
|
|
|
|
action: 1,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Shared(item::BankName("asdf".into()))).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 0);
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Shared(item::BankName("qwer".into()))).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
bank_items.items[0].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(6));
|
|
|
|
}).unwrap();
|
|
|
|
|
|
|
|
let bank_items = entity_gateway.get_character_bank(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
assert_eq!(bank_items.items.len(), 1);
|
|
|
|
bank_items.items[0].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(2));
|
|
|
|
}).unwrap();
|
|
|
|
|
|
|
|
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
|
|
|
assert_eq!(inventory_items.items.len(), 4);
|
|
|
|
inventory_items.items[0].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(1));
|
|
|
|
}).unwrap();
|
|
|
|
inventory_items.items[1].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(4));
|
|
|
|
}).unwrap();
|
|
|
|
inventory_items.items[2].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(3));
|
|
|
|
}).unwrap();
|
|
|
|
inventory_items.items[3].with_individual(|item| {
|
|
|
|
assert_eq!(item.id, item::ItemEntityId(5));
|
|
|
|
}).unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
async fn test_withdraw_meseta_from_shared_banks() {
|
|
|
|
let mut entity_gateway = InMemoryGateway::default();
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankIdentifier::Character, item::Meseta(300)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankIdentifier::Shared(item::BankName("asdf".into())), item::Meseta(300)).await.unwrap();
|
|
|
|
entity_gateway.set_bank_meseta(&char1.id, &item::BankIdentifier::Shared(item::BankName("qwer".into())), item::Meseta(300)).await.unwrap();
|
|
|
|
|
|
|
|
let mut ship = Box::new(ShipServerState::builder()
|
|
|
|
.gateway(entity_gateway.clone())
|
|
|
|
.build());
|
|
|
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
|
|
|
join_lobby(&mut ship, ClientId(1)).await;
|
|
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
|
action: 1,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 23,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::PlayerChat(PlayerChat::new(0, "\tE/sbank asdf".into()))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
|
action: 1,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 55,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::PlayerChat(PlayerChat::new(0, "\tE/sbank qwer".into()))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
|
action: 1,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 32,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::PlayerChat(PlayerChat::new(0, "\tE/bank".into()))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankRequest(BankRequest {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BankInteraction(BankInteraction {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0xFFFFFFFF,
|
|
|
|
action: 1,
|
|
|
|
item_amount: 0,
|
|
|
|
meseta_amount: 5,
|
|
|
|
unknown: 0,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
let meseta = entity_gateway.get_character_meseta(&char1.id).await.unwrap();
|
|
|
|
let bank_meseta1 = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Character).await.unwrap();
|
|
|
|
let bank_meseta2 = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Shared(item::BankName("asdf".into()))).await.unwrap();
|
|
|
|
let bank_meseta3 = entity_gateway.get_bank_meseta(&char1.id, &item::BankIdentifier::Shared(item::BankName("qwer".into()))).await.unwrap();
|
|
|
|
assert_eq!(meseta.0, 23+55+32+5);
|
|
|
|
assert_eq!(bank_meseta1.0, 300-23-5);
|
|
|
|
assert_eq!(bank_meseta2.0, 300-55);
|
|
|
|
assert_eq!(bank_meseta3.0, 300-32);
|
|
|
|
}
|