好友:寻宝关系加成及黑名单屏蔽
This commit is contained in:
@@ -4,12 +4,14 @@ export enum ROLE_SELECT {
|
||||
ENTRY = 'serverId userInfo.uid userInfo.tel userInfo.serverType ce topFiveCe teraphs roleId roleName tili lv exp gold coin vLv title hasGuild',
|
||||
// 玩家列表显示基础数据
|
||||
SHOW_SIMPLE = 'roleId roleName ce headHid sHid lv title job quitTime vLv guildName serverId userInfo.serverType',
|
||||
// 显示申请需要的信息
|
||||
SHOW_FRIEND_APPLY_LIST = 'roleId roleName ce headHid sHid lv title job quitTime vLv guildName friendCnt recFrdApplyCnt serverId userInfo.serverType',
|
||||
HANDLE_APPLY = 'roleId friendCnt lv',
|
||||
ATTR = 'globalCeAttr',
|
||||
GET_LV = 'lv',
|
||||
GET_ROLE_ID = 'roleId',
|
||||
GET_MY_SERVER = 'lv serverId userInfo.serverType',
|
||||
COM_BATTLE = 'lv headHid sHid topFiveCe'
|
||||
};
|
||||
|
||||
export enum HERO_SELECT {
|
||||
@@ -31,4 +33,8 @@ export enum USER_GUILD_SELECT {
|
||||
|
||||
export enum GUILD_SELECT {
|
||||
ENTRY = 'guildCode lv memberCnt'
|
||||
}
|
||||
|
||||
export enum FRIEND_SHIP_SELECT {
|
||||
GET_FRIEND_VALUE = 'friendValue friendLv'
|
||||
}
|
||||
@@ -107,6 +107,7 @@ export const STATUS = {
|
||||
COM_BATTLE_REWARDED: { code: 20628, simStr: '奖励已领取' },
|
||||
COM_BATTLE_HEROES_ERR: { code: 20629, simStr: '阵容异常' },
|
||||
COM_BATTLE_SET_FRD_ERR: { code: 20630, simStr: '设置情谊助战异常' },
|
||||
COM_BATTLE_BLACKLIST: { code: 20633, simStr: '队伍中存在黑名单玩家' },
|
||||
|
||||
// 共斗藏宝图合成
|
||||
COM_BLUEPRT_QUALITY_CANNOT_COMPOSE: { code: 20630, simStr: '该品质藏宝图不可合成' },
|
||||
|
||||
@@ -46,6 +46,9 @@ export class RoleStatus {
|
||||
// 固定奖励
|
||||
@prop({ required: true, default: '&' })
|
||||
fixReward: string;
|
||||
// 好友间伤害加成
|
||||
@prop({ required: true, default: 0 })
|
||||
frdRatio: number = 0;
|
||||
|
||||
constructor(roleId: string, roleName: string, isCap: boolean, isFrd: boolean, headHid: number, sHid: number, topFiveCe: number, lv: number, heroes = [], isRobot = false) {
|
||||
this.roleId = roleId;
|
||||
@@ -61,6 +64,14 @@ export class RoleStatus {
|
||||
this.killed = [];
|
||||
this.isRobot = isRobot;
|
||||
}
|
||||
|
||||
addFrdRatio(frdRatio: number) {
|
||||
if(!this.frdRatio) {
|
||||
this.frdRatio = frdRatio;
|
||||
} else {
|
||||
this.frdRatio += frdRatio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class BossHp {
|
||||
@@ -233,7 +244,7 @@ export default class ComBattleTeam extends BaseModel {
|
||||
|
||||
public static async getOtherTeamByQualityAndSt(roleId: string, qualityArr: Array<number>, status: number, lvRange: number, ce = 0, pub = true, cntLmt = 2, lean = true) {
|
||||
const curTime = new Date(Date.now() - 10 * 60 * 1000); // 10分钟之前
|
||||
const team: ComBattleTeamType = await ComBattleTeamModel.findOne({quality: {$in: qualityArr}, status, lvRange, ceLimit: {$lte: ce}, pub, roleCnt: {$lte: cntLmt}, roleIds: {$nin: [roleId]}, updatedAt: {$gte: curTime}}).lean(lean);
|
||||
const team: ComBattleTeamType[] = await ComBattleTeamModel.find({quality: {$in: qualityArr}, status, lvRange, ceLimit: {$lte: ce}, pub, roleCnt: {$lte: cntLmt}, roleIds: {$nin: [roleId]}, updatedAt: {$gte: curTime}}).lean(lean);
|
||||
return team;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,9 @@ export default class FriendRelation extends BaseModel {
|
||||
document.populate('friends.friendShip', null, 'FriendShip');
|
||||
}
|
||||
|
||||
let result: FriendRelationType = await document;
|
||||
let result: FriendRelationType = await document.lean({ getters: true, virtuals: true });;
|
||||
|
||||
console.log(JSON.stringify(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -79,6 +81,13 @@ export default class FriendRelation extends BaseModel {
|
||||
return result
|
||||
}
|
||||
|
||||
public static async isInBlackList(roleId: string, hisRoleId: string) {
|
||||
let result = await FriendRelationModel.find({
|
||||
$or: [{ roleId, 'blacklist.roleId': hisRoleId}, { hisRoleId, 'blacklist.roleId': roleId}]
|
||||
}).lean();
|
||||
return result.length > 0;
|
||||
}
|
||||
|
||||
public static async deleteAccount(roleId: string) {
|
||||
let result = await FriendRelationModel.deleteMany({ roleId });
|
||||
await FriendRelationModel.updateMany({}, { $pull: { friends: { roleId }, blacklist: { roleId } }});
|
||||
|
||||
@@ -4,7 +4,7 @@ import { getFriendLvByExp } from '../pubUtils/data';
|
||||
import * as util from '../pubUtils/friendUtil';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { FRIEND } from '../pubUtils/dicParam';
|
||||
import { FRIEND_SELECT } from '../consts';
|
||||
import { FRIEND_SELECT, FRIEND_SHIP_SELECT } from '../consts';
|
||||
|
||||
/**
|
||||
* 好友直接的亲密值
|
||||
@@ -59,7 +59,7 @@ export default class FriendShip extends BaseModel {
|
||||
const doc = new FriendShipModel();
|
||||
const update = Object.assign(doc.toJSON(), { roleIdA, roleIdB, roleIds });
|
||||
|
||||
const result: FriendShipType = await FriendShipModel.findOneAndUpdate({ roleIds }, { $setOnInsert: update }, { upsert: true, new: true }).lean();
|
||||
const result: FriendShipType = await FriendShipModel.findOneAndUpdate({ roleIds }, { $setOnInsert: update }, { upsert: true, new: true }).lean({ virtuals: true });
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ export default class FriendShip extends BaseModel {
|
||||
if (roleIdList.length != 2) return false;
|
||||
let { roleIds } = util.getRoleIds(roleIdList);
|
||||
|
||||
const result: FriendShipType = await FriendShipModel.findOneAndUpdate({ roleIds }, { $set: { friendValue: 0 } }, { new: true }).lean();
|
||||
const result: FriendShipType = await FriendShipModel.findOneAndUpdate({ roleIds }, { $set: { friendValue: 0 } }, { new: true }).lean({ virtuals: true });
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export default class FriendShip extends BaseModel {
|
||||
let obj = this.getRefData();
|
||||
const result: FriendShipType = await FriendShipModel.findOneAndUpdate({ roleIds }, {
|
||||
$set: { ...obj }
|
||||
}, { new: true }).lean();
|
||||
}, { new: true }).lean({ virtuals: true });
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -155,6 +155,13 @@ export default class FriendShip extends BaseModel {
|
||||
.lean({ virtuals: true });
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getFriendLv(roleId: string, hisRoleId: string) {
|
||||
let { roleIds } = util.getRoleIds([roleId, hisRoleId]);
|
||||
|
||||
let result: FriendShipType = await FriendShipModel.findOne({ roleIds }).select(FRIEND_SHIP_SELECT.GET_FRIEND_VALUE).lean({ virtuals: true });
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const FriendShipModel = getModelForClass(FriendShip);
|
||||
|
||||
Reference in New Issue
Block a user