diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 0080d3b1e..5cfdbf189 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -8,7 +8,7 @@ export const ENCRYPT_KEY = 'fiqaxijabbantusmprc234fj'; export const AUTH_SMS_CNT_PER_DAY = 8; export const ADULT_AGE = 18; -export const GUEST_MAX_TIME = 60 * 60 * 100; // 游客体验时间 +export const GUEST_MAX_TIME = 60 * 60; // 游客体验时间 export const GUEST_DAY = 15; // 同一设备15天内不得重复体验游客模式 export const COUNTER = { @@ -409,4 +409,13 @@ export enum ADDICTION_PREVENTION_CODE { CURFEW = 2, // 每日22时至次日8时,未成年禁止游戏 HOLIDAY = 3, // 法定节假日每日累计不得超过3小时 WORKDAY = 4, // 非法定节假日每日累计不得超过1.5小时 +} + +export enum GET_SMS_TYPE { + LOGIN = 1, + BIND = 2 +} + +export enum DEFAULT_DEVICE_ID { + PC = 'pc' } \ No newline at end of file diff --git a/shared/domain/roleField/attribute.ts b/shared/domain/roleField/attribute.ts index 7cbcd2e9d..0da2c0e15 100644 --- a/shared/domain/roleField/attribute.ts +++ b/shared/domain/roleField/attribute.ts @@ -162,6 +162,7 @@ export class Attribute { public calCe() { let { hp, atk, def, mdef } = this.getRealMainAttr(); let { cri, flee, damageIncrease, damageDecrease, damageCri } = this.getRealSubAttr(); + let putHit = CE_CONST.PUT_HIT / HERO_SUB_ATTR_RATIO; let putAntCri = CE_CONST.PUT_ANT_CRI / HERO_SUB_ATTR_RATIO; @@ -179,6 +180,7 @@ export class Attribute { let validHp = hp + (def + mdef) * 0.5 / ((1 - fleeRate * CE_CONST.FLEE_VALUE) * (1 - damageDecrease)); // 有效生命 let validAtk = atk * hitRate * ( 1 + criRate * criValue) * ( 1 + damageIncrease); // 有效输出 let ce = Math.floor(validHp * validAtk * HERO_CE_RATIO * HERO_CE_RATIO); + return ce > 0? ce: 1; } diff --git a/web-server/app/controller/account.ts b/web-server/app/controller/account.ts index 091b87551..034881af9 100644 --- a/web-server/app/controller/account.ts +++ b/web-server/app/controller/account.ts @@ -10,8 +10,8 @@ export default class AccountController extends Controller { public async getSms() { const { ctx } = this; - const { tel } = ctx.request.body; - ctx.body = await ctx.service.auth.getSms(tel); + const { type, tel } = ctx.request.body; + ctx.body = await ctx.service.auth.getSms(type, tel); } public async smsLogin() { diff --git a/web-server/app/service/Auth.ts b/web-server/app/service/Auth.ts index c8eefe428..7afb986e7 100644 --- a/web-server/app/service/Auth.ts +++ b/web-server/app/service/Auth.ts @@ -3,7 +3,7 @@ import { DEFAULT_HEROES } from '@consts'; import { HeroModel } from '@db/Hero'; import { RoleModel } from '@db/Role'; import { UserModel, UserType } from '@db/User'; -import { STATUS } from '@consts'; +import { STATUS, GET_SMS_TYPE, DEFAULT_DEVICE_ID } from '@consts'; import { smsModel } from '@db/Sms'; import { Service } from 'egg'; import Counter from '@db/Counter'; @@ -35,10 +35,18 @@ export default class Auth extends Service { if(isGuest) { const tel = ctx.service.utils.genCode(10); const token = ctx.service.utils.generateStr(256); - let lastGuest = await UserModel.getLastDeviceGuest(deviceId); - let { guestTime, createdAt } = lastGuest; - if(shouldRefresh(createdAt, new Date(), 0, GUEST_DAY)) { - guestTime = 0; + let lastGuest = null; + let guestTime = 0; + if(deviceId != DEFAULT_DEVICE_ID.PC) { + lastGuest = await UserModel.getLastDeviceGuest(deviceId); + if(lastGuest) { + guestTime = lastGuest.guestTime; + + let { createdAt } = lastGuest; + if(shouldRefresh(createdAt, new Date(), 0, GUEST_DAY)) { + guestTime = 0; + } + } } if(guestTime > GUEST_MAX_TIME) { loginType = 3; @@ -135,12 +143,21 @@ export default class Auth extends Service { * @param telNo - 用户手机号 */ - public async getSms(tel: string) { + public async getSms(type: number, tel: string) { + const ctx = this.ctx; const telVerify = this.checkTelNo(tel); if (telVerify.status !== 0) { return telVerify.resResult; } + + if(type == GET_SMS_TYPE.BIND) { + let telUser = await UserModel.findUserByTel(tel); + if(telUser && telUser.uid != ctx.uid) { + return ctx.service.utils.resResult(STATUS.TEL_HAS_USED); + } + } + const sms = await smsModel.findByTel(tel, false); if (sms) { if (await sms.timeLimit(10000)) {