/* ************************************************************************* *
 *
 * Datei:       tblCharacter.sql
 *
 * Aufgabe:     Tabelle tblCharacter anlegen
 *           
 * Aenderungen: 
 *              2021-09-23, MWN, erstellt.
 *
 * ************************************************************************* */

if not exists (select * from sys.tables where object_id = object_id (N'tblCharacter')) begin

  -- Protokollausgabe
  print 'Anlegen der Tabelle <' + db_name() + '.dbo.tblCharacter>'

  -- drop table tblCharacter
  create table tblCharacter (

      -- Primaerschluessel
      constraint [PK_tblCharacter] primary key ([key])
    ,	[key]					int					identity(1, 1) not null
         
      -- ----------------------------------------------------------------------
      -- Allgemeine Parameter
      -- ----------------------------------------------------------------------
	,	[created]				DateTime			NOT NULL
	,	[lastModified]			DateTime			NOT NULL
                           
      -- ----------------------------------------------------------------------
      -- Parameter
      -- ----------------------------------------------------------------------
    ,	[playerLink]			int					NOT NULL
	,   [groupLink]				int					NOT NULL
	,	[classLink]				int					NOT NULL
	,	[raceLink]				int					NOT NULL
	,	[alignmentLink]         int					NOT NULL
	,	[deityLink]				int					NOT NULL
	,	[sizeLink]				int					NOT NULL
    ,	[name]					nvarchar(250)		NOT NULL
	,	[level]					int					NOT NULL
	,	[age]					int					NOT NULL
	,	[gender]				nvarchar(250)		NOT NULL
	,	[height]				decimal				NOT NULL
	,	[weight]				decimal				NOT NULL
	,	[eyes]					nvarchar(250)		NOT NULL
	,	[hair]					nvarchar(250)		NOT NULL
	,	[skin]					nvarchar(250)		NOT NULL
	,	[strength]				int					NOT NULL
	,	[dexterity]				int					NOT NULL
	,	[constitution]			int					NOT NULL
	,	[intelligence]			int					NOT NULL
	,	[wisdom]				int					NOT NULL
	,	[charisma]				int					NOT NULL
	,	[strengthtemp]			int					NULL
	,	[dexteritytemp]			int					NULL
	,	[constitutiontemp]		int					NULL
	,	[intelligencetemp]		int					NULL
	,	[wisdomtemp]			int					NULL
	,	[charismatemp]			int					NULL
	,	[fortitude]				int					NOT NULL
	,	[reflex]				int					NOT NULL
	,	[will]					int					NOT NULL
	,	[baseAttack]			int					NOT NULL
	,	[hp]					int					NOT NULL
	,	[tempHp]				int					NOT NULL
	,	[nonLethalDmg]			int					NOT NULL
	,	[speed]					int					NOT NULL
	,	[dmgReduction]			int					NOT NULL
	,	[spellResistance]	    int					NOT NULL
	,	[miscInitiative]		int					NULL
	,	[miscArmor]				int					NULL
	,	[miscFortitude]			int					NULL
	,	[miscReflex]			int					NULL
	,	[miscWill]				int					NULL
	,	[miscGrapple]			int					NULL
	,	[exp]					int					NOT NULL
	,	[copper]				int					NOT NULL
	,	[silver]				int					NOT NULL
	,	[gold]					int					NOT NULL
	,	[platin]				int					NOT NULL
	, 
  )

  if not exists (select * from sys.tables where object_id = object_id ('tblCharacter')) begin
    print ''
    print '************************************'
    print 'Fehler beim Erstellen der Tabelle tblCharacter'
    print '************************************'
    print ''
  end

end /*else begin  -- [if not exists (Tabelle)...]

  -- Hinzufuegen einer Spalte
  if not exists (select * from syscolumns where name = 'nSeqDataXLink' and id = object_id('tblCharacter') and objectproperty(id, N'IsUserTable') = 1) begin
    print 'alter table tblCharacter add nSeqDataXLink bigint null'
    alter table tblCharacter add nSeqDataXLink bigint null
  end

end  -- [if not exists (Tabelle)...]*/
go

-- :EOF:
