Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
@@ -0,0 +1,889 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server;
|
||||
using Server.ContextMenus;
|
||||
using Server.Gumps;
|
||||
using Solaris.BoardGames;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public enum BoardGameState
|
||||
{
|
||||
Disabled = 0,
|
||||
Inactive = 1,
|
||||
Pending = 2,
|
||||
Recruiting = 3,
|
||||
Active = 4,
|
||||
GameOver = 5
|
||||
}
|
||||
|
||||
//the main control object for a boardgame system. Each board game needs exactly one control object
|
||||
public abstract class BoardGameControlItem : Item
|
||||
{
|
||||
public virtual string GameName{ get{ return "-UNDEFINED-"; } }
|
||||
public virtual string GameDescription{ get{ return "-UNDEFINED-"; } }
|
||||
public virtual string GameRules{ get{ return "-UNDEFINED-"; } }
|
||||
|
||||
public virtual bool CanCastSpells{ get{ return true; } }
|
||||
public virtual bool CanUseSkills{ get{ return true; } }
|
||||
public virtual bool CanUsePets{ get{ return true; } }
|
||||
|
||||
public virtual bool UseFromBackpack{ get{ return true; } }
|
||||
|
||||
public virtual TimeSpan WinDelay{ get{ return TimeSpan.Zero; } }
|
||||
|
||||
protected BoardGameState _State;
|
||||
|
||||
protected WinnerTimer _WinnerTimer;
|
||||
protected EndGameTimer _EndGameTimer;
|
||||
|
||||
//valid distance from the control item
|
||||
public virtual int UseRange{ get{ return 10; } }
|
||||
|
||||
public virtual int MinPlayers{ get{ return 0; } }
|
||||
public virtual int MaxPlayers{ get{ return 0; } }
|
||||
|
||||
public int CurrentMaxPlayers;
|
||||
|
||||
protected int _CostToPlay;
|
||||
|
||||
//the list of all players participating in the game
|
||||
protected List<Mobile> _Players;
|
||||
|
||||
//the list of all players pending a decision when interacting with the boardgame controller
|
||||
protected List<Mobile> _PendingPlayers;
|
||||
|
||||
//the defined region where the game is taking place
|
||||
public Rectangle3D GameZone;
|
||||
|
||||
protected Point3D _BoardOffset;
|
||||
|
||||
public Point3D BoardOffset{ get{ return _BoardOffset; } }
|
||||
|
||||
protected bool _SettingsReady;
|
||||
|
||||
public bool SettingsReady
|
||||
{
|
||||
get{ return _SettingsReady; }
|
||||
set
|
||||
{
|
||||
_SettingsReady = value;
|
||||
if( _SettingsReady && Players.Count == CurrentMaxPlayers && _State < BoardGameState.Active && _State != BoardGameState.Disabled )
|
||||
{
|
||||
InitializeGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Point3D BoardLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point3D( X + _BoardOffset.X, Y + _BoardOffset.Y, Z + _BoardOffset.Z );
|
||||
}
|
||||
set
|
||||
{
|
||||
Point3D location = value;
|
||||
_BoardOffset = new Point3D( location.X - X, location.Y - Y, location.Z - Z );
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
protected Map _BoardMap;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public Map BoardMap
|
||||
{
|
||||
get{ return _BoardMap; }
|
||||
set
|
||||
{
|
||||
_BoardMap = value;
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool ForceGameOver
|
||||
{
|
||||
get{ return false; }
|
||||
set
|
||||
{
|
||||
if( value )
|
||||
{
|
||||
EndGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected bool _AllowPlayerConfiguration;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool AllowPlayerConfiguration
|
||||
{
|
||||
get{ return _AllowPlayerConfiguration; }
|
||||
set
|
||||
{
|
||||
_AllowPlayerConfiguration = value;
|
||||
|
||||
if( _State != BoardGameState.Recruiting )
|
||||
{
|
||||
_SettingsReady = !value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//these hold the height and width of the game board
|
||||
protected int _BoardWidth;
|
||||
protected int _BoardHeight;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public virtual int BoardWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return _BoardWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
if( (int)_State <= (int)BoardGameState.Recruiting )
|
||||
{
|
||||
_BoardWidth = value;
|
||||
ResetBoard();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public virtual int BoardHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return _BoardHeight;
|
||||
}
|
||||
set
|
||||
{
|
||||
if( (int)_State <= (int)BoardGameState.Recruiting )
|
||||
{
|
||||
_BoardHeight = value;
|
||||
ResetBoard();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//the list of all items used as background for the game board
|
||||
protected List<GamePiece> _BackgroundItems;
|
||||
|
||||
protected BoardGameRegion _BoardGameRegion;
|
||||
|
||||
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public BoardGameState State
|
||||
{
|
||||
get
|
||||
{
|
||||
return _State;
|
||||
}
|
||||
set
|
||||
{
|
||||
_State = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public int CostToPlay
|
||||
{
|
||||
get{ return _CostToPlay; }
|
||||
set
|
||||
{
|
||||
_CostToPlay = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<Mobile> Players
|
||||
{
|
||||
get
|
||||
{
|
||||
if( _Players == null )
|
||||
{
|
||||
_Players = new List<Mobile>();
|
||||
}
|
||||
return _Players;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Mobile> PendingPlayers
|
||||
{
|
||||
get
|
||||
{
|
||||
if( _PendingPlayers == null )
|
||||
{
|
||||
_PendingPlayers = new List<Mobile>();
|
||||
}
|
||||
return _PendingPlayers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<GamePiece> BackgroundItems
|
||||
{
|
||||
get
|
||||
{
|
||||
if( _BackgroundItems == null )
|
||||
{
|
||||
_BackgroundItems = new List<GamePiece>();
|
||||
}
|
||||
return _BackgroundItems;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//main constructor
|
||||
public BoardGameControlItem() : base( 4006 ) //default itemid 4006: checkerboard
|
||||
{
|
||||
_AllowPlayerConfiguration = true;
|
||||
CurrentMaxPlayers = MinPlayers;
|
||||
InitializeControl();
|
||||
|
||||
}
|
||||
|
||||
//deserialization constructor
|
||||
public BoardGameControlItem( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
//this method initializes the game control and connects it with this item
|
||||
protected virtual void InitializeControl()
|
||||
{
|
||||
ResetBoard();
|
||||
Movable = UseFromBackpack;
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
|
||||
{
|
||||
base.GetContextMenuEntries( from, list );
|
||||
|
||||
list.Add( new ViewBoardGameScoresEntry( from, this, 1 ) );
|
||||
|
||||
if( from.AccessLevel >= AccessLevel.GameMaster )
|
||||
{
|
||||
list.Add( new ResetBoardGameScoresEntry( from, this, 2 ) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//this method builds the game board
|
||||
public virtual void BuildBoard()
|
||||
{
|
||||
}
|
||||
|
||||
//this resets the gameboard and refreshes it
|
||||
public virtual void ResetBoard()
|
||||
{
|
||||
WipeBoard();
|
||||
|
||||
BuildBoard();
|
||||
}
|
||||
|
||||
protected virtual void PrimePlayers()
|
||||
{
|
||||
foreach( Mobile player in Players )
|
||||
{
|
||||
|
||||
player.CloseGump( typeof( AwaitRecruitmentGump ) );
|
||||
player.CloseGump( typeof( SelectStyleGump ) );
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void WipeBoard()
|
||||
{
|
||||
foreach( GamePiece piece in BackgroundItems )
|
||||
{
|
||||
piece.BoardGameControlItem = null; //detach reference to this boardgame so that it doesn't wipe the board itself
|
||||
piece.Delete();
|
||||
}
|
||||
|
||||
if( _BoardGameRegion != null )
|
||||
{
|
||||
_BoardGameRegion.Unregister();
|
||||
}
|
||||
|
||||
_BackgroundItems = null;
|
||||
}
|
||||
|
||||
|
||||
//this moves the players into the board, gives them the equipment they need, and starts the game
|
||||
protected virtual void StartGame()
|
||||
{
|
||||
//define and clear the game field, then rebuild it
|
||||
ResetBoard();
|
||||
|
||||
//move players into the board, give them game interface items, or otherwise get them set up
|
||||
PrimePlayers();
|
||||
|
||||
}
|
||||
|
||||
public virtual void EndGame()
|
||||
{
|
||||
if( _WinnerTimer != null )
|
||||
{
|
||||
_WinnerTimer.Stop();
|
||||
_WinnerTimer = null;
|
||||
}
|
||||
|
||||
_PendingPlayers = null;
|
||||
_SettingsReady = !_AllowPlayerConfiguration;
|
||||
InvalidateProperties();
|
||||
|
||||
foreach( Mobile player in Players )
|
||||
{
|
||||
player.CloseGump( typeof( BoardGameGump ) );
|
||||
}
|
||||
}
|
||||
|
||||
protected void StartEndGameTimer( TimeSpan delay )
|
||||
{
|
||||
if( _EndGameTimer != null )
|
||||
{
|
||||
_EndGameTimer.Stop();
|
||||
|
||||
_EndGameTimer = null;
|
||||
}
|
||||
|
||||
_EndGameTimer = new EndGameTimer( this, delay );
|
||||
_EndGameTimer.Start();
|
||||
}
|
||||
|
||||
//this triggers the actual engame detection
|
||||
protected virtual void OnEndGameTimer()
|
||||
{
|
||||
if( _EndGameTimer != null )
|
||||
{
|
||||
_EndGameTimer.Stop();
|
||||
_EndGameTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected virtual void AnnounceWinner()
|
||||
{
|
||||
_State = BoardGameState.GameOver;
|
||||
if( _WinnerTimer == null )
|
||||
{
|
||||
_WinnerTimer = new WinnerTimer( this, WinDelay );
|
||||
_WinnerTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//this method is called by the control item when a player doubleclicks it
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if( CanUse( from ) )
|
||||
{
|
||||
OnUse( from );
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CanUse( Mobile from )
|
||||
{
|
||||
//if they've logged out
|
||||
if( from.NetState == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( UseFromBackpack )
|
||||
{
|
||||
if( !IsChildOf( from.Backpack ) )
|
||||
{
|
||||
from.SendMessage( "This must be in your backpack to use." );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !from.InRange( this, UseRange ) )
|
||||
{
|
||||
from.SendMessage( "You are out of range." );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return CheckRequirements( from );
|
||||
}
|
||||
|
||||
public virtual bool CheckRequirements( Mobile from )
|
||||
{
|
||||
if( !CanUsePets && from.Followers > 0 )
|
||||
{
|
||||
from.SendMessage( "You are not allowed to have pets in this game." );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !CheckCost( from, false ) )
|
||||
{
|
||||
from.SendMessage( "You lack the gold to play this game." );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//this checks for money, and withdraws it if necessary
|
||||
public bool CheckCost( Mobile from, bool withdraw )
|
||||
{
|
||||
if( CostToPlay == 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Gold gold = (Gold)from.Backpack.FindItemByType( typeof( Gold ) );
|
||||
|
||||
if( gold == null || gold.Amount < CostToPlay )
|
||||
{
|
||||
Container bankbox = from.FindBankNoCreate();
|
||||
|
||||
if( bankbox != null )
|
||||
{
|
||||
gold = (Gold)bankbox.FindItemByType( typeof( Gold ) );
|
||||
|
||||
if( gold != null && gold.Amount >= CostToPlay )
|
||||
{
|
||||
if( withdraw )
|
||||
{
|
||||
bankbox.ConsumeTotal( typeof( Gold ), CostToPlay );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if( withdraw )
|
||||
{
|
||||
from.Backpack.ConsumeTotal( typeof( Gold ), CostToPlay );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//updates all game pieces position
|
||||
public virtual void UpdatePosition()
|
||||
{
|
||||
if( _BoardMap == null || _BoardMap == Map.Internal )
|
||||
{
|
||||
_BoardMap = Map;
|
||||
}
|
||||
|
||||
foreach( GamePiece piece in BackgroundItems )
|
||||
{
|
||||
piece.UpdatePosition();
|
||||
}
|
||||
|
||||
if( _BoardGameRegion != null )
|
||||
{
|
||||
_BoardGameRegion.Unregister();
|
||||
}
|
||||
|
||||
_BoardGameRegion = new BoardGameRegion( this );
|
||||
_BoardGameRegion.Register();
|
||||
}
|
||||
|
||||
//mouse-over properties info
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
list.Add( 1070722, "Status: " + Enum.GetName( typeof( BoardGameState ), _State ) ); //~1_NOTHING~
|
||||
list.Add( 1060658, "Cost to play\t{0}", CostToPlay.ToString() ); // ~1_val~: ~2_val~
|
||||
}
|
||||
|
||||
|
||||
|
||||
//this method is called when a successful OnDoubleClick method is performed
|
||||
protected virtual void OnUse( Mobile from )
|
||||
{
|
||||
switch( _State )
|
||||
{
|
||||
case BoardGameState.Disabled:
|
||||
{
|
||||
DisabledGame( from );
|
||||
break;
|
||||
}
|
||||
case BoardGameState.Inactive:
|
||||
{
|
||||
OfferNewGame( from );
|
||||
break;
|
||||
}
|
||||
case BoardGameState.Pending:
|
||||
{
|
||||
GamePending( from );
|
||||
break;
|
||||
}
|
||||
case BoardGameState.Recruiting:
|
||||
{
|
||||
OfferRecruiting( from );
|
||||
break;
|
||||
}
|
||||
case BoardGameState.Active:
|
||||
{
|
||||
GameActive( from );
|
||||
break;
|
||||
}
|
||||
case BoardGameState.GameOver:
|
||||
{
|
||||
GameOver( from );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected virtual void DisabledGame( Mobile from )
|
||||
{
|
||||
if( from.AccessLevel < AccessLevel.GameMaster )
|
||||
{
|
||||
from.SendMessage( "That game has been disabled by staff." );
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OfferNewGame( Mobile from )
|
||||
{
|
||||
PendingPlayers.Add( from );
|
||||
|
||||
State = BoardGameState.Pending;
|
||||
|
||||
from.SendGump( new OfferNewGameGump( from, this, true ) );
|
||||
}
|
||||
|
||||
protected virtual void GamePending( Mobile from )
|
||||
{
|
||||
from.SendMessage( "This game is pending use from another player. Please try again later." );
|
||||
}
|
||||
|
||||
protected virtual void OfferRecruiting( Mobile from )
|
||||
{
|
||||
if( PendingPlayers.IndexOf( from ) == -1 )
|
||||
{
|
||||
if( PendingPlayers.Count < CurrentMaxPlayers )
|
||||
{
|
||||
PendingPlayers.Add( from );
|
||||
from.SendGump( new OfferNewGameGump( from, this, false ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage( "This game has enough players attempting to start a game. Please try again later." );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendGump( new AwaitRecruitmentGump( from, this ) );
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void GameActive( Mobile from )
|
||||
{
|
||||
if( Players.IndexOf( from ) == -1 )
|
||||
{
|
||||
from.SendMessage( "A game is already in progess. Please try again later." );
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void GameOver( Mobile from )
|
||||
{
|
||||
from.SendMessage( "The last game has just ended. Please try again later." );
|
||||
}
|
||||
|
||||
//this is called by the recruitment gump when a player agrees to play the game
|
||||
public virtual void AddPlayer( Mobile from )
|
||||
{
|
||||
Players.Add( from );
|
||||
from.SendGump( new AwaitRecruitmentGump( from, this ) );
|
||||
|
||||
if( Players.Count == CurrentMaxPlayers && SettingsReady )
|
||||
{
|
||||
InitializeGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
State = BoardGameState.Recruiting;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeGame()
|
||||
{
|
||||
//perform final check on all players to make sure they're still good to play
|
||||
|
||||
Mobile toboot = null;
|
||||
foreach( Mobile player in Players )
|
||||
{
|
||||
if( !CanUse( player ) )
|
||||
{
|
||||
player.SendMessage( "You can no longer enter the game, and have been removed from the list." );
|
||||
toboot = player;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( toboot != null )
|
||||
{
|
||||
if( Players.IndexOf( toboot ) == 0 )
|
||||
{
|
||||
_SettingsReady = !_AllowPlayerConfiguration;
|
||||
}
|
||||
RemovePlayer( toboot );
|
||||
return;
|
||||
}
|
||||
|
||||
_PendingPlayers = null;
|
||||
State = BoardGameState.Active;
|
||||
|
||||
foreach( Mobile player in Players )
|
||||
{
|
||||
CheckCost( player, true );
|
||||
player.SendMessage( "Game on!" );
|
||||
}
|
||||
|
||||
//Start the game!
|
||||
StartGame();
|
||||
}
|
||||
|
||||
//this is called by the await recruitment gump when the player chooses to cancel waiting
|
||||
public virtual void RemovePlayer( Mobile from )
|
||||
{
|
||||
from.CloseGump( typeof( AwaitRecruitmentGump ) );
|
||||
from.CloseGump( typeof( SelectStyleGump ) );
|
||||
|
||||
Players.Remove( from );
|
||||
PendingPlayers.Remove( from );
|
||||
|
||||
if( Players.Count == 0 )
|
||||
{
|
||||
State = BoardGameState.Inactive;
|
||||
_SettingsReady = !_AllowPlayerConfiguration;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//these are used to update all movable addon components
|
||||
public override void OnLocationChange( Point3D oldLoc )
|
||||
{
|
||||
if ( Deleted )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
//these are used to update all movable addon components
|
||||
public override void OnMapChange()
|
||||
{
|
||||
if ( Deleted )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if( _WinnerTimer != null )
|
||||
{
|
||||
_WinnerTimer.Stop();
|
||||
_WinnerTimer = null;
|
||||
}
|
||||
if( _EndGameTimer != null )
|
||||
{
|
||||
_EndGameTimer.Stop();
|
||||
_EndGameTimer = null;
|
||||
}
|
||||
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
//this cleans up all movable addon components, and removes the reference to this addon in the key item
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
if( _WinnerTimer != null )
|
||||
{
|
||||
_WinnerTimer.Stop();
|
||||
_WinnerTimer = null;
|
||||
}
|
||||
|
||||
foreach( GamePiece piece in BackgroundItems )
|
||||
{
|
||||
if( piece != null && !piece.Deleted )
|
||||
{
|
||||
piece.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
if( _BoardGameRegion != null )
|
||||
{
|
||||
_BoardGameRegion.Unregister();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( 2 );
|
||||
|
||||
writer.Write( BoardMap );
|
||||
|
||||
writer.Write( _AllowPlayerConfiguration );
|
||||
|
||||
writer.Write( (int)_State );
|
||||
writer.Write( _CostToPlay );
|
||||
|
||||
writer.Write( CurrentMaxPlayers );
|
||||
|
||||
writer.Write( _BoardWidth );
|
||||
writer.Write( _BoardHeight );
|
||||
|
||||
writer.Write( GameZone.Start.X );
|
||||
writer.Write( GameZone.Start.Y );
|
||||
writer.Write( GameZone.Start.Z );
|
||||
writer.Write( GameZone.End.X );
|
||||
writer.Write( GameZone.End.Y );
|
||||
writer.Write( GameZone.End.Z );
|
||||
|
||||
writer.Write( _BoardOffset.X );
|
||||
writer.Write( _BoardOffset.Y );
|
||||
writer.Write( _BoardOffset.Z );
|
||||
|
||||
|
||||
|
||||
writer.Write( Players.Count );
|
||||
foreach( Mobile mobile in Players )
|
||||
{
|
||||
writer.Write( mobile );
|
||||
}
|
||||
|
||||
writer.Write( BackgroundItems.Count );
|
||||
foreach( GamePiece piece in BackgroundItems )
|
||||
{
|
||||
writer.Write( (Item)piece );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if( version >= 2 )
|
||||
{
|
||||
_BoardMap = reader.ReadMap();
|
||||
}
|
||||
else
|
||||
{
|
||||
_BoardMap = Map;
|
||||
}
|
||||
|
||||
if( version >= 1 )
|
||||
{
|
||||
_AllowPlayerConfiguration = reader.ReadBool();
|
||||
}
|
||||
else
|
||||
{
|
||||
_AllowPlayerConfiguration = true;
|
||||
}
|
||||
|
||||
State = (BoardGameState)reader.ReadInt();
|
||||
_CostToPlay = reader.ReadInt();
|
||||
|
||||
CurrentMaxPlayers = reader.ReadInt();
|
||||
|
||||
_BoardWidth = reader.ReadInt();
|
||||
_BoardHeight = reader.ReadInt();
|
||||
|
||||
GameZone = new Rectangle3D( new Point3D( reader.ReadInt(), reader.ReadInt(), reader.ReadInt() ), new Point3D( reader.ReadInt(), reader.ReadInt(), reader.ReadInt() ) );
|
||||
|
||||
|
||||
_BoardOffset = new Point3D( reader.ReadInt(), reader.ReadInt(), reader.ReadInt() );
|
||||
|
||||
int count = reader.ReadInt();
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
Players.Add( reader.ReadMobile() );
|
||||
}
|
||||
|
||||
count = reader.ReadInt();
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
BackgroundItems.Add( (GamePiece)reader.ReadItem() );
|
||||
}
|
||||
|
||||
if( _State == BoardGameState.Pending || _State == BoardGameState.Recruiting )
|
||||
{
|
||||
_State = BoardGameState.Inactive;
|
||||
_Players = null;
|
||||
}
|
||||
|
||||
_BoardGameRegion = new BoardGameRegion( this );
|
||||
_BoardGameRegion.Register();
|
||||
|
||||
_SettingsReady = !_AllowPlayerConfiguration;
|
||||
}
|
||||
|
||||
protected class EndGameTimer : Timer
|
||||
{
|
||||
private BoardGameControlItem _ControlItem;
|
||||
|
||||
public EndGameTimer( BoardGameControlItem controlitem, TimeSpan delay ) : base( delay, TimeSpan.FromSeconds( 1.0 ) )
|
||||
{
|
||||
_ControlItem = controlitem;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
_ControlItem.OnEndGameTimer();
|
||||
}
|
||||
}
|
||||
|
||||
//this timer delays the game a bit, so the winner can stand proud over the game
|
||||
protected class WinnerTimer : Timer
|
||||
{
|
||||
private BoardGameControlItem _ControlItem;
|
||||
|
||||
public WinnerTimer( BoardGameControlItem controlitem, TimeSpan delay ) : base( delay, TimeSpan.FromSeconds( 1.0 ) )
|
||||
{
|
||||
_ControlItem = controlitem;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
_ControlItem.EndGame();
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
333
Scripts/Scripts-master/Games/Bomberman/Base/BoardGameData.cs
Normal file
333
Scripts/Scripts-master/Games/Bomberman/Base/BoardGameData.cs
Normal file
@@ -0,0 +1,333 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
|
||||
namespace Solaris.BoardGames
|
||||
{
|
||||
//this data class is used to keep track of player scores for various boardgames
|
||||
public class BoardGameData
|
||||
{
|
||||
public const string SAVE_PATH = @"Saves\BoardGame Data";
|
||||
public const string FILENAME = "boardgames.bin";
|
||||
|
||||
protected static List<BoardGameData> _GameData;
|
||||
|
||||
public static List<BoardGameData> GameData
|
||||
{
|
||||
get
|
||||
{
|
||||
if( _GameData == null )
|
||||
{
|
||||
_GameData = new List<BoardGameData>();
|
||||
}
|
||||
return _GameData;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected string _GameName;
|
||||
protected List<BoardGamePlayerScore> _Scores;
|
||||
|
||||
public string GameName{ get{ return _GameName; } }
|
||||
|
||||
public List<BoardGamePlayerScore> Scores
|
||||
{
|
||||
get
|
||||
{
|
||||
if( _Scores == null )
|
||||
{
|
||||
_Scores = new List<BoardGamePlayerScore>();
|
||||
}
|
||||
return _Scores;
|
||||
}
|
||||
}
|
||||
|
||||
protected BoardGameData( string gamename )
|
||||
{
|
||||
_GameName = gamename;
|
||||
}
|
||||
|
||||
protected BoardGameData( GenericReader reader )
|
||||
{
|
||||
Deserialize( reader );
|
||||
}
|
||||
|
||||
protected virtual void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.Write( 0 );
|
||||
|
||||
writer.Write( _GameName );
|
||||
|
||||
writer.Write( Scores.Count );
|
||||
|
||||
foreach( BoardGamePlayerScore score in Scores )
|
||||
{
|
||||
score.Serialize( writer );
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Deserialize( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
_GameName = reader.ReadString();
|
||||
|
||||
int count = reader.ReadInt();
|
||||
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
BoardGamePlayerScore playerscore = new BoardGamePlayerScore( reader );
|
||||
|
||||
if( playerscore.Player != null && !playerscore.Player.Deleted )
|
||||
{
|
||||
Scores.Add( playerscore );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static BoardGamePlayerScore GetScoreData( string gamename, Mobile player )
|
||||
{
|
||||
List<BoardGamePlayerScore> scores = GetScores( gamename );
|
||||
|
||||
if( scores == null )
|
||||
{
|
||||
BoardGameData gamedata = new BoardGameData( gamename );
|
||||
GameData.Add( gamedata );
|
||||
scores = gamedata.Scores;
|
||||
}
|
||||
|
||||
int index = BoardGamePlayerScore.IndexOf( scores, player );
|
||||
|
||||
if( index == -1 )
|
||||
{
|
||||
BoardGamePlayerScore newscore = new BoardGamePlayerScore( player );
|
||||
scores.Add( newscore );
|
||||
return newscore;
|
||||
}
|
||||
else
|
||||
{
|
||||
return scores[ index ];
|
||||
}
|
||||
}
|
||||
|
||||
public static List<BoardGamePlayerScore> GetScores( string gamename )
|
||||
{
|
||||
int gameindex = IndexOf( gamename );
|
||||
|
||||
if( gameindex == -1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GameData[ gameindex ].Scores;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetScore( string gamename, Mobile player, int score )
|
||||
{
|
||||
BoardGamePlayerScore scoredata = GetScoreData( gamename, player );
|
||||
|
||||
if( scoredata != null )
|
||||
{
|
||||
scoredata.Score = score;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetScore( string gamename, Mobile player )
|
||||
{
|
||||
BoardGamePlayerScore scoredata = GetScoreData( gamename, player );
|
||||
|
||||
if( scoredata != null )
|
||||
{
|
||||
return scoredata.Score;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ChangeScore( string gamename, Mobile player, int delta )
|
||||
{
|
||||
SetScore( gamename, player, Math.Max( 0, GetScore( gamename, player ) + delta ) );
|
||||
}
|
||||
|
||||
public static void AddWin( string gamename, Mobile player )
|
||||
{
|
||||
BoardGamePlayerScore playerscore = GetScoreData( gamename, player );
|
||||
|
||||
playerscore.Wins += 1;
|
||||
}
|
||||
|
||||
public static void AddLose( string gamename, Mobile player )
|
||||
{
|
||||
BoardGamePlayerScore playerscore = GetScoreData( gamename, player );
|
||||
|
||||
playerscore.Losses += 1;
|
||||
|
||||
}
|
||||
|
||||
public static void ResetScores( string gamename )
|
||||
{
|
||||
int gameindex = IndexOf( gamename );
|
||||
|
||||
if( gameindex > -1 )
|
||||
{
|
||||
GameData.RemoveAt( gameindex );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int IndexOf( string gamename )
|
||||
{
|
||||
for( int i = 0; i < GameData.Count; i++ )
|
||||
{
|
||||
if( GameData[i].GameName == gamename )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
EventSink.WorldLoad += new WorldLoadEventHandler( OnLoad );
|
||||
EventSink.WorldSave += new WorldSaveEventHandler( OnSave );
|
||||
}
|
||||
|
||||
public static void OnSave( WorldSaveEventArgs e )
|
||||
{
|
||||
if( !Directory.Exists( SAVE_PATH ) )
|
||||
{
|
||||
Directory.CreateDirectory( SAVE_PATH );
|
||||
}
|
||||
|
||||
GenericWriter writer = new BinaryFileWriter( Path.Combine( SAVE_PATH, FILENAME ), true );
|
||||
|
||||
writer.Write( 0 );
|
||||
|
||||
writer.Write( GameData.Count );
|
||||
|
||||
foreach( BoardGameData data in GameData )
|
||||
{
|
||||
data.Serialize( writer );
|
||||
}
|
||||
|
||||
writer.Close();
|
||||
|
||||
}
|
||||
|
||||
public static void OnLoad()
|
||||
{
|
||||
//don't load the file if it don't exist!
|
||||
if( !File.Exists( Path.Combine( SAVE_PATH, FILENAME ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using( FileStream bin = new FileStream( Path.Combine( SAVE_PATH, FILENAME ), FileMode.Open, FileAccess.Read, FileShare.Read ) )
|
||||
{
|
||||
GenericReader reader = new BinaryFileReader( new BinaryReader( bin ) );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
int count = reader.ReadInt();
|
||||
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
GameData.Add( new BoardGameData( reader ) );
|
||||
}
|
||||
|
||||
reader.End();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class BoardGamePlayerScore : IComparable
|
||||
{
|
||||
protected Mobile _Player;
|
||||
|
||||
|
||||
public Mobile Player{ get{ return _Player; } }
|
||||
|
||||
public int Score;
|
||||
public int Wins;
|
||||
public int Losses;
|
||||
|
||||
public BoardGamePlayerScore( Mobile player ) : this( player, 0 )
|
||||
{
|
||||
}
|
||||
|
||||
public BoardGamePlayerScore( Mobile player, int score )
|
||||
{
|
||||
_Player = player;
|
||||
Score = score;
|
||||
}
|
||||
|
||||
//deserialize constructor
|
||||
public BoardGamePlayerScore( GenericReader reader )
|
||||
{
|
||||
Deserialize( reader );
|
||||
}
|
||||
|
||||
public int CompareTo( object obj )
|
||||
{
|
||||
if( !( obj is BoardGamePlayerScore ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BoardGamePlayerScore comparescore = (BoardGamePlayerScore)obj;
|
||||
|
||||
return -Score.CompareTo( comparescore.Score );
|
||||
}
|
||||
|
||||
public virtual void Serialize( GenericWriter writer )
|
||||
{
|
||||
writer.Write( 0 );
|
||||
|
||||
writer.Write( _Player );
|
||||
writer.Write( Score );
|
||||
writer.Write( Wins );
|
||||
writer.Write( Losses );
|
||||
|
||||
}
|
||||
|
||||
public virtual void Deserialize( GenericReader reader )
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
_Player = reader.ReadMobile();
|
||||
Score = reader.ReadInt();
|
||||
Wins = reader.ReadInt();
|
||||
Losses = reader.ReadInt();
|
||||
}
|
||||
|
||||
public static int IndexOf( List<BoardGamePlayerScore> scores, Mobile player )
|
||||
{
|
||||
if( scores == null )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for( int i = 0; i < scores.Count; i++ )
|
||||
{
|
||||
if( scores[i].Player == player )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Accounting;
|
||||
|
||||
namespace Solaris.BoardGames
|
||||
{
|
||||
//this class defines all data access for tracking player scores within boardgames
|
||||
public class BoardGamePlayer
|
||||
{
|
||||
|
||||
//current plan is to use account tags.
|
||||
//TODO: explore XML tags and such to better integrate with XML quest systems?
|
||||
|
||||
//this sets the players score for a particular game type
|
||||
public static bool SetScore( Mobile mobile, string gametype, int score )
|
||||
{
|
||||
if( mobile.Account == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Account acct = (Account)mobile.Account;
|
||||
|
||||
acct.SetTag( "BoardGames-" + gametype, score.ToString() );
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int GetScore( Mobile mobile, string gametype )
|
||||
{
|
||||
try
|
||||
{
|
||||
Account acct = (Account)mobile.Account;
|
||||
|
||||
return Convert.ToInt32( acct.GetTag( "BoardGames-" + gametype ) );
|
||||
}
|
||||
catch
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
108
Scripts/Scripts-master/Games/Bomberman/Base/BoardGameRegion.cs
Normal file
108
Scripts/Scripts-master/Games/Bomberman/Base/BoardGameRegion.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using Server;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Server.Items;
|
||||
using Server.Spells;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
|
||||
namespace Solaris.BoardGames
|
||||
{
|
||||
//a boardgame region is a custom region that handles rules for players within the region (no casting, no pets, etc)
|
||||
public class BoardGameRegion : GuardedRegion
|
||||
{
|
||||
protected static int _RegionIndex = 0;
|
||||
protected BoardGameControlItem _BoardGameControlItem;
|
||||
|
||||
public static string GetUniqueName( BoardGameControlItem controlitem )
|
||||
{
|
||||
return controlitem.GameName + " " + ( _RegionIndex++ ).ToString();
|
||||
}
|
||||
|
||||
public BoardGameControlItem BoardGameControlItem
|
||||
{
|
||||
get{ return _BoardGameControlItem; }
|
||||
}
|
||||
|
||||
public BoardGameRegion( BoardGameControlItem controlitem ): base( GetUniqueName( controlitem ), controlitem.Map, 255, controlitem.GameZone )
|
||||
{
|
||||
Disabled = true;
|
||||
_BoardGameControlItem = controlitem;
|
||||
}
|
||||
|
||||
public override bool AllowHousing(Mobile from, Point3D p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool AllowSpawn()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CanUseStuckMenu( Mobile m )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnDamage( Mobile m, ref int Damage )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnBeginSpellCast( Mobile from, ISpell s )
|
||||
{
|
||||
if( from.AccessLevel > AccessLevel.Player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return _BoardGameControlItem.CanCastSpells;
|
||||
|
||||
}
|
||||
|
||||
public override void OnEnter( Mobile m )
|
||||
{
|
||||
m.SendMessage( "Entering boardgame" );
|
||||
if( _BoardGameControlItem.Players.IndexOf( m ) == -1 && m.AccessLevel == AccessLevel.Player )
|
||||
{
|
||||
m.SendMessage( "You are not allowed in there." );
|
||||
m.MoveToWorld( _BoardGameControlItem.Location, _BoardGameControlItem.Map );
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnExit( Mobile m )
|
||||
{
|
||||
m.SendMessage( "Exiting boardgame" );
|
||||
}
|
||||
|
||||
public override bool OnSkillUse( Mobile m, int skill )
|
||||
{
|
||||
return _BoardGameControlItem.CanUseSkills;
|
||||
}
|
||||
|
||||
public override bool OnMoveInto( Mobile m, Direction d, Point3D newLocation, Point3D oldLocation )
|
||||
{
|
||||
if( m is BaseCreature && !_BoardGameControlItem.CanUsePets )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( _BoardGameControlItem.Players.IndexOf( m ) == -1 )
|
||||
{
|
||||
if( !( m is PlayerMobile ) || m.AccessLevel > AccessLevel.Player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool OnDoubleClick( Mobile m, object o )
|
||||
{
|
||||
//TODO: put shrunken pet control here
|
||||
return base.OnDoubleClick( m, o );
|
||||
}
|
||||
}
|
||||
}
|
||||
56
Scripts/Scripts-master/Games/Bomberman/Base/ContextMenus.cs
Normal file
56
Scripts/Scripts-master/Games/Bomberman/Base/ContextMenus.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.ContextMenus;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
|
||||
namespace Solaris.BoardGames
|
||||
{
|
||||
|
||||
public class ViewBoardGameScoresEntry : ContextMenuEntry
|
||||
{
|
||||
Mobile _From;
|
||||
BoardGameControlItem _ControlItem;
|
||||
|
||||
//3006239 = "View events"
|
||||
public ViewBoardGameScoresEntry( Mobile from, BoardGameControlItem controlitem, int index ) : base( 6239, index )
|
||||
{
|
||||
_From = from;
|
||||
_ControlItem = controlitem;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
if ( _ControlItem == null || _ControlItem.Deleted )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_From.SendGump( new BoardGameScoresGump( _From, _ControlItem ) );
|
||||
}
|
||||
}
|
||||
|
||||
public class ResetBoardGameScoresEntry : ContextMenuEntry
|
||||
{
|
||||
Mobile _From;
|
||||
BoardGameControlItem _ControlItem;
|
||||
|
||||
//3006162 = "Reset Game"
|
||||
public ResetBoardGameScoresEntry( Mobile from, BoardGameControlItem controlitem, int index ) : base( 6162, index )
|
||||
{
|
||||
_From = from;
|
||||
_ControlItem = controlitem;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
if ( _ControlItem == null || _ControlItem.Deleted )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_From.SendGump( new ConfirmResetGameScoreGump( _From, _ControlItem ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
158
Scripts/Scripts-master/Games/Bomberman/Base/GamePiece.cs
Normal file
158
Scripts/Scripts-master/Games/Bomberman/Base/GamePiece.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
|
||||
namespace Solaris.BoardGames
|
||||
{
|
||||
//a gamepiece behaves much like an addon component
|
||||
public class GamePiece : Item
|
||||
{
|
||||
//offset from the boardgame control item
|
||||
public Point3D Offset;
|
||||
|
||||
//reference to the LOSBlocker used to block line of sight thru this gamepiece
|
||||
public LOSBlocker _Blocker;
|
||||
|
||||
//reference to the boardgame control item that this piece belongs to
|
||||
public BoardGameControlItem BoardGameControlItem;
|
||||
|
||||
//randomize itemid constructor
|
||||
public GamePiece( int itemidmin, int itemidmax, string name ) : this( Utility.RandomMinMax( itemidmin, itemidmax ), name )
|
||||
{
|
||||
}
|
||||
|
||||
//randomize itemid constructor
|
||||
public GamePiece( int itemidmin, int itemidmax, string name, bool blocklos ) : this( Utility.RandomMinMax( itemidmin, itemidmax ), name, blocklos )
|
||||
{
|
||||
}
|
||||
|
||||
//default no block los constructor
|
||||
public GamePiece( int itemid, string name ) : this( itemid, name, false )
|
||||
{
|
||||
}
|
||||
|
||||
//master constructor
|
||||
public GamePiece( int itemid, string name, bool blocklos ) : base( itemid )
|
||||
{
|
||||
Movable = false;
|
||||
Name = name;
|
||||
|
||||
if( blocklos )
|
||||
{
|
||||
_Blocker = new LOSBlocker();
|
||||
}
|
||||
}
|
||||
|
||||
//deserialize constructor
|
||||
public GamePiece( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public void RegisterToBoardGameControlItem( BoardGameControlItem boardgamecontrolitem, Point3D offset )
|
||||
{
|
||||
BoardGameControlItem = boardgamecontrolitem;
|
||||
Offset = offset;
|
||||
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
|
||||
//move the item based on its position with respect to the boardgame control item
|
||||
public void UpdatePosition()
|
||||
{
|
||||
if( BoardGameControlItem != null )
|
||||
{
|
||||
MoveToWorld( new Point3D( BoardGameControlItem.X + BoardGameControlItem.BoardOffset.X + Offset.X, BoardGameControlItem.Y + BoardGameControlItem.BoardOffset.Y + Offset.Y, BoardGameControlItem.Z + BoardGameControlItem.BoardOffset.Z + Offset.Z ), BoardGameControlItem.BoardMap );
|
||||
}
|
||||
else
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLocationChange( Point3D old )
|
||||
{
|
||||
if( BoardGameControlItem != null )
|
||||
{
|
||||
BoardGameControlItem.Location = new Point3D( X - BoardGameControlItem.BoardOffset.X - Offset.X, Y - BoardGameControlItem.BoardOffset.Y - Offset.Y, Z - BoardGameControlItem.BoardOffset.Z - Offset.Z );
|
||||
}
|
||||
|
||||
if( _Blocker != null )
|
||||
{
|
||||
_Blocker.MoveToWorld( Location, Map );
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnMapChange()
|
||||
{
|
||||
if( BoardGameControlItem != null && BoardGameControlItem.BoardMap != Map )
|
||||
{
|
||||
BoardGameControlItem.BoardMap = Map;
|
||||
}
|
||||
|
||||
if( _Blocker != null )
|
||||
{
|
||||
_Blocker.MoveToWorld( Location, Map );
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
if( BoardGameControlItem != null )
|
||||
{
|
||||
BoardGameControlItem.Delete();
|
||||
}
|
||||
|
||||
if( _Blocker != null )
|
||||
{
|
||||
_Blocker.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( 1 );
|
||||
|
||||
writer.Write( (Item)_Blocker );
|
||||
|
||||
writer.Write( (Item)BoardGameControlItem );
|
||||
|
||||
writer.Write( Offset.X );
|
||||
writer.Write( Offset.Y );
|
||||
writer.Write( Offset.Z );
|
||||
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch( version )
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
{
|
||||
_Blocker = (LOSBlocker)reader.ReadItem();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
|
||||
|
||||
BoardGameControlItem = (BoardGameControlItem)reader.ReadItem();
|
||||
|
||||
Offset.X = reader.ReadInt();
|
||||
Offset.Y = reader.ReadInt();
|
||||
Offset.Z = reader.ReadInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Solaris.BoardGames;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
//offers a new game to a player
|
||||
public class AwaitRecruitmentGump : BoardGameGump
|
||||
{
|
||||
|
||||
public override int Height{ get{ return 200; } }
|
||||
public override int Width{ get{ return 400; } }
|
||||
|
||||
public AwaitRecruitmentGump( Mobile owner, BoardGameControlItem controlitem ) : base( owner, controlitem )
|
||||
{
|
||||
//force it so players can't close this gump
|
||||
Closable = false;
|
||||
|
||||
AddLabel( 40, 20, 1152, "Game:" );
|
||||
|
||||
AddLabel( 140, 20, 1172, _ControlItem.GameName );
|
||||
|
||||
AddHtml( 40, 50, Width - 80, 80, "You are waiting for more players to join this game. When there are enough, this window will automatically close and the game will start. If you wish to cancel waiting, click the Cancel button.", true, false );
|
||||
|
||||
AddButton( 160, 160, 0xF1, 0xF2, 1, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
protected override void DeterminePageLayout()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
int buttonid = info.ButtonID;
|
||||
|
||||
//cancel button
|
||||
if( buttonid == 1 )
|
||||
{
|
||||
_Owner.CloseGump( typeof( SelectStyleGump ) );
|
||||
_ControlItem.RemovePlayer( _Owner );
|
||||
|
||||
_Owner.SendMessage( "You are no longer waiting to play this game." );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Solaris.BoardGames;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
//main gump class for boardgames
|
||||
public class BoardGameGump : Gump
|
||||
{
|
||||
public virtual int Height{ get{ return 100; } }
|
||||
public virtual int Width{ get{ return 100; } }
|
||||
|
||||
//reference to the control system for the boardgame
|
||||
protected BoardGameControlItem _ControlItem;
|
||||
protected Mobile _Owner;
|
||||
|
||||
public BoardGameGump( Mobile owner, BoardGameControlItem controlitem ) : base( 50, 50 )
|
||||
{
|
||||
_Owner = owner;
|
||||
_ControlItem = controlitem;
|
||||
|
||||
_Owner.CloseGump( typeof( BoardGameGump ) );
|
||||
|
||||
|
||||
DrawBackground();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected virtual void DrawBackground()
|
||||
{
|
||||
AddPage(0);
|
||||
|
||||
//determine page layout, sizes, and what gets displayed where
|
||||
DeterminePageLayout();
|
||||
|
||||
|
||||
AddBackground( 0, 0, Width, Height, 9270 );
|
||||
AddImageTiled( 11, 10, Width - 22, Height - 20, 2624 );
|
||||
|
||||
AddAlphaRegion( 11, 10, Width - 22, Height - 20 );
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected virtual void DeterminePageLayout()
|
||||
{
|
||||
}
|
||||
|
||||
public void AddTextField( int x, int y, int width, int height, int index, string text )
|
||||
{
|
||||
AddImageTiled( x - 2, y - 2, width + 4, height + 4, 0xA2C );
|
||||
AddAlphaRegion( x -2, y - 2, width + 4, height + 4 );
|
||||
AddTextEntry( x + 2, y + 2, width - 4, height - 4, 1153, index, text );
|
||||
}
|
||||
|
||||
public string GetTextField( RelayInfo info, int index )
|
||||
{
|
||||
TextRelay relay = info.GetTextEntry( index );
|
||||
return ( relay == null ? null : relay.Text.Trim() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Solaris.BoardGames;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class BoardGameLostGump : BoardGameGump
|
||||
{
|
||||
public override int Height{ get{ return 140; } }
|
||||
public override int Width{ get{ return 300; } }
|
||||
|
||||
public BoardGameLostGump( Mobile owner, BoardGameControlItem controlitem ) : base( owner, controlitem )
|
||||
{
|
||||
AddLabel( 40, 20, 1152, "Game:" );
|
||||
|
||||
AddLabel( 140, 20, 1172, _ControlItem.GameName );
|
||||
|
||||
AddLabel( 40, 50, 1152, "You've lost the game!" );
|
||||
|
||||
//TODO: add info about points earned?
|
||||
|
||||
AddButton( 100, 80, 0xF7, 0xF8, 0, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Solaris.BoardGames;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class BoardGameScoresGump : BoardGameGump
|
||||
{
|
||||
public const int ENTRIES_PER_PAGE = 10;
|
||||
|
||||
public override int Height{ get{ return 440; } }
|
||||
public override int Width{ get{ return 350; } }
|
||||
|
||||
protected List<BoardGamePlayerScore> _PlayerScores;
|
||||
|
||||
protected int _X;
|
||||
protected int _Y;
|
||||
|
||||
//maximum entry listing height, for multi-page calculation
|
||||
public int MaxEntryDisplayHeight{ get{ return 300; } }
|
||||
|
||||
//line spacing between entries
|
||||
public int EntryLineSpacing{ get{ return 20; } }
|
||||
|
||||
protected int _Page;
|
||||
|
||||
//this is determined based on the number of entries and the maximum number to display per page
|
||||
protected int _MaxPages;
|
||||
|
||||
public BoardGameScoresGump( Mobile owner, BoardGameControlItem controlitem ) : this( owner, controlitem, 0 )
|
||||
{
|
||||
}
|
||||
|
||||
public BoardGameScoresGump( Mobile owner, BoardGameControlItem controlitem, int page ) : base( owner, controlitem )
|
||||
{
|
||||
_Page = page;
|
||||
|
||||
AddLabel( 40, 20, 1152, "Game:" );
|
||||
|
||||
AddLabel( 140, 20, 1172, _ControlItem.GameName );
|
||||
|
||||
AddLabel( 40, 50, 1152, "Scores" );
|
||||
|
||||
_PlayerScores = BoardGameData.GetScores( controlitem.GameName );
|
||||
|
||||
if( _PlayerScores == null || _PlayerScores.Count == 0 )
|
||||
{
|
||||
AddLabel( 40, 80, 1152, "- NO SCORES SET YET -" );
|
||||
return;
|
||||
}
|
||||
|
||||
_PlayerScores.Sort();
|
||||
|
||||
_X = 20;
|
||||
_Y = 80;
|
||||
|
||||
_MaxPages = _PlayerScores.Count / ENTRIES_PER_PAGE + 1;
|
||||
|
||||
if( _PlayerScores.Count % ENTRIES_PER_PAGE == 0 )
|
||||
{
|
||||
_MaxPages -= 1;
|
||||
}
|
||||
|
||||
_Page = Math.Max( 0, Math.Min( _Page, _MaxPages ) );
|
||||
|
||||
int listingstart = _Page * ENTRIES_PER_PAGE;
|
||||
int listingend = Math.Min( _PlayerScores.Count, (_Page + 1 ) * ENTRIES_PER_PAGE );
|
||||
|
||||
AddLabel( _X, _Y, 1152, "Name" );
|
||||
AddLabel( _X + 150, _Y, 1152, "Score" );
|
||||
AddLabel( _X+ 200, _Y, 1152, "Wins" );
|
||||
AddLabel( _X + 250, _Y, 1152, "Losses" );
|
||||
|
||||
for( int i = listingstart; i < listingend; i++ )
|
||||
{
|
||||
AddLabel( _X, _Y += 20, 1152, _PlayerScores[i].Player.Name );
|
||||
AddLabel( _X + 150, _Y, 1152, _PlayerScores[i].Score.ToString() );
|
||||
AddLabel( _X + 200, _Y, 1152, _PlayerScores[i].Wins.ToString() );
|
||||
AddLabel( _X + 250, _Y, 1152, _PlayerScores[i].Losses.ToString() );
|
||||
}
|
||||
|
||||
AddPageButtons();
|
||||
|
||||
AddButton( 60, Height - 40, 0xF7, 0xF8, 0, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
protected void AddPageButtons()
|
||||
{
|
||||
//page buttons
|
||||
_Y = Height - 90;
|
||||
|
||||
if ( _Page > 0 )
|
||||
{
|
||||
AddButton( 20, _Y, 0x15E3, 0x15E7, 4, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage( 20, _Y, 0x25EA );
|
||||
}
|
||||
AddLabel( 40, _Y, 88, "Previous Page" );
|
||||
|
||||
|
||||
if ( _Page < _MaxPages - 1 )
|
||||
{
|
||||
AddButton( Width - 40, _Y, 0x15E1, 0x15E5, 5, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage( Width - 40, _Y, 0x25E6 );
|
||||
}
|
||||
AddLabel( Width - 120, _Y, 88, "Next Page" );
|
||||
|
||||
AddLabel( Width / 2 - 10, _Y, 88, String.Format( "({0}/{1})", _Page + 1, _MaxPages ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
int buttonid = info.ButtonID;
|
||||
|
||||
if( buttonid == 4 )
|
||||
{
|
||||
_Owner.SendGump( new BoardGameScoresGump( _Owner, _ControlItem, _Page - 1 ) );
|
||||
}
|
||||
else if( buttonid == 5 )
|
||||
{
|
||||
_Owner.SendGump( new BoardGameScoresGump( _Owner, _ControlItem, _Page + 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Solaris.BoardGames;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class BoardGameWonGump : BoardGameGump
|
||||
{
|
||||
public override int Height{ get{ return 140; } }
|
||||
public override int Width{ get{ return 300; } }
|
||||
|
||||
public BoardGameWonGump( Mobile owner, BoardGameControlItem controlitem ) : base( owner, controlitem )
|
||||
{
|
||||
AddLabel( 40, 20, 1152, "Game:" );
|
||||
|
||||
AddLabel( 140, 20, 1172, _ControlItem.GameName );
|
||||
|
||||
AddLabel( 40, 50, 1152, "Congratulations, you won the game!!" );
|
||||
|
||||
//TODO: add info about points earned?
|
||||
|
||||
AddButton( 100, 80, 0xF7, 0xF8, 0, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
_ControlItem.EndGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Solaris.BoardGames;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class ConfirmResetGameScoreGump : BoardGameGump
|
||||
{
|
||||
public override int Height{ get{ return 200; } }
|
||||
public override int Width{ get{ return 400; } }
|
||||
|
||||
protected int _Y = 30;
|
||||
protected int _X = 20;
|
||||
|
||||
public ConfirmResetGameScoreGump( Mobile owner, BoardGameControlItem controlitem ) : base( owner, controlitem )
|
||||
{
|
||||
AddLabel( 40, 20, 1152, "Game:" );
|
||||
|
||||
AddLabel( 140, 20, 1172, _ControlItem.GameName );
|
||||
|
||||
AddHtml( 40, 50, Width - 80, 80, "You are about to reset all the score data for " + _ControlItem.GameName + ". Once you do this, it cannot be undone. Are you sure you wish to do this?", true, false );
|
||||
|
||||
AddButton( 30, 160, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0 );
|
||||
|
||||
AddButton( 160, 160, 0xF1, 0xF2, 0, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState state, RelayInfo info )
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
|
||||
if( info.ButtonID == 1 )
|
||||
{
|
||||
BoardGameData.ResetScores( _ControlItem.GameName );
|
||||
|
||||
_Owner.SendMessage( "You have now reset all the scores." );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Solaris.BoardGames;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
//offers a new game to a player
|
||||
public class OfferNewGameGump : BoardGameGump
|
||||
{
|
||||
protected bool _ControlNumberOfPlayers;
|
||||
|
||||
public override int Height{ get{ return 500; } }
|
||||
public override int Width{ get{ return 400; } }
|
||||
|
||||
public OfferNewGameGump( Mobile owner, BoardGameControlItem controlitem, bool controlnumberofplayers ) : base( owner, controlitem )
|
||||
{
|
||||
_ControlNumberOfPlayers = controlnumberofplayers;
|
||||
|
||||
AddLabel( 40, 20, 1152, "Game:" );
|
||||
|
||||
AddLabel( 140, 20, 1172, _ControlItem.GameName );
|
||||
|
||||
AddLabel( 40, 50, 1152, "Description:" );
|
||||
|
||||
AddHtml( 40, 70, 300, 100, _ControlItem.GameDescription, true, true );
|
||||
|
||||
AddLabel( 40, 180, 1152, "Rules:" );
|
||||
|
||||
AddHtml( 40, 200, 300, 150, _ControlItem.GameRules, true, true );
|
||||
|
||||
if( _ControlItem.CostToPlay > 0 )
|
||||
{
|
||||
AddLabel( 40, 370, 1152, "Cost to play:" );
|
||||
AddLabel( 240, 370, 1172, _ControlItem.CostToPlay.ToString() + " gold" );
|
||||
}
|
||||
|
||||
if( _ControlItem.MaxPlayers != _ControlItem.MinPlayers )
|
||||
{
|
||||
AddLabel( 40, 430, 1152, "# of players (" + _ControlItem.MinPlayers.ToString() + "-" + _ControlItem.MaxPlayers.ToString() + "):" );
|
||||
|
||||
if( _ControlNumberOfPlayers )
|
||||
{
|
||||
AddLabel( 60, 410, 1172, "Pick the number of players" );
|
||||
AddTextField( 240, 430, 30, 20, 0, _ControlItem.CurrentMaxPlayers.ToString() );
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLabel( 240, 430, 1152, _ControlItem.CurrentMaxPlayers.ToString() );
|
||||
}
|
||||
}
|
||||
|
||||
AddLabel( 40, 470, 1152, "Play this game?" );
|
||||
|
||||
AddButton( 200, 460, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 300, 460, 0xF1, 0xF2, 0, GumpButtonType.Reply, 0 );
|
||||
|
||||
}
|
||||
|
||||
protected override void DeterminePageLayout()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
int buttonid = info.ButtonID;
|
||||
|
||||
//cancel or right click
|
||||
if( buttonid == 0 )
|
||||
{
|
||||
_ControlItem.RemovePlayer( _Owner );
|
||||
|
||||
_Owner.SendMessage( "You decide not to play this game" );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if( _ControlItem.MaxPlayers != _ControlItem.MinPlayers && _ControlNumberOfPlayers )
|
||||
{
|
||||
try
|
||||
{
|
||||
_ControlItem.CurrentMaxPlayers = Int32.Parse( GetTextField( info, 0 ) );
|
||||
|
||||
if( _ControlItem.CurrentMaxPlayers > _ControlItem.MaxPlayers || _ControlItem.CurrentMaxPlayers < _ControlItem.MinPlayers )
|
||||
{
|
||||
throw( new Exception() );
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_Owner.SendMessage( "Invalid number of players selected. Please try again." );
|
||||
_Owner.SendGump( new OfferNewGameGump( _Owner, _ControlItem, _ControlNumberOfPlayers ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
_Owner.SendMessage( "You have signed up for this game." );
|
||||
|
||||
_ControlItem.AddPlayer( _Owner );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Solaris.BoardGames;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SelectStyleGump : Gump
|
||||
{
|
||||
public virtual int Height{ get{ return 150; } }
|
||||
public virtual int Width{ get{ return 200; } }
|
||||
|
||||
protected int _Y = 30;
|
||||
protected int _X = 20;
|
||||
|
||||
protected BoardGameControlItem _ControlItem;
|
||||
|
||||
public SelectStyleGump( Mobile owner, BoardGameControlItem controlitem ) : base( 450, 80 )
|
||||
{
|
||||
Closable = false;
|
||||
|
||||
owner.CloseGump( typeof( SelectStyleGump ) );
|
||||
|
||||
_ControlItem = controlitem;
|
||||
|
||||
if( _ControlItem.Players.IndexOf( owner ) == -1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddPage( 0 );
|
||||
AddBackground( 0, 0, Width, Height, 0x1400 );
|
||||
|
||||
AddLabel( 20, 60, 1152, "# of players (" + _ControlItem.MinPlayers.ToString() + "-" + _ControlItem.MaxPlayers.ToString() + "):" );
|
||||
|
||||
int minplayers = Math.Max( _ControlItem.MinPlayers, _ControlItem.Players.Count );
|
||||
|
||||
if( _ControlItem.MaxPlayers != _ControlItem.MinPlayers && !_ControlItem.SettingsReady )
|
||||
{
|
||||
AddLabel( 20, 40, 1172, "Pick the number of players" );
|
||||
AddTextField( 150, 60, 30, 20, 0, _ControlItem.CurrentMaxPlayers.ToString() );
|
||||
AddButton( 182, 62, 0x4B9, 0x4BA, 500, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLabel( 150, 60, 1152, _ControlItem.CurrentMaxPlayers.ToString() );
|
||||
}
|
||||
|
||||
|
||||
//AddButton( Width - 15, 0, 3, 4, 0, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
public void AddTextField( int x, int y, int width, int height, int index, string text )
|
||||
{
|
||||
AddImageTiled( x - 2, y - 2, width + 4, height + 4, 0xA2C );
|
||||
AddAlphaRegion( x -2, y - 2, width + 4, height + 4 );
|
||||
AddTextEntry( x + 2, y + 2, width - 4, height - 4, 1153, index, text );
|
||||
}
|
||||
|
||||
public string GetTextField( RelayInfo info, int index )
|
||||
{
|
||||
TextRelay relay = info.GetTextEntry( index );
|
||||
return ( relay == null ? null : relay.Text.Trim() );
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState state, RelayInfo info )
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
if( _ControlItem.Players.IndexOf( from ) != 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if( !_ControlItem.SettingsReady )
|
||||
{
|
||||
_ControlItem.CurrentMaxPlayers = Math.Max( Int32.Parse( GetTextField( info, 0 ) ), _ControlItem.Players.Count );
|
||||
|
||||
if( _ControlItem.CurrentMaxPlayers > _ControlItem.MaxPlayers || _ControlItem.CurrentMaxPlayers < _ControlItem.MinPlayers )
|
||||
{
|
||||
throw( new Exception() );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
from.SendMessage( "Invalid number of players selected. Please try again." );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user