军团活动:修改粮草先行道具分配
This commit is contained in:
+19
-12
@@ -60,7 +60,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, getRandValueByMinMax, getRandEelm, readTsFile, getRandEelmWithWeight } from "./util";
|
||||
import { decodeIdCntArrayStr, parseGoodStr, decodeArrayListStr, getRandEelm, readTsFile, getRandEelmWithWeight } from "./util";
|
||||
import { RACE_EVENT_TYPE } from "../consts";
|
||||
import { dicShop, dicShopItem, loadShop } from "./dictionary/DicShop";
|
||||
import { dicShopList, loadShopList } from "./dictionary/DicShopList";
|
||||
@@ -187,7 +187,7 @@ export const gameData = {
|
||||
raceActivityEvents: dicRaceActivity,
|
||||
raceTypes: dicRaceTypes,
|
||||
raceActivityEncounter: { events: new Map<number, number>(), eventNum: 0 },
|
||||
raceNormalItems: new Array<{id: number, min: number, max: number}>(),
|
||||
raceNormalItems: new Array<{id: number, total: number, max: number}>(),
|
||||
raceEventItems: new Array<{id: number, count: number}>(),
|
||||
shop: dicShop,
|
||||
shopItem: dicShopItem,
|
||||
@@ -617,14 +617,14 @@ function decodeRaceActivityEncounter() {
|
||||
function decodeRaceNormalItems() {
|
||||
let str = GUILDACTIVITY.RACEACTIVITY_NORMAL_ITEMS;
|
||||
|
||||
let result = new Array<{ id: number, min: number, max: number }>();
|
||||
let result = new Array<{ id: number, total: number, max: number }>();
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let [id, min, max] of decodeArr) {
|
||||
if (isNaN(parseInt(id)) || isNaN(parseInt(min)) || isNaN(parseInt(max))) {
|
||||
for (let [id, total, max] of decodeArr) {
|
||||
if (isNaN(parseInt(id)) || isNaN(parseInt(total)) || isNaN(parseInt(max))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({ id: parseInt(id), min: parseInt(min), max: parseInt(max) });
|
||||
result.push({ id: parseInt(id), total: parseInt(total), max: parseInt(max) });
|
||||
}
|
||||
gameData.raceNormalItems = result;
|
||||
}
|
||||
@@ -635,15 +635,22 @@ function decodeRaceEventItems() {
|
||||
}
|
||||
|
||||
export function getRaceEventItems() {
|
||||
let items = gameData.raceNormalItems;
|
||||
let result = new Array<RewardInter>();
|
||||
for (let { id, min, max } of items) {
|
||||
let count = getRandValueByMinMax(min, max, 0);
|
||||
result.push({ id, count });
|
||||
let items = new Map<number, { total: number, max: number }>();
|
||||
for(let {id, total, max} of gameData.raceNormalItems) {
|
||||
items.set(id, { total, max });
|
||||
}
|
||||
return result;
|
||||
return items;
|
||||
}
|
||||
|
||||
// export function getRaceEventItems(members: WoodenHorseMember[], items: { id: number, total: number, max: number }[]) {
|
||||
// let result = new Array<RewardInter>();
|
||||
// for (let { id, min, max } of items) {
|
||||
// let count = getRandValueByMinMax(min, max, 0);
|
||||
// result.push({ id, count });
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// 根据保底类型获得保底数量
|
||||
export function getDicGachaFloor(id: number) {
|
||||
let map = decodeIdCntArrayStr(RECRUIT.RECRUIT_MUST, 1);
|
||||
|
||||
+23
-3
@@ -237,8 +237,8 @@ export function getRandEelmWithWeight<T extends { weight: number }>(randomList:
|
||||
* 不改变原数组长度,将内部元素打乱
|
||||
* @param source
|
||||
*/
|
||||
export function sortArrRandom(source = []) {
|
||||
let arr = deepCopy(source);
|
||||
export function sortArrRandom<T>(source: T[] = []): T[] {
|
||||
let arr: T[] = deepCopy(source);
|
||||
return arr.sort(() => { return Math.random() - 0.5; });
|
||||
}
|
||||
|
||||
@@ -752,4 +752,24 @@ export function getWarTypeName(warType: number) {
|
||||
case WAR_TYPE.TRY: return '试用关卡';
|
||||
case WAR_TYPE.BOSS: return '演武台';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 一群人分总数固定的东西
|
||||
* @param total 总数
|
||||
* @param max 每个人能拿到的最大数量
|
||||
* @param memberCnt 人数
|
||||
*/
|
||||
export function getRandResultByMember(total: number, max: number, memberCnt: number) {
|
||||
let arr: number[] = [];
|
||||
for(let i = 1; i <= memberCnt; i++) {
|
||||
let randMax = total > max? max: total;
|
||||
let randMin = total - (memberCnt - i) * max;
|
||||
if(randMin < 0) randMin = 0;
|
||||
if(randMin > max) randMin = max;
|
||||
let rand = getRandValueByMinMax(randMin, randMax + 1, 0);
|
||||
arr.push(rand);
|
||||
total -= rand;
|
||||
}
|
||||
return { arr, remain: total }
|
||||
}
|
||||
Reference in New Issue
Block a user