ModernUO/Scripts/Misc/Gifts/GiftGiving.cs
asayre 2ad37d54aa Lots of fixes, changes, rewrites of various things, including but not limited to:
Logging of staff crafting items,
Fixes for the OSI client changes
The potion stacking stuff
BaseWeapon fix, so that damage increase things don't multiply themselves.
admin gump fixes for Firewall
Various display tweaks for weight
SoS no longer spawn in Tokuno
Hiryu hues happified to OSI standards
staff now see alliance chat correctly
Play barkeeper text increased per OSI
Various other OSI skill requirement changes
Various unimplemented features of the SE moves
EventSink for when the client version is received from client.
Client validation moved out of the core.
Client version validation now has options to ignore/kick/warn/annoy.  Automagically tries to detect current client.
Reverted the delayeddamagecontext back to OSI standards.
Can no longer use bags of sending in jail.

MagerySpell implemented. Now only Magery spells have a circle, and various other properties of 'em.
TransformationSpellHelper now implemented.  Things moved around for this.
Spells now need a Timespan for the cast delay, instead of arbitrarily based on Circle.  Circle doesn't make sense for non-Magery spells!
Alot of the spellweaving spells added to OSI standards.
2007-05-26 03:12:41 +00:00

88 lines
No EOL
1.9 KiB
C#

using System;
using System.Collections.Generic;
using Server;
using Server.Accounting;
using Server.Items;
namespace Server.Misc
{
public enum GiftResult
{
Backpack,
BankBox
}
public class GiftGiving
{
private static List<GiftGiver> m_Givers = new List<GiftGiver>();
public static void Register( GiftGiver giver )
{
m_Givers.Add( giver );
}
public static void Initialize()
{
EventSink.Login += new LoginEventHandler( EventSink_Login );
}
private static void EventSink_Login( LoginEventArgs e )
{
Account acct = e.Mobile.Account as Account;
if ( acct == null )
return;
DateTime now = DateTime.Now;
for ( int i = 0; i < m_Givers.Count; ++i )
{
GiftGiver giver = m_Givers[i];
if ( now < giver.Start || now >= giver.Finish )
continue; // not in the correct timefream
if ( acct.Created > (giver.Start - giver.MinimumAge) )
continue; // newly created account
if ( acct.LastLogin >= giver.Start )
continue; // already got one
giver.DelayGiveGift( TimeSpan.FromSeconds( 5.0 ), e.Mobile );
}
acct.LastLogin = now;
}
}
public abstract class GiftGiver
{
public virtual TimeSpan MinimumAge{ get{ return TimeSpan.FromDays( 30.0 ); } }
public abstract DateTime Start{ get; }
public abstract DateTime Finish{ get; }
public abstract void GiveGift( Mobile mob );
public virtual void DelayGiveGift( TimeSpan delay, Mobile mob )
{
Timer.DelayCall( delay, new TimerStateCallback( DelayGiveGift_Callback ), mob );
}
protected virtual void DelayGiveGift_Callback( object state )
{
GiveGift( (Mobile) state );
}
public virtual GiftResult GiveGift( Mobile mob, Item item )
{
if ( mob.PlaceInBackpack( item ) )
{
if ( !WeightOverloading.IsOverloaded( mob ) )
return GiftResult.Backpack;
}
mob.BankBox.DropItem( item );
return GiftResult.BankBox;
}
}
}