pvp:随机对手
This commit is contained in:
@@ -2,12 +2,12 @@
|
|||||||
import { PvpDefenseModel, PvpDefenseType, pvpUpdateInter } from '../db/PvpDefense';
|
import { PvpDefenseModel, PvpDefenseType, pvpUpdateInter } from '../db/PvpDefense';
|
||||||
import { Defense, Attack, LineupCe, OppPlayer, HeroScore, HeroReward, OppPlayerReturn, AttackHero, DefenseHero } from '../domain/battleField/pvp';
|
import { Defense, Attack, LineupCe, OppPlayer, HeroScore, HeroReward, OppPlayerReturn, AttackHero, DefenseHero } from '../domain/battleField/pvp';
|
||||||
import { RoleType } from '../db/Role';
|
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 { dicPvpOpponent, DicPvpOpponent } from "../pubUtils/dictionary/DicPvpOpponent";
|
||||||
import { getRandSingleIndex, genCode, shouldRefresh, getChineseName, makeRobotId, robotIdComBack, getRandSingleEelm } from '../pubUtils/util';
|
import { getRandSingleIndex, genCode, shouldRefresh, getChineseName, makeRobotId, robotIdComBack, getRandSingleEelm } from '../pubUtils/util';
|
||||||
import { pvpEndParamInter, RewardInter } from '../pubUtils/interface';
|
import { pvpEndParamInter, RewardInter } from '../pubUtils/interface';
|
||||||
import { gameData, getPLvByScore, getPvpHeroRewardsByScore, getPvpRankRewardsByRank, getPvpDifficultByScore, getPlvAndScore, getPvpBoxsBySeasonNum, getPvpRankMaxRewardsBySeasonNum } from "../pubUtils/data";
|
import { gameData, getPLvByScore, getPvpHeroRewardsByScore, getPvpRankRewardsByRank, getPvpDifficultByScore, getPlvAndScore, getPvpBoxsBySeasonNum, getPvpRankMaxRewardsBySeasonNum, randomGoodsByItid } from "../pubUtils/data";
|
||||||
import { PVP } from '../pubUtils/dicParam';
|
import { EXTERIOR, PVP } from '../pubUtils/dicParam';
|
||||||
import { PVPConfigModel, PVPConfigType } from '../db/SystemConfig'
|
import { PVPConfigModel, PVPConfigType } from '../db/SystemConfig'
|
||||||
import { nowSeconds, getTimeFun } from '../pubUtils/timeUtil';
|
import { nowSeconds, getTimeFun } from '../pubUtils/timeUtil';
|
||||||
import { HeroesRecord, PvpRecordPlayerInfo } from '../db/PvpRecord';
|
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
|
if (hisPLv < 1) hisPLv = 1
|
||||||
return {
|
return {
|
||||||
isRobot: true, roleId, oppRoleId, roleName, pos, defCe, pLv: hisPLv, lv: myLv, heroes, rankLv: 0, warId: result.war_id, buff: getRandSingleEelm(result.mapseid)||0,
|
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
|
// 生成机器人roleId
|
||||||
function generateRobotRoleId() {
|
function generateRobotRoleId() {
|
||||||
return `${genCode(10)}_r`;
|
return `${genCode(10)}_r`;
|
||||||
|
|||||||
@@ -204,6 +204,21 @@ export function getCurNameById(gid: number) {
|
|||||||
return currency.type;
|
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 {
|
export enum QUALITY_TYPE {
|
||||||
BLUE = 1, // 蓝
|
BLUE = 1, // 蓝
|
||||||
PURPLE = 2, // 紫
|
PURPLE = 2, // 紫
|
||||||
|
|||||||
+11
-1
@@ -57,7 +57,7 @@ import { dicCityActivityReward, loadCityActivityReward } from "./dictionary/DicC
|
|||||||
import { dicRaceActivity, dicRaceTypes, loadRaceActivity } from './dictionary/DicRaceActivity';
|
import { dicRaceActivity, dicRaceTypes, loadRaceActivity } from './dictionary/DicRaceActivity';
|
||||||
import { GUILDACTIVITY, RECRUIT } from "./dicParam";
|
import { GUILDACTIVITY, RECRUIT } from "./dicParam";
|
||||||
import * as param 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 { RACE_EVENT_TYPE } from "../consts";
|
||||||
import { dicShopByType, dicShopItem, loadShop } from "./dictionary/DicShop";
|
import { dicShopByType, dicShopItem, loadShop } from "./dictionary/DicShop";
|
||||||
import { dicShopType, loadShopType } from "./dictionary/DicShopType";
|
import { dicShopType, loadShopType } from "./dictionary/DicShopType";
|
||||||
@@ -425,6 +425,16 @@ export function getGoodById(gid: number) {
|
|||||||
return gameData.goods.get(gid);
|
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) {
|
export function getHeroJob(jobId: number) {
|
||||||
const job = gameData.job.get(jobId);
|
const job = gameData.job.get(jobId);
|
||||||
return job;
|
return job;
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ export interface DicGoods {
|
|||||||
readonly image_id: number;
|
readonly image_id: number;
|
||||||
// 礼包id
|
// 礼包id
|
||||||
readonly gift: number;
|
readonly gift: number;
|
||||||
|
// 是否可以用于pvp随机
|
||||||
|
readonly randomShow: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||||
@@ -51,6 +53,7 @@ const DicGoodsKeys: KeysEnum<DicGoods> = {
|
|||||||
timeLimit: true,
|
timeLimit: true,
|
||||||
image_id: true,
|
image_id: true,
|
||||||
gift: true,
|
gift: true,
|
||||||
|
randomShow: true,
|
||||||
}
|
}
|
||||||
export const dicGoods = new Map<number, DicGoods>();
|
export const dicGoods = new Map<number, DicGoods>();
|
||||||
export const figureCondition = new Map<number, { params: number[], id: number, gid: number }[]>(); // type => {params, id, gid}
|
export const figureCondition = new Map<number, { params: number[], id: number, gid: number }[]>(); // type => {params, id, gid}
|
||||||
|
|||||||
Reference in New Issue
Block a user