first commit

This commit is contained in:
Beyhan Oğur
2026-09-03 04:45:36 +03:00
commit d5f52cc3d3
1038 changed files with 169579 additions and 0 deletions
+524
View File
@@ -0,0 +1,524 @@
//TODO
//using System.Collections.Generic;
//using System.Collections.ObjectModel;
//using System.Diagnostics;
//using System.IO;
//using System.Linq;
//using System.Threading;
//using Assistant;
//using ClassicAssist.Data.Autoloot;
//using ClassicAssist.UO.Data;
//using ClassicAssist.UO.Network;
//using ClassicAssist.UO.Network.PacketFilter;
//using ClassicAssist.UO.Objects;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
//namespace ClassicAssist.Tests.Agents
//{
// [TestClass]
// public class AutolootTests
// {
// [TestMethod]
// public void WillRehueMatchingItemProperties()
// {
// const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";
// if ( !Directory.Exists( localPath ) )
// {
// Debug.WriteLine( "Not running test, requires Cliloc.enu" );
// return;
// }
// Cliloc.Initialize( localPath );
// Item corpse = new Item( 0x40000000 ) { ID = 0x2006 };
// Engine.Items.Add( corpse );
// IncomingPacketHandlers.Initialize();
// AutolootViewModel vm = new AutolootViewModel { Enabled = true };
// AutolootEntry lootEntry = new AutolootEntry
// {
// Rehue = true,
// Autoloot = false,
// Constraints = new ObservableCollection<AutolootConstraintEntry>(),
// ID = 0x108a
// };
// AutolootConstraintEntry constraintEntry = new AutolootConstraintEntry
// {
// Property = vm.Constraints.FirstOrDefault( c => c.Name == "Faster Casting" ),
// Operator = AutolootOperator.GreaterThan,
// Value = 1
// };
// lootEntry.Constraints.Add( constraintEntry );
// vm.Items.Add( lootEntry );
// Engine.PacketWaitEntries = new PacketWaitEntries();
// AutoResetEvent are = new AutoResetEvent( false );
// void OnPacketReceivedEvent( byte[] data, int length )
// {
// if ( data[0] == 0x25 )
// {
// are.Set();
// }
// else
// {
// Assert.Fail();
// }
// }
// Engine.InternalPacketReceivedEvent += OnPacketReceivedEvent;
// Engine.PacketWaitEntries.WaitEntryAddedEvent += entry =>
// {
// byte[] containerContentsPacket =
// {
// 0x3C, 0x00, 0x19, 0x00, 0x01, 0x43, 0x13, 0xFC, 0x5E, 0x10, 0x8A, 0x00, 0x00, 0x01, 0x00, 0x13,
// 0x00, 0x82, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00
// };
// PacketHandler handler = IncomingPacketHandlers.GetHandler( 0x3C );
// handler.OnReceive( new PacketReader( containerContentsPacket, containerContentsPacket.Length, false ) );
// entry.Packet = containerContentsPacket;
// entry.Lock.Set();
// byte[] propertiesPacket =
// {
// 0xD6, 0x00, 0x53, 0x00, 0x01, 0x43, 0x13, 0xFC, 0x5E, 0x00, 0x00, 0x01, 0x6E, 0x08, 0xB4, 0x00,
// 0x0F, 0xA0, 0xEA, 0x00, 0x00, 0x00, 0x10, 0x5E, 0x94, 0x00, 0x02, 0x31, 0x00, 0x00, 0x10, 0x2E,
// 0x64, 0x00, 0x14, 0x23, 0x00, 0x31, 0x00, 0x30, 0x00, 0x34, 0x00, 0x34, 0x00, 0x30, 0x00, 0x38,
// 0x00, 0x35, 0x00, 0x09, 0x00, 0x39, 0x00, 0x00, 0x10, 0x2E, 0x3C, 0x00, 0x02, 0x32, 0x00, 0x00,
// 0x10, 0x2E, 0x3D, 0x00, 0x02, 0x31, 0x00, 0x00, 0x10, 0x2E, 0x83, 0x00, 0x02, 0x34, 0x00, 0x00,
// 0x00, 0x00, 0x00
// };
// handler = IncomingPacketHandlers.GetHandler( 0xD6 );
// handler.OnReceive( new PacketReader( propertiesPacket, propertiesPacket.Length, false ) );
// };
// vm.OnCorpseEvent( corpse.Serial );
// bool result = are.WaitOne( 5000 );
// Assert.IsTrue( result );
// Engine.Items.Clear();
// Engine.PacketWaitEntries = null;
// Engine.InternalPacketReceivedEvent -= OnPacketReceivedEvent;
// }
// [TestMethod]
// public void WillRehueMatchingObjectProperties()
// {
// Item corpse = new Item( 0x40000000 ) { ID = 0x2006 };
// Engine.Items.Add( corpse );
// IncomingPacketHandlers.Initialize();
// AutolootViewModel vm = new AutolootViewModel { Enabled = true };
// AutolootEntry lootEntry = new AutolootEntry
// {
// Rehue = true,
// Autoloot = false,
// Constraints = new ObservableCollection<AutolootConstraintEntry>(),
// ID = 0x108a
// };
// AutolootConstraintEntry autolootConstraint = new AutolootConstraintEntry
// {
// Property = vm.Constraints.FirstOrDefault( c => c.Name == "Hue" ),
// Operator = AutolootOperator.Equal,
// Value = 0
// };
// lootEntry.Constraints.Add( autolootConstraint );
// vm.Items.Add( lootEntry );
// Engine.PacketWaitEntries = new PacketWaitEntries();
// AutoResetEvent are = new AutoResetEvent( false );
// void OnPacketReceivedEvent( byte[] data, int length )
// {
// if ( data[0] == 0x25 )
// {
// are.Set();
// }
// else
// {
// Assert.Fail();
// }
// }
// Engine.InternalPacketReceivedEvent += OnPacketReceivedEvent;
// Engine.PacketWaitEntries.WaitEntryAddedEvent += entry =>
// {
// byte[] containerContentsPacket =
// {
// 0x3C, 0x00, 0x19, 0x00, 0x01, 0x43, 0x13, 0xFC, 0x5E, 0x10, 0x8A, 0x00, 0x00, 0x01, 0x00, 0x13,
// 0x00, 0x82, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00
// };
// PacketHandler handler = IncomingPacketHandlers.GetHandler( 0x3C );
// handler.OnReceive( new PacketReader( containerContentsPacket, containerContentsPacket.Length, false ) );
// entry.Packet = containerContentsPacket;
// entry.Lock.Set();
// };
// vm.OnCorpseEvent( corpse.Serial );
// bool result = are.WaitOne( 5000 );
// Assert.IsTrue( result );
// Engine.Items.Clear();
// Engine.PacketWaitEntries = null;
// Engine.InternalPacketReceivedEvent -= OnPacketReceivedEvent;
// }
// [TestMethod]
// public void WillLootMatchingObjectProperties()
// {
// const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";
// if ( !Directory.Exists( localPath ) )
// {
// Debug.WriteLine( "Not running test, requires Cliloc.enu" );
// return;
// }
// TileData.Initialize( localPath );
// Engine.Player = new PlayerMobile( 0x01 );
// Item backpack = new Item( 0x40000001, 0x01 ) { Container = new ItemCollection( 0x40000001 ) };
// Engine.Player.SetLayer( Layer.Backpack, backpack.Serial );
// Engine.Items.Add( backpack );
// Item corpse = new Item( 0x40000000 ) { ID = 0x2006 };
// Engine.Items.Add( corpse );
// IncomingPacketHandlers.Initialize();
// AutolootViewModel vm = new AutolootViewModel { Enabled = true };
// AutolootEntry lootEntry = new AutolootEntry
// {
// Rehue = false,
// Autoloot = true,
// Constraints = new ObservableCollection<AutolootConstraintEntry>(),
// ID = 0x108a
// };
// AutolootConstraintEntry autolootConstraint = new AutolootConstraintEntry
// {
// Property = vm.Constraints.FirstOrDefault( c => c.Name == "ID" ),
// Operator = AutolootOperator.Equal,
// Value = 0x108a
// };
// lootEntry.Constraints.Add( autolootConstraint );
// vm.Items.Add( lootEntry );
// Engine.PacketWaitEntries = new PacketWaitEntries();
// AutoResetEvent are = new AutoResetEvent( false );
// void OnPacketSentEvent( byte[] data, int length )
// {
// if ( data[0] == 0x07 || data[0] == 0x08 )
// {
// are.Set();
// }
// else if ( data[0] == 0xD6 || data[0] == 0x06 )
// {
// }
// else
// {
// Assert.Fail();
// }
// }
// Engine.InternalPacketSentEvent += OnPacketSentEvent;
// Engine.PacketWaitEntries.WaitEntryAddedEvent += entry =>
// {
// byte[] containerContentsPacket =
// {
// 0x3C, 0x00, 0x19, 0x00, 0x01, 0x43, 0x13, 0xFC, 0x5E, 0x10, 0x8A, 0x00, 0x00, 0x01, 0x00, 0x13,
// 0x00, 0x82, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x64
// };
// PacketHandler handler = IncomingPacketHandlers.GetHandler( 0x3C );
// handler.OnReceive( new PacketReader( containerContentsPacket, containerContentsPacket.Length, false ) );
// entry.Packet = containerContentsPacket;
// entry.Lock.Set();
// };
// vm.OnCorpseEvent( corpse.Serial );
// bool result = are.WaitOne( 5000 );
// Assert.IsTrue( result );
// Engine.Items.Clear();
// Engine.PacketWaitEntries = null;
// Engine.InternalPacketSentEvent -= OnPacketSentEvent;
// Engine.Player = null;
// }
// [TestMethod]
// public void WontLootDisabledInGuardzone()
// {
// const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";
// if ( !Directory.Exists( localPath ) )
// {
// Debug.WriteLine( "Not running test, requires Cliloc.enu" );
// return;
// }
// TileData.Initialize( localPath );
// Engine.Player = new PlayerMobile( 0x01 ) { X = 652, Y = 869 };
// Item backpack = new Item( 0x40000001, 0x01 ) { Container = new ItemCollection( 0x40000001 ) };
// Engine.Player.SetLayer( Layer.Backpack, backpack.Serial );
// Engine.Items.Add( backpack );
// Item corpse = new Item( 0x40000000 ) { ID = 0x2006 };
// Engine.Items.Add( corpse );
// IncomingPacketHandlers.Initialize();
// AutolootViewModel vm = new AutolootViewModel { Enabled = true, DisableInGuardzone = true };
// AutolootEntry lootEntry = new AutolootEntry
// {
// Rehue = false,
// Autoloot = true,
// Constraints = new ObservableCollection<AutolootConstraintEntry>(),
// ID = 0x108a
// };
// AutolootConstraintEntry autolootConstraint = new AutolootConstraintEntry
// {
// Property = vm.Constraints.FirstOrDefault( c => c.Name == "Hue" ),
// Operator = AutolootOperator.Equal,
// Value = 0
// };
// lootEntry.Constraints.Add( autolootConstraint );
// vm.Items.Add( lootEntry );
// Engine.PacketWaitEntries = new PacketWaitEntries();
// void OnPacketSentEvent( byte[] data, int length )
// {
// if ( data[0] == 0xD6 || data[0] == 0x06 )
// {
// return;
// }
// Assert.Fail();
// }
// Engine.InternalPacketSentEvent += OnPacketSentEvent;
// Engine.PacketWaitEntries.WaitEntryAddedEvent += entry =>
// {
// byte[] containerContentsPacket =
// {
// 0x3C, 0x00, 0x19, 0x00, 0x01, 0x43, 0x13, 0xFC, 0x5E, 0x10, 0x8A, 0x00, 0x00, 0x01, 0x00, 0x13,
// 0x00, 0x82, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00
// };
// PacketHandler handler = IncomingPacketHandlers.GetHandler( 0x3C );
// handler.OnReceive( new PacketReader( containerContentsPacket, containerContentsPacket.Length, false ) );
// entry.Packet = containerContentsPacket;
// entry.Lock.Set();
// };
// vm.OnCorpseEvent( corpse.Serial );
// Engine.Items.Clear();
// Engine.PacketWaitEntries = null;
// Engine.InternalPacketSentEvent -= OnPacketSentEvent;
// Engine.Player = null;
// }
// [TestMethod]
// public void WontRehueNotEnabledEntry()
// {
// Item corpse = new Item( 0x40000000 ) { ID = 0x2006 };
// Engine.Items.Add( corpse );
// IncomingPacketHandlers.Initialize();
// AutolootViewModel vm = new AutolootViewModel { Enabled = true };
// AutolootEntry lootEntry = new AutolootEntry
// {
// Rehue = true,
// Autoloot = false,
// Constraints = new ObservableCollection<AutolootConstraintEntry>(),
// ID = 0x108a,
// Enabled = false
// };
// vm.Items.Add( lootEntry );
// Engine.PacketWaitEntries = new PacketWaitEntries();
// void OnPacketReceivedEvent( byte[] data, int length )
// {
// Assert.Fail();
// }
// Engine.InternalPacketReceivedEvent += OnPacketReceivedEvent;
// Engine.PacketWaitEntries.WaitEntryAddedEvent += entry =>
// {
// byte[] containerContentsPacket =
// {
// 0x3C, 0x00, 0x19, 0x00, 0x01, 0x43, 0x13, 0xFC, 0x5E, 0x10, 0x8A, 0x00, 0x00, 0x01, 0x00, 0x13,
// 0x00, 0x82, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00
// };
// PacketHandler handler = IncomingPacketHandlers.GetHandler( 0x3C );
// handler.OnReceive( new PacketReader( containerContentsPacket, containerContentsPacket.Length, false ) );
// entry.Packet = containerContentsPacket;
// entry.Lock.Set();
// };
// vm.OnCorpseEvent( corpse.Serial );
// Engine.Items.Clear();
// Engine.PacketWaitEntries = null;
// Engine.InternalPacketReceivedEvent -= OnPacketReceivedEvent;
// }
// [TestMethod]
// public void WontRehueNotEnabled()
// {
// Item corpse = new Item( 0x40000000 ) { ID = 0x2006 };
// Engine.Items.Add( corpse );
// IncomingPacketHandlers.Initialize();
// AutolootViewModel vm = new AutolootViewModel { Enabled = true };
// AutolootEntry lootEntry = new AutolootEntry
// {
// Rehue = true,
// Autoloot = false,
// Constraints = new ObservableCollection<AutolootConstraintEntry>(),
// ID = 0x108a,
// Enabled = true
// };
// vm.Items.Add( lootEntry );
// vm.Enabled = false;
// Engine.PacketWaitEntries = new PacketWaitEntries();
// void OnPacketReceivedEvent( byte[] data, int length )
// {
// Assert.Fail();
// }
// Engine.InternalPacketReceivedEvent += OnPacketReceivedEvent;
// Engine.PacketWaitEntries.WaitEntryAddedEvent += entry =>
// {
// byte[] containerContentsPacket =
// {
// 0x3C, 0x00, 0x19, 0x00, 0x01, 0x43, 0x13, 0xFC, 0x5E, 0x10, 0x8A, 0x00, 0x00, 0x01, 0x00, 0x13,
// 0x00, 0x82, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00
// };
// PacketHandler handler = IncomingPacketHandlers.GetHandler( 0x3C );
// handler.OnReceive( new PacketReader( containerContentsPacket, containerContentsPacket.Length, false ) );
// entry.Packet = containerContentsPacket;
// entry.Lock.Set();
// };
// vm.OnCorpseEvent( corpse.Serial );
// Engine.Items.Clear();
// Engine.PacketWaitEntries = null;
// Engine.InternalPacketReceivedEvent -= OnPacketReceivedEvent;
// }
// [TestMethod]
// public void WontMatchNotIncluded()
// {
// PropertyEntry property1 = new PropertyEntry { ClilocIndex = -1, Clilocs = new[] { 1 }, Name = "Test" };
// PropertyEntry property2 = new PropertyEntry { ClilocIndex = -1, Clilocs = new[] { 2 }, Name = "Test 2" };
// ItemCollection container = new ItemCollection( 2 )
// {
// new Item( 1 ) { Properties = new[] { new Property { Cliloc = 1, Text = "Test" } } }
// };
// AutolootEntry filter = new AutolootEntry
// {
// Constraints = new ObservableCollection<AutolootConstraintEntry>
// {
// new AutolootConstraintEntry
// {
// Operator = AutolootOperator.Equal, Property = property1, Value = 0
// }
// }
// };
// IEnumerable<Item> matchItems = AutolootHelpers.AutolootFilter( container.GetItems(), filter );
// Assert.IsTrue( matchItems.Any() );
// container.Clear();
// container.Add( new Item( 3 )
// {
// Properties = new[]
// {
// new Property { Cliloc = 1, Text = "Test" }, new Property { Cliloc = 2, Text = "Test 2" }
// }
// } );
// filter.Constraints.Add( new AutolootConstraintEntry
// {
// Operator = AutolootOperator.NotPresent, Property = property2, Value = 0
// } );
// matchItems = AutolootHelpers.AutolootFilter( container.GetItems(), filter );
// Assert.IsTrue( !matchItems.Any() );
// Engine.Items.Clear();
// }
// [TestCleanup]
// public void Cleanup()
// {
// ActionPacketQueue.Clear();
// }
// }
//}
+205
View File
@@ -0,0 +1,205 @@
#region License
// Copyright (C) 2020 Reetus
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#endregion
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using ClassicAssist.Shared;
using ClassicAssist.Data.Vendors;
using ClassicAssist.UO.Data;
using ClassicAssist.UO.Network;
using ClassicAssist.UO.Objects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ClassicAssist.Tests.Agents
{
[TestClass]
public class BuyAgentTests
{
[TestMethod]
public void WillBuyCorrectAmount()
{
int vendorSerial = 0x0b0354;
byte[] shopList =
{
0x74, 0x01, 0x67, 0x42, 0x0C, 0x82, 0x83, 0x1B, 0x00, 0x00, 0x00, 0x12, 0x08, 0x31, 0x30, 0x32,
0x33, 0x38, 0x33, 0x34, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x31, 0x30, 0x32, 0x34, 0x30, 0x33,
0x31, 0x00, 0x00, 0x00, 0x00, 0x05, 0x08, 0x31, 0x30, 0x32, 0x33, 0x38, 0x32, 0x37, 0x00, 0x00,
0x00, 0x00, 0x0B, 0x08, 0x31, 0x30, 0x34, 0x31, 0x30, 0x37, 0x32, 0x00, 0x00, 0x00, 0x00, 0x0F,
0x08, 0x31, 0x30, 0x32, 0x37, 0x39, 0x35, 0x36, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x08, 0x31, 0x30,
0x32, 0x33, 0x38, 0x35, 0x31, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x08, 0x31, 0x30, 0x32, 0x33, 0x38,
0x34, 0x38, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x08, 0x31, 0x30, 0x32, 0x33, 0x38, 0x34, 0x36, 0x00,
0x00, 0x00, 0x00, 0x0F, 0x08, 0x31, 0x30, 0x32, 0x33, 0x38, 0x35, 0x32, 0x00, 0x00, 0x00, 0x00,
0x0F, 0x08, 0x31, 0x30, 0x32, 0x33, 0x38, 0x34, 0x39, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x08, 0x31,
0x30, 0x32, 0x33, 0x38, 0x34, 0x37, 0x00, 0x00, 0x00, 0x00, 0x05, 0x08, 0x31, 0x30, 0x32, 0x33,
0x39, 0x36, 0x32, 0x00, 0x00, 0x00, 0x00, 0x05, 0x08, 0x31, 0x30, 0x32, 0x33, 0x39, 0x36, 0x33,
0x00, 0x00, 0x00, 0x00, 0x03, 0x08, 0x31, 0x30, 0x32, 0x33, 0x39, 0x37, 0x32, 0x00, 0x00, 0x00,
0x00, 0x03, 0x08, 0x31, 0x30, 0x32, 0x33, 0x39, 0x37, 0x33, 0x00, 0x00, 0x00, 0x00, 0x03, 0x08,
0x31, 0x30, 0x32, 0x33, 0x39, 0x37, 0x34, 0x00, 0x00, 0x00, 0x00, 0x03, 0x08, 0x31, 0x30, 0x32,
0x33, 0x39, 0x37, 0x36, 0x00, 0x00, 0x00, 0x00, 0x03, 0x08, 0x31, 0x30, 0x32, 0x33, 0x39, 0x38,
0x31, 0x00, 0x00, 0x00, 0x00, 0x03, 0x08, 0x31, 0x30, 0x32, 0x33, 0x39, 0x38, 0x30, 0x00, 0x00,
0x00, 0x00, 0x0C, 0x08, 0x31, 0x30, 0x32, 0x37, 0x39, 0x38, 0x32, 0x00, 0x00, 0x00, 0x00, 0x0C,
0x08, 0x31, 0x30, 0x32, 0x37, 0x39, 0x38, 0x33, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x08, 0x31, 0x30,
0x32, 0x37, 0x39, 0x38, 0x34, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x08, 0x31, 0x30, 0x32, 0x37, 0x39,
0x38, 0x35, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x08, 0x31, 0x30, 0x32, 0x37, 0x39, 0x38, 0x36, 0x00,
0x00, 0x00, 0x00, 0x0C, 0x08, 0x31, 0x30, 0x32, 0x37, 0x39, 0x38, 0x37, 0x00, 0x00, 0x00, 0x00,
0x0C, 0x08, 0x31, 0x30, 0x32, 0x37, 0x39, 0x38, 0x31, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x08, 0x31,
0x30, 0x32, 0x37, 0x39, 0x38, 0x38, 0x00
};
byte[] contents =
{
0x3C, 0x02, 0x21, 0x00, 0x1B, 0x40, 0x1F, 0x00, 0x1B, 0x1F, 0x34, 0x00, 0x00, 0x14, 0x00, 0x1B,
0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x1A, 0x1F, 0x2D, 0x00,
0x00, 0x14, 0x00, 0x1A, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00,
0x19, 0x1F, 0x33, 0x00, 0x00, 0x14, 0x00, 0x19, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00,
0x00, 0x40, 0x1F, 0x00, 0x17, 0x1F, 0x32, 0x00, 0x00, 0x14, 0x00, 0x18, 0x00, 0x01, 0x00, 0x42,
0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x14, 0x1F, 0x31, 0x00, 0x00, 0x14, 0x00, 0x17,
0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x13, 0x1F, 0x30, 0x00,
0x00, 0x14, 0x00, 0x16, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00,
0x12, 0x1F, 0x2F, 0x00, 0x00, 0x14, 0x00, 0x15, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00,
0x00, 0x40, 0x1F, 0x00, 0x10, 0x1F, 0x2E, 0x00, 0x00, 0x14, 0x00, 0x14, 0x00, 0x01, 0x00, 0x42,
0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x0F, 0x0F, 0x8C, 0x00, 0x00, 0x28, 0x00, 0x13,
0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x0E, 0x0F, 0x8D, 0x00,
0x00, 0x28, 0x00, 0x12, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00,
0x0D, 0x0F, 0x88, 0x00, 0x00, 0x28, 0x00, 0x11, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00,
0x00, 0x40, 0x1F, 0x00, 0x0C, 0x0F, 0x86, 0x00, 0x00, 0x14, 0x00, 0x10, 0x00, 0x01, 0x00, 0x42,
0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x0A, 0x0F, 0x85, 0x00, 0x00, 0x28, 0x00, 0x0F,
0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x09, 0x0F, 0x84, 0x00,
0x00, 0x28, 0x00, 0x0E, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00,
0x08, 0x0F, 0x7B, 0x00, 0x00, 0x14, 0x00, 0x0D, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00,
0x00, 0x40, 0x1F, 0x00, 0x07, 0x0F, 0x7A, 0x00, 0x00, 0x14, 0x00, 0x0C, 0x00, 0x01, 0x00, 0x42,
0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x06, 0x0F, 0x07, 0x00, 0x00, 0x14, 0x00, 0x0B,
0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x05, 0x0F, 0x09, 0x00,
0x00, 0x14, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00,
0x04, 0x0F, 0x0C, 0x00, 0x00, 0x14, 0x00, 0x09, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00,
0x00, 0x40, 0x1F, 0x00, 0x02, 0x0F, 0x06, 0x00, 0x00, 0x14, 0x00, 0x08, 0x00, 0x01, 0x00, 0x42,
0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x01, 0x0F, 0x08, 0x00, 0x00, 0x14, 0x00, 0x07,
0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x00, 0x0F, 0x0B, 0x00,
0x00, 0x14, 0x00, 0x06, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1E, 0xFF,
0xFF, 0x1F, 0x14, 0x00, 0x00, 0x10, 0x00, 0x05, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00,
0x00, 0x40, 0x1E, 0xFF, 0xFE, 0x17, 0x18, 0x00, 0x00, 0x0A, 0x00, 0x04, 0x00, 0x01, 0x00, 0x42,
0x0C, 0x82, 0x83, 0x00, 0xE1, 0x40, 0x1E, 0xFF, 0xFD, 0x0E, 0xF3, 0x00, 0x00, 0x14, 0x00, 0x03,
0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1E, 0xFF, 0xFC, 0x0F, 0xBF, 0x00,
0x00, 0x14, 0x00, 0x02, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00, 0x40, 0x1E, 0xFF,
0xFB, 0x0E, 0xFA, 0x00, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x01, 0x00, 0x42, 0x0C, 0x82, 0x83, 0x00, 0x00
};
byte[] containerDisplay = { 0x24, 0x00, 0x0B, 0x03, 0x54, 0x00, 0x30, 0x00, 0x00 };
Mobile vendor = new Mobile( vendorSerial );
vendor.SetLayer( Layer.ShopBuy, 0x420c8283 );
Engine.Mobiles.Add( vendor );
IncomingPacketHandlers.Initialize();
//TODO
//VendorBuyTabViewModel vm = new VendorBuyTabViewModel();
//vm.Items.Add( new VendorBuyAgentEntry
//{
// Graphic = 0xf8c,
// Amount = 1,
// Enabled = true,
// Hue = -1,
// MaxPrice = -1
//} );
//vm.Items.Add( new VendorBuyAgentEntry
//{
// Graphic = 0xf8d,
// Amount = 1,
// Enabled = true,
// Hue = -1,
// MaxPrice = -1
//} );
//vm.Items.Add( new VendorBuyAgentEntry
//{
// Graphic = 0xf85,
// Amount = 1,
// Enabled = true,
// Hue = -1,
// MaxPrice = -1
//} );
//vm.Items.Add( new VendorBuyAgentEntry
//{
// Graphic = 0xf88,
// Amount = 1,
// Enabled = true,
// Hue = -1,
// MaxPrice = -1
//} );
//vm.Enabled = true;
//PacketHandler containerContentsHandler = IncomingPacketHandlers.GetHandler( 0x3C );
//containerContentsHandler?.OnReceive( new PacketReader( contents, contents.Length, false ) );
//vendor.Equipment.Add( Engine.Items.GetItem( 0x420c8283 ) );
//PacketHandler shopListHandler = IncomingPacketHandlers.GetHandler( 0x74 );
//shopListHandler?.OnReceive( new PacketReader( shopList, shopList.Length, false ) );
//PacketHandler containerDisplayHandler = IncomingPacketHandlers.GetHandler( 0x24 );
//AutoResetEvent are = new AutoResetEvent( false );
//List<ShopListEntry> buyList = new List<ShopListEntry>();
//void OnPacketSentEvent( byte[] data, int length )
//{
// if ( data[0] != 0x3B )
// {
// return;
// }
// PacketReader reader = new PacketReader( data, data.Length, false );
// int count = ( data.Length - 8 ) / 7;
// reader.Seek( 5, SeekOrigin.Current );
// for ( int i = 0; i < count; i++ )
// {
// reader.ReadByte(); // layer
// int serial = reader.ReadInt32();
// int amount = reader.ReadInt16();
// buyList.Add( new ShopListEntry { Amount = amount, Item = Engine.Items.GetItem( serial ) } );
// }
//}
//Engine.InternalPacketSentEvent += OnPacketSentEvent;
//containerDisplayHandler?.OnReceive( new PacketReader( containerDisplay, containerDisplay.Length, true ) );
//foreach ( VendorBuyAgentEntry entry in vm.Items )
//{
// int amount = buyList.Where( e => e.Item.ID == entry.Graphic ).Sum( e => e.Amount );
// Assert.AreEqual( entry.Amount, amount, 0, "Buy incorrect amount" );
//}
//Engine.Items.Clear();
//Engine.Mobiles.Clear();
}
}
}
@@ -0,0 +1,269 @@
using System;
using System.Collections.Generic;
using System.IO;
using ClassicAssist.Shared;
using ClassicAssist.Data.Dress;
using ClassicAssist.UO.Data;
using ClassicAssist.UO.Network;
using ClassicAssist.UO.Objects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
namespace ClassicAssist.Tests.Agents
{
[TestClass]
public class DressAgentTests
{
private Item _backpack;
private int[] _packetLengths;
private PlayerMobile _player;
[TestInitialize]
public void Initialize()
{
_packetLengths = new int[byte.MaxValue];
string json = File.ReadAllText( Path.Combine( Environment.CurrentDirectory, "packetlengths.json" ) );
JObject jsonObj = JObject.Parse( json );
foreach ( JProperty token in jsonObj["PacketLengths"].Children<JProperty>() )
{
int key = int.Parse( token.Name );
int val = token.Value.ToObject<int>();
if ( val == 0x8000 )
{
val = 0;
}
_packetLengths[key] = val;
}
_player = new PlayerMobile( 0x01 ) { Equipment = new ItemCollection( 0x01 ) };
_backpack = new Item( 0x40000002 ) { Container = new ItemCollection( 0x40000002 ), Owner = 0x01 };
_player.SetLayer( Layer.Backpack, _backpack.Serial );
Engine.Items.Add( _backpack );
Engine.Player = _player;
IncomingPacketHandlers.Initialize();
OutgoingPacketHandlers.Initialize();
Engine.ClientVersion = new Version( 7, 0, 45, 1 );
Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;
}
private void OnInternalPacketSentEvent( byte[] data, int length )
{
PacketHandler handler = OutgoingPacketHandlers.GetHandler( data[0] );
handler?.OnReceive( new PacketReader( data, data.Length, _packetLengths[data[0]] != 0 ) );
if ( data[0] == 0x08 )
{
int serial = ( data[1] << 24 ) | ( data[2] << 16 ) | ( data[3] << 8 ) | data[4];
int containerSerial = ( data[11] << 24 ) | ( data[12] << 16 ) | ( data[13] << 8 ) | data[14];
//container cont update
PacketWriter pw = new PacketWriter( 21 );
pw.Write( (byte) 0x25 );
pw.Write( serial );
pw.Seek( 10, SeekOrigin.Current );
pw.Write( containerSerial );
pw.Write( (short) 0 );
byte[] packet = pw.ToArray();
handler = IncomingPacketHandlers.GetHandler( packet[0] );
handler?.OnReceive( new PacketReader( packet, packet.Length, true ) );
}
if ( data[0] == 0x13 )
{
int serial = ( data[1] << 24 ) | ( data[2] << 16 ) | ( data[3] << 8 ) | data[4];
Layer layer = (Layer) data[5];
int containerSerial = ( data[6] << 24 ) | ( data[7] << 16 ) | ( data[8] << 8 ) | data[9];
Mobile mobile = Engine.Mobiles.GetMobile( containerSerial );
int itemInLayer = mobile?.GetLayer( layer ) ?? 0;
if ( itemInLayer != 0 )
{
// item already in layer / liftrej
return;
}
// equip update
PacketWriter pw = new PacketWriter( 15 );
pw.Write( (byte) 0x2E );
pw.Write( serial );
pw.Write( (short) 0 );
pw.Write( (byte) 0 );
pw.Write( (byte) layer );
pw.Write( containerSerial );
pw.Write( (short) 0 );
byte[] packet = pw.ToArray();
handler = IncomingPacketHandlers.GetHandler( packet[0] );
handler?.OnReceive( new PacketReader( packet, packet.Length, true ) );
}
}
[TestMethod]
public void WillDressUndressItem()
{
Item dressItem = new Item( 0x40000003 );
Engine.Items.Add( dressItem );
DressAgentEntry dae = new DressAgentEntry
{
Name = "Test",
Items = new List<DressAgentItem>
{
new DressAgentItem { Layer = Layer.Talisman, Serial = dressItem.Serial }
}
};
dae.Dress().Wait();
Assert.AreEqual( dressItem.Serial, _player.GetLayer( dressItem.Layer ) );
dae.Undress().Wait();
Assert.AreEqual( 0, _player.GetLayer( dressItem.Layer ) );
Assert.AreEqual( 1, _player.Backpack.Container.GetTotalItemCount() );
Assert.IsNotNull( _player.Backpack.Container.GetItem( dressItem.Serial ) );
}
[TestMethod]
public void WillDressUndressItemContainer()
{
Item dressItem = new Item( 0x40000003 );
Item undressContainer = new Item( 0x40000004 ) { Container = new ItemCollection( 0x40000004 ) };
Engine.Items.Add( dressItem );
Engine.Items.Add( undressContainer );
DressAgentEntry dae = new DressAgentEntry
{
Name = "Test",
Items = new List<DressAgentItem>
{
new DressAgentItem { Layer = Layer.Talisman, Serial = dressItem.Serial }
},
UndressContainer = undressContainer.Serial
};
dae.Dress().Wait();
Assert.AreEqual( dressItem.Serial, _player.GetLayer( dressItem.Layer ) );
dae.Undress().Wait();
Assert.AreEqual( 0, _player.GetLayer( dressItem.Layer ) );
Assert.AreEqual( 1, undressContainer.Container.GetTotalItemCount() );
Assert.IsNotNull( undressContainer.Container.GetItem( dressItem.Serial ) );
Engine.Items.Remove( undressContainer );
}
[TestMethod]
public void WillUndressAll()
{
Item dressItem = new Item( 0x40000003 );
Engine.Items.Add( dressItem );
DressAgentEntry dae = new DressAgentEntry
{
Name = "Test",
Items = new List<DressAgentItem>
{
new DressAgentItem { Layer = Layer.Talisman, Serial = dressItem.Serial }
}
};
dae.Dress().Wait();
Assert.AreEqual( dressItem.Serial, _player.GetLayer( dressItem.Layer ) );
DressManager.GetInstance().UndressAll().Wait();
Assert.AreEqual( 0, _player.GetLayer( dressItem.Layer ) );
Assert.AreEqual( 1, _player.Backpack.Container.GetTotalItemCount() );
Assert.IsNotNull( _player.Backpack.Container.GetItem( dressItem.Serial ) );
}
[TestMethod]
public void WontDressNoMoveConflicting()
{
Item dressItem = new Item( 0x40000003 );
Engine.Items.Add( dressItem );
Item conflictingItem = new Item( 0x40000004 ) { Owner = _player.Serial };
Engine.Items.Add( conflictingItem );
_player.SetLayer( Layer.Talisman, conflictingItem.Serial );
DressAgentEntry dae = new DressAgentEntry
{
Name = "Test",
Items = new List<DressAgentItem>
{
new DressAgentItem { Layer = Layer.Talisman, Serial = dressItem.Serial }
}
};
Assert.AreEqual( conflictingItem.Serial, _player.GetLayer( Layer.Talisman ) );
dae.Dress( false ).Wait();
Assert.AreEqual( conflictingItem.Serial, _player.GetLayer( Layer.Talisman ) );
Engine.Items.Remove( conflictingItem );
}
[TestMethod]
public void WillDressMoveConflicting()
{
Item dressItem = new Item( 0x40000003 );
Engine.Items.Add( dressItem );
Item conflictingItem = new Item( 0x40000004 ) { Owner = _player.Serial };
Engine.Items.Add( conflictingItem );
_player.SetLayer( Layer.Talisman, conflictingItem.Serial );
DressAgentEntry dae = new DressAgentEntry
{
Name = "Test",
Items = new List<DressAgentItem>
{
new DressAgentItem { Layer = Layer.Talisman, Serial = dressItem.Serial }
}
};
Assert.AreEqual( conflictingItem.Serial, _player.GetLayer( Layer.Talisman ) );
dae.Dress().Wait();
Assert.AreEqual( dressItem.Serial, _player.GetLayer( Layer.Talisman ) );
Engine.Items.Remove( conflictingItem );
}
[TestCleanup]
public void Cleanup()
{
ActionPacketQueue.Clear();
Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
Engine.Player = null;
Engine.Items.Clear();
}
}
}
@@ -0,0 +1,151 @@
#region License
// Copyright (C) 2020 Reetus
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#endregion
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using ClassicAssist.Shared;
using ClassicAssist.Data.Organizer;
using ClassicAssist.UO.Data;
using ClassicAssist.UO.Network.PacketFilter;
using ClassicAssist.UO.Objects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ClassicAssist.Tests.Agents
{
[TestClass]
public class OrganizerTests
{
[TestMethod]
public void WillOrganizeAnyHue()
{
Engine.Items.Clear();
Item container = new Item( 0x40000000 ) { Container = new ItemCollection( 0x40000000 ) };
container.Container.Add( new Item( 0x40000001 ) { ID = 0xf06, Hue = 1000 } );
container.Container.Add( new Item( 0x40000002 ) { ID = 0xf06, Hue = 1161 } );
Engine.Items.Add( container );
Engine.PacketWaitEntries = new PacketWaitEntries();
OrganizerManager manager = OrganizerManager.GetInstance();
OrganizerEntry entry = new OrganizerEntry();
entry.Items.Add( new OrganizerItem { ID = 0xf06, Hue = -1, Amount = -1, Item = "Test" } );
AutoResetEvent are = new AutoResetEvent( false );
void OnInternalPacketSentEvent( byte[] data, int length )
{
if ( data[0] == 0x06 )
{
int serial = ( data[1] << 24 ) | ( data[2] << 16 ) | ( data[3] << 8 ) | data[4];
PacketWriter writer = new PacketWriter();
writer.Write( 0x3C );
writer.Seek( 19, SeekOrigin.Begin );
writer.Write( serial );
Engine.SendPacketToClient( writer );
}
if ( data[0] == 0x07 )
{
are.Set();
}
}
Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;
Task.Run( () => manager.Organize( entry, container.Serial, container.Serial ) ).Wait();
bool result = are.WaitOne( 4000 );
Assert.IsTrue( result );
manager.Items.Clear();
Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
Engine.PacketWaitEntries = null;
Engine.Items.Clear();
}
[TestMethod]
public void WillOrganizeOnlyHue()
{
Engine.Items.Clear();
Item container = new Item( 0x40000000 ) { Container = new ItemCollection( 0x40000000 ) };
container.Container.Add( new Item( 0x40000001 ) { ID = 0xf06, Hue = 1000 } );
container.Container.Add( new Item( 0x40000002 ) { ID = 0xf06, Hue = 1161 } );
Engine.Items.Add( container );
Engine.PacketWaitEntries = new PacketWaitEntries();
OrganizerManager manager = OrganizerManager.GetInstance();
OrganizerEntry entry = new OrganizerEntry();
entry.Items.Add( new OrganizerItem { ID = 0xf06, Hue = 1161, Amount = -1, Item = "Test" } );
AutoResetEvent are = new AutoResetEvent( false );
void OnInternalPacketSentEvent( byte[] data, int length )
{
if ( data[0] == 0x06 )
{
int serial = ( data[1] << 24 ) | ( data[2] << 16 ) | ( data[3] << 8 ) | data[4];
PacketWriter writer = new PacketWriter();
writer.Write( 0x3C );
writer.Seek( 19, SeekOrigin.Begin );
writer.Write( serial );
Engine.SendPacketToClient( writer );
}
if ( data[0] == 0x07 )
{
int serial = ( data[1] << 24 ) | ( data[2] << 16 ) | ( data[3] << 8 ) | data[4];
if ( serial == 0x40000002 )
{
are.Set();
}
else
{
Assert.Fail();
}
}
}
Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;
Task.Run( () => manager.Organize( entry, container.Serial, container.Serial ) ).Wait();
bool result = are.WaitOne( 4000 );
Assert.IsTrue( result );
manager.Items.Clear();
Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
Engine.PacketWaitEntries = null;
Engine.Items.Clear();
}
}
}
@@ -0,0 +1,123 @@
#region License
// Copyright (C) 2020 Reetus
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#endregion
using System.IO;
using System.Threading;
using ClassicAssist.Shared;
using ClassicAssist.Data.Scavenger;
using ClassicAssist.UO.Data;
using ClassicAssist.UO.Objects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ClassicAssist.Tests.Agents
{
[TestClass]
public class ScavengerTests
{
[TestMethod]
public void WillScavengerEnabled()
{
//TODO
//ScavengerTabViewModel vm = new ScavengerTabViewModel { Enabled = true };
//ScavengerManager manager = ScavengerManager.GetInstance();
//if ( !Directory.Exists( @"C:\Program Files (x86)\Electronic Arts\Ultima Online Classic" ) )
//{
// return;
//}
//TileData.Initialize( @"C:\Program Files (x86)\Electronic Arts\Ultima Online Classic" );
//Engine.Player = new PlayerMobile( 0x0 ) { WeightMax = 500 };
//Engine.Player.SetLayer( Layer.Backpack, 0x40000001 );
//manager.Items.Add( new ScavengerEntry { Enabled = true, Graphic = 0xff, Hue = -1, Name = "Test" } );
//Engine.Items.Add( new Item( 0x40000001 ) { Container = new ItemCollection( 0x4000001 ) } );
//Engine.Items.Add( new Item( 0x40000000 ) { ID = 0xff } );
//AutoResetEvent are = new AutoResetEvent( false );
//void OnInternalPacketSentEvent( byte[] data, int length )
//{
// if ( data[0] == 0x07 )
// {
// are.Set();
// }
//}
//Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;
//vm.CheckArea();
//bool result = are.WaitOne( 5000 );
//if ( !result )
//{
// Assert.Fail();
//}
//Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
//Engine.Player = null;
//Engine.Items.Clear();
//manager.Items.Clear();
}
[TestMethod]
public void WontScavengerEntryDisabled()
{
//TODO
//ScavengerTabViewModel vm = new ScavengerTabViewModel { Enabled = true };
ScavengerManager manager = ScavengerManager.GetInstance();
if ( !Directory.Exists( @"C:\Program Files (x86)\Electronic Arts\Ultima Online Classic" ) )
{
return;
}
TileData.Initialize( @"C:\Program Files (x86)\Electronic Arts\Ultima Online Classic" );
Engine.Player = new PlayerMobile( 0x0 ) { WeightMax = 500 };
Engine.Player.SetLayer( Layer.Backpack, 0x40000001 );
manager.Items.Add( new ScavengerEntry { Enabled = false, Graphic = 0xff, Hue = -1, Name = "Test" } );
Engine.Items.Add( new Item( 0x40000001 ) { Container = new ItemCollection( 0x4000001 ) } );
Engine.Items.Add( new Item( 0x40000000 ) { ID = 0xff } );
AutoResetEvent are = new AutoResetEvent( false );
void OnInternalPacketSentEvent( byte[] data, int length )
{
if ( data[0] == 0x07 )
{
Assert.Fail();
}
}
Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;
//TODO
//vm.CheckArea();
bool result = are.WaitOne( 500 );
Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
Engine.Player = null;
Engine.Items.Clear();
manager.Items.Clear();
}
}
}
@@ -0,0 +1,202 @@
//TODO
//using System.Threading;
//using Assistant;
//using ClassicAssist.Data.Vendors;
//using ClassicAssist.UO.Data;
//using ClassicAssist.UO.Network;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
//namespace ClassicAssist.Tests.Agents
//{
// [TestClass]
// public class SellAgentTests
// {
// [TestMethod]
// public void WontSellIncorrectHue()
// {
// //TODO
// //void OnPacket( byte[] data, int length )
// //{
// // Assert.Fail();
// //}
// //Engine.InternalPacketSentEvent += OnPacket;
// //VendorSellTabViewModel vsvm = new VendorSellTabViewModel();
// //vsvm.Items.Add( new VendorSellAgentEntry
// //{
// // Enabled = true,
// // Graphic = 0xff,
// // MinPrice = 10,
// // Name = "Shmoo",
// // Hue = 0xff
// //} );
// //IncomingPacketHandlers.Initialize();
// //PacketHandler handler = IncomingPacketHandlers.GetHandler( 0x9E );
// //PacketWriter pw = new PacketWriter( 23 );
// //pw.Write( (byte) 0x9E );
// //pw.Write( (short) 21 );
// //pw.Write( 0 );
// //pw.Write( (short) 1 );
// //pw.Write( 0 );
// //pw.Write( (short) 0xFF );
// //pw.Write( (short) 0 );
// //pw.Write( (short) 0 );
// //pw.Write( (short) 9 );
// //pw.Write( (short) 0 );
// //byte[] packet = pw.ToArray();
// //handler.OnReceive( new PacketReader( packet, packet.Length, false ) );
// //vsvm.Items.Clear();
// //Engine.InternalPacketSentEvent -= OnPacket;
// }
// [TestMethod]
// public void WontSellUnderMinPrice()
// {
// //TODO
// //void OnPacket( byte[] data, int length )
// //{
// // Assert.Fail();
// //}
// //Engine.InternalPacketSentEvent += OnPacket;
// //VendorSellTabViewModel vsvm = new VendorSellTabViewModel();
// //vsvm.Items.Add( new VendorSellAgentEntry
// //{
// // Enabled = true, Graphic = 0xff, MinPrice = 10, Name = "Shmoo"
// //} );
// //IncomingPacketHandlers.Initialize();
// //PacketHandler handler = IncomingPacketHandlers.GetHandler( 0x9E );
// //PacketWriter pw = new PacketWriter( 23 );
// //pw.Write( (byte) 0x9E );
// //pw.Write( (short) 21 );
// //pw.Write( 0 );
// //pw.Write( (short) 1 );
// //pw.Write( 0 );
// //pw.Write( (short) 0xFF );
// //pw.Write( (short) 0 );
// //pw.Write( (short) 0 );
// //pw.Write( (short) 9 );
// //pw.Write( (short) 0 );
// //byte[] packet = pw.ToArray();
// //handler.OnReceive( new PacketReader( packet, packet.Length, false ) );
// //vsvm.Items.Clear();
// //Engine.InternalPacketSentEvent -= OnPacket;
// }
// [TestMethod]
// public void WillSellMinPrice()
// {
// AutoResetEvent are = new AutoResetEvent( false );
// void OnPacket( byte[] data, int length )
// {
// if ( data[0] == 0x9F )
// {
// are.Set();
// }
// }
// Engine.InternalPacketSentEvent += OnPacket;
// VendorSellTabViewModel vsvm = new VendorSellTabViewModel();
// vsvm.Items.Add( new VendorSellAgentEntry { Enabled = true, Graphic = 0xff, MinPrice = 9, Name = "Shmoo" } );
// IncomingPacketHandlers.Initialize();
// PacketHandler handler = IncomingPacketHandlers.GetHandler( 0x9E );
// PacketWriter pw = new PacketWriter( 23 );
// pw.Write( (byte) 0x9E );
// pw.Write( (short) 21 );
// pw.Write( 0 );
// pw.Write( (short) 1 );
// pw.Write( 0 );
// pw.Write( (short) 0xFF );
// pw.Write( (short) 0 );
// pw.Write( (short) 0 );
// pw.Write( (short) 9 );
// pw.Write( (short) 0 );
// byte[] packet = pw.ToArray();
// handler.OnReceive( new PacketReader( packet, packet.Length, false ) );
// bool result = are.WaitOne( 1000 );
// Assert.IsTrue( result );
// vsvm.Items.Clear();
// Engine.InternalPacketSentEvent -= OnPacket;
// }
// [TestMethod]
// public void WontSellMoreThanAmount()
// {
// AutoResetEvent are = new AutoResetEvent( false );
// void OnPacket( byte[] data, int length )
// {
// if ( data[0] != 0x9F )
// {
// return;
// }
// int amount = ( data[13] << 8 ) | data[14];
// if ( amount != 10 )
// {
// Assert.Fail();
// return;
// }
// are.Set();
// }
// Engine.InternalPacketSentEvent += OnPacket;
// VendorSellTabViewModel vsvm = new VendorSellTabViewModel();
// vsvm.Items.Add( new VendorSellAgentEntry { Enabled = true, Graphic = 0xff, Amount = 10, Name = "Shmoo" } );
// IncomingPacketHandlers.Initialize();
// PacketHandler handler = IncomingPacketHandlers.GetHandler( 0x9E );
// PacketWriter pw = new PacketWriter( 23 );
// pw.Write( (byte) 0x9E );
// pw.Write( (short) 21 );
// pw.Write( 0 );
// pw.Write( (short) 1 );
// pw.Write( 0 );
// pw.Write( (short) 0xFF );
// pw.Write( (short) 0 );
// pw.Write( (short) 100 );
// pw.Write( (short) 9 );
// pw.Write( (short) 0 );
// byte[] packet = pw.ToArray();
// handler.OnReceive( new PacketReader( packet, packet.Length, false ) );
// bool result = are.WaitOne( 1000 );
// Assert.IsTrue( result );
// vsvm.Items.Clear();
// Engine.InternalPacketSentEvent -= OnPacket;
// }
// }
//}