标签:流程图 class 重置 注册时间 last default sign 递增 pre
游戏基本需求CD机制。用来处理隔天重置。XX小时步进。每日/每周/每月XXX的重置。 每日X点+1. 等功能触发/结算.
CD类型划分 deduct_type
1 递增时CD(正CD) 数值自动累加到max
eg. 体力,能量恢复.
2 周期重置型CD(负CD) .数值扣除,到达指定周期后重置为max
eg.每天挑战次数3次. 每天可买礼包3次..
对应的CD类设计
对应的算法流程图
数据库结构设计
CREATE TABLE `t_cd` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`char_id` int(20) unsigned NOT NULL DEFAULT ‘0‘ COMMENT ‘角色id‘,
`tid` int(20) unsigned NOT NULL DEFAULT ‘0‘,
`typeName` varchar(60) NOT NULL DEFAULT ‘‘ COMMENT ‘类型名‘,
`update_time` datetime NOT NULL,
`next_time` datetime NOT NULL COMMENT ‘下次到达时间‘,
`deduct_type` int(4) unsigned NOT NULL DEFAULT ‘0‘ COMMENT ‘CD机制 1负CD ,0正CD‘,
`last_value` int(11) DEFAULT ‘0‘ COMMENT ‘最后更新数值‘,
`curr_value` int(11) unsigned DEFAULT ‘0‘ COMMENT ‘当前值‘,
`max_value` int(11) NOT NULL DEFAULT ‘0‘,
`interval_time` int(11) unsigned DEFAULT ‘3600‘ COMMENT ‘计算周期s‘,
`interval_value` int(11) DEFAULT ‘0‘ COMMENT ‘周期增长值‘,
`init_value` int(11) unsigned DEFAULT ‘0‘ COMMENT ‘初始值‘,
`interval_type` int(4) DEFAULT ‘0‘ COMMENT ‘cd周期类型0默认,1每日,2每周,3每月‘,
`offset_value` int(4) unsigned DEFAULT ‘0‘ COMMENT ‘(当天8点)周期偏移量hour‘,
`day_interval` int(4) unsigned DEFAULT ‘0‘ COMMENT ‘每*天更新周期‘,
`week_interval` int(4) unsigned DEFAULT ‘0‘ COMMENT ‘每周第几天0-6‘,
`month_interval` int(4) unsigned DEFAULT ‘0‘ COMMENT ‘每月几号0-31‘,
`cd_count` int(11) unsigned NOT NULL DEFAULT ‘0‘ COMMENT ‘累积消耗计数‘,
`create_time` datetime DEFAULT NULL COMMENT ‘注册时间‘,
`delete_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `uid` (`tid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1513 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
模板表配置示例
正cd t_cd_increment
<cd> <tid>1002</tid> <typeName>cargo2005</typeName> <maxValue>1</maxValue> <initValue>1</initValue> <intervalType>1</intervalType> <dayInterval>1</dayInterval> <weekInterval>0</weekInterval> <monthInterval>0</monthInterval> <offsetValue>8</offsetValue> <autoInit>1</autoInit> </cd>
负CD t_cd_reset
<cd> <tid>1005</tid> <typeName>dayGiftCargo9002</typeName> <maxValue>3</maxValue> <initValue>3</initValue> <intervalType>1</intervalType> <dayInterval>1</dayInterval> <weekInterval>0</weekInterval> <monthInterval>0</monthInterval> <offsetValue>8</offsetValue> <autoInit>1</autoInit> </cd>
标签:流程图 class 重置 注册时间 last default sign 递增 pre
原文地址:https://www.cnblogs.com/xiloweiEVE/p/13035648.html