Very Simple RollShop Implement

This commit is contained in:
oureveryday
2024-07-07 10:58:52 +08:00
parent ac401079d7
commit 657ee823f7
7 changed files with 224 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EggLink.DanhengServer.Data.Excel
{
[ResourceEntity("RollShopConfig.json")]
public class RollShopConfigExcel : ExcelResource
{
public int RollShopID { get; set; }
public List<SpecialGroup> SpecialGroupList { get; set; } = new List<SpecialGroup>();
public uint CostItemID { get; set; }
public uint CostItemNum { get; set; }
public uint T1GroupID { get; set; }
public uint T2GroupID { get; set; }
public uint T3GroupID { get; set; }
public uint T4GroupID { get; set; }
public uint SecretGroupID { get; set; }
public string RollShopType { get; set; }
public uint IntroduceID { get; set; }
public ShopName ShopName { get; set; }
public override int GetId()
{
return RollShopID;
}
public override void Loaded()
{
GameData.RollShopConfigData.Add(GetId(), this);
}
}
public class SpecialGroup
{
public string GroupID { get; set; }
public int GroupValue { get; set; }
}
public class ShopName
{
public int Hash { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EggLink.DanhengServer.Data.Excel
{
[ResourceEntity("RollShopReward.json")]
public class RollShopRewardExcel : ExcelResource
{
public uint GroupID { get; set; }
public uint RewardID { get; set; }
public override int GetId()
{
return (int)RewardID;
}
public override void Loaded()
{
GameData.RollShopRewardData.Add(GetId(), this);
}
}
}

View File

@@ -128,6 +128,8 @@ namespace EggLink.DanhengServer.Data
#region Item Exchange
public static Dictionary<int, ShopConfigExcel> ShopConfigData { get; private set; } = [];
public static Dictionary<int, RollShopConfigExcel> RollShopConfigData { get; private set; } = [];
public static Dictionary<int, RollShopRewardExcel> RollShopRewardData { get; private set; } = [];
public static Dictionary<int, ItemComposeConfigExcel> ItemComposeConfigData { get; private set; } = [];
#endregion

View File

@@ -0,0 +1,66 @@
using EggLink.DanhengServer.Data;
using EggLink.DanhengServer.Database.Inventory;
using EggLink.DanhengServer.Proto;
using EggLink.DanhengServer.Server.Packet.Send.Challenge;
using EggLink.DanhengServer.Server.Packet.Send.Gacha;
using EggLink.DanhengServer.Server.Packet.Send.Shop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EggLink.DanhengServer.Server.Packet.Recv.Shop
{
[Opcode(CmdIds.DoGachaInRollShopCsReq)]
public class HandlerDoGachaInRollShopCsReq : Handler
{
public override void OnHandle(Connection connection, byte[] header, byte[] data)
{
var req = DoGachaInRollShopCsReq.Parser.ParseFrom(data);
ItemList itemList = new();
var count = req.JLLODFFJGDM;
uint maxtype = 3;
for (uint i = 0; i < count; i++)
{
Dictionary<uint, uint> GroupIds = new();
Dictionary<uint, uint> RewardIds = new();
GameData.RollShopConfigData.Values.ToList().ForEach(x =>
{
if (x.RollShopID == req.RollShopId)
{
GroupIds.Add(x.T1GroupID,1);
GroupIds.Add(x.T2GroupID,2);
GroupIds.Add(x.T3GroupID,3);
GroupIds.Add(x.T4GroupID,4);
}
});
GameData.RollShopRewardData.Values.ToList().ForEach(x =>
{
GroupIds.Keys.ToList().ForEach(y =>
{
if (x.GroupID == y)
{
RewardIds.Add(x.RewardID, GroupIds[y]);
}
});
});
var RewardId = RewardIds.Keys.ToList()[new Random().Next(0, RewardIds.Count)];
var type = RewardIds[RewardId];
if (type < maxtype) maxtype = type;
var rewardExcel = GameData.RewardDataData[(int)RewardId];
var rewardItems = rewardExcel.GetItems();
var itemData = new ItemData()
{
ItemId = rewardItems[0].Item1,
Count = rewardItems[0].Item2
};
itemList.ItemList_.Add(itemData.ToProto());
connection.Player!.InventoryManager!.RemoveItem(122000, 1);
}
connection.SendPacket(new PacketDoGachaInRollShopScRsp(req.RollShopId, itemList, maxtype));
}
}
}

View File

@@ -0,0 +1,21 @@
using EggLink.DanhengServer.Proto;
using EggLink.DanhengServer.Server.Packet.Send.Shop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EggLink.DanhengServer.Server.Packet.Recv.Shop
{
[Opcode(CmdIds.GetRollShopInfoCsReq)]
public class HandlerGetRollShopInfoCsReq : Handler
{
public override void OnHandle(Connection connection, byte[] header, byte[] data)
{
var req = GetRollShopInfoCsReq.Parser.ParseFrom(data);
connection.SendPacket(new PacketGetRollShopInfoScRsp(req.RollShopId));
}
}
}

View File

@@ -0,0 +1,26 @@
using EggLink.DanhengServer.Data;
using EggLink.DanhengServer.Proto;
using EggLink.DanhengServer.Proto;
using EggLink.DanhengServer.Server.Packet.Send.Challenge;
using Org.BouncyCastle.Ocsp;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
namespace EggLink.DanhengServer.Server.Packet.Send.Shop
{
public class PacketDoGachaInRollShopScRsp : BasePacket
{
public PacketDoGachaInRollShopScRsp(uint RollShopId, ItemList reward, uint type) : base(CmdIds.DoGachaInRollShopScRsp)
{
var proto = new DoGachaInRollShopScRsp();
proto.RollShopId = RollShopId;
proto.MJCIOJJKGMI = type; //Reward type display
proto.JCPIIANIDML = 0;
proto.Reward = reward;
proto.Retcode = 0; ;
SetData(proto);
}
}
}

View File

@@ -0,0 +1,37 @@
using EggLink.DanhengServer.Data;
using EggLink.DanhengServer.Proto;
using Microsoft.OpenApi.Writers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EggLink.DanhengServer.Server.Packet.Send.Shop
{
public class PacketGetRollShopInfoScRsp : BasePacket
{
public PacketGetRollShopInfoScRsp(uint rollShopId) : base(CmdIds.GetRollShopInfoScRsp)
{
var proto = new GetRollShopInfoScRsp();
proto.RollShopId = rollShopId;
proto.GachaRandom = 1;
foreach (var item in GameData.RollShopConfigData.Values)
{
if (item.RollShopID == rollShopId)
{
proto.NOPNEOADJEI.Add(item.T1GroupID);
proto.NOPNEOADJEI.Add(item.T2GroupID);
proto.NOPNEOADJEI.Add(item.T3GroupID);
proto.NOPNEOADJEI.Add(item.T4GroupID);
}
}
proto.Retcode = 0;
SetData(proto);
}
}
}