商店:一般购物流程
This commit is contained in:
@@ -215,7 +215,7 @@ export class CityActivityObject {
|
||||
|
||||
// 军团诸侯混战等数据
|
||||
export class RaceActivityObject {
|
||||
private status = 0; // 活动状态 0-未开始 1-已开始 2-已结束
|
||||
private status = 0; // 活动状态 0-未开始 1-已开始 2-已结束 // TODO 写进const表
|
||||
public guildList: Array<{ serverId: number, guildCode: string }> = []; // 所有军团
|
||||
private members: Map<string, Array<Member>> = new Map(); // 每个军团参与的成员 guildCode => [{roleId, job}]
|
||||
private woodenHorses: Map<string, WoodenHorse> = new Map(); // 每个军团的木牛流马 guildCode => WoodenHorse
|
||||
@@ -250,7 +250,7 @@ export class RaceActivityObject {
|
||||
woodenHorse.joinMember(roleId, roleName, sid)
|
||||
this.pushMember(guildCode, roleId, job);
|
||||
|
||||
if(this.status == 1) {
|
||||
if(this.status == 1) { // TODO 写进const表
|
||||
let item = getRaceEventItems();
|
||||
this.handleItems(roleId, sid, item);
|
||||
}
|
||||
@@ -269,14 +269,14 @@ export class RaceActivityObject {
|
||||
let { name: guildName, guildCe } = guild;
|
||||
this.woodenHorses.set(guildCode, new WoodenHorse(guildCode, guildName, guildCe, serverId));
|
||||
this.guildList.push({guildCode, serverId});
|
||||
if(this.status == 1) {
|
||||
if(this.status == 1) { // TODO 写进const表
|
||||
this.woodenHorseStartRace(this.woodenHorses.get(guildCode));
|
||||
}
|
||||
}
|
||||
let woodenHorse = this.woodenHorses.get(guildCode);
|
||||
let events = this.events.get(guildCode)||[];
|
||||
let needSendEnd = woodenHorse.calCurWoodenHorse(events);
|
||||
if(woodenHorse.status == 1 || woodenHorse.status == 2) { // 更新距离
|
||||
if(woodenHorse.status == 1 || woodenHorse.status == 2) { // 更新距离 // TODO 写进const表
|
||||
await setRankWithoutUserInfo(REDIS_KEY.RACE_ACTIVITY, serverId, guildCode, woodenHorse.distance, Math.floor((woodenHorse.time - woodenHorse.startTime)/1000), true, false);
|
||||
if (needSendEnd) { // 抵达后发送奖励,发送消息,结算
|
||||
await sendSingleRaceActEndMsg(guildCode, woodenHorse);
|
||||
@@ -305,7 +305,7 @@ export class RaceActivityObject {
|
||||
|
||||
// 定时任务到,开始比赛,设置开始赛道,发放初始道具
|
||||
public startRace() {
|
||||
this.status = 1;
|
||||
this.status = 1; // TODO 写进const表
|
||||
let guildCodes = new Array<string>();
|
||||
for(let [code, woodenHorse] of this.woodenHorses) {
|
||||
this.woodenHorseStartRace(woodenHorse);
|
||||
@@ -315,7 +315,7 @@ export class RaceActivityObject {
|
||||
}
|
||||
|
||||
private woodenHorseStartRace(woodenHorse: WoodenHorse) {
|
||||
woodenHorse.status = 1;
|
||||
woodenHorse.status = 1; // TODO 写进const表
|
||||
woodenHorse.time = Date.now();
|
||||
woodenHorse.startTime = Date.now();
|
||||
let members = woodenHorse.members;
|
||||
@@ -459,7 +459,7 @@ export class WoodenHorse {
|
||||
*/
|
||||
public calCurWoodenHorse(events: Event[]): boolean {
|
||||
console.log('**', JSON.stringify(events))
|
||||
if(this.status == 2) return false;
|
||||
if(this.status == 2) return false; // TODO 写进const表
|
||||
if(this.status == 0 && this.stopContinueTime && Date.now() > this.stopContinueTime) {
|
||||
this.status = 1; this.stopContinueTime = 0;
|
||||
}
|
||||
@@ -528,7 +528,7 @@ export class WoodenHorse {
|
||||
case RACE_EVENT.GUISHOUYINFU:
|
||||
if (this.shieldTime < Date.now()) {
|
||||
this.stopContinueTime = endTime;
|
||||
this.status = 0;
|
||||
this.status = 0; // TODO 写进const表
|
||||
}
|
||||
break;
|
||||
case RACE_EVENT.FENGCHE:
|
||||
@@ -538,9 +538,9 @@ export class WoodenHorse {
|
||||
this.shield += count * effect[0]; break;
|
||||
case RACE_EVENT.TIANSHIDUNFU:
|
||||
this.shieldTime = endTime; break;
|
||||
case RACE_EVENT.JIANSU_1:
|
||||
case RACE_EVENT.JIASU_1:
|
||||
this.speed *= 1 + effect[0]; break;
|
||||
case RACE_EVENT.JIANSU_2:
|
||||
case RACE_EVENT.JIASU_2:
|
||||
this.speed += effect[0]; break;
|
||||
case RACE_EVENT.HUIFU_1:
|
||||
this.durability += effect[0];
|
||||
@@ -570,7 +570,7 @@ export class WoodenHorse {
|
||||
break;
|
||||
}
|
||||
if(this.durability <= 0) {
|
||||
this.status = 0;
|
||||
this.status = 0; // TODO 写进const表
|
||||
this.speed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,4 +279,18 @@ export class DividendRec {
|
||||
total: number; // 总分红
|
||||
@prop({ required: true, default: 0 })
|
||||
status: number; // 0:未领取,1:已领取
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 商店商品
|
||||
* @export
|
||||
* @class ShopItem
|
||||
*/
|
||||
export class ShopItem {
|
||||
@prop({ required: true, default: 0 })
|
||||
id: number; // 商品id shopItemId
|
||||
@prop({ required: true, default: 0 })
|
||||
order: number; // 显示排序
|
||||
@prop({ required: true, default: 0 })
|
||||
discount: number; // 折扣
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { EXTERIOR } from "../pubUtils/dicParam";
|
||||
import { WoodenHorse } from "./battleField/guildActivity";
|
||||
|
||||
// 排行榜返回玩家值
|
||||
export class RankParam {
|
||||
@@ -65,10 +66,10 @@ export class GuildLeader {
|
||||
}
|
||||
|
||||
export class SimpleGuildRankParam {
|
||||
rank: number;
|
||||
code: string;
|
||||
name: string;
|
||||
num: number;
|
||||
rank: number = 0;
|
||||
code: string = "";
|
||||
name: string = "";
|
||||
num: number = 0;
|
||||
|
||||
constructor(rank: number, code: string, name: string, num: number) {
|
||||
this.rank = rank;
|
||||
@@ -79,13 +80,16 @@ export class SimpleGuildRankParam {
|
||||
}
|
||||
|
||||
export class SimpleGuildRankWithTimeParam extends SimpleGuildRankParam {
|
||||
time: number;
|
||||
durability: number;
|
||||
time: number = 0;
|
||||
durability: number = 0;
|
||||
|
||||
constructor(rank: number, code: string, name: string, num: number, time: number, durability: number) {
|
||||
super(rank, code, name, num);
|
||||
this.time = time;
|
||||
this.durability = durability;
|
||||
constructor(rank: number, code: string, name: string, obj: WoodenHorse|false) {
|
||||
super(rank, code, name, obj?obj.distance:0);
|
||||
if(obj) {
|
||||
this.num = obj.distance;
|
||||
this.time = Math.floor((obj.time - obj.startTime)/1000);
|
||||
this.durability = obj.durability;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
17
shared/domain/roleField/shop.ts
Normal file
17
shared/domain/roleField/shop.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
// hero表内属性基础格式
|
||||
export class ShopItemListParam {
|
||||
shopItemId: number;
|
||||
discount: number;
|
||||
typeId: number;
|
||||
buyCount: number;
|
||||
order: number;
|
||||
|
||||
constructor(shopItemId: number, discount: number, typeId: number, buyCount: number, order: number) {
|
||||
this.shopItemId = shopItemId;
|
||||
this.discount = discount;
|
||||
this.typeId = typeId;
|
||||
this.buyCount = buyCount;
|
||||
this.order = order;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user