/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Jan-01-2012 10:09:01pm
Filepath: scripts\Commands\conttransfer.cs
Lines of code: 56

Description: 

***********************************************************/


using System;
using System.Reflection;
using Server.Items;
using Server.Targeting;
using Server.Mobiles;
using Server.Gumps;

namespace Server.Commands
{
	public class ContTransferCommand
	{
		public static void Initialize()
		{
			CommandSystem.Register( "conttransfer", AccessLevel.Player, new CommandEventHandler( ContTransfer_OnCommand ) );
		}

		[Usage( "ContTransfer" )]
		[Description( "Transfers items from one container to the other" )]
		private static void ContTransfer_OnCommand( CommandEventArgs e )
		{		
			PlayerMobile pm = e.Mobile as PlayerMobile;
			
			pm.SendMessage("Target a container to move items from");
			pm.Target = new ContTransferTarget();
	
		}
		

		
		private class ContTransferTarget : Target
		{
			Container m_source;
			
			
			public ContTransferTarget() : base( -1, true, TargetFlags.None )
			{
			}
			
			public ContTransferTarget(Container source) : base( -1, true, TargetFlags.None )
			{
				m_source=source;
			}

			protected override void OnTarget( Mobile from, object o )
			{
				if(o is Mobile && ((Mobile)o).Backpack!=null)o = ((Mobile)o).Backpack;
				
				
				
				if(!(o is Container))
				{
					from.SendMessage("That is not a container");
					return;
				}
				
				Container cont = (Container)o;
				
				if(m_source==null)
				{
					m_source=cont;
					
					from.Target = new ContTransferTarget(m_source);
					from.SendMessage("Target a container to move items to");
				}
				else
				{
					m_source.MoveItemsToOtherContainer(cont);
					
					
					from.SendMessage("The items have been transferd");
				}
				
				
			}
		}
		
	}
}



