协议调试
This commit is contained in:
@@ -4,6 +4,10 @@ import type { IGirlService } from "./IGirlService";
|
||||
import { ConfigManager, ConfigId } from "../../manager/ConfigManager";
|
||||
import { GirlConfig } from "../../config/GirlConfig";
|
||||
import { GirlDetailConfig } from "../../config/GirlDetailConfig";
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
import { WalletData } from "../../data/WalletData";
|
||||
|
||||
export class MockGirlService implements IGirlService {
|
||||
private delay(ms = 180) { return new Promise<void>(r => setTimeout(r, ms)); }
|
||||
private randInt(min: number, max: number) { return Math.floor(Math.random() * (max - min + 1)) + min; }
|
||||
@@ -240,20 +244,61 @@ export class MockGirlService implements IGirlService {
|
||||
}
|
||||
|
||||
// 解锁技师
|
||||
async reqUnlockGirl(_req: proto.cs.ICSUnlockGirlReq): Promise<ApiResponse<proto.cs.ICSUnlockGirlRes>> {
|
||||
async reqUnlockGirl(req: proto.cs.ICSUnlockGirlReq): Promise<ApiResponse<proto.cs.ICSUnlockGirlRes>> {
|
||||
// 延时
|
||||
await this.delay(180);
|
||||
// 请求数据
|
||||
const reqGirlId = req.id;
|
||||
// 数据层的数据
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
const category = girlData.getGrilCategoryById(reqGirlId);
|
||||
const price = girlData.getGrilPrice(category.toString(), reqGirlId);
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
// 余额
|
||||
let balanceNumber = Number(walletData.balance) - Number(price);
|
||||
let balance = balanceNumber.toString();
|
||||
// vip 30天后过期
|
||||
const nowSeconds = Math.floor(Date.now() / 1000);
|
||||
let vipExpire = nowSeconds + 30 * 24 * 3600;
|
||||
// 返回数据
|
||||
const res: proto.cs.ICSUnlockGirlRes = {};
|
||||
const res: proto.cs.ICSUnlockGirlRes = {
|
||||
balance,
|
||||
vipExpire,
|
||||
};
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
// 解锁资源
|
||||
async reqUnlockGirlRes(_req: proto.cs.ICSUnlockResourceReq): Promise<ApiResponse<proto.cs.ICSUnlockResourceRes>> {
|
||||
async reqUnlockGirlRes(req: proto.cs.ICSUnlockResourceReq): Promise<ApiResponse<proto.cs.ICSUnlockResourceRes>> {
|
||||
// 延时
|
||||
await this.delay(180);
|
||||
// 请求数据
|
||||
const reqGirlId = req.girlId;
|
||||
const resId = req.resId;
|
||||
const resType = req.type;
|
||||
// 数据层的数据
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
const category = girlData.getGrilCategoryById(reqGirlId);
|
||||
let price = 0;
|
||||
if (resType === proto.cs.EnmResType.ERT_Image) {
|
||||
// 图片
|
||||
price = girlData.getGrilPhotoPrice(category.toString(), reqGirlId, resId);
|
||||
} else if (resType === proto.cs.EnmResType.ERT_Video) {
|
||||
// 视频
|
||||
price = girlData.getGrilVideoPrice(category.toString(), reqGirlId, resId);
|
||||
}
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
// 余额
|
||||
let balanceNumber = Number(walletData.balance) - Number(price);
|
||||
let balance = balanceNumber.toString();
|
||||
// vip 30天后过期
|
||||
const nowSeconds = Math.floor(Date.now() / 1000);
|
||||
let vipExpire = nowSeconds + 30 * 24 * 3600;
|
||||
// 返回数据
|
||||
const res: proto.cs.ICSUnlockResourceRes = {};
|
||||
const res: proto.cs.ICSUnlockResourceRes = {
|
||||
balance,
|
||||
vipExpire,
|
||||
};
|
||||
return this.ok(res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import type { IShopService } from "./IShopService";
|
||||
import { PurchaseConfig } from "../../config/PurchaseConfig";
|
||||
import { ConfigManager, ConfigId } from "../../manager/ConfigManager";
|
||||
import { DataManager, DataId } from "../../data/DataManager";
|
||||
import { GirlData } from "../../data/GirlData";
|
||||
import { WalletData } from "../../data/WalletData";
|
||||
import { ShopData } from "../../data/ShopData";
|
||||
|
||||
export class MockShopService implements IShopService {
|
||||
private delay(ms = 180) { return new Promise<void>(r => setTimeout(r, ms)); }
|
||||
@@ -26,7 +30,7 @@ export class MockShopService implements IShopService {
|
||||
}
|
||||
|
||||
// 获取商品列表
|
||||
async reqShopList(_req: proto.cs.ICSGetPurchaseReq): Promise<ApiResponse<proto.cs.ICSGetPurchaseRes>> {
|
||||
async reqShopList(req: proto.cs.ICSGetPurchaseReq): Promise<ApiResponse<proto.cs.ICSGetPurchaseRes>> {
|
||||
// 延时
|
||||
await this.delay();
|
||||
// 配置数据
|
||||
@@ -46,11 +50,42 @@ export class MockShopService implements IShopService {
|
||||
}
|
||||
|
||||
// 使用余额购买商品
|
||||
async reqBuyGood(_req: proto.cs.ICSBuyGoodReq): Promise<ApiResponse<proto.cs.ICSBuyGoodRes>> {
|
||||
async reqBuyGood(req: proto.cs.ICSBuyGoodReq): Promise<ApiResponse<proto.cs.ICSBuyGoodRes>> {
|
||||
// 延时
|
||||
await this.delay();
|
||||
// 请求数据
|
||||
const reqGirlId = req.girlId;
|
||||
const goodId = req.goodId;
|
||||
// 数据层的数据
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||
const category = girlData.getGrilCategoryById(reqGirlId);
|
||||
|
||||
let chatRemainCount = 0;
|
||||
if (shopData.isRechargeId(goodId)) {
|
||||
// 充值
|
||||
} else if (shopData.isMemberId(goodId)) {
|
||||
// 会员
|
||||
chatRemainCount = -1;
|
||||
} else if (shopData.isChatId(goodId)) {
|
||||
// 聊天
|
||||
const curCount = girlData.getChatRemainCount(category.toString(), reqGirlId);
|
||||
chatRemainCount = curCount + shopData.getCountById(goodId);
|
||||
}
|
||||
// 余额
|
||||
const price = shopData.getPriceById(goodId);
|
||||
let balanceNumber = Number(walletData.balance) - Number(price);
|
||||
let balance = balanceNumber.toString();
|
||||
// vip 30天后过期
|
||||
const nowSeconds = Math.floor(Date.now() / 1000);
|
||||
let vipExpire = nowSeconds + 30 * 24 * 3600;
|
||||
// 返回数据
|
||||
const res: proto.cs.ICSBuyGoodRes = {};
|
||||
const res: proto.cs.ICSBuyGoodRes = {
|
||||
balance,
|
||||
vipExpire,
|
||||
chatRemainCount,
|
||||
};
|
||||
return this.ok(res);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user