pvp:随机对手
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
import { PvpDefenseModel, PvpDefenseType, pvpUpdateInter } from '../db/PvpDefense';
|
||||
import { Defense, Attack, LineupCe, OppPlayer, HeroScore, HeroReward, OppPlayerReturn, AttackHero, DefenseHero } from '../domain/battleField/pvp';
|
||||
import { RoleType } from '../db/Role';
|
||||
import { REDIS_KEY, TASK_TYPE, MAIL_TYPE, TA_EVENT } from '../consts';
|
||||
import { REDIS_KEY, TASK_TYPE, MAIL_TYPE, TA_EVENT, ITID, getHeadItid, getFrameItid, getSpineItid } from '../consts';
|
||||
import { dicPvpOpponent, DicPvpOpponent } from "../pubUtils/dictionary/DicPvpOpponent";
|
||||
import { getRandSingleIndex, genCode, shouldRefresh, getChineseName, makeRobotId, robotIdComBack, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { pvpEndParamInter, RewardInter } from '../pubUtils/interface';
|
||||
import { gameData, getPLvByScore, getPvpHeroRewardsByScore, getPvpRankRewardsByRank, getPvpDifficultByScore, getPlvAndScore, getPvpBoxsBySeasonNum, getPvpRankMaxRewardsBySeasonNum } from "../pubUtils/data";
|
||||
import { PVP } from '../pubUtils/dicParam';
|
||||
import { gameData, getPLvByScore, getPvpHeroRewardsByScore, getPvpRankRewardsByRank, getPvpDifficultByScore, getPlvAndScore, getPvpBoxsBySeasonNum, getPvpRankMaxRewardsBySeasonNum, randomGoodsByItid } from "../pubUtils/data";
|
||||
import { EXTERIOR, PVP } from '../pubUtils/dicParam';
|
||||
import { PVPConfigModel, PVPConfigType } from '../db/SystemConfig'
|
||||
import { nowSeconds, getTimeFun } from '../pubUtils/timeUtil';
|
||||
import { HeroesRecord, PvpRecordPlayerInfo } from '../db/PvpRecord';
|
||||
@@ -275,9 +275,22 @@ async function matchRobot(chosenOpps: string[], role: RoleType, score: number, d
|
||||
if (hisPLv < 1) hisPLv = 1
|
||||
return {
|
||||
isRobot: true, roleId, oppRoleId, roleName, pos, defCe, pLv: hisPLv, lv: myLv, heroes, rankLv: 0, warId: result.war_id, buff: getRandSingleEelm(result.mapseid)||0,
|
||||
head: randomHead(), frame: randomFrame(), spine: randomSpine()
|
||||
};
|
||||
}
|
||||
|
||||
function randomHead() {
|
||||
return randomGoodsByItid(getHeadItid())||EXTERIOR.EXTERIOR_FACE;
|
||||
}
|
||||
|
||||
function randomFrame() {
|
||||
return randomGoodsByItid(getFrameItid())||EXTERIOR.EXTERIOR_FACECASE;
|
||||
}
|
||||
|
||||
function randomSpine() {
|
||||
return randomGoodsByItid(getSpineItid())||EXTERIOR.EXTERIOR_APPEARANCE;
|
||||
}
|
||||
|
||||
// 生成机器人roleId
|
||||
function generateRobotRoleId() {
|
||||
return `${genCode(10)}_r`;
|
||||
|
||||
@@ -204,6 +204,21 @@ export function getCurNameById(gid: number) {
|
||||
return currency.type;
|
||||
}
|
||||
|
||||
export function getHeadItid() {
|
||||
let dicItid = itid_array.find(cur => cur.table == 'role' && cur.type == CONSUME_TYPE.HEAD);
|
||||
return dicItid?.id;
|
||||
}
|
||||
|
||||
export function getFrameItid() {
|
||||
let dicItid = itid_array.find(cur => cur.table == 'role' && cur.type == CONSUME_TYPE.FRAME);
|
||||
return dicItid?.id;
|
||||
}
|
||||
|
||||
export function getSpineItid() {
|
||||
let dicItid = itid_array.find(cur => cur.table == 'role' && cur.type == CONSUME_TYPE.SPINE);
|
||||
return dicItid?.id;
|
||||
}
|
||||
|
||||
export enum QUALITY_TYPE {
|
||||
BLUE = 1, // 蓝
|
||||
PURPLE = 2, // 紫
|
||||
|
||||
@@ -57,7 +57,7 @@ import { dicCityActivityReward, loadCityActivityReward } from "./dictionary/DicC
|
||||
import { dicRaceActivity, dicRaceTypes, loadRaceActivity } from './dictionary/DicRaceActivity';
|
||||
import { GUILDACTIVITY, RECRUIT } from "./dicParam";
|
||||
import * as param from "./dicParam";
|
||||
import { decodeIdCntArrayStr, parseGoodStr, decodeArrayListStr, getRandEelm, readTsFile, getRandEelmWithWeight } from "./util";
|
||||
import { decodeIdCntArrayStr, parseGoodStr, decodeArrayListStr, getRandEelm, readTsFile, getRandEelmWithWeight, getRandSingleEelm } from "./util";
|
||||
import { RACE_EVENT_TYPE } from "../consts";
|
||||
import { dicShopByType, dicShopItem, loadShop } from "./dictionary/DicShop";
|
||||
import { dicShopType, loadShopType } from "./dictionary/DicShopType";
|
||||
@@ -425,6 +425,16 @@ export function getGoodById(gid: number) {
|
||||
return gameData.goods.get(gid);
|
||||
}
|
||||
|
||||
export function randomGoodsByItid(itid: number) {
|
||||
let result: number[] = [];
|
||||
for(let [id, dicGoods] of gameData.goods) {
|
||||
if(dicGoods.randomShow == 1 && dicGoods.itid == itid) {
|
||||
result.push(id);
|
||||
}
|
||||
}
|
||||
return getRandSingleEelm(result)
|
||||
}
|
||||
|
||||
export function getHeroJob(jobId: number) {
|
||||
const job = gameData.job.get(jobId);
|
||||
return job;
|
||||
|
||||
@@ -34,6 +34,8 @@ export interface DicGoods {
|
||||
readonly image_id: number;
|
||||
// 礼包id
|
||||
readonly gift: number;
|
||||
// 是否可以用于pvp随机
|
||||
readonly randomShow: number;
|
||||
}
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
@@ -51,6 +53,7 @@ const DicGoodsKeys: KeysEnum<DicGoods> = {
|
||||
timeLimit: true,
|
||||
image_id: true,
|
||||
gift: true,
|
||||
randomShow: true,
|
||||
}
|
||||
export const dicGoods = new Map<number, DicGoods>();
|
||||
export const figureCondition = new Map<number, { params: number[], id: number, gid: number }[]>(); // type => {params, id, gid}
|
||||
|
||||
Reference in New Issue
Block a user