活动:大富翁
This commit is contained in:
@@ -22,6 +22,7 @@ import { getPlayerDailyRMBGiftsData } from './dailyRMBGiftsService';
|
||||
import { getPlayerDailyGKData } from './dailyGKService';
|
||||
import { getPlayerRefreshShopData } from './refreshShopService';
|
||||
import { getPlayerRefreshTaskData } from './refreshTaskService';
|
||||
import { getMonopolyActivity, getPlayerMonopolyData } from './monopolyService';
|
||||
|
||||
/**
|
||||
* 获取活动数据
|
||||
@@ -155,6 +156,11 @@ export async function getActivity(serverId: number, roleId: string, activityId:
|
||||
activityData = await getPlayerRefreshTaskData(activityId, serverId, roleId);
|
||||
break;
|
||||
}
|
||||
case ACTIVITY_TYPE.MONOPOLY://大富翁游戏 35
|
||||
{
|
||||
activityData = await getPlayerMonopolyData(activityId, serverId, roleId);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
console.log('未知活动类型.........')
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { ACTIVITY_TYPE } from '../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../db/Activity';
|
||||
import { ActivityDailyChallengesModel, ActivityDailyChallengesModelType } from '../db/ActivityDailyChallenges';
|
||||
import { ActivityMonopolyModel, ActivityMonopolyModelType } from '../db/ActivityMonopoly';
|
||||
import { ActivityMonopolyLandModel, ActivityMonopolyLandModelType } from '../db/ActivityMonopolyLand';
|
||||
import { ServerlistModel } from '../db/Serverlist';
|
||||
import { MonopolyData, LandItem } from '../domain/activityField/monopolyField';
|
||||
|
||||
|
||||
/**
|
||||
* 获取活动数据
|
||||
*
|
||||
* @param {number} serverId 区Id
|
||||
* @param {number} activityId 活动Id
|
||||
* @param {string} roleId 角色Id
|
||||
*
|
||||
*/
|
||||
export async function getMonopolyActivity(serverId: number, roleId: string) {
|
||||
let { activityGroupId } = await ServerlistModel.findByServerId(serverId);
|
||||
let activityDataArray: ActivityModelType[] = await ActivityModel.findOpenActivityByType(activityGroupId, ACTIVITY_TYPE.MONOPOLY, new Date());
|
||||
if (activityDataArray.length === 0) {
|
||||
return null;
|
||||
}
|
||||
let activityData: ActivityModelType = activityDataArray[0];
|
||||
let playerMonopolyData: ActivityMonopolyModelType = await ActivityMonopolyModel.findData(serverId, activityData.activityId, roleId);
|
||||
let playerLandData: ActivityMonopolyLandModelType[] = await ActivityMonopolyLandModel.findData(serverId, activityData.activityId, roleId);
|
||||
let playerData = new MonopolyData(activityData);
|
||||
playerData.setPlayerRecords(playerMonopolyData, playerLandData);
|
||||
return playerData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 玩家玩家活动数据
|
||||
*
|
||||
* @param {number} serverId 区Id
|
||||
* @param {number} activityId 活动Id
|
||||
* @param {string} roleId 角色Id
|
||||
*
|
||||
*/
|
||||
export async function getPlayerMonopolyData(activityId: number, serverId: number, roleId: string) {
|
||||
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId);
|
||||
if (!activityData) {
|
||||
return null;
|
||||
}
|
||||
let playerMonopolyData: ActivityMonopolyModelType = await ActivityMonopolyModel.findData(serverId, activityData.activityId, roleId);
|
||||
let playerLandData: ActivityMonopolyLandModelType[] = await ActivityMonopolyLandModel.findData(serverId, activityData.activityId, roleId);
|
||||
let playerData = new MonopolyData(activityData);
|
||||
playerData.setPlayerRecords(playerMonopolyData, playerLandData);
|
||||
return playerData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家玩家活动数据
|
||||
*
|
||||
* @param {number} position 当前位置
|
||||
* @param {number} addStep 移动步数
|
||||
* @param {number} max 最大位置
|
||||
*
|
||||
*/
|
||||
export function nextPosition(position: number, addStep: number, max: number) {
|
||||
let temp = (position + addStep) % max;
|
||||
return (temp == 0) ? max : temp;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ import { makeGrowthFund } from './growthFundService';
|
||||
import { makeLimitPackageReward } from './limitPackageService';
|
||||
import { makeShop } from './treasureHuntService';
|
||||
import { makeSelfServerShop } from './selfServiceShopActivityService';
|
||||
import { makeRefreshShopReward } from './refreshShopService';
|
||||
import { ActivityMonopolyModel, ActivityMonopolyModelType } from '../db/ActivityMonopoly';
|
||||
import { ActivityMonopolyLandModel, ActivityMonopolyLandModelType } from '../db/ActivityMonopolyLand';
|
||||
|
||||
|
||||
|
||||
@@ -115,6 +118,21 @@ export async function makeOrder(localOrderID: string, sid: string, orderInfo: Us
|
||||
rewardResult = await makeSelfServerShop(roleId, roleInfo.roleName, sid, orderInfo.serverId, roleInfo.funcs, orderInfo.activityId, orderInfo.productID)
|
||||
break;
|
||||
}
|
||||
case ACTIVITY_TYPE.REFRESH_SHOP://通用的刷新商店(分页,可刷新,限制购买次数,支持rmb与资源兑换)
|
||||
{
|
||||
if (orderInfo.paramStr) {//大富翁商店结算
|
||||
let paramObj = JSON.parse(orderInfo.paramStr);
|
||||
let activityId = paramObj.activityId;//大富翁活动id; orderInfo.activityId是大富翁中的商店活动id
|
||||
let playerMonopolyData: ActivityMonopolyModelType = await ActivityMonopolyModel.findData(orderInfo.serverId, activityId, roleId);
|
||||
let playerLandData: ActivityMonopolyLandModelType = await ActivityMonopolyLandModel.findDataByPosition(orderInfo.serverId, activityId, roleId, playerMonopolyData.curPosition);
|
||||
let roundIndex = playerLandData.stopCount;
|
||||
rewardResult = await makeRefreshShopReward(roleId, roleInfo.roleName, sid, orderInfo.serverId, roleInfo.funcs, orderInfo.activityId, orderInfo.productID, roundIndex)
|
||||
|
||||
} else {//正常商店结算
|
||||
rewardResult = await makeRefreshShopReward(roleId, roleInfo.roleName, sid, orderInfo.serverId, roleInfo.funcs, orderInfo.activityId, orderInfo.productID, 0)
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
rewardResult = STATUS.ERROR_TYPE;
|
||||
break;
|
||||
|
||||
@@ -48,6 +48,23 @@ export async function getPlayerRefreshShopData(activityId: number, serverId: num
|
||||
return playerData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家商店数据(指定回合数,大富翁商店每回合刷新)
|
||||
*
|
||||
* @param {number} serverId 区Id
|
||||
* @param {number} activityId 活动Id
|
||||
* @param {string} roleId 角色Id
|
||||
*
|
||||
*/
|
||||
export async function getPlayerRefreshShopDataByRoundIndex(activityId: number, serverId: number, roleId: string, roundIndex: number) {
|
||||
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId);
|
||||
let playerData = new RefreshShopData(activityData);
|
||||
playerData.roundIndex = roundIndex;
|
||||
let playerRecord: ActivityRefreshShopModelType = await ActivityRefreshShopModel.findData(activityId, roleId, playerData.roundIndex);
|
||||
playerData.setPlayerRecords(playerRecord);
|
||||
return playerData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家活动第几天
|
||||
*
|
||||
@@ -73,10 +90,11 @@ export async function newPlayerActivityDays(roleId: string) {
|
||||
* @param {number} activityId 活动Id
|
||||
* @param {string} roleId 角色Id
|
||||
* @param {string} productID 商品ID
|
||||
* @param {number} roundIndex 大富翁重置回合数
|
||||
*
|
||||
*/
|
||||
export async function makeRefreshPackageReward(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[],
|
||||
activityId: number, productID: string) {
|
||||
export async function makeRefreshShopReward(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[],
|
||||
activityId: number, productID: string, roundIndex: number) {
|
||||
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId);
|
||||
if (!activityData) {
|
||||
return STATUS.ACTIVITY_MISSING;
|
||||
@@ -85,6 +103,9 @@ export async function makeRefreshPackageReward(roleId: string, roleName: string,
|
||||
return STATUS.ACTIVITY_TYPE_ERROR;
|
||||
}
|
||||
let playerData = new RefreshShopData(activityData);
|
||||
if (roundIndex) {
|
||||
playerData.roundIndex = roundIndex;
|
||||
}
|
||||
|
||||
let playerRecord: ActivityRefreshShopModelType = await ActivityRefreshShopModel.findData(activityData.activityId, roleId, playerData.roundIndex);
|
||||
playerData.setPlayerRecords(playerRecord);
|
||||
|
||||
Reference in New Issue
Block a user