寻宝:抽象队长匹配队友的逻辑;抽象 channel 中的用户

This commit is contained in:
liangtongchuan
2021-02-19 17:58:00 +08:00
parent ea5d507983
commit 45ce962709
4 changed files with 73 additions and 37 deletions
+10
View File
@@ -1,3 +1,5 @@
import { ChannelUser } from './../domain/ChannelUser';
import { Channel } from 'pinus';
import { getRandNum, getRandomArr } from '../pubUtils/util';
import { TERAPH_RANDOM } from "../consts/consts";
import { indexOf } from 'underscore';
@@ -57,4 +59,12 @@ export function checkMaterialEnough(count: number, attrs:Array<any>, teraphInfo:
consumes.push({ id, count: count*times});
}
return {attr: res, consumes};
}
export function addUserToChannel(channel: Channel, user: ChannelUser) {
const users = channel.getMembers();
const { uid, sid } = user;
if (users.indexOf(uid) === -1) {
channel.add(uid, sid);
}
}