You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
236 lines
8.3 KiB
236 lines
8.3 KiB
using Google.Protobuf.WellKnownTypes;
|
|
using Org.BouncyCastle.Bcpg;
|
|
using ProtoCSStruct;
|
|
using Sog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Game
|
|
{
|
|
public static class HomeAdSvc
|
|
{
|
|
public static void InitOrReset(PlayerOnGame player)
|
|
{
|
|
//判断是否是初始化过或者同一天再刷
|
|
|
|
|
|
var openDay = GameServerUtils.GetOpenDay(player.RealmID);
|
|
if (player.RoleData.HomeAd.Infos.Count == 0 || openDay != player.RoleData.HomeAd.NextTime)
|
|
{
|
|
player.RoleData.HomeAd.Infos.Clear();
|
|
player.RoleData.HomeAd.NextTime = openDay;
|
|
}
|
|
|
|
foreach (var desc in AdvertisementConfigDescMgr.Instance.ItemTable.Values)
|
|
{
|
|
var index = -1;
|
|
for (int i = 0; i < player.RoleData.HomeAd.Infos.Count; i++)
|
|
{
|
|
if (player.RoleData.HomeAd.Infos[i].Id == desc.InternalId)
|
|
{
|
|
index = i;
|
|
break;
|
|
}
|
|
}
|
|
if (index > -1)
|
|
{
|
|
continue;
|
|
}
|
|
if (player.RoleData.HomeAd.Infos.Count >= player.RoleData.HomeAd.Infos.GetMaxCount())
|
|
{
|
|
TraceLog.Error("HomeAdEvent.OnRoleEnter error adCount more than GetMaxCount");
|
|
break;
|
|
}
|
|
var info = new DBADInfo
|
|
{
|
|
Id = desc.InternalId,
|
|
GetCount = 0,
|
|
ColdTime = 0
|
|
};
|
|
player.RoleData.HomeAd.Infos.Add(info);
|
|
}
|
|
SendAdInfo(player);
|
|
}
|
|
|
|
public static CSErrCode PassAd(PlayerOnGame player, int type)
|
|
{
|
|
int needMoney = 5;
|
|
|
|
UnifyOp bagOp = new UnifyOp(player, BillChangeItemReason.HomeAD, "PassAd");
|
|
bagOp.CostDiamond(needMoney);
|
|
if (bagOp.DoOp() != CSErrCode.None)
|
|
return CSErrCode.Fail;
|
|
|
|
CSErrCode ret = CSErrCode.Fail;
|
|
switch (type)
|
|
{
|
|
case 1: //钻石
|
|
break;
|
|
}
|
|
|
|
|
|
return ret;
|
|
}
|
|
|
|
public static void SendAdInfo(PlayerOnGame player, int advId = 0)
|
|
{
|
|
CSAdGetInfoRes res = new CSAdGetInfoRes();
|
|
for (int i = 0; i < player.RoleData.HomeAd.Infos.Count; i++)
|
|
{
|
|
var infoDesc =
|
|
AdvertisementConfigDescMgr.Instance.GetConfigByInternal(player.RoleData.HomeAd.Infos[i].Id);
|
|
if (infoDesc == null)
|
|
continue;
|
|
|
|
if (advId == 0)
|
|
{
|
|
res.Infos.Add(ref player.RoleData.HomeAd.Infos[i]);
|
|
res.Infos[res.Infos.Count - 1].ColdTime -= GameServerUtils.GetTimeSecond();
|
|
if (res.Infos[res.Infos.Count - 1].ColdTime <= 0)
|
|
res.Infos[res.Infos.Count - 1].ColdTime = 0;
|
|
}
|
|
else
|
|
{
|
|
if (player.RoleData.HomeAd.Infos[i].Id == advId)
|
|
{
|
|
res.Infos.Add(ref player.RoleData.HomeAd.Infos[i]);
|
|
res.Infos[res.Infos.Count - 1].ColdTime -= GameServerUtils.GetTimeSecond();
|
|
if (res.Infos[res.Infos.Count - 1].ColdTime <= 0)
|
|
res.Infos[res.Infos.Count - 1].ColdTime = 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
player.SendToClient((int)CSGameMsgID.AdGetInfoRes, ref res);
|
|
}
|
|
|
|
public static void SendAdvReward(PlayerOnGame player, int advId)
|
|
{
|
|
var desc = AdvertisementConfigDescMgr.Instance.GetConfigByInternal(advId);
|
|
var list = new List<CSItemChgInfo>();
|
|
var syn = new CSHomeAdGiveMoneySyn
|
|
{
|
|
AdvId = advId
|
|
};
|
|
switch (desc.type)
|
|
{
|
|
case AdvertisementConfigType.Sweep:
|
|
ChapterSvc.OnMopUp(player, true);
|
|
break;
|
|
case AdvertisementConfigType.Gacha:
|
|
var poolId = GachaDescMgr.Instance.GetConfig(desc.typeParam).InternalId;
|
|
RecruitSvc.RecruitAdv(player, poolId);
|
|
break;
|
|
case AdvertisementConfigType.Market:
|
|
if (string.IsNullOrEmpty(desc.typeParam))
|
|
{
|
|
break;
|
|
}
|
|
|
|
var split = desc.typeParam.Split("_");
|
|
var shopId = split[0];
|
|
var goodIndex = split[1];
|
|
MarketShopHandler.OnAdvBuyGoods(player, int.Parse(shopId), int.Parse(goodIndex));
|
|
break;
|
|
case AdvertisementConfigType.Revive:
|
|
var packet = new StructPacket();
|
|
packet.Header.Type = (int)CSGameMsgID.BattleOptionReq;
|
|
var parser = new StructMessageParser<OnBattleOptionReq>();
|
|
packet.Parser = parser;
|
|
ref var req = ref packet.GetMessage<OnBattleOptionReq>();
|
|
req.Option = ChapterOption.ResurrectionBattle;
|
|
ChapterSvc.OnBattleOption(player, packet, true);
|
|
break;
|
|
case AdvertisementConfigType.ShopRefresh:
|
|
if (string.IsNullOrEmpty(desc.typeParam))
|
|
{
|
|
break;
|
|
}
|
|
|
|
MarketShopSvc.RefreshShopByAdv(player, int.Parse(desc.typeParam));
|
|
break;
|
|
case AdvertisementConfigType.PopPack:
|
|
PayCommSvc.FakePay(player.UserID, int.Parse(desc.typeParam));
|
|
break;
|
|
}
|
|
|
|
var reward = ChapterHelper.ConvRewardInternal(player, desc.adReward, false);
|
|
|
|
if (reward != null && reward.Count > 0)
|
|
{
|
|
var unifyOp = new UnifyOp(player, BillChangeItemReason.HomeAD);
|
|
foreach (var r in reward)
|
|
{
|
|
unifyOp.AddGoods(r.Type, r.Id, r.Value);
|
|
}
|
|
|
|
unifyOp.DoOp(retList: list);
|
|
}
|
|
|
|
foreach (var item in list)
|
|
{
|
|
if (item.ChgCount < 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
syn.Rewards.Add(item);
|
|
}
|
|
|
|
player.SendToClient((int)CSGameMsgID.HomeadAdGiveMoneySyn, ref syn);
|
|
TaskEXEvent.TriggerWatchAdsN(player, 1);
|
|
}
|
|
|
|
public static void CheckLoginCount(PlayerOnGame player)
|
|
{
|
|
if (AppTime.IsSameDay(GameServerUtils.GetTimeSecond(), player.RoleData.BurtyingPoint.LsatLoginTime) ==
|
|
false)
|
|
{
|
|
player.RoleData.BurtyingPoint.UserloginCount += 1;
|
|
player.RoleData.BurtyingPoint.LsatLoginTime = GameServerUtils.GetTimeSecond();
|
|
if (player.RoleData.BurtyingPoint.UserloginCount == 1)
|
|
{
|
|
GameTALogUtils.LogToClient(player, "UserLogin_1day");
|
|
}
|
|
else if (player.RoleData.BurtyingPoint.UserloginCount == 3)
|
|
{
|
|
GameTALogUtils.LogToClient(player, "UserLogin_3day");
|
|
}
|
|
else if (player.RoleData.BurtyingPoint.UserloginCount == 5)
|
|
{
|
|
GameTALogUtils.LogToClient(player, "UserLogin_5day");
|
|
}
|
|
else if (player.RoleData.BurtyingPoint.UserloginCount == 7)
|
|
{
|
|
GameTALogUtils.LogToClient(player, "UserLogin_7day");
|
|
}
|
|
}
|
|
}
|
|
|
|
//获取广告次数
|
|
public static int GetAdvTimes(PlayerOnGame player, AdvertisementConfigDesc desc)
|
|
{
|
|
var baseVal = desc.adverTimes;
|
|
|
|
if (baseVal == -1)
|
|
{
|
|
return Int32.MaxValue;
|
|
}
|
|
|
|
if (desc.adverId != "BuyPower")
|
|
{
|
|
return baseVal;
|
|
}
|
|
|
|
var ret = MonthlyCardSvc.GetMonthlyCardBuff(player, MonthlyCardBuffId.AdBuyPowerTimes);
|
|
return baseVal + ret;
|
|
}
|
|
|
|
public static void SunRaceHorsrTime(PlayerOnGame player)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|