This commit is contained in:
		
							parent
							
								
									fbc68c7a26
								
							
						
					
					
						commit
						d84b2fc663
					
				@ -674,4 +674,99 @@ async fn test_selling_untekked_weapon() {
 | 
				
			|||||||
    let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
 | 
					    let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
 | 
				
			||||||
    let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
 | 
					    let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
 | 
				
			||||||
    assert_eq!(c1.meseta, 1);
 | 
					    assert_eq!(c1.meseta, 1);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[async_std::test]
 | 
				
			||||||
 | 
					async fn test_player_sells_rare_item() {
 | 
				
			||||||
 | 
					    let mut entity_gateway = InMemoryGateway::default();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let mut p1_inv = Vec::new();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    p1_inv.push(entity_gateway.create_item(
 | 
				
			||||||
 | 
					        item::NewItemEntity {
 | 
				
			||||||
 | 
					            item: item::ItemDetail::Weapon(
 | 
				
			||||||
 | 
					                item::weapon::Weapon {
 | 
				
			||||||
 | 
					                    weapon: item::weapon::WeaponType::DarkFlow,
 | 
				
			||||||
 | 
					                    grind: 5,
 | 
				
			||||||
 | 
					                    special: None,
 | 
				
			||||||
 | 
					                    attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}),
 | 
				
			||||||
 | 
					                            Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}),
 | 
				
			||||||
 | 
					                            Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Native, value: 100}),],
 | 
				
			||||||
 | 
					                    tekked: true,
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					            location: item::ItemLocation::Inventory {
 | 
				
			||||||
 | 
					                character_id: char1.id,
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }).await.unwrap());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(p1_inv)).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_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSoldItem(PlayerSoldItem {
 | 
				
			||||||
 | 
					        client: 0,
 | 
				
			||||||
 | 
					        target: 0,
 | 
				
			||||||
 | 
					        item_id: 0x10000,
 | 
				
			||||||
 | 
					        amount: 1,
 | 
				
			||||||
 | 
					    })))).await.unwrap().for_each(drop);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
 | 
				
			||||||
 | 
					    let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
 | 
				
			||||||
 | 
					    assert_eq!(c1.meseta, 10);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[async_std::test]
 | 
				
			||||||
 | 
					async fn test_player_sells_photon_drops() {
 | 
				
			||||||
 | 
					    let mut entity_gateway = InMemoryGateway::default();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let mut p1_inv = Vec::new();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let mut photon_drops = Vec::new();
 | 
				
			||||||
 | 
					    for _ in 0..7usize {
 | 
				
			||||||
 | 
					        photon_drops.push(entity_gateway.create_item(
 | 
				
			||||||
 | 
					            item::NewItemEntity {
 | 
				
			||||||
 | 
					                item: item::ItemDetail::Tool(
 | 
				
			||||||
 | 
					                    item::tool::Tool {
 | 
				
			||||||
 | 
					                        tool: item::tool::ToolType::PhotonDrop,
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                ),
 | 
				
			||||||
 | 
					                location: item::ItemLocation::Inventory {
 | 
				
			||||||
 | 
					                    character_id: char1.id,
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }).await.unwrap());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    p1_inv.push(item::InventoryItemEntity::Stacked(photon_drops));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(p1_inv)).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_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSoldItem(PlayerSoldItem {
 | 
				
			||||||
 | 
					        client: 0,
 | 
				
			||||||
 | 
					        target: 0,
 | 
				
			||||||
 | 
					        item_id: 0x10000,
 | 
				
			||||||
 | 
					        amount: 3,
 | 
				
			||||||
 | 
					    })))).await.unwrap().for_each(drop);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let characters1 = entity_gateway.get_characters_by_user(&user1).await.unwrap();
 | 
				
			||||||
 | 
					    let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
 | 
				
			||||||
 | 
					    assert_eq!(c1.meseta, 3000);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user