找回密码
 立即注册
查看: 212|回复: 1

[服务端] 魔法药水储存

[复制链接]

5

主题

2

回帖

179

积分

注册会员

积分
179
发表于 2024-7-11 00:30:23 | 显示全部楼层 |阅读模式
CREATE PROCEDURE [dbo].[RMS_TESTING]
@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

2

主题

216

回帖

3795

积分

中级会员

积分
3795
发表于 2024-7-26 09:03:58 | 显示全部楼层
!上向天天,习学好好
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|玩红月技术论坛 |网站地图

GMT+8, 2024-11-21 18:20 , Processed in 0.040888 second(s), 24 queries .

快速回复 返回顶部 返回列表