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.
788 lines
31 KiB
788 lines
31 KiB
using Org.BouncyCastle.Bcpg;
|
|
using Org.BouncyCastle.Ocsp;
|
|
using ProtoCSStruct;
|
|
using Sog;
|
|
using StackExchange.Redis;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static Google.Protobuf.WellKnownTypes.Field.Types;
|
|
|
|
namespace Game
|
|
{
|
|
public static class GemSvc
|
|
{
|
|
|
|
public static int AddGem(PlayerOnGame player, string gemId, int count )
|
|
{
|
|
var config = GemDescMgr.Instance.GetConfig(gemId);
|
|
if (config == null) {
|
|
return -1;
|
|
}
|
|
bool find = false;
|
|
for (int i = 0; i < player.RoleData.PandoraBag.GemList.Count; i++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[i].ConfId == config.InternalId)
|
|
{
|
|
ref var dBGem = ref player.RoleData.PandoraBag.GemList[i];
|
|
find = true;
|
|
dBGem.Count += count;
|
|
dBGem.NewGet = true;
|
|
CSGemSync cSGemSync = new CSGemSync();
|
|
cSGemSync.Add.CopyFrom(ref dBGem);
|
|
TaskEXEvent.TriggerGetGem(player);
|
|
player.SendToClient((int)CSGameMsgID.GemSync, ref cSGemSync);
|
|
break;
|
|
}
|
|
}
|
|
if(!find)
|
|
{
|
|
DBGem dBGem = GemNew(player, gemId, count);
|
|
if (player.RoleData.PandoraBag.GemList.Count < player.RoleData.PandoraBag.GemList.GetMaxCount())
|
|
{
|
|
player.RoleData.PandoraBag.GemList.Add(ref dBGem);
|
|
CSGemSync cSGemSync = new CSGemSync();
|
|
cSGemSync.Add.CopyFrom(ref dBGem);
|
|
player.SendToClient((int)CSGameMsgID.GemSync, ref cSGemSync);
|
|
}
|
|
}
|
|
return config.InternalId;
|
|
}
|
|
public static DBGem GemNew(PlayerOnGame player, string gemId, int count)
|
|
{
|
|
var config = GemDescMgr.Instance.GetConfig(gemId);
|
|
var rand = GameServerUtils.GetApp().Rand;
|
|
DBGem dBGem = new DBGem();
|
|
dBGem.ConfId = config.InternalId;
|
|
dBGem.GemType = (int)config.type;
|
|
if (config.position == EquipType.All)
|
|
{
|
|
dBGem.Lock = true;
|
|
}
|
|
else
|
|
{
|
|
dBGem.Lock = false;
|
|
}
|
|
dBGem.Pos = (int)config.position;
|
|
dBGem.Quality = (int)config.quality;
|
|
dBGem.Count = count;
|
|
dBGem.NewGet = true;
|
|
dBGem.EffIdx = (int)config.effIndex;
|
|
for (int i = 0; i < config.csPropId.Length; i++)
|
|
{
|
|
string key = config.csPropId[i];
|
|
long v = config.csPropValue[i];
|
|
if (!string.IsNullOrEmpty(key))
|
|
{
|
|
ID32Value64 iD = new ID32Value64();
|
|
var pconf = CSPropIDTypeDescMgr.Instance.GetConfig(key);
|
|
iD.Id = (int)pconf.id;
|
|
iD.Value = v;
|
|
dBGem.BaseProp.Add(ref iD);
|
|
}
|
|
}
|
|
dBGem.TalengId = config.talentId;
|
|
TaskEXEvent.TriggerGetGem(player, 1);
|
|
|
|
return dBGem;
|
|
}
|
|
public static void GemWear(PlayerOnGame player, StructPacket packet)
|
|
{
|
|
ref var req = ref packet.GetMessage<CSGemWear>();
|
|
int opType = req.OpType;
|
|
var res = new CSGemWearRes();
|
|
res.OpType = opType;
|
|
res.GemId = req.GemId;
|
|
res.ToGemId = req.ToGemId;
|
|
res.ToPos = req.ToPos;
|
|
if (opType == 2)
|
|
{
|
|
res.Ret = GemReplace(player, ref req);
|
|
} else if (opType == 3)
|
|
{
|
|
res.Ret = GemUnWear(player, req.GemId);
|
|
}
|
|
else
|
|
{
|
|
res.Ret = GemWearOn(player, req.GemId, req.ToPos, true, true);
|
|
}
|
|
player.SendToClient((int)CSGameMsgID.GemWearRes, ref res);
|
|
|
|
}
|
|
public static CSErrCode GemWearOn(PlayerOnGame player, int gemId, int toPos, bool sendNotify = true, bool calcProp = true)
|
|
{
|
|
DBGem dBGem = new DBGem();
|
|
bool find = false;
|
|
int findIdx = -1;
|
|
for (int i = 0; i < player.RoleData.PandoraBag.GemList.Count; i++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[i].ConfId == gemId)
|
|
{
|
|
dBGem = player.RoleData.PandoraBag.GemList[i];
|
|
find = true;
|
|
findIdx = i;
|
|
break;
|
|
}
|
|
}
|
|
if (!find)
|
|
{
|
|
return CSErrCode.Fail;
|
|
}
|
|
int sameCount = 0;
|
|
int sameId = 0;
|
|
int sameEffCount = 0;
|
|
for (int i = 0; i < player.RoleData.Knight.DbHero.WearGem.Count; i++)
|
|
{
|
|
ref var d = ref player.RoleData.Knight.DbHero.WearGem[i];
|
|
if (d.Pos == dBGem.Pos || d.Pos == toPos && dBGem.Pos == (int)EquipType.All
|
|
|| d.ToPos == dBGem.Pos && d.Pos == (int)EquipType.All)
|
|
{
|
|
sameCount++;
|
|
if (d.EffIdx == dBGem.EffIdx)
|
|
{
|
|
sameEffCount++;
|
|
break;
|
|
}
|
|
}
|
|
if (d.ConfId == dBGem.ConfId)
|
|
{
|
|
sameId++;
|
|
break;
|
|
}
|
|
|
|
}
|
|
if (sameEffCount > 0)
|
|
{
|
|
return CSErrCode.Fail;
|
|
}
|
|
if (sameId > 0)
|
|
{
|
|
return CSErrCode.Fail;
|
|
}
|
|
if (sameCount >= CommParamDescMgr.Instance.GemPositionNum.int_val)//超过4个
|
|
{
|
|
return CSErrCode.Fail;
|
|
}
|
|
|
|
if (dBGem.Count == 1)
|
|
{
|
|
player.RoleData.PandoraBag.GemList.RemoveAt(findIdx);
|
|
}
|
|
else
|
|
{
|
|
player.RoleData.PandoraBag.GemList[findIdx].Count -= 1;
|
|
}
|
|
dBGem.Count = 1;
|
|
if(dBGem.Pos == (int)EquipType.All)
|
|
{
|
|
dBGem.ToPos = toPos;
|
|
}
|
|
else
|
|
{
|
|
dBGem.ToPos = 0;
|
|
}
|
|
player.RoleData.Knight.DbHero.WearGem.Add(ref dBGem);
|
|
if (calcProp)
|
|
{
|
|
RolePropUtil.RecalRoleProp(player);
|
|
}
|
|
//PlayerDataSvc.SendGemListSYnc(player);
|
|
|
|
var c = new CSGemChangeSync();
|
|
if (sendNotify)
|
|
{
|
|
c.Change.Add(new IDValue32 { Id = dBGem.ConfId, Value = -1 });
|
|
player.SendToClient((int)CSGameMsgID.GemChangeSync, ref c);
|
|
PlayerDataSvc.SendHeroInfoSync(player);
|
|
}
|
|
TaskEXEvent.TriggerProcessWearQualityGem(player);
|
|
return CSErrCode.None;
|
|
}
|
|
public static CSErrCode GemReplace(PlayerOnGame player, ref CSGemWear req)
|
|
{
|
|
int gemId = req.GemId;
|
|
int toGemId = req.ToGemId;
|
|
if(GemUnWear(player, toGemId, false) != CSErrCode.None)
|
|
{
|
|
return CSErrCode.Fail;
|
|
}
|
|
DBGem dBGem = new DBGem();
|
|
bool find = false;
|
|
int findIdx = -1;
|
|
for (int i = 0; i < player.RoleData.PandoraBag.GemList.Count; i++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[i].ConfId == gemId)
|
|
{
|
|
dBGem = player.RoleData.PandoraBag.GemList[i];
|
|
find = true;
|
|
findIdx = i;
|
|
break;
|
|
}
|
|
}
|
|
if (!find)
|
|
{
|
|
return CSErrCode.Fail;
|
|
}
|
|
int sameCount = 0;
|
|
int sameId = 0;
|
|
int sameEffCount = 0;
|
|
for (int i = 0; i < player.RoleData.Knight.DbHero.WearGem.Count; i++)
|
|
{
|
|
ref var d = ref player.RoleData.Knight.DbHero.WearGem[i];
|
|
if (d.Pos == dBGem.Pos || d.Pos == req.ToPos && dBGem.Pos == (int)EquipType.All
|
|
|| d.ToPos == dBGem.Pos && d.Pos == (int)EquipType.All)
|
|
{
|
|
sameCount++;
|
|
if (d.EffIdx == dBGem.EffIdx)
|
|
{
|
|
sameEffCount++;
|
|
break;
|
|
}
|
|
}
|
|
if (d.ConfId == dBGem.ConfId)
|
|
{
|
|
sameId++;
|
|
break;
|
|
}
|
|
}
|
|
if (sameEffCount > 0)
|
|
{
|
|
return CSErrCode.Fail;
|
|
}
|
|
if (sameId > 0)
|
|
{
|
|
return CSErrCode.Fail;
|
|
}
|
|
if (sameCount >= CommParamDescMgr.Instance.GemPositionNum.int_val)
|
|
{
|
|
return CSErrCode.Fail;
|
|
}
|
|
if (dBGem.Count == 1)
|
|
{
|
|
player.RoleData.PandoraBag.GemList.RemoveAt(findIdx);
|
|
}
|
|
else
|
|
{
|
|
player.RoleData.PandoraBag.GemList[findIdx].Count -= 1;
|
|
}
|
|
var c = new CSGemChangeSync();
|
|
c.Change.Add(new IDValue32 { Id = dBGem.ConfId, Value = -1 });
|
|
player.SendToClient((int)CSGameMsgID.GemChangeSync, ref c);
|
|
|
|
dBGem.Count = 1;
|
|
if (dBGem.Pos == (int)EquipType.All)
|
|
{
|
|
dBGem.ToPos = req.ToPos;
|
|
}
|
|
else
|
|
{
|
|
dBGem.ToPos = 0;
|
|
}
|
|
player.RoleData.Knight.DbHero.WearGem.Add(ref dBGem);
|
|
RolePropUtil.RecalRoleProp(player);
|
|
//PlayerDataSvc.SendGemListSYnc(player);
|
|
PlayerDataSvc.SendHeroInfoSync(player);
|
|
return CSErrCode.None;
|
|
}
|
|
public static CSErrCode GemUnWear(PlayerOnGame player, int gemId, bool notify = true)
|
|
{
|
|
DBGem dBGem = new DBGem();
|
|
bool find = false;
|
|
int findIdx = -1;
|
|
|
|
for (int i = 0; i < player.RoleData.Knight.DbHero.WearGem.Count; i++)
|
|
{
|
|
ref var d = ref player.RoleData.Knight.DbHero.WearGem[i];
|
|
if(d.ConfId == gemId)
|
|
{
|
|
find = true;
|
|
findIdx = i;
|
|
dBGem = d;
|
|
break;
|
|
}
|
|
}
|
|
if (!find)
|
|
{
|
|
return CSErrCode.Fail;
|
|
}
|
|
if (player.RoleData.PandoraBag.GemList.Count >= player.RoleData.PandoraBag.GemList.GetMaxCount())
|
|
{
|
|
return CSErrCode.Fail;
|
|
}
|
|
player.RoleData.Knight.DbHero.WearGem.RemoveAt(findIdx);
|
|
find = false;
|
|
for (int i = 0; i < player.RoleData.PandoraBag.GemList.Count; i++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[i].ConfId == gemId)
|
|
{
|
|
ref var d = ref player.RoleData.PandoraBag.GemList[i];
|
|
find = true;
|
|
d.Count++;
|
|
break;
|
|
}
|
|
}
|
|
if (!find)
|
|
{
|
|
dBGem.Count = 1;
|
|
dBGem.ToPos = 0;
|
|
player.RoleData.PandoraBag.GemList.Add(ref dBGem);
|
|
|
|
var add = new CSGemSync();
|
|
add.Add.CopyFrom(ref dBGem);
|
|
player.SendToClient((int)CSGameMsgID.GemSync, ref add);
|
|
}
|
|
else
|
|
{
|
|
var c = new CSGemChangeSync();
|
|
c.Change.Add(new IDValue32 { Id = dBGem.ConfId, Value = 1 });
|
|
player.SendToClient((int)CSGameMsgID.GemChangeSync, ref c);
|
|
|
|
}
|
|
if (notify)
|
|
{
|
|
RolePropUtil.RecalRoleProp(player);
|
|
//PlayerDataSvc.SendGemListSYnc(player);
|
|
PlayerDataSvc.SendHeroInfoSync(player);
|
|
}
|
|
return CSErrCode.None;
|
|
}
|
|
|
|
public static void GemCompose(PlayerOnGame player, StructPacket packet)
|
|
{
|
|
ref var req = ref packet.GetMessage<CSGemCompose>();
|
|
//var change = new CSGemChangeSync();
|
|
var res = new CSGemComposeRes();
|
|
var removeId = new List<int>();
|
|
var addRewards = new List<string>();
|
|
int needGold = req.Costs.Count * CommParamDescMgr.Instance.GemCMixCost.int_val;
|
|
UnifyOp op = new UnifyOp(player, BillChangeItemReason.GemCompose);
|
|
op.CostGold(needGold);
|
|
res.Ret = op.DoOp(true, true);
|
|
if(res.Ret != CSErrCode.None)
|
|
{
|
|
player.SendToClient((int)CSGameMsgID.GemComposeRes, ref res);
|
|
return;
|
|
}
|
|
res.Ret = CSErrCode.Fail;
|
|
|
|
List<string> costs = new List<string>();
|
|
var mgoods = new CSPlayerGoodsChgNotify();
|
|
for (int i = 0;i < req.Costs.Count;i++)
|
|
{
|
|
ref var cu = ref req.Costs[i];
|
|
bool cok = true;
|
|
int quality = -1; int pos = -1;
|
|
int count = 0;
|
|
for (int j = 0;j < cu.ConfId.Count;j++)
|
|
{
|
|
int id = cu.ConfId[j];
|
|
int c = cu.Count[j];
|
|
count += c;
|
|
bool ok = false;
|
|
for (int k = 0; k < player.RoleData.PandoraBag.GemList.Count; k++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[k].ConfId == id)
|
|
{
|
|
ref var d = ref player.RoleData.PandoraBag.GemList[k];
|
|
if (quality == -1)
|
|
{
|
|
if(d.Pos == (int)EquipType.All)
|
|
{
|
|
ok = false;
|
|
break;
|
|
}
|
|
quality = d.Quality;
|
|
pos = d.Pos;
|
|
}
|
|
if (d.Count >= c && d.Lock == false && d.Quality == quality && (d.Pos == pos || d.Pos == (int)EquipType.All))
|
|
{
|
|
ok = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if (!ok)
|
|
{
|
|
cok = false;
|
|
break;
|
|
}
|
|
}
|
|
if (cok && count == 5)
|
|
{
|
|
//扣除并且合成
|
|
res.Costs.Add(ref cu);
|
|
for (int j = 0; j < cu.ConfId.Count; j++)
|
|
{
|
|
int id = cu.ConfId[j];
|
|
int c = cu.Count[j];
|
|
for (int k = 0; k < player.RoleData.PandoraBag.GemList.Count; k++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[k].ConfId == id)
|
|
{
|
|
ref var d = ref player.RoleData.PandoraBag.GemList[k];
|
|
if (d.Count >= c)
|
|
{
|
|
d.Count -= c;
|
|
}
|
|
if(d.Count == 0)
|
|
{
|
|
removeId.Add(k);
|
|
}
|
|
//change.Change.Add(new IDValue32 { Id = d.ConfId, Value = -c });
|
|
var chginfo = new CSItemChgInfo();
|
|
chginfo.Type = (int)GoodsType.Gem;
|
|
chginfo.UniqueID = d.ConfId;
|
|
chginfo.Iid = d.ConfId;
|
|
chginfo.ChgCount = -c;
|
|
var conf = GemDescMgr.Instance.GetConfigByInternal(d.ConfId);
|
|
chginfo.Id.SetString(conf.id);
|
|
mgoods.ChgItems.Add(ref chginfo);
|
|
if(mgoods.ChgItems.Count == mgoods.ChgItems.GetMaxCount())
|
|
{
|
|
GameTALogUtils.LogResourceChange(player, BillChangeItemReason.GemCompose, "合成", ref mgoods);
|
|
mgoods.ChgItems.Clear();
|
|
}
|
|
for(int ic = 0; ic < c; ic++)
|
|
{
|
|
costs.Add(conf.id);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
string key = "GemMix_" + quality+"_"+pos;
|
|
addRewards.Add(key);
|
|
}
|
|
}
|
|
if (mgoods.ChgItems.Count > 0)
|
|
{
|
|
GameTALogUtils.LogResourceChange(player, BillChangeItemReason.GemCompose, "合成", ref mgoods);
|
|
mgoods.ChgItems.Clear();
|
|
}
|
|
removeId.Sort((a,b)=>b-a);
|
|
for (int i = 0; i < removeId.Count; i++)
|
|
{
|
|
player.RoleData.PandoraBag.GemList.RemoveAt(removeId[i]);
|
|
}
|
|
List < RewardItemRW > rewardItemRWs = new List < RewardItemRW >();
|
|
for (int i = 0; i < addRewards.Count; i++)
|
|
{
|
|
rewardItemRWs.AddRange(RewardSvc.Reward(player, addRewards[i], false));
|
|
}
|
|
rewardItemRWs = RewardSvc.MergeReward(rewardItemRWs);
|
|
RewardSvc.ApplyGiveReward(player, rewardItemRWs, true);
|
|
//player.SendToClient((int)CSGameMsgID.GemChangeSync, ref change);
|
|
PlayerDataSvc.SendGemListSYnc(player);
|
|
res.Ret = CSErrCode.None;
|
|
player.SendToClient((int)CSGameMsgID.GemComposeRes, ref res);
|
|
var rlist = new List<string>();
|
|
rewardItemRWs.ForEach((a) => rlist.Add(a.code));
|
|
GameTALogUtils.LogGemCompose(player, 1, costs, "", null, rlist);
|
|
}
|
|
public static void GemComposeOne(PlayerOnGame player, StructPacket packet)
|
|
{
|
|
ref var req = ref packet.GetMessage<CSGemComposeOne>();
|
|
var res = new CSGemComposeOneRes();
|
|
res.Ret = CSErrCode.Fail;
|
|
res.ConfId = req.ConfId;
|
|
if (player.RoleData.PandoraBag.ComposeTempNew.ConfId > 0)
|
|
{
|
|
player.SendToClient((int)CSGameMsgID.GemComposeOneRes, ref res);
|
|
return;
|
|
}
|
|
UnifyOp op = new UnifyOp(player, BillChangeItemReason.GemComposeOne);
|
|
op.CostGoods((int)GoodsType.Items, CommParamDescMgr.Instance.GemMixCost.str_val, CommParamDescMgr.Instance.GemMixCost.int_val);
|
|
res.Ret = op.CheckOp();
|
|
if(res.Ret != CSErrCode.None)
|
|
{
|
|
player.SendToClient((int)CSGameMsgID.GemComposeOneRes, ref res);
|
|
return;
|
|
}
|
|
|
|
int quality = -1; int pos = -1;
|
|
DBGem main = new DBGem();
|
|
bool find = false;
|
|
for (int k = 0; k < player.RoleData.PandoraBag.GemList.Count; k++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[k].ConfId == req.ConfId)
|
|
{
|
|
ref var d = ref player.RoleData.PandoraBag.GemList[k];
|
|
if(d.Lock || d.Count <= 0)
|
|
{
|
|
break;
|
|
}
|
|
main.CopyFrom(ref d);
|
|
find = true;
|
|
break;
|
|
}
|
|
}
|
|
res.Ret = CSErrCode.Fail;
|
|
if(!find)
|
|
{
|
|
|
|
player.SendToClient((int)CSGameMsgID.GemComposeOneRes, ref res);
|
|
return;
|
|
}
|
|
if(main.Pos == (int)EquipType.All)
|
|
{
|
|
player.SendToClient((int)CSGameMsgID.GemComposeOneRes, ref res);
|
|
return;
|
|
}
|
|
quality = main.Quality;
|
|
pos = main.Pos;
|
|
int count = 1;
|
|
for (int j = 0; j < req.Costs.ConfId.Count; j++)
|
|
{
|
|
int id = req.Costs.ConfId[j];
|
|
int c = req.Costs.Count[j];
|
|
count += c;
|
|
bool ok = false;
|
|
for (int k = 0; k < player.RoleData.PandoraBag.GemList.Count; k++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[k].ConfId == id)
|
|
{
|
|
ref var d = ref player.RoleData.PandoraBag.GemList[k];
|
|
if (d.Count >= c && d.Lock == false && d.Quality == quality && (d.Pos == pos || d.Pos == (int)EquipType.All))
|
|
{
|
|
ok = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if (!ok)
|
|
{
|
|
player.SendToClient((int)CSGameMsgID.GemComposeOneRes, ref res);
|
|
return;
|
|
}
|
|
}
|
|
if(count != 5)
|
|
{
|
|
player.SendToClient((int)CSGameMsgID.GemComposeOneRes, ref res);
|
|
return;
|
|
}
|
|
//扣除钻石和主的和其他的
|
|
op.DoOp(true, true);
|
|
var removeId = new List<int>();
|
|
var mgoods = new CSPlayerGoodsChgNotify();
|
|
|
|
List<string> costs = new List<string>();
|
|
req.Costs.ConfId.Add(req.ConfId);
|
|
req.Costs.Count.Add(1);
|
|
main.Count = 1;
|
|
for (int j = 0; j < req.Costs.ConfId.Count; j++)
|
|
{
|
|
int id = req.Costs.ConfId[j];
|
|
int c = req.Costs.Count[j];
|
|
for (int k = 0; k < player.RoleData.PandoraBag.GemList.Count; k++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[k].ConfId == id)
|
|
{
|
|
ref var d = ref player.RoleData.PandoraBag.GemList[k];
|
|
if (d.Count >= c)
|
|
{
|
|
d.Count -= c;
|
|
}
|
|
if (d.Count == 0)
|
|
{
|
|
removeId.Add(k);
|
|
}
|
|
|
|
var chginfo = new CSItemChgInfo();
|
|
chginfo.Type = (int)GoodsType.Gem;
|
|
chginfo.UniqueID = d.ConfId;
|
|
chginfo.Iid = d.ConfId;
|
|
chginfo.ChgCount = -c;
|
|
var conf = GemDescMgr.Instance.GetConfigByInternal(d.ConfId);
|
|
chginfo.Id.SetString(conf.id);
|
|
mgoods.ChgItems.Add(ref chginfo);
|
|
for(int ic = 0;ic < c; ic++)
|
|
{
|
|
costs.Add(conf.id);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
removeId.Sort((a, b) => b - a);
|
|
for (int i = 0; i < removeId.Count; i++)
|
|
{
|
|
player.RoleData.PandoraBag.GemList.RemoveAt(removeId[i]);
|
|
}
|
|
string rewardId = "GemMix_" + quality + "_" + pos;
|
|
List<RewardItemRW> rewardItemRWs = RewardSvc.Reward(player, rewardId, false);
|
|
string gemId = rewardItemRWs[0].code;
|
|
DBGem gem = GemSvc.GemNew(player, gemId, 1);
|
|
player.RoleData.PandoraBag.ComposeTempOld.CopyFrom(ref main);
|
|
player.RoleData.PandoraBag.ComposeTempNew.CopyFrom(ref gem);
|
|
res.NewGem.CopyFrom(ref gem);
|
|
res.Ret = CSErrCode.None;
|
|
PlayerDataSvc.SendGemListSYnc(player);
|
|
player.SendToClient((int)CSGameMsgID.GemComposeOneRes, ref res);
|
|
|
|
var mconf = GemDescMgr.Instance.GetConfigByInternal(main.ConfId);
|
|
GameTALogUtils.LogGemCompose(player, 2, costs, mconf.id , gemId);
|
|
|
|
GameTALogUtils.LogResourceChange(player, BillChangeItemReason.GemComposeOne, "合成", ref mgoods);
|
|
}
|
|
public static void GemComposeOneSave(PlayerOnGame player, StructPacket packet)
|
|
{
|
|
ref var req = ref packet.GetMessage<CSGemComposeOneSave>();
|
|
var push = new CSGoodsGetPush();
|
|
if (req.OpType == 1)
|
|
{
|
|
//保留旧的,删除新的
|
|
if(player.RoleData.PandoraBag.ComposeTempNew.ConfId > 0 && player.RoleData.PandoraBag.ComposeTempOld.ConfId > 0)
|
|
{
|
|
player.RoleData.PandoraBag.ComposeTempNew.Clear();
|
|
bool find = false;
|
|
for (int k = 0; k < player.RoleData.PandoraBag.GemList.Count; k++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[k].ConfId == player.RoleData.PandoraBag.ComposeTempOld.ConfId)
|
|
{
|
|
ref var d = ref player.RoleData.PandoraBag.GemList[k];
|
|
d.Count++;
|
|
find = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!find)
|
|
{
|
|
player.RoleData.PandoraBag.GemList.Add(ref player.RoleData.PandoraBag.ComposeTempOld);
|
|
}
|
|
var chginfo = new CSItemChgInfo();
|
|
chginfo.Type = (int)GoodsType.Gem;
|
|
chginfo.UniqueID = player.RoleData.PandoraBag.ComposeTempOld.ConfId;
|
|
chginfo.Iid = player.RoleData.PandoraBag.ComposeTempOld.ConfId;
|
|
chginfo.ChgCount = 1;
|
|
var conf = GemDescMgr.Instance.GetConfigByInternal(chginfo.Iid);
|
|
chginfo.Id.SetString(conf.id);
|
|
player.RoleData.PandoraBag.ComposeTempOld.Clear();
|
|
|
|
var mgoods = new CSPlayerGoodsChgNotify();
|
|
mgoods.ChgItems.Add(ref chginfo);
|
|
GameTALogUtils.LogResourceChange(player, BillChangeItemReason.GemComposeOne, "保留", ref mgoods);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//保留新的,删除旧的
|
|
if (player.RoleData.PandoraBag.ComposeTempNew.ConfId > 0 && player.RoleData.PandoraBag.ComposeTempOld.ConfId > 0)
|
|
{
|
|
player.RoleData.PandoraBag.ComposeTempOld.Clear();
|
|
bool find = false;
|
|
for (int k = 0; k < player.RoleData.PandoraBag.GemList.Count; k++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[k].ConfId == player.RoleData.PandoraBag.ComposeTempNew.ConfId)
|
|
{
|
|
ref var d = ref player.RoleData.PandoraBag.GemList[k];
|
|
d.Count++;
|
|
find = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!find)
|
|
{
|
|
player.RoleData.PandoraBag.GemList.Add(ref player.RoleData.PandoraBag.ComposeTempNew);
|
|
}
|
|
var chginfo = new CSItemChgInfo();
|
|
chginfo.Type = (int)GoodsType.Gem;
|
|
chginfo.UniqueID = player.RoleData.PandoraBag.ComposeTempNew.ConfId;
|
|
chginfo.Iid = player.RoleData.PandoraBag.ComposeTempNew.ConfId;
|
|
chginfo.ChgCount = 1;
|
|
var conf = GemDescMgr.Instance.GetConfigByInternal(chginfo.Iid);
|
|
chginfo.Id.SetString(conf.id);
|
|
player.RoleData.PandoraBag.ComposeTempNew.Clear();
|
|
|
|
push.Items.Add(ref chginfo);
|
|
var mgoods = new CSPlayerGoodsChgNotify();
|
|
mgoods.ChgItems.Add(ref chginfo);
|
|
GameTALogUtils.LogResourceChange(player, BillChangeItemReason.GemComposeOne, "保存", ref mgoods);
|
|
}
|
|
}
|
|
var res = new CSGemComposeOneSaveRes();
|
|
res.Ret = CSErrCode.None;
|
|
res.OpType = req.OpType;
|
|
PlayerDataSvc.SendGemListSYnc(player);
|
|
player.SendToClient((int)CSGameMsgID.GemComposeOneSaveRes, ref res);
|
|
if(push.Items.Count > 0)
|
|
{
|
|
player.SendToClient((int)CSGameMsgID.GoodsGetPush, ref push);
|
|
}
|
|
}
|
|
public static void GemLock(PlayerOnGame player, StructPacket packet)
|
|
{
|
|
ref var req = ref packet.GetMessage<CSGemLock>();
|
|
for (int i = 0; i < player.RoleData.PandoraBag.GemList.Count; i++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[i].ConfId == req.GemId)
|
|
{
|
|
ref var d = ref player.RoleData.PandoraBag.GemList[i];
|
|
if(req.OpType == 1)
|
|
{
|
|
d.Lock = true;
|
|
}
|
|
else
|
|
{
|
|
d.Lock = false;
|
|
}
|
|
var res = new CSGemLockRes();
|
|
res.OpType = req.OpType;
|
|
res.GemId = req.GemId;
|
|
res.Ret = CSErrCode.None;
|
|
res.Geam.CopyFrom(ref d);
|
|
player.SendToClient((int)CSGameMsgID.GemLockRes, ref res);
|
|
return;
|
|
}
|
|
}
|
|
{
|
|
var res = new CSGemLockRes();
|
|
res.OpType = req.OpType;
|
|
res.GemId = req.GemId;
|
|
res.Ret = CSErrCode.Fail;
|
|
player.SendToClient((int)CSGameMsgID.GemLockRes, ref res);
|
|
}
|
|
}
|
|
public static void GemSetNewGet(PlayerOnGame player, StructPacket packet)
|
|
{
|
|
ref var req = ref packet.GetMessage<CSGemSetNewGet>();
|
|
bool change = false;
|
|
for (int i = 0; i < player.RoleData.PandoraBag.GemList.Count; i++)
|
|
{
|
|
if (player.RoleData.PandoraBag.GemList[i].NewGet)
|
|
{
|
|
ref var d = ref player.RoleData.PandoraBag.GemList[i];
|
|
if(req.GemId ==0 || d.ConfId == req.GemId)
|
|
{
|
|
d.NewGet = false;
|
|
change = true;
|
|
}
|
|
}
|
|
}
|
|
if (change && req.GemId == 0)
|
|
{
|
|
//PlayerDataSvc.SendGemListSYnc(player);
|
|
}
|
|
var res = new CSGemSetNewGetRes();
|
|
res.GemId = req.GemId;
|
|
player.SendToClient((int)CSGameMsgID.GemSetnewgetRes, ref res);
|
|
}
|
|
public static void CollectGemProp(ref DBRoleData roleDat, RoleProp roleProp)
|
|
{
|
|
for (int i = 0; i < roleDat.Knight.DbHero.WearGem.Count; i++)
|
|
{
|
|
ref var gem = ref roleDat.Knight.DbHero.WearGem[i];
|
|
if(gem.GemType != (int)GemType.CSPropIDType)
|
|
{
|
|
continue;
|
|
}
|
|
for (int j = 0; j < gem.BaseProp.Count; j++)
|
|
{
|
|
roleProp.AddProp(gem.BaseProp[j].Id, gem.BaseProp[j].Value);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|