新武将活动:修改字段以及ur武将处理

This commit is contained in:
luying
2022-10-12 10:35:14 +08:00
parent eccd9f0051
commit 9f5771e923
16 changed files with 79 additions and 69 deletions

View File

@@ -235,6 +235,7 @@ export enum HERO_QUALITY_TYPE {
BLUE = 1, // 蓝将
PURPLE = 2, // 紫将
GOLD = 3, // 金
UR = 4, // ur武将
}
export const FIX_ATTRIBUTES_RAN = 20; // 固定属性值+-20%随机

View File

@@ -434,7 +434,7 @@ export const STATUS = {
// 抽卡相关 31101-31200
GACHA_COST_NOT_ENOUGH: { code: 31101, simStr: '招募券不足' },
GACHA_NOT_ASSIGN: { code: 31102, simStr: '请选择武将' },
GACHA_HOPE_NOT_GOLD: { code: 31103, simStr: '武将品质错误' },
GACHA_HOPE_NOT_GOLD: { code: 31103, simStr: '武将不可许愿' },
GACHA_CAN_NOT_PICK: { code: 31104, simStr: '不可选择该武将' },
GACHA_TURNTABLE_POINT_NOT_ENOUGH: { code: 31105, simStr: '转盘积分不足' },
GACHA_HAS_VISITED: { code: 31106, simStr: '该武将已拜访过' },

View File

@@ -224,9 +224,9 @@ export default class Hero extends BaseModel {
public static getInitInfo(hid: number, heroInfo: HeroUpdate = {}): HeroUpdate {
let dicHero = gameData.hero.get(hid)
let { quality, initialStars: star, jobid: job, name: hName } = dicHero;
let { quality, initialStar: star, initialColorStar: colorStar, jobid: job, name: hName } = dicHero;
const doc = new HeroModel();
const update = { ...doc.toJSON(), hid, skinId: hid, hName, star, quality, job, lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0, ...heroInfo};
const update = { ...doc.toJSON(), hid, skinId: hid, hName, star, colorStar, quality, job, lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0, ...heroInfo};
delete update._id;
return update
}

View File

@@ -6,12 +6,10 @@ import { ActivityBase } from './activityField';
/******* 存在数据库里的数据 *******/
interface NewHeroGkWarInDb {
warId: number; // 关卡id
icon: string; // 图标文件名
startDay: number; // 活动第几天开启
}
interface NewHeroGkDataInDb {
bg: string; // 背景图
wars: NewHeroGkWarInDb[]; // 关卡
}
@@ -19,13 +17,11 @@ interface NewHeroGkDataInDb {
// 每日关卡活动数据
export class NewHeroGachaWar {
warId: number; // 关卡id
icon: string; // 图标文件名
startTime: number; // 活动第几天开启13位时间戳
isSuccess: boolean = false; // 是否成功
constructor(data: NewHeroGkWarInDb, beginTime: number) {
this.warId = data.warId;
this.icon = data.icon;
this.startTime = <number>getTimeFunM(beginTime).getAfterDayWithHour(data.startDay - 1);
}
@@ -35,7 +31,6 @@ export class NewHeroGachaWar {
}
export class NewHeroGKData extends ActivityBase {
bg: string; // 背景图
wars: NewHeroGachaWar[] = []; // 关卡
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
@@ -45,7 +40,6 @@ export class NewHeroGKData extends ActivityBase {
public initData(data: string) {
let dataObj: NewHeroGkDataInDb = JSON.parse(data);
this.bg = dataObj.bg;
let arr = dataObj.wars||[];
for (let obj of arr) {
this.wars.push(new NewHeroGachaWar(obj, this.beginTime))

View File

@@ -1,33 +1,34 @@
import { ActivityModelType } from '../../db/Activity';
import { UserGachaType } from '../../db/UserGacha';
import { DicGacha } from '../../pubUtils/dictionary/DicGacha';
import { RewardInter } from '../../pubUtils/interface';
import { ActivityBase } from './activityField';
interface NewHeroGachaItemInDb {
hid: number;
position: string; // x&y
isDefault: boolean;
}
interface NewHeroGachaDataInDb {
gachaId: number; // dic_zyz_gacha表的id卡池的概率消耗都通过这个表读取
icon: string; // 大地图的icon图片文件名
heroes: NewHeroGachaItemInDb[]; // 本期活动pick的武将
bg: string; // 首页背景图片
uiType: number; // 布局格式,具体什么代表什么含义由策划和客户端定
}
class NewHeroGachaItem {
hid: number;
isDefault: boolean;
constructor(hero: NewHeroGachaItemInDb) {
this.hid = hero.hid;
this.isDefault = hero.isDefault;
}
}
// 每日关卡活动数据
export class NewHeroGachaData extends ActivityBase {
gachaId: number;
icon: string;
heroes: NewHeroGachaItemInDb[];
bg: string;
uiType: number;
heroes: NewHeroGachaItem[] = [];
pickHero: number = 0;
count: number = 0;
isFree: boolean = false; // 免费次数
cost: RewardInter[] = []; // 消耗
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
super(activityData, createTime, serverTime)
@@ -37,25 +38,30 @@ export class NewHeroGachaData extends ActivityBase {
public initData(data: string) {
let dataObj: NewHeroGachaDataInDb = JSON.parse(data);
this.gachaId = dataObj.gachaId;
this.icon = dataObj.icon;
this.heroes = dataObj.heroes;
this.bg = dataObj.bg;
this.uiType = dataObj.uiType;
let heroes = dataObj.heroes||[];
for(let hero of heroes) {
this.heroes.push(new NewHeroGachaItem(hero))
}
}
public findItem(hid: number) {
return this.heroes.find(obj => { return obj && obj.hid == hid })
}
public getDefaultHero() {
let hero = this.heroes.find(obj => obj.isDefault)||this.heroes[0];
return hero?.hid||0;
}
//解析玩家记录
public setPlayerRecords(data: UserGachaType, dic: DicGacha) {
if(dic) this.cost = dic.cost;
if (data) {
this.pickHero = data.pickHero;
this.count = data.count;
this.isFree = data.freeCount < dic?.free.count;
}
}
public isPickHero(hid: number) {
return this.heroes.findIndex(cur => cur.hid == hid) != -1;

View File

@@ -1,24 +1,17 @@
import moment = require('moment');
import { ActivityModelType } from '../../db/Activity';
import { ActivityNewHeroGiftModelType } from '../../db/ActivityNewHeroGift';
import { ActivityBase } from './activityField';
/******* 存在数据库里的数据 *******/
interface NewHeroGiftExplain {
index: number;
explain: string;
}
interface NewHeroGiftRewardInDb {
index: number; // 下标
cover: string; // 翻牌背面的图片文件名
reward: string; // 奖励 type&id&count
countMax: number; // 最多抽出次数
}
interface NewHeroGiftDataInDb {
hid: number; // 左侧的立绘武将
position: string; // 位置 x&y
explain: NewHeroGiftExplain[]; // 玩法说明
startTaskTime: string; // 开始计算任务积分的时间 hh:mm:ss
rewards: NewHeroGiftRewardInDb[]; // 奖励
consumePoint: number; // 每转一次消耗的点数
}
@@ -26,14 +19,12 @@ interface NewHeroGiftDataInDb {
/******* 返回给客户端的数据 *******/
class NewHeroGiftReward {
index: number; // 下标
cover: string; // 翻牌背面的图片文件名
reward: string; // 奖励 type&id&count
countMax: number; // 最多抽出次数
buyCount: number = 0; // 转出的次数
constructor(data: NewHeroGiftRewardInDb) {
this.index = data.index;
this.cover = data.cover;
this.reward = data.reward;
this.countMax = data.countMax;
}
@@ -44,11 +35,9 @@ class NewHeroGiftReward {
}
export class NewHeroGiftData extends ActivityBase {
hid: number; // 左侧的立绘武将
position: string; // 位置 x&y
consumePoint: number; // 每转一次消耗的点数
explain: NewHeroGiftExplain[]; // 玩法说明
rewards: NewHeroGiftReward[] = []; // 奖励
startTaskTime: number; // 开始计算任务积分的时间 时间戳
totalPoint: number = 0; // 已获得的点数
consumeTotalPoint: number = 0; // 总消耗的点数
@@ -60,14 +49,12 @@ export class NewHeroGiftData extends ActivityBase {
public initData(data: string) {
let dataObj: NewHeroGiftDataInDb = JSON.parse(data);
this.hid = dataObj.hid;
this.position = dataObj.position;
this.consumePoint = dataObj.consumePoint;
this.explain = dataObj.explain
let arr = dataObj.rewards||[];
for (let obj of arr) {
this.rewards.push(new NewHeroGiftReward(obj))
}
this.startTaskTime = moment(moment(this.beginTime).format(`YYYY-MM-DD ${dataObj.startTaskTime}`)).valueOf();
}
public findItem(index: number) {
@@ -88,4 +75,7 @@ export class NewHeroGiftData extends ActivityBase {
}
}
public canRecordTaskPoint() {
return Date.now() >= this.startTaskTime && Date.now() <= this.endTime
}
}

View File

@@ -62,13 +62,8 @@ export class PvpHeroInfo {
this.actorName = dicHero.name;
this.quality = dicHero.quality;
this.job = dicHero.jobid;
if(dicHero.quality == 4) {
this.star = 6;
this.colorStar = dicHero.initialStars;
} else {
this.star = dicHero.initialStars;
}
this.star = dicHero.initialStar;
this.colorStar = dicHero.initialColorStar;
this.lv = lv;
}

View File

@@ -22,7 +22,9 @@ export interface DicHero {
// 武将碎片
readonly pieceId: number;
// 初始星级
readonly initialStars: number;
readonly initialStar: number;
// 初始星级
readonly initialColorStar: number;
// 合成碎片数量
readonly pieceCount: number;
// 主属性
@@ -38,7 +40,7 @@ export interface DicHero {
}
type KeysEnum<T> = { [P in keyof Required<T>]: true };
const DicHeroKeys: KeysEnum<DicHero> = {heroId: true, name: true, quality: true, camp: true, jobClass: true, jobid: true, skill: true, pieceId: true, initialStars: true, pieceCount: true, baseAbilityArr: true, baseAbilityUpArr: true, initialSkin: true, recruit: true, face_id: true, talentId: true};
const DicHeroKeys: KeysEnum<DicHero> = {heroId: true, name: true, quality: true, camp: true, jobClass: true, jobid: true, skill: true, pieceId: true, initialStar: true, initialColorStar: true, pieceCount: true, baseAbilityArr: true, baseAbilityUpArr: true, initialSkin: true, recruit: true, face_id: true, talentId: true};
export const dicHero = new Map<number, DicHero>();
export function loadHero() {
dicHero.clear();
@@ -48,6 +50,13 @@ export function loadHero() {
o.baseAbilityArr = parseBaseAbilityArr(o);
o.baseAbilityUpArr = parseBaseAbilityUpArr(o);
o.recruit = parseInt(o.recruit) == 1;
if(o.quality == 4) {
o.initialStar = 6;
o.initialColorStar = o.initialStars - 6;
} else {
o.initialStar = o.initialStars;
o.initialColorStar = 0;
}
dicHero.set(o.heroId, _.pick(o, Object.keys(DicHeroKeys)));
});
arr = undefined;

View File

@@ -10,16 +10,20 @@ export interface DicRecruit {
readonly actorId: number;
// 权重
readonly weight: number;
// 是否可以拜访
readonly canVisit: number;
// 是否可以许愿
readonly canHope: number;
}
export const dicRecruit = new Array<DicRecruit>();
export const dicRecruit = new Map<number, DicRecruit>();
export function loadRecruit() {
dicRecruit.splice(0, dicRecruit.length);
dicRecruit.clear();
let arr = readFileAndParse(FILENAME.DIC_RECRUIT);
arr.forEach(o => {
dicRecruit.push(o);
dicRecruit.set(o.actorId, o);
});
arr = undefined;