商店:一般购物流程

This commit is contained in:
luying
2021-03-31 17:52:34 +08:00
parent e487d07bfd
commit 8c8adacfdc
21 changed files with 1631 additions and 327 deletions

View File

@@ -69,6 +69,8 @@ import { dicRaceActivity, dicRaceTypes } from './dictionary/DicRaceActivity';
import { GUILDACTIVITY } from "./dicParam";
import { decodeIdCntArrayStr, parseGoodStr, decodeArrayListStr, getRandValueByMinMax } from "./util";
import { GUILD_SELECT, RACE_EVENT_TYPE } from "../consts";
import { dicShop, dicShopItem } from "./dictionary/DicShop";
import { dicShopList } from "./dictionary/DicShopList";
export const gameData = {
blurprtCompose: dicBlueprtCompose,
@@ -161,7 +163,10 @@ export const gameData = {
raceTypes: dicRaceTypes,
raceActivityEncounter: decodeRaceActivityEncounter(),
raceNormalItems: decodeRaceNormalItems(),
raceEventItems: decodeRaceEventItems()
raceEventItems: decodeRaceEventItems(),
shop: dicShop,
shopItem: dicShopItem,
shopList: dicShopList
};
// 在此提供一些原先在gamedata中提供的方法以便更方便获取gameData数据

View File

@@ -0,0 +1,45 @@
// 商店商品表
import { readJsonFile } from '../util'
import { FILENAME } from '../../consts'
export interface DicShop {
// 商品id
readonly id: number;
// 物品表id
readonly goodid: number;
// 物品表名
readonly goodname: number;
// 商店id 对应 dic_zyz_shoplist的id
readonly shop: number;
// 商店标签 对应 dic_zyz_shopType的id
readonly type: number;
// 军团等级需求
readonly guildLvLimit: number;
// 购买次数限制
readonly purchaseLimit: number;
// 刷新类型 1-每日 2-每周 3-每月
readonly refreshType: number;
// 用于购买的货币
readonly money: number;
// 价格
readonly price: number;
}
const str = readJsonFile(FILENAME.DIC_SHOP);
let arr = JSON.parse(str);
export const dicShopItem = new Map<number, DicShop>(); // itemid => DicShop
export const dicShop = new Map<number, DicShop[]>(); // shop => DicShop[]
arr.forEach(o => {
o.guildLvLimit = o.guildlvlimit == '&'?0: o.guildlvlimit;
o.purchaseLimit = o.purchaselimit == '&'?-1: o.purchaselimit;
if(!dicShop.has(o.shop)) {
dicShop.set(o.shop, [o]);
} else {
dicShop.get(o.shop).push(o);
}
dicShopItem.set(o.id, o);
});

View File

@@ -0,0 +1,26 @@
// 商店表
import { readJsonFile, parseNumberList } from '../util'
import { FILENAME } from '../../consts'
export interface DicShopList {
// 商店id
readonly shopid: number;
// 商店名
readonly shopname: number;
// 商店内标签,小分类
readonly type: number[];
// 使用的货币
readonly money: number[];
}
const str = readJsonFile(FILENAME.DIC_SHOP_LIST);
let arr = JSON.parse(str);
export const dicShopList = new Map<number, DicShopList>();
arr.forEach(o => {
o.type = parseNumberList(o.typeid);
o.money = parseNumberList(o.moneyid);
dicShopList.set(o.shopid, o);
});

View File

@@ -13,9 +13,9 @@ export function nowSeconds() {
return Math.floor(Date.now() / PER_SECOND );
}
export function getTodayZeroPoint() {
export function getTodayZeroPoint(hour = 0) {
var date = new Date();
date.setHours(0);
date.setHours(hour);
date.setMinutes(0);
date.setSeconds(0);
var time = Math.floor(date.getTime() / PER_SECOND);
@@ -78,6 +78,28 @@ export function getCurWeekTime(day: number, hour: number) {
return Math.floor(data.getTime()/PER_SECOND);
}
export function getCurMonthDate(day: number, hour: number) {
return getMonthDate(new Date(), day, hour);
}
export function getCurMonthTime(day: number, hour: number) {
let data = getMonthDate(new Date(), day, hour);
return Math.floor(data.getTime()/PER_SECOND);
}
/**
* @description 获取某个时间的当月的某一天的某一时
* @param {{Date}} now 时间
* @param {{number}} day 哪天
* @param {{number}} hour 几点
*/
export function getMonthDate(now: Date, day: number, hour: number){ //获得本周的开端日期
let nowYear = now.getFullYear(); //当前年
let nowMonth = now.getMonth(); //月
return new Date(nowYear, nowMonth, day, hour);
};
export function getHourPoint(hour: number) {
var date = new Date();
date.setHours(hour);
@@ -115,9 +137,9 @@ export function getNextHourPoint(hour: number) {
return time;
}
export function getTodayZeroDate() {
export function getTodayZeroDate(hour = 0) {
var date = new Date();
date.setHours(0);
date.setHours(hour);
date.setMinutes(0);
date.setSeconds(0);
return date;