Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -1,162 +1,176 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Targeting;
|
||||
using Server.Items;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.SkillHandlers
|
||||
{
|
||||
public class Inscribe
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
SkillInfo.Table[(int)SkillName.Inscribe].Callback = OnUse;
|
||||
}
|
||||
public class Inscribe
|
||||
{
|
||||
private static Dictionary<BaseBook, Mobile> m_UseTable = new Dictionary<BaseBook, Mobile>();
|
||||
|
||||
public static TimeSpan OnUse( Mobile m )
|
||||
{
|
||||
Target target = new InternalTargetSrc();
|
||||
m.Target = target;
|
||||
m.SendLocalizedMessage( 1046295 ); // Target the book you wish to copy.
|
||||
target.BeginTimeout( m, TimeSpan.FromMinutes( 1.0 ) );
|
||||
public static void Initialize()
|
||||
{
|
||||
SkillInfo.Table[(int)SkillName.Inscribe].Callback = OnUse;
|
||||
}
|
||||
|
||||
return TimeSpan.FromSeconds( 1.0 );
|
||||
}
|
||||
public static TimeSpan OnUse(Mobile m)
|
||||
{
|
||||
Target target = new InternalTargetSrc();
|
||||
m.Target = target;
|
||||
m.SendLocalizedMessage(1046295); // Target the book you wish to copy.
|
||||
target.BeginTimeout(m, TimeSpan.FromMinutes(1.0));
|
||||
|
||||
private static Dictionary<BaseBook, Mobile> m_UseTable = new Dictionary<BaseBook, Mobile>();
|
||||
return TimeSpan.FromSeconds(1.0);
|
||||
}
|
||||
|
||||
private static void SetUser( BaseBook book, Mobile mob )
|
||||
{
|
||||
m_UseTable[book] = mob;
|
||||
}
|
||||
private static void SetUser(BaseBook book, Mobile mob)
|
||||
{
|
||||
m_UseTable[book] = mob;
|
||||
}
|
||||
|
||||
private static void CancelUser( BaseBook book )
|
||||
{
|
||||
m_UseTable.Remove( book );
|
||||
}
|
||||
private static void CancelUser(BaseBook book)
|
||||
{
|
||||
m_UseTable.Remove(book);
|
||||
}
|
||||
|
||||
public static Mobile GetUser( BaseBook book )
|
||||
{
|
||||
m_UseTable.TryGetValue( book, out Mobile m );
|
||||
return m;
|
||||
}
|
||||
public static Mobile GetUser(BaseBook book)
|
||||
{
|
||||
m_UseTable.TryGetValue(book, out Mobile m);
|
||||
return m;
|
||||
}
|
||||
|
||||
public static bool IsEmpty( BaseBook book )
|
||||
{
|
||||
foreach ( BookPageInfo page in book.Pages )
|
||||
{
|
||||
foreach ( string line in page.Lines )
|
||||
{
|
||||
if ( line.Trim().Length != 0 )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static bool IsEmpty(BaseBook book)
|
||||
{
|
||||
foreach (BookPageInfo page in book.Pages)
|
||||
foreach (string line in page.Lines)
|
||||
if (line.Trim().Length != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Copy( BaseBook bookSrc, BaseBook bookDst )
|
||||
{
|
||||
bookDst.Title = bookSrc.Title;
|
||||
bookDst.Author = bookSrc.Author;
|
||||
public static void Copy(BaseBook bookSrc, BaseBook bookDst)
|
||||
{
|
||||
bookDst.Title = bookSrc.Title;
|
||||
bookDst.Author = bookSrc.Author;
|
||||
|
||||
BookPageInfo[] pagesSrc = bookSrc.Pages;
|
||||
BookPageInfo[] pagesDst = bookDst.Pages;
|
||||
for ( int i = 0; i < pagesSrc.Length && i < pagesDst.Length; i++ )
|
||||
{
|
||||
BookPageInfo pageSrc = pagesSrc[i];
|
||||
BookPageInfo pageDst = pagesDst[i];
|
||||
BookPageInfo[] pagesSrc = bookSrc.Pages;
|
||||
BookPageInfo[] pagesDst = bookDst.Pages;
|
||||
for (int i = 0; i < pagesSrc.Length && i < pagesDst.Length; i++)
|
||||
{
|
||||
BookPageInfo pageSrc = pagesSrc[i];
|
||||
BookPageInfo pageDst = pagesDst[i];
|
||||
|
||||
int length = pageSrc.Lines.Length;
|
||||
pageDst.Lines = new string[length];
|
||||
int length = pageSrc.Lines.Length;
|
||||
pageDst.Lines = new string[length];
|
||||
|
||||
for ( int j = 0; j < length; j++ )
|
||||
pageDst.Lines[j] = pageSrc.Lines[j];
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < length; j++)
|
||||
pageDst.Lines[j] = pageSrc.Lines[j];
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTargetSrc : Target
|
||||
{
|
||||
public InternalTargetSrc() : base ( 3, false, TargetFlags.None )
|
||||
{
|
||||
}
|
||||
private class InternalTargetSrc : Target
|
||||
{
|
||||
public InternalTargetSrc() : base(3, false, TargetFlags.None)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
BaseBook book = targeted as BaseBook;
|
||||
if ( book == null )
|
||||
from.SendLocalizedMessage( 1046296 ); // That is not a book
|
||||
else if ( IsEmpty( book ) )
|
||||
from.SendLocalizedMessage( 501611 ); // Can't copy an empty book.
|
||||
else if ( GetUser( book ) != null )
|
||||
from.SendLocalizedMessage( 501621 ); // Someone else is inscribing that item.
|
||||
else
|
||||
{
|
||||
Target target = new InternalTargetDst( book );
|
||||
from.Target = target;
|
||||
from.SendLocalizedMessage( 501612 ); // Select a book to copy this to.
|
||||
target.BeginTimeout( from, TimeSpan.FromMinutes( 1.0 ) );
|
||||
SetUser( book, from );
|
||||
}
|
||||
}
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
BaseBook book = targeted as BaseBook;
|
||||
if (book == null)
|
||||
{
|
||||
from.SendLocalizedMessage(1046296); // That is not a book
|
||||
}
|
||||
else if (IsEmpty(book))
|
||||
{
|
||||
from.SendLocalizedMessage(501611); // Can't copy an empty book.
|
||||
}
|
||||
else if (GetUser(book) != null)
|
||||
{
|
||||
from.SendLocalizedMessage(501621); // Someone else is inscribing that item.
|
||||
}
|
||||
else
|
||||
{
|
||||
Target target = new InternalTargetDst(book);
|
||||
from.Target = target;
|
||||
from.SendLocalizedMessage(501612); // Select a book to copy this to.
|
||||
target.BeginTimeout(from, TimeSpan.FromMinutes(1.0));
|
||||
SetUser(book, from);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTargetCancel( Mobile from, TargetCancelType cancelType )
|
||||
{
|
||||
if ( cancelType == TargetCancelType.Timeout )
|
||||
from.SendLocalizedMessage( 501619 ); // You have waited too long to make your inscribe selection, your inscription attempt has timed out.
|
||||
}
|
||||
}
|
||||
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
|
||||
{
|
||||
if (cancelType == TargetCancelType.Timeout)
|
||||
from.SendLocalizedMessage(
|
||||
501619); // You have waited too long to make your inscribe selection, your inscription attempt has timed out.
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTargetDst : Target
|
||||
{
|
||||
private BaseBook m_BookSrc;
|
||||
private class InternalTargetDst : Target
|
||||
{
|
||||
private BaseBook m_BookSrc;
|
||||
|
||||
public InternalTargetDst( BaseBook bookSrc ) : base ( 3, false, TargetFlags.None )
|
||||
{
|
||||
m_BookSrc = bookSrc;
|
||||
}
|
||||
public InternalTargetDst(BaseBook bookSrc) : base(3, false, TargetFlags.None)
|
||||
{
|
||||
m_BookSrc = bookSrc;
|
||||
}
|
||||
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
if ( m_BookSrc.Deleted )
|
||||
return;
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (m_BookSrc.Deleted)
|
||||
return;
|
||||
|
||||
BaseBook bookDst = targeted as BaseBook;
|
||||
BaseBook bookDst = targeted as BaseBook;
|
||||
|
||||
if ( bookDst == null )
|
||||
from.SendLocalizedMessage( 1046296 ); // That is not a book
|
||||
else if ( IsEmpty( m_BookSrc ) )
|
||||
from.SendLocalizedMessage( 501611 ); // Can't copy an empty book.
|
||||
else if ( bookDst == m_BookSrc )
|
||||
from.SendLocalizedMessage( 501616 ); // Cannot copy a book onto itself.
|
||||
else if ( !bookDst.Writable )
|
||||
from.SendLocalizedMessage( 501614 ); // Cannot write into that book.
|
||||
else if ( GetUser( bookDst ) != null )
|
||||
from.SendLocalizedMessage( 501621 ); // Someone else is inscribing that item.
|
||||
else
|
||||
{
|
||||
if ( from.CheckTargetSkill( SkillName.Inscribe, bookDst, 0, 50 ) )
|
||||
{
|
||||
Copy( m_BookSrc, bookDst );
|
||||
if (bookDst == null)
|
||||
{
|
||||
from.SendLocalizedMessage(1046296); // That is not a book
|
||||
}
|
||||
else if (IsEmpty(m_BookSrc))
|
||||
{
|
||||
from.SendLocalizedMessage(501611); // Can't copy an empty book.
|
||||
}
|
||||
else if (bookDst == m_BookSrc)
|
||||
{
|
||||
from.SendLocalizedMessage(501616); // Cannot copy a book onto itself.
|
||||
}
|
||||
else if (!bookDst.Writable)
|
||||
{
|
||||
from.SendLocalizedMessage(501614); // Cannot write into that book.
|
||||
}
|
||||
else if (GetUser(bookDst) != null)
|
||||
{
|
||||
from.SendLocalizedMessage(501621); // Someone else is inscribing that item.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (from.CheckTargetSkill(SkillName.Inscribe, bookDst, 0, 50))
|
||||
{
|
||||
Copy(m_BookSrc, bookDst);
|
||||
|
||||
from.SendLocalizedMessage( 501618 ); // You make a copy of the book.
|
||||
from.PlaySound( 0x249 );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 501617 ); // You fail to make a copy of the book.
|
||||
}
|
||||
}
|
||||
}
|
||||
from.SendLocalizedMessage(501618); // You make a copy of the book.
|
||||
from.PlaySound(0x249);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(501617); // You fail to make a copy of the book.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTargetCancel( Mobile from, TargetCancelType cancelType )
|
||||
{
|
||||
if ( cancelType == TargetCancelType.Timeout )
|
||||
from.SendLocalizedMessage( 501619 ); // You have waited too long to make your inscribe selection, your inscription attempt has timed out.
|
||||
}
|
||||
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
|
||||
{
|
||||
if (cancelType == TargetCancelType.Timeout)
|
||||
from.SendLocalizedMessage(
|
||||
501619); // You have waited too long to make your inscribe selection, your inscription attempt has timed out.
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish( Mobile from )
|
||||
{
|
||||
CancelUser( m_BookSrc );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
CancelUser(m_BookSrc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue