魔法药水储存
CREATE PROCEDURE .@GameID varchar(14),
@ItemIndex int,
@WindowKind int,
@WindowIndex int
AS
set nocount on;
/*
--这个是简单版的,时间不累加,如果时间累加版的出现什么BUG,可以使用注释里的这一段替换
DECLARE @DeleteItemError int, @UpdateError int , @SETimer varchar(20),@Time int
SET @DeleteItemError = 1
SET @UpdateError = 1
BEGIN TRANSACTION REDZL
DELETE tblSpecialItem1 WHERE ID = (select top 1 ID FROM tblSpecialItem1 WHERE ItemKind = 6 AND ItemIndex = @ItemIndex AND Position = 1 AND GameID = @GameID AND WindowKind = @WindowKind AND WindowIndex = @WindowIndex)
IF @@ROWCOUNT > 0 and @@ERROR = 0 SET @DeleteItemError = 0
SET @Time = 60 --药水魔法持续时间,单位分钟
Select @SETimer =
Case @ItemIndex
When 204 Then '3' --飞莲舞
When 205 Then '60' --御剑术
When 206 Then '42' --星星
When 207 Then '62' --无限疾奔
Else '8' End--其他为蛋
UPDATE tblGameID1 SET SETimer = SETimer + @SETimer + ':' + Cast(@Time * 60000 as varchar)+ '.' WHERE GameID = @GameID
SET @UpdateError = @@ERROR
IF @DeleteItemError = 0 AND @UpdateError = 0
BEGIN
COMMIT TRANSACTION REDZL
END
ELSE
BEGIN
ROLLBACK TRANSACTION REDZL
END
*/
DECLARE @DeleteItemError int, @UpdateError int , @mf varchar(20), @Time int
SET @DeleteItemError = 1
SET @UpdateError = 1
BEGIN TRANSACTION REDZL
DELETE tblSpecialItem1 WHERE ID = (select top 1 ID FROM tblSpecialItem1 WHERE ItemKind = 6 AND ItemIndex = @ItemIndex AND Position = 1 AND GameID = @GameID AND WindowKind = @WindowKind AND WindowIndex = @WindowIndex)
IF @@ROWCOUNT > 0 and @@ERROR = 0 SET @DeleteItemError = 0
SET @Time = 60 --药水魔法持续时间,单位分钟
Select @mf =
Case @ItemIndex
When 204 Then '3' --飞莲舞
When 205 Then '60' --御剑术
When 206 Then '42' --星星
When 207 Then '62' --无限疾奔
Else '8' End--其他为蛋
declare @SETimer varchar(1000) , @overtime int, @tmp_str varchar(500)
select @SETimer = SETimer from tblGameID1 where GameID = @GameID
set @SETimer = '.' + @SETimer
select @tmp_str = right(@SETimer,len(@SETimer) - charindex('.' + @mf +':', @SETimer))
--获得魔法剩余时间
if @mf != '42' --如果要加的魔法不是星星
select @overtime = cast(replace(left(@tmp_str,charindex('.',@tmp_str) - 1) , @mf + ':','') as int)
ELSE --星星魔法格式特殊,需要特殊处理
BEGIN
select @overtime = charindex(':50:',@tmp_str)
if @overtime > 0 select @overtime = cast(replace(left(@tmp_str,charindex(':50:',@tmp_str) - 1) , @mf + ':','') as int)
END
if @overTime = 0 --等于0则原来不存在此魔法
BEGIN
--星星特殊处理
if @mf = '42' Set @SETimer = right(@SETimer,len(@SETimer)-1) + @mf + ':' + CAST(@Time * 60000 as varchar)+ ':50:0.'
ELSE Set @SETimer = right(@SETimer,len(@SETimer)-1) + @mf + ':' + CAST(@Time * 60000 as varchar)+ '.'
END
ELSE --否则再原来基础上增加时间
BEGIN
Set @SETimer = replace(right(@SETimer,len(@SETimer)-1), @mf + ':' + CAST(@overTime as varchar), @mf + ':' + CAST(@overTime + @Time * 60000 as varchar))
END
UPDATE tblGameID1 SET SETimer = @SETimer WHERE GameID = @GameID
SET @UpdateError = @@ERROR
IF @DeleteItemError = 0 AND @UpdateError = 0
BEGIN
COMMIT TRANSACTION REDZL
END
ELSE
BEGIN
ROLLBACK TRANSACTION REDZL
END
GO
!上向天天,习学好好
页:
[1]