mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2025-12-14 05:44:34 +01:00
feat: add affix stigmata roll
This commit is contained in:
@@ -4,6 +4,7 @@ using KianaBH.Database.Inventory;
|
||||
using KianaBH.Enums.Item;
|
||||
using KianaBH.GameServer.Game.Player;
|
||||
using KianaBH.GameServer.Server.Packet.Send.Item;
|
||||
using KianaBH.Proto;
|
||||
using KianaBH.Util;
|
||||
|
||||
namespace KianaBH.GameServer.Game.Inventory;
|
||||
@@ -200,4 +201,99 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
||||
|
||||
await Player.SyncValk();
|
||||
}
|
||||
|
||||
public async ValueTask GenerateRune(int uniqueId, StigmataRefineType type, StigmataRefineTimesType times, int lockRuneIndex)
|
||||
{
|
||||
var item = Data.StigmataItems.Find(x => x.UniqueId == uniqueId);
|
||||
if (item == null) return;
|
||||
|
||||
|
||||
var proto = new StigmataRuneGroup
|
||||
{
|
||||
UniqueId = (uint)uniqueId,
|
||||
};
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case StigmataRefineType.StigmataRefineAddSlot:
|
||||
if (item.SlotNum >= 2) return;
|
||||
item.SlotNum++;
|
||||
proto.RuneList.Add(item.AddRune());
|
||||
item.WaitSelectRuneGroupLists.Add(new RuneGroup
|
||||
{
|
||||
UniqueId = uniqueId,
|
||||
RuneLists = proto.RuneList.Select(x => new Rune
|
||||
{
|
||||
RuneId = (int)x.RuneId,
|
||||
Strength = (int)x.StrengthPercent,
|
||||
}).ToList()
|
||||
});
|
||||
break;
|
||||
case StigmataRefineType.StigmataRefineNormal:
|
||||
item.WaitSelectRuneGroupLists.Clear();
|
||||
if (times == StigmataRefineTimesType.StigmataRefineTimesTen)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var runeList = new List<StigmataRune>
|
||||
{
|
||||
item.AddRune(),
|
||||
item.AddRune(),
|
||||
};
|
||||
|
||||
proto.RuneList.AddRange(runeList);
|
||||
|
||||
item.WaitSelectRuneGroupLists.Add(new RuneGroup
|
||||
{
|
||||
UniqueId = uniqueId++,
|
||||
RuneLists = runeList.Select(x => new Rune
|
||||
{
|
||||
RuneId = (int)x.RuneId,
|
||||
Strength = (int)x.StrengthPercent,
|
||||
}).ToList()
|
||||
});
|
||||
}
|
||||
}
|
||||
else // One Time
|
||||
{
|
||||
if (item.SlotNum < 2 && new Random().Next(0, 10) == 9) item.SlotNum++;
|
||||
if (item.SlotNum >= 1) proto.RuneList.Add(item.AddRune());
|
||||
if (item.SlotNum == 2) proto.RuneList.Add(item.AddRune());
|
||||
|
||||
item.WaitSelectRuneGroupLists.Add(new RuneGroup
|
||||
{
|
||||
UniqueId = uniqueId++,
|
||||
RuneLists = proto.RuneList.Select(x => new Rune
|
||||
{
|
||||
RuneId = (int)x.RuneId,
|
||||
Strength = (int)x.StrengthPercent,
|
||||
}).ToList()
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
await Player.SyncInventory();
|
||||
}
|
||||
|
||||
|
||||
public async ValueTask SelectRune(int uniqueId, int selectUniqueId)
|
||||
{
|
||||
var item = Data.StigmataItems.Find(x => x.UniqueId == uniqueId);
|
||||
if (item == null) return;
|
||||
|
||||
var select = item.WaitSelectRuneGroupLists.Find(x => x.UniqueId == selectUniqueId);
|
||||
if (select == null) return;
|
||||
|
||||
item.RuneLists.Clear();
|
||||
item.RuneLists.AddRange(
|
||||
select.RuneLists.Select(x => new Rune
|
||||
{
|
||||
RuneId = x.RuneId,
|
||||
Strength = x.Strength
|
||||
})
|
||||
);
|
||||
item.WaitSelectRuneGroupLists.Clear();
|
||||
|
||||
await Player.SyncInventory();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using KianaBH.GameServer.Server.Packet.Send.Item;
|
||||
using KianaBH.Proto;
|
||||
|
||||
namespace KianaBH.GameServer.Server.Packet.Recv.Item;
|
||||
|
||||
[Opcode(CmdIds.RefineStigmataRuneReq)]
|
||||
public class HandlerRefineStigmataRuneReq : Handler
|
||||
{
|
||||
public override async Task OnHandle(Connection connection, byte[] header, byte[] data)
|
||||
{
|
||||
var req = RefineStigmataRuneReq.Parser.ParseFrom(data);
|
||||
var player = connection.Player!;
|
||||
|
||||
await player.InventoryManager!.GenerateRune((int)req.UniqueId,req.Type,req.TimesType,(int)req.LockRuneIndex);
|
||||
await connection.SendPacket(new PacketRefineStigmataRuneRsp(player,(int)req.UniqueId, req.TimesType));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using KianaBH.GameServer.Server.Packet.Send.Item;
|
||||
using KianaBH.Proto;
|
||||
|
||||
namespace KianaBH.GameServer.Server.Packet.Recv.Item;
|
||||
|
||||
[Opcode(CmdIds.SelectNewStigmataRuneReq)]
|
||||
public class HandlerSelectNewStigmataRuneReq : Handler
|
||||
{
|
||||
public override async Task OnHandle(Connection connection, byte[] header, byte[] data)
|
||||
{
|
||||
var req = SelectNewStigmataRuneReq.Parser.ParseFrom(data);
|
||||
var player = connection.Player!;
|
||||
|
||||
if (req.IsSelect && req.SelectUniqueId > 0)
|
||||
{
|
||||
await player.InventoryManager!.SelectRune((int)req.UniqueId, (int)req.SelectUniqueId);
|
||||
}
|
||||
|
||||
await connection.SendPacket(new PacketSelectNewStigmataRuneRsp(req.SelectUniqueId,req.IsSelect));
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using KianaBH.GameServer.Server.Packet.Send.Test;
|
||||
using KianaBH.Proto;
|
||||
|
||||
namespace KianaBH.GameServer.Server.Packet.Recv.Test;
|
||||
|
||||
[Opcode(CmdIds.RefineStigmataRuneReq)]
|
||||
public class HandlerRefineStigmataRuneReq : Handler
|
||||
{
|
||||
public override async Task OnHandle(Connection connection, byte[] header, byte[] data)
|
||||
{
|
||||
await connection.SendPacket(new PacketRefineStigmataRuneRsp());
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using KianaBH.GameServer.Server.Packet.Send.Test;
|
||||
using KianaBH.Proto;
|
||||
|
||||
namespace KianaBH.GameServer.Server.Packet.Recv.Test;
|
||||
|
||||
[Opcode(CmdIds.SelectNewStigmataRuneReq)]
|
||||
public class HandlerSelectNewStigmataRuneReq : Handler
|
||||
{
|
||||
public override async Task OnHandle(Connection connection, byte[] header, byte[] data)
|
||||
{
|
||||
await connection.SendPacket(new PacketSelectNewStigmataRuneRsp());
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,17 @@
|
||||
using KianaBH.GameServer.Game.Player;
|
||||
using KianaBH.KcpSharp;
|
||||
using KianaBH.Proto;
|
||||
|
||||
namespace KianaBH.GameServer.Server.Packet.Send.Test;
|
||||
namespace KianaBH.GameServer.Server.Packet.Send.Item;
|
||||
|
||||
public class PacketRefineStigmataRuneRsp : BasePacket
|
||||
{
|
||||
public PacketRefineStigmataRuneRsp() : base(CmdIds.RefineStigmataRuneRsp)
|
||||
public PacketRefineStigmataRuneRsp(PlayerInstance player,int uniqueId, StigmataRefineTimesType type) : base(CmdIds.RefineStigmataRuneRsp)
|
||||
{
|
||||
var proto = new RefineStigmataRuneRsp
|
||||
{
|
||||
|
||||
RuneGroupList = { player.InventoryManager!.Data!.StigmataItems.Find(x => x.UniqueId == uniqueId)!.ToWaitSelectRuneGroup() },
|
||||
TimesType = type
|
||||
};
|
||||
|
||||
SetData(proto);
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
using KianaBH.KcpSharp;
|
||||
using KianaBH.Proto;
|
||||
|
||||
namespace KianaBH.GameServer.Server.Packet.Send.Test;
|
||||
namespace KianaBH.GameServer.Server.Packet.Send.Item;
|
||||
|
||||
public class PacketSelectNewStigmataRuneRsp : BasePacket
|
||||
{
|
||||
public PacketSelectNewStigmataRuneRsp() : base(CmdIds.SelectNewStigmataRuneRsp)
|
||||
public PacketSelectNewStigmataRuneRsp(uint selectUniqueId, bool isSelect) : base(CmdIds.SelectNewStigmataRuneRsp)
|
||||
{
|
||||
var proto = new SelectNewStigmataRuneRsp
|
||||
{
|
||||
|
||||
SelectUniqueId = selectUniqueId,
|
||||
IsSelect = isSelect
|
||||
};
|
||||
|
||||
SetData(proto);
|
||||
|
||||
Reference in New Issue
Block a user