寻宝:点击头像接口设置机器人

This commit is contained in:
luying
2021-08-25 16:57:11 +08:00
parent 14eac59d43
commit fe78c998b2
13 changed files with 98 additions and 31 deletions
+5
View File
@@ -704,4 +704,9 @@ export enum HANDLE_REWARD_TYPE {
export enum RECEIVE_MAIL_TYPE {
SINGLE = 1, // 领取单个
ALL = 2, // 一件领取
}
export enum ROBOT_SYS_TYPE {
COM_BTL = 1,
PVP = 2
}
+5
View File
@@ -183,6 +183,11 @@ export default class ComBattleTeam extends BaseModel {
return team;
}
public static async findByRoleId(roleId: string) {
const team: ComBattleTeamType = await ComBattleTeamModel.findOne({ roleIds: { $in: [roleId] }}).lean();
return team;
}
public static async addRole(teamCode: string, roleStatus: RoleStatus, lean = true) {
const team: ComBattleTeamType = await ComBattleTeamModel.findOneAndUpdate({ teamCode, roleCnt: { $lte: 2 } }, {$push: {roleIds: roleStatus.roleId, roleStatus}, $inc: {roleCnt: 1}}, {new: true}).lean(lean);
return team;
+2 -1
View File
@@ -1,6 +1,7 @@
import { RoleType } from "../../db/Role";
import { FriendShipType } from "../../db/FriendShip";
import * as friendUtil from '../../pubUtils/friendUtil'
import { FRIEND_RELATION_TYPE } from "../../consts";
export class FriendParams {
roleId: string;
@@ -13,7 +14,7 @@ export class FriendParams {
title: number;
serverId: number;
serverName: string;
type: number;
type: number = FRIEND_RELATION_TYPE.NORMAL;
constructor(role: RoleType) {
this.roleId = role.roleId;
+32 -3
View File
@@ -4,7 +4,7 @@ import { HeroModel, HeroType } from '../db/Hero';
import fs = require('fs');
import path = require('path');
import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, } from '../consts';
import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, ROBOT_SYS_TYPE, } from '../consts';
import { findIndex } from 'underscore';
import { getTimeFunM } from './timeUtil';
@@ -546,13 +546,42 @@ export function getChineseName() {
return randomName.generate()
}
export function getRobotInfo() {
export function getRobotInfo(sysType = ROBOT_SYS_TYPE.COM_BTL) {
return {
robotRoleName: getChineseName(),
robotRoleId: genCode(8)
robotRoleId: makeRobotId(genCode(8), sysType),
}
}
// 根据roleId判断是不是机器人
export function checkRoleIsRobot(roleId: string) {
return !!roleId.match(/_r/);
}
// 将一般的roleId转为带_r的
export function makeRobotId(roleId: string, sysType = ROBOT_SYS_TYPE.COM_BTL) {
if(sysType) {
return `${sysType}|${roleId}_r`;
} else {
return `${roleId}_r`;
}
}
// 获取来源系统
export function getRobotSysType(roleId: string) {
let type = roleId.split('|')[0];
if(isNaN(parseInt(type))) {
return 0
} else {
return parseInt(type);
}
}
// 将一般的roleId去掉_r
export function robotIdComBack(robotRoleId: string) {
return robotRoleId.replace(/_r/, '')
}
export function splitString(dataString: string, key: string) {
if (!dataString) {
return [];