using System;
using Server.Items;
using Server.Misc;

namespace Server.Misc
{
    class CitizenDressing
    {
		public static void CitizenDress( Mobile m, int job )
		{
			bool specific = false;
				if ( job > 0 )
					specific = true;

			if ( job < 1 ){ job = Utility.RandomMinMax(1,3); }
			int weapon = Utility.Random( 40 );
			bool shield = true;

			if ( job == 1 ) // FIGHTER
			{
				weapon = Utility.RandomMinMax( 4, 32 );
					if ( !specific && Utility.RandomMinMax(1,35) == 1 )
						weapon = Utility.RandomMinMax( 37, 39 );

				if ( Utility.RandomMinMax(1,20) == 1 )
				{
					if ( Utility.RandomBool() ){ m.AddItem( new BoneArms() ); } else { m.AddItem( new OrcHelm() ); }
					m.AddItem( new BoneChest() );
					m.AddItem( new BoneGloves() );
					m.AddItem( new BoneHelm() );
					m.AddItem( new BoneLegs() );
				}
				else
				{
					switch ( Utility.Random( 10 ) )
					{
						case 0: m.AddItem( new PlateHelm() ); break;
						case 1: m.AddItem( new ChainCoif() ); break;
						case 2: m.AddItem( new Bascinet() ); break;
						case 3: m.AddItem( new CloseHelm() ); break;
						case 4: m.AddItem( new Helmet() ); break;
						case 5: m.AddItem( new NorseHelm() ); break;
					}
					switch ( Utility.Random( 3 ) )
					{
						case 0: m.AddItem( new PlateArms() ); break;
						case 1: m.AddItem( new RingmailArms() ); break;
					}
					switch ( Utility.Random( 2 ) )
					{
						case 0: m.AddItem( new PlateGorget() ); break;
					}
					switch ( Utility.Random( 3 ) )
					{
						case 0: m.AddItem( new PlateLegs() ); break;
						case 1: m.AddItem( new RingmailLegs() ); break;
						case 2: m.AddItem( new ChainLegs() ); break;
					}
					switch ( Utility.Random( 3 ) )
					{
						case 0: m.AddItem( new PlateGloves() ); break;
						case 1: m.AddItem( new RingmailGloves() ); break;
					}
					switch ( Utility.Random( 3 ) )
					{
						case 0: if ( m.Female && Utility.RandomBool() ){ m.AddItem( new FemalePlateChest() ); } else { m.AddItem( new PlateChest() ); } break;
						case 1: m.AddItem( new RingmailChest() ); break;
						case 2: m.AddItem( new ChainChest() ); break;
					}
				}

				switch ( Utility.Random( 2 ) )
				{
					case 0: m.AddItem( new Boots() ); break;
					case 1: m.AddItem( new ThighBoots() ); break;
				}

				switch ( Utility.Random( 2 ) )
				{
					case 0: m.AddItem( new Cloak( Utility.RandomHue() ) ); break;
				}
				switch ( Utility.Random( 10 ) )
				{
					case 0: m.AddItem( new Robe( Utility.RandomHue() ) ); break;
				}
			}
			else if ( job == 2 ) // THIEF
			{
				weapon = Utility.RandomList( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 37, 38, 39 );

				switch ( Utility.Random( 2 ) )
				{
					case 0: m.AddItem( new LeatherCap() ); break;
				}
				switch ( Utility.Random( 3 ) )
				{
					case 0: m.AddItem( new StuddedArms() ); break;
					case 1: m.AddItem( new LeatherArms() ); break;
				}
				switch ( Utility.Random( 3 ) )
				{
					case 0: m.AddItem( new StuddedGorget() ); break;
					case 1: m.AddItem( new LeatherGorget() ); break;
				}
				switch ( Utility.Random( 4 ) )
				{
					case 0: m.AddItem( new LeatherLegs() ); break;
					case 1: m.AddItem( new LeatherShorts() ); break;
					case 2: m.AddItem( new LeatherSkirt() ); break;
					case 3: m.AddItem( new StuddedLegs() ); break;
				}
				switch ( Utility.Random( 3 ) )
				{
					case 0: m.AddItem( new LeatherGloves() ); break;
					case 1: m.AddItem( new StuddedGloves() ); break;
				}
				switch ( Utility.Random( 2 ) )
				{
					case 0: if ( m.Female && Utility.RandomBool() ){ m.AddItem( new FemaleStuddedChest() ); } else { m.AddItem( new StuddedChest() ); } break;
					case 1: if ( m.Female && Utility.RandomBool() ){ m.AddItem( new FemaleLeatherChest() ); } else { m.AddItem( new LeatherChest() ); } break;
				}
				switch ( Utility.Random( 2 ) )
				{
					case 0: m.AddItem( new Boots() ); break;
					case 1: m.AddItem( new ThighBoots() ); break;
				}
				switch ( Utility.Random( 2 ) )
				{
					case 0: m.AddItem( new Cloak( Utility.RandomHue() ) ); break;
				}
				switch ( Utility.Random( 10 ) )
				{
					case 0: m.AddItem( new Robe( Utility.RandomHue() ) ); break;
				}
			}
			else if ( job == 3 ) // WIZARD
			{
				weapon = Utility.RandomList( 0, 1, 2, 3, 5, 7, 9, 30, 33, 34, 35, 36, 38, 39 );

				int robeHue = Utility.RandomHue();
				int cloakHue = Utility.RandomHue();
				int hatHue = Utility.RandomList( robeHue, cloakHue );

				bool robed = false;
				bool cloaked = false;

				switch ( Utility.Random( 5 ) )
				{
					case 0: m.AddItem( new FancyShirt( Utility.RandomHue() ) ); break;
					case 1: m.AddItem( new Doublet( Utility.RandomHue() ) ); break;
					case 2: m.AddItem( new Shirt( Utility.RandomHue() ) ); break;
					case 3: m.AddItem( new Tunic( Utility.RandomHue() ) ); break;
					case 4: m.AddItem( new Surcoat( Utility.RandomHue() ) ); break;
				}

				if ( m.Female )
				{
					switch ( Utility.Random( 4 ) )
					{
						case 0: m.AddItem( new Skirt( Utility.RandomHue() ) ); break;
						case 1: m.AddItem( new Kilt( Utility.RandomHue() ) ); break;
						case 2: m.AddItem( new LongPants( Utility.RandomHue() ) ); break;
						case 3: m.AddItem( new ShortPants( Utility.RandomHue() ) ); break;
					}
				}
				else
				{
					switch ( Utility.Random( 3 ) )
					{
						case 0: m.AddItem( new LongPants( Utility.RandomHue() ) ); break;
						case 1: m.AddItem( new ShortPants( Utility.RandomHue() ) ); break;
						case 2: m.AddItem( new Kilt( Utility.RandomHue() ) ); break;
					}
				}

				switch ( Utility.Random( 4 ) )
				{
					case 0: m.AddItem( new Shoes( Utility.RandomNeutralHue() ) ); break;
					case 1: m.AddItem( new Boots( Utility.RandomNeutralHue() ) );	break;
					case 2: m.AddItem( new Sandals( Utility.RandomNeutralHue() ) );	break;
					case 3: m.AddItem( new ThighBoots( Utility.RandomNeutralHue() ) );	break;
				}

				switch ( Utility.Random( 3 ) )
				{
					case 0: m.AddItem( new LeatherGloves() ); break;
				}

				if ( Utility.RandomBool() ){ m.AddItem( new Cloak( cloakHue ) ); cloaked = true; }

				switch ( Utility.Random( 5 ) )
				{
					case 0: if ( m.Female ){ m.AddItem( new PlainDress( robeHue ) ); } else { m.AddItem( new Robe( robeHue ) ); } robed = true; break;
					case 1: if ( m.Female ){ m.AddItem( new FancyDress( robeHue ) ); } else { m.AddItem( new Robe( robeHue ) ); } robed = true; break;
					case 2: m.AddItem( new Robe( robeHue ) ); robed = true; break;
				}

				if ( robed && !cloaked ){ hatHue = robeHue; }
				else if ( !robed && cloaked ){ hatHue = cloakHue; }

				switch ( Utility.Random( 13 ) )
				{
					case 0: m.AddItem( new FloppyHat( hatHue ) ); break;
					case 1: m.AddItem( new Hood( hatHue ) ); break;
					case 2: m.AddItem( new WideBrimHat( hatHue ) ); break;
					case 3: m.AddItem( new Cap( hatHue ) ); break;
					case 4: m.AddItem( new SkullCap( hatHue ) ); break;
					case 5: m.AddItem( new Bandana( hatHue ) ); break;
					case 6: m.AddItem( new FeatheredHat( hatHue ) ); break;
					case 7: m.AddItem( new Hood( hatHue ) ); break;
					case 8: m.AddItem( new WizardsHat( hatHue ) ); break;
					case 9: m.AddItem( new WizardsHat( hatHue ) ); break;
				}
			}
			else if ( job == 4 ) // BRIGAND
			{
				weapon = Utility.RandomList( 1000 );

				switch ( Utility.Random( 8 ))
				{
					case 0: m.AddItem( new Longsword() ); break;
					case 1: m.AddItem( new Cutlass() ); break;
					case 2: m.AddItem( new Broadsword() ); break;
					case 3: m.AddItem( new Axe() ); break;
					case 4: m.AddItem( new Club() ); break;
					case 5: m.AddItem( new Dagger() ); break;
					case 6: m.AddItem( new Rapier() ); break;
					case 7: m.AddItem( new Whip() ); break;
				}

				if ( Utility.RandomBool() )
				{
					switch ( Utility.Random( 4 ))
					{
						case 0: m.AddItem( new Buckler() ); break;
						case 1: m.AddItem( new WoodenShield() ); break;
						case 2: m.AddItem( new WoodenKiteShield() ); break;
						case 3: m.AddItem( new MetalShield() ); break;
					}
				}

				switch ( Utility.Random( 5 ) )
				{
					case 0: m.AddItem( new FancyShirt( Utility.RandomHue() ) ); break;
					case 1: m.AddItem( new Doublet( Utility.RandomHue() ) ); break;
					case 2: m.AddItem( new Shirt( Utility.RandomHue() ) ); break;
					case 3: m.AddItem( new Tunic( Utility.RandomHue() ) ); break;
					case 4: m.AddItem( new Surcoat( Utility.RandomHue() ) ); break;
				}

				if ( m.Female )
				{
					switch ( Utility.Random( 4 ) )
					{
						case 0: m.AddItem( new Skirt( Utility.RandomHue() ) ); break;
						case 1: m.AddItem( new Kilt( Utility.RandomHue() ) ); break;
						case 2: m.AddItem( new LongPants( Utility.RandomHue() ) ); break;
						case 3: m.AddItem( new ShortPants( Utility.RandomHue() ) ); break;
					}
				}
				else
				{
					switch ( Utility.Random( 3 ) )
					{
						case 0: m.AddItem( new LongPants( Utility.RandomHue() ) ); break;
						case 1: m.AddItem( new ShortPants( Utility.RandomHue() ) ); break;
						case 2: m.AddItem( new Kilt( Utility.RandomHue() ) ); break;
					}
				}

				switch ( Utility.Random( 4 ) )
				{
					case 0: m.AddItem( new Shoes( Utility.RandomNeutralHue() ) ); break;
					case 1: m.AddItem( new Boots( Utility.RandomNeutralHue() ) );	break;
					case 2: m.AddItem( new Sandals( Utility.RandomNeutralHue() ) );	break;
					case 3: m.AddItem( new ThighBoots( Utility.RandomNeutralHue() ) );	break;
				}

				if ( Utility.RandomBool() )
				{
					switch ( Utility.Random( 7 ) )
					{
						case 0: m.AddItem( new FloppyHat( Utility.RandomHue() ) ); break;
						case 1: m.AddItem( new Hood( Utility.RandomHue() ) ); break;
						case 2: m.AddItem( new WideBrimHat( Utility.RandomHue() ) ); break;
						case 3: m.AddItem( new Cap( Utility.RandomHue() ) ); break;
						case 4: m.AddItem( new SkullCap( Utility.RandomHue() ) ); break;
						case 5: m.AddItem( new Bandana( Utility.RandomHue() ) ); break;
						case 6: m.AddItem( new FeatheredHat( Utility.RandomHue() ) ); break;
					}
				}

				if ( Utility.RandomBool() )
				{
					m.AddItem( new Cloak( Utility.RandomHue() ) );
				}

				if ( Utility.RandomBool() )
				{
					m.AddItem( new Robe( Utility.RandomHue() ) );
				}
			}
			else if ( job == 5 ) // EVIL MAGE
			{
				weapon = 1000;

				int robeHue = Utility.RandomEvilHue();
				int cloakHue = Utility.RandomEvilHue();
				int shirtHue = Utility.RandomEvilHue();
				int legsHue = Utility.RandomEvilHue();
				int hatHue = Utility.RandomList( robeHue, cloakHue );

				bool robed = false;
				bool cloaked = false;

				switch ( Utility.Random( 5 ) )
				{
					case 0: m.AddItem( new FancyShirt( shirtHue ) ); break;
					case 1: m.AddItem( new Doublet( shirtHue ) ); break;
					case 2: m.AddItem( new Shirt( shirtHue ) ); break;
					case 3: m.AddItem( new Tunic( shirtHue ) ); break;
					case 4: m.AddItem( new Surcoat( shirtHue ) ); break;
				}

				if ( m.Female )
				{
					switch ( Utility.Random( 4 ) )
					{
						case 0: m.AddItem( new Skirt( legsHue ) ); break;
						case 1: m.AddItem( new Kilt( legsHue ) ); break;
						case 2: m.AddItem( new LongPants( legsHue ) ); break;
						case 3: m.AddItem( new ShortPants( legsHue ) ); break;
					}
				}
				else
				{
					switch ( Utility.Random( 3 ) )
					{
						case 0: m.AddItem( new LongPants( legsHue ) ); break;
						case 1: m.AddItem( new ShortPants( legsHue ) ); break;
						case 2: m.AddItem( new Kilt( legsHue ) ); break;
					}
				}

				switch ( Utility.Random( 3 ) )
				{
					case 0: m.AddItem( new Shoes( Utility.RandomEvilHue() ) ); break;
					case 1: m.AddItem( new Boots() );	break;
					case 2: m.AddItem( new ThighBoots() );	break;
				}

				if ( Utility.RandomBool() ){ m.AddItem( new Cloak( cloakHue ) ); cloaked = true; }

				switch ( Utility.Random( 3 ) )
				{
					case 0: if ( m.Female ){ m.AddItem( new PlainDress( robeHue ) ); } else { m.AddItem( new Robe( robeHue ) ); } robed = true; break;
					case 1: if ( m.Female ){ m.AddItem( new FancyDress( robeHue ) ); } else { m.AddItem( new Robe( robeHue ) ); } robed = true; break;
					case 2: m.AddItem( new Robe( robeHue ) ); robed = true; break;
				}

				if ( robed && !cloaked ){ hatHue = robeHue; }
				else if ( !robed && cloaked ){ hatHue = cloakHue; }

				switch ( Utility.Random( 3 ) )
				{
					case 0: m.AddItem( new Hood( hatHue ) ); break;
					case 1: m.AddItem( new WizardsHat( hatHue ) ); break;
				}
			}

			switch ( weapon )
			{
				case 0: m.AddItem( new ButcherKnife() ); break;
				case 1: m.AddItem( new Cleaver() ); break;
				case 2: m.AddItem( new Dagger() ); break;
				case 3: m.AddItem( new SkinningKnife() ); break;

				case 4: m.AddItem( new Broadsword() ); break;
				case 5: m.AddItem( new Cutlass() ); break;
				case 6: m.AddItem( new Katana() ); break;
				case 7: m.AddItem( new Kryss() ); break;
				case 8: m.AddItem( new Longsword() ); break;
				case 9: m.AddItem( new Scimitar() ); break;
				case 10: m.AddItem( new ThinLongsword() ); break;
				case 11: m.AddItem( new VikingSword() ); break;
				case 12: m.AddItem( new Scythe() ); shield = false; break;
				case 13: m.AddItem( new Rapier() ); break;

				case 14: m.AddItem( new BattleAxe() ); shield = false; break;
				case 15: m.AddItem( new DoubleAxe() ); shield = false; break;
				case 16: m.AddItem( new GreatAxe() ); shield = false; break;
				case 17: m.AddItem( new LargeBattleAxe() ); shield = false; break;
				case 18: m.AddItem( new Pickaxe() ); shield = false; break;
				case 19: m.AddItem( new TwoHandedAxe() ); shield = false; break;
				case 20: m.AddItem( new WarAxe() ); shield = false; break;
				case 21: m.AddItem( new Axe() ); shield = false; break;

				case 22: m.AddItem( new Spear() ); shield = false; break;
				case 23: m.AddItem( new Pitchfork() ); shield = false; break;
				case 24: m.AddItem( new Pike() ); shield = false; break;

				case 25: m.AddItem( new Bardiche() ); shield = false; break;
				case 26: m.AddItem( new Halberd() ); shield = false; break;

				case 27: m.AddItem( new Club() ); break;
				case 28: m.AddItem( new HammerPick() ); break;
				case 29: m.AddItem( new Mace() ); break;
				case 30: m.AddItem( new Maul() ); break;
				case 31: m.AddItem( new WarHammer() ); break;
				case 32: m.AddItem( new WarMace() ); break;

				case 33: m.AddItem( new BlackStaff() ); shield = false; break;
				case 34: m.AddItem( new GnarledStaff() ); shield = false; break;
				case 35: m.AddItem( new QuarterStaff() ); shield = false; break;
				case 36: m.AddItem( new ShepherdsCrook() ); shield = false; break;

				case 37: m.AddItem( new HeavyCrossbow() ); shield = false; break;
				case 38: m.AddItem( new Bow() ); shield = false; break;
				case 39: m.AddItem( new Crossbow() ); shield = false; break;
			}

			if ( shield && job == 1 && Utility.RandomBool() )
			{
				switch ( Utility.Random( 8 ) )
				{
					case 0: m.AddItem( new BronzeShield() ); break;
					case 1: m.AddItem( new ChaosShield() ); break;
					case 2: m.AddItem( new HeaterShield() ); break;
					case 3: m.AddItem( new MetalKiteShield() ); break;
					case 4: m.AddItem( new MetalShield() ); break;
					case 5: m.AddItem( new OrderShield() ); break;
					case 6: m.AddItem( new WoodenKiteShield() ); break;
					case 7: m.AddItem( new WoodenShield() ); break;
				}
			}
			else if ( shield && job == 2 && Utility.RandomBool() )
			{
				switch ( Utility.Random( 3 ) )
				{
					case 0: m.AddItem( new Buckler() ); break;
					case 1: m.AddItem( new WoodenKiteShield() ); break;
					case 2: m.AddItem( new WoodenShield() ); break;
				}
			}
			else if ( shield && job == 3 && Utility.RandomBool() )
			{
				switch ( Utility.Random( 4 ) )
				{
					case 0: m.AddItem( new Buckler() ); break;
				}
			}
		}

		public static void RemoveMyGear( Mobile m )
		{
			if ( m.FindItemOnLayer( Layer.OneHanded ) != null ) { m.FindItemOnLayer( Layer.OneHanded ).Delete(); }
			if ( m.FindItemOnLayer( Layer.TwoHanded ) != null ) { m.FindItemOnLayer( Layer.TwoHanded ).Delete(); }
			if ( m.FindItemOnLayer( Layer.FirstValid ) != null ) { m.FindItemOnLayer( Layer.FirstValid ).Delete(); }
			if ( m.FindItemOnLayer( Layer.Helm ) != null ) { m.FindItemOnLayer( Layer.Helm ).Delete(); }
			if ( m.FindItemOnLayer( Layer.Gloves ) != null ) { m.FindItemOnLayer( Layer.Gloves ).Delete(); }
		}
	}
}