CREATE TRIGGER TG_AutoChangePearlDiamond ON dbo.tblMail1
For Insert
AS declare@iTitle varchar(80)
declare@Sender varchar(16)
declare@璐村惂鐢ㄦ埛_0U9tVea馃惥 varchar(16)
declare@icontent varchar(200)
declare@time datetime
declare @iCount int
declare @DHWP varchar(10)
declare @iDHWPDM int
declare @iDHXYSL int
declare @iLL int
declare @iYZ int
declare @iMJ int
declare @iGQ int
declare @iTmpS varchar(200)
declare @iLen int
declare @iID int
--角色类型临时变量
declare @face int
Select @iTitle=Title,@Sender=Sender,@Recipient=Recipient,@iContent=Content,@Time=Time From Inserted
set @iTitle=ltrim(rtrim(@iTitle))
set @iContent=ltrim(rtrim(@iContent))
--判断发信人和收信人的名字是否相同,不相同直接结束
if (@Sender<>@Recipient) return
--判断标题是否少于3个字,少于则直接结束
if (len(@iTitle)<3) return
--判断标题前2个字是否为兑换或退还生化,不是则直接结束
if (left(@iTitle,2)<>'兑换' AND @iTitle<>'退还生化' AND left(@iTitle,2)<>'变身') return
--在这里增加变身的处理
if (left(@iTitle,2)='变身')
begin
--获取变身角色
if (@iTitle='变身0' OR @iTitle='变身菲拉洛')
set @face=0
else if (@iTitle='变身1' OR @iTitle='变身阿基拉')
set @face=1
else if (@iTitle='变身2' OR @iTitle='变身撒达得')
set @face=2
else if (@iTitle='变身3' OR @iTitle='变身邓斯帝诺')
set @face=3
else if (@iTitle='变身4' OR @iTitle='变身朴真熙')
set @face=4
else if (@iTitle='变身5' OR @iTitle='变身凯诺')
set @face=5
else if (@iTitle='变身6' OR @iTitle='变身韩智华')
set @face=6
else if (@iTitle='变身7' OR @iTitle='变身露娜莉娜')
set @face=7
else if (@iTitle='变身8' OR @iTitle='变身罗贝塔')
set @face=8
else
begin
set @iContent='您想变成什么角色?请仔细阅读主页帮助!'
update tblMail1 Set Content=@iContent,Line=20 Where Sender=@Sender AND Recipient=@Recipient AND Time=@Time
return
end
--同角色变身保护
select @iID=face from tblGameID1 where GameID=@Recipient
if (@iID=@face)
begin
set @iContent='您如果不进行变身就不要使用本功能,
如果造成物品丢失,后果自负!'
update tblMail1 Set Content=@iContent,Line=20 Where Sender=@Sender AND Recipient=@Recipient AND Time=@Time
return
end
--检查物品数量是否符合条件
select @iCount=(select Count(GameID) AS iCount From tblSpecialItem1
Where ItemKind=6 AND Position=1 AND GameID=@Recipient AND (WindowKind=1 OR WindowKind=3) AND ItemDurability>=4 AND (ItemIndex=200 ))
if (@iCount<50)
begin
set @iContent='您的F3和F8中的珍珠钻石总数不够[80个]!'
update tblMail1 Set Content=@iContent,Line=20 Where Sender=@Sender AND Recipient=@Recipient AND Time=@Time
return
end
begin transaction
--删除珍珠钻石
delete tblSpecialItem1 Where ID IN (Select Top 50 ID From tblSpecialItem1 Where ItemKind=6 AND
Position=1 AND GameID=@Recipient AND (WindowKind=1 OR WindowKind=3)
AND ItemDurability>=4 AND (ItemIndex=200 ))
--角色变身
update tblGameID1 set face=@face where GameID=@Recipient
--发放毒药
insert into tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, Position, Map, X, Y, TileKind, GameID, WindowKind, WindowIndex, MiscTime, AttackGrade, StrengthGrade, SpiritGrade, DexterityGrade, PowerGrade)
values (6, 67, 4, 2, 1, 100, 100, 1, @Recipient, 100, 0, @Time, 0,0,0,0,0)
set @iContent='恭喜变身成功!
请吃毒药后继续游戏
[需切换地图后才能看到变身效果]!'
update tblMail1 Set Content=@iContent,Line=20 Where Sender=@Sender AND Recipient=@Recipient AND Time=@Time
commit transaction
return
end
For Insert
AS declare@iTitle varchar(80)
declare@Sender varchar(16)
declare@璐村惂鐢ㄦ埛_0U9tVea馃惥 varchar(16)
declare@icontent varchar(200)
declare@time datetime
declare @iCount int
declare @DHWP varchar(10)
declare @iDHWPDM int
declare @iDHXYSL int
declare @iLL int
declare @iYZ int
declare @iMJ int
declare @iGQ int
declare @iTmpS varchar(200)
declare @iLen int
declare @iID int
--角色类型临时变量
declare @face int
Select @iTitle=Title,@Sender=Sender,@Recipient=Recipient,@iContent=Content,@Time=Time From Inserted
set @iTitle=ltrim(rtrim(@iTitle))
set @iContent=ltrim(rtrim(@iContent))
--判断发信人和收信人的名字是否相同,不相同直接结束
if (@Sender<>@Recipient) return
--判断标题是否少于3个字,少于则直接结束
if (len(@iTitle)<3) return
--判断标题前2个字是否为兑换或退还生化,不是则直接结束
if (left(@iTitle,2)<>'兑换' AND @iTitle<>'退还生化' AND left(@iTitle,2)<>'变身') return
--在这里增加变身的处理
if (left(@iTitle,2)='变身')
begin
--获取变身角色
if (@iTitle='变身0' OR @iTitle='变身菲拉洛')
set @face=0
else if (@iTitle='变身1' OR @iTitle='变身阿基拉')
set @face=1
else if (@iTitle='变身2' OR @iTitle='变身撒达得')
set @face=2
else if (@iTitle='变身3' OR @iTitle='变身邓斯帝诺')
set @face=3
else if (@iTitle='变身4' OR @iTitle='变身朴真熙')
set @face=4
else if (@iTitle='变身5' OR @iTitle='变身凯诺')
set @face=5
else if (@iTitle='变身6' OR @iTitle='变身韩智华')
set @face=6
else if (@iTitle='变身7' OR @iTitle='变身露娜莉娜')
set @face=7
else if (@iTitle='变身8' OR @iTitle='变身罗贝塔')
set @face=8
else
begin
set @iContent='您想变成什么角色?请仔细阅读主页帮助!'
update tblMail1 Set Content=@iContent,Line=20 Where Sender=@Sender AND Recipient=@Recipient AND Time=@Time
return
end
--同角色变身保护
select @iID=face from tblGameID1 where GameID=@Recipient
if (@iID=@face)
begin
set @iContent='您如果不进行变身就不要使用本功能,
如果造成物品丢失,后果自负!'
update tblMail1 Set Content=@iContent,Line=20 Where Sender=@Sender AND Recipient=@Recipient AND Time=@Time
return
end
--检查物品数量是否符合条件
select @iCount=(select Count(GameID) AS iCount From tblSpecialItem1
Where ItemKind=6 AND Position=1 AND GameID=@Recipient AND (WindowKind=1 OR WindowKind=3) AND ItemDurability>=4 AND (ItemIndex=200 ))
if (@iCount<50)
begin
set @iContent='您的F3和F8中的珍珠钻石总数不够[80个]!'
update tblMail1 Set Content=@iContent,Line=20 Where Sender=@Sender AND Recipient=@Recipient AND Time=@Time
return
end
begin transaction
--删除珍珠钻石
delete tblSpecialItem1 Where ID IN (Select Top 50 ID From tblSpecialItem1 Where ItemKind=6 AND
Position=1 AND GameID=@Recipient AND (WindowKind=1 OR WindowKind=3)
AND ItemDurability>=4 AND (ItemIndex=200 ))
--角色变身
update tblGameID1 set face=@face where GameID=@Recipient
--发放毒药
insert into tblSpecialItem1 (ItemKind, ItemIndex, ItemDurability, Position, Map, X, Y, TileKind, GameID, WindowKind, WindowIndex, MiscTime, AttackGrade, StrengthGrade, SpiritGrade, DexterityGrade, PowerGrade)
values (6, 67, 4, 2, 1, 100, 100, 1, @Recipient, 100, 0, @Time, 0,0,0,0,0)
set @iContent='恭喜变身成功!
请吃毒药后继续游戏
[需切换地图后才能看到变身效果]!'
update tblMail1 Set Content=@iContent,Line=20 Where Sender=@Sender AND Recipient=@Recipient AND Time=@Time
commit transaction
return
end