好友:赠送领取爱心
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { gameData } from "../pubUtils/data";
|
||||
import { RoleType, RoleModel } from "../db/Role";
|
||||
import { FriendRelationType } from "../db/FriendRelation";
|
||||
import { FriendRelationType, Relation } from "../db/FriendRelation";
|
||||
import { getResStr } from "../pubUtils/util";
|
||||
import { STATUS, FRIEND_RELATION_TYPE } from "../consts";
|
||||
import { FriendShipType } from "../db/FriendShip";
|
||||
import { outputCnt } from '../pubUtils/friendUtil';
|
||||
|
||||
/**
|
||||
* 增加双方好友数
|
||||
@@ -48,4 +50,41 @@ export function getRecommendType(myFriendRelation: FriendRelationType, myRoleId:
|
||||
return FRIEND_RELATION_TYPE.HAS_BLOCKED;
|
||||
}
|
||||
return FRIEND_RELATION_TYPE.NORMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据收到的新及时间排序
|
||||
*
|
||||
* @param roleId 自己的玩家id
|
||||
* @param list 需要排序列表
|
||||
*/
|
||||
export function sortByBeSentHeart(roleId: string, list: Relation[]) {
|
||||
|
||||
let result = list.map(cur => {
|
||||
let json = getSentHeart(roleId, cur);
|
||||
return {...cur, ...json};
|
||||
})
|
||||
result.sort((a, b) => {
|
||||
if(a.beSentHeart == b.beSentHeart) {
|
||||
return a.beSentHeartTime - b.beSentHeartTime;
|
||||
} else {
|
||||
return b.beSentHeart - a.beSentHeart;
|
||||
}
|
||||
});
|
||||
return result
|
||||
}
|
||||
|
||||
function getSentHeart(roleId: string, relation: Relation) {
|
||||
let friendShip = <FriendShipType>relation.friendShip;
|
||||
let json = outputCnt(roleId, friendShip);
|
||||
if(!json) {
|
||||
return {
|
||||
beSentHeart: 0,
|
||||
beSentHeartTime: 0
|
||||
}
|
||||
}
|
||||
return {
|
||||
beSentHeart: json.beSentHeart,
|
||||
beSentHeartTime: json.beSentHeartTime
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user