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.
81 lines
2.6 KiB
81 lines
2.6 KiB
using System.Linq;
|
|
using ProtoCSStruct;
|
|
using Sog;
|
|
|
|
namespace Game
|
|
{
|
|
public static class BeginnerGuideSvc
|
|
{
|
|
public static CSErrCode ChangeState(PlayerOnGame player, int id)
|
|
{
|
|
var index = -1;
|
|
for (var i = 0; i < player.RoleData.BeginnerGuide.Count; i++)
|
|
{
|
|
if (player.RoleData.BeginnerGuide[i] == id)
|
|
{
|
|
index = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (index > -1)
|
|
{
|
|
return CSErrCode.None;
|
|
}
|
|
|
|
player.RoleData.BeginnerGuide.Add(id);
|
|
|
|
return CSErrCode.None;
|
|
}
|
|
|
|
public static void Award(PlayerOnGame player, StructPacket packet)
|
|
{
|
|
var req = packet.GetMessage<CSBeginnerGuideAwardReq>();
|
|
var res = new CSBeginnerGuideAwardRes
|
|
{
|
|
Type = req.Type
|
|
};
|
|
var id = req.Id;
|
|
var type = req.Type;
|
|
var v = StatisticsOp.GetIDTotal(player, (int)CSRoleStatisticsID.BeginnerReward);
|
|
var ids = CommParamDescMgr.Instance.GuideMonId.int_list;
|
|
|
|
if (v > ids.Length + 1)
|
|
{
|
|
player.SendToClient((int)CSGameMsgID.BeginnerGuideAwardRes, ref res);
|
|
return;
|
|
}
|
|
var statChgOp = new RoleStatChgOp(player);
|
|
statChgOp.SetIDDaily((int)CSRoleStatisticsID.BeginnerReward, v + 1);
|
|
switch (type)
|
|
{
|
|
case (int)GoodsType.Exp:
|
|
{
|
|
if (!ids.Contains(id))
|
|
{
|
|
player.SendToClient((int)CSGameMsgID.BeginnerGuideAwardRes, ref res);
|
|
return;
|
|
}
|
|
var desc = MonsterPropDescMgr.Instance.GetConfig(id);
|
|
if (desc == null)
|
|
{
|
|
break;
|
|
}
|
|
LevelUtils.AddExp(player,desc.exp,"");
|
|
}
|
|
break;
|
|
default:
|
|
var rewardId = CommParamDescMgr.Instance.GuideGunId.str_val;
|
|
if (string.IsNullOrEmpty(rewardId))
|
|
{
|
|
player.SendToClient((int)CSGameMsgID.BeginnerGuideAwardRes, ref res);
|
|
return;
|
|
}
|
|
RewardSvc.Reward(player, rewardId, true, false);
|
|
break;
|
|
}
|
|
player.MakeDirty();
|
|
player.SendToClient((int)CSGameMsgID.BeginnerGuideAwardRes, ref res);
|
|
}
|
|
}
|
|
}
|