mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-27 15:15:51 +03:00
Added Acquired and Origin properties to InventoryItem
This commit is contained in:
parent
17d7263973
commit
208af219d2
@ -74,6 +74,32 @@ public async Task GetAllItems()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task GetItemSpecialProperties()
|
||||||
|
{
|
||||||
|
await SteamInventory.WaitForDefinitions();
|
||||||
|
|
||||||
|
var result = await SteamInventory.GetAllItemsAsync();
|
||||||
|
|
||||||
|
Assert.IsTrue( result.HasValue );
|
||||||
|
Assert.IsTrue( result.Value.ItemCount > 0 );
|
||||||
|
|
||||||
|
using ( result )
|
||||||
|
{
|
||||||
|
var items = result.Value.GetItems( true );
|
||||||
|
|
||||||
|
Assert.IsNotNull( items );
|
||||||
|
|
||||||
|
foreach ( var item in items )
|
||||||
|
{
|
||||||
|
Console.WriteLine( $"{item.Id} / {item.DefId} / {item.Quantity} / {item.Def?.Name} " );
|
||||||
|
|
||||||
|
Console.WriteLine( $" Acquired: {item.Acquired}" );
|
||||||
|
Console.WriteLine( $" Origin: {item.Origin}" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task GetAllItemsMultipleTimes()
|
public async Task GetAllItemsMultipleTimes()
|
||||||
{
|
{
|
||||||
|
@ -123,6 +123,43 @@ internal static Dictionary<string, string> GetProperties( SteamInventoryResult_t
|
|||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will try to return the date that this item was aquired. You need to have for the items
|
||||||
|
/// with their properties for this to work.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Acquired
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if ( Properties == null ) return DateTime.UtcNow;
|
||||||
|
|
||||||
|
var str = Properties["acquired"];
|
||||||
|
|
||||||
|
var y = int.Parse( str.Substring( 0, 4 ) );
|
||||||
|
var m = int.Parse( str.Substring( 4, 2 ) );
|
||||||
|
var d = int.Parse( str.Substring( 6, 2 ) );
|
||||||
|
|
||||||
|
var h = int.Parse( str.Substring( 9, 2 ) );
|
||||||
|
var mn = int.Parse( str.Substring( 11, 2 ) );
|
||||||
|
var s = int.Parse( str.Substring( 13, 2 ) );
|
||||||
|
|
||||||
|
return new DateTime( y, m, d, h, mn, s, DateTimeKind.Utc );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to get the origin property. Need properties for this to work.
|
||||||
|
/// Will return a string like "market"
|
||||||
|
/// </summary>
|
||||||
|
public string Origin
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if ( Properties == null ) return null;
|
||||||
|
return Properties["origin"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Small utility class to describe an item with a quantity
|
/// Small utility class to describe an item with a quantity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user