mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2025-12-12 13:04:33 +01:00
feat: add affix stigmata roll
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
using KianaBH.Proto;
|
using KianaBH.Data;
|
||||||
|
using KianaBH.Proto;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
||||||
|
|
||||||
namespace KianaBH.Database.Inventory;
|
namespace KianaBH.Database.Inventory;
|
||||||
|
|
||||||
@@ -65,14 +65,14 @@ public class ItemData
|
|||||||
{
|
{
|
||||||
return new Stigmata
|
return new Stigmata
|
||||||
{
|
{
|
||||||
Id= (uint)ItemId,
|
Id = (uint)ItemId,
|
||||||
UniqueId= (uint)UniqueId,
|
UniqueId = (uint)UniqueId,
|
||||||
Level= (uint)Level,
|
Level = (uint)Level,
|
||||||
Exp= (uint)Exp,
|
Exp = (uint)Exp,
|
||||||
SlotNum = (uint)SlotNum,
|
SlotNum = (uint)SlotNum,
|
||||||
RefineValue = (uint)RefineValue,
|
RefineValue = (uint)RefineValue,
|
||||||
PromoteTimes = (uint)PromoteTimes,
|
PromoteTimes = (uint)PromoteTimes,
|
||||||
IsProtected= IsLocked,
|
IsProtected = IsLocked,
|
||||||
IsAffixIdentify = IsAffixIdentify,
|
IsAffixIdentify = IsAffixIdentify,
|
||||||
RuneList =
|
RuneList =
|
||||||
{
|
{
|
||||||
@@ -97,7 +97,7 @@ public class ItemData
|
|||||||
UniqueId = (uint)x.UniqueId,
|
UniqueId = (uint)x.UniqueId,
|
||||||
RuneList =
|
RuneList =
|
||||||
{
|
{
|
||||||
RuneLists.Select(l => new StigmataRune
|
x.RuneLists.Select(l => new StigmataRune
|
||||||
{
|
{
|
||||||
RuneId = (uint)l.RuneId,
|
RuneId = (uint)l.RuneId,
|
||||||
StrengthPercent = (uint)l.Strength,
|
StrengthPercent = (uint)l.Strength,
|
||||||
@@ -107,6 +107,46 @@ public class ItemData
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<StigmataRuneGroup> ToWaitSelectRuneGroup()
|
||||||
|
{
|
||||||
|
return WaitSelectRuneGroupLists.Select(x => new StigmataRuneGroup
|
||||||
|
{
|
||||||
|
UniqueId = (uint)x.UniqueId,
|
||||||
|
RuneList =
|
||||||
|
{
|
||||||
|
x.RuneLists.Select(l => new StigmataRune
|
||||||
|
{
|
||||||
|
RuneId = (uint)l.RuneId,
|
||||||
|
StrengthPercent = (uint)l.Strength,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StigmataRune AddRune(int min = 1, int max = 4)
|
||||||
|
{
|
||||||
|
var proto = new StigmataRune
|
||||||
|
{
|
||||||
|
RuneId = GenerateAffixId(),
|
||||||
|
StrengthPercent = GenerateAffixStrength()
|
||||||
|
};
|
||||||
|
return proto;
|
||||||
|
}
|
||||||
|
|
||||||
|
private uint GenerateAffixId()
|
||||||
|
{
|
||||||
|
Random _random = new Random();
|
||||||
|
var affixKeys = GameData.AffixListData.Keys.ToList();
|
||||||
|
int affixBase = affixKeys[_random.Next(affixKeys.Count)];
|
||||||
|
return (uint)affixBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
private uint GenerateAffixStrength(int min = 1, int max = 101)
|
||||||
|
=> (uint)(new Random().Next(
|
||||||
|
min > 0 && min < max ? min : 1, max > min && max < 102 ? max : 101
|
||||||
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RuneGroup
|
public class RuneGroup
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using KianaBH.Database.Inventory;
|
|||||||
using KianaBH.Enums.Item;
|
using KianaBH.Enums.Item;
|
||||||
using KianaBH.GameServer.Game.Player;
|
using KianaBH.GameServer.Game.Player;
|
||||||
using KianaBH.GameServer.Server.Packet.Send.Item;
|
using KianaBH.GameServer.Server.Packet.Send.Item;
|
||||||
|
using KianaBH.Proto;
|
||||||
using KianaBH.Util;
|
using KianaBH.Util;
|
||||||
|
|
||||||
namespace KianaBH.GameServer.Game.Inventory;
|
namespace KianaBH.GameServer.Game.Inventory;
|
||||||
@@ -200,4 +201,99 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
|
|
||||||
await Player.SyncValk();
|
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.KcpSharp;
|
||||||
using KianaBH.Proto;
|
using KianaBH.Proto;
|
||||||
|
|
||||||
namespace KianaBH.GameServer.Server.Packet.Send.Test;
|
namespace KianaBH.GameServer.Server.Packet.Send.Item;
|
||||||
|
|
||||||
public class PacketRefineStigmataRuneRsp : BasePacket
|
public class PacketRefineStigmataRuneRsp : BasePacket
|
||||||
{
|
{
|
||||||
public PacketRefineStigmataRuneRsp() : base(CmdIds.RefineStigmataRuneRsp)
|
public PacketRefineStigmataRuneRsp(PlayerInstance player,int uniqueId, StigmataRefineTimesType type) : base(CmdIds.RefineStigmataRuneRsp)
|
||||||
{
|
{
|
||||||
var proto = new RefineStigmataRuneRsp
|
var proto = new RefineStigmataRuneRsp
|
||||||
{
|
{
|
||||||
|
RuneGroupList = { player.InventoryManager!.Data!.StigmataItems.Find(x => x.UniqueId == uniqueId)!.ToWaitSelectRuneGroup() },
|
||||||
|
TimesType = type
|
||||||
};
|
};
|
||||||
|
|
||||||
SetData(proto);
|
SetData(proto);
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
using KianaBH.KcpSharp;
|
using KianaBH.KcpSharp;
|
||||||
using KianaBH.Proto;
|
using KianaBH.Proto;
|
||||||
|
|
||||||
namespace KianaBH.GameServer.Server.Packet.Send.Test;
|
namespace KianaBH.GameServer.Server.Packet.Send.Item;
|
||||||
|
|
||||||
public class PacketSelectNewStigmataRuneRsp : BasePacket
|
public class PacketSelectNewStigmataRuneRsp : BasePacket
|
||||||
{
|
{
|
||||||
public PacketSelectNewStigmataRuneRsp() : base(CmdIds.SelectNewStigmataRuneRsp)
|
public PacketSelectNewStigmataRuneRsp(uint selectUniqueId, bool isSelect) : base(CmdIds.SelectNewStigmataRuneRsp)
|
||||||
{
|
{
|
||||||
var proto = new SelectNewStigmataRuneRsp
|
var proto = new SelectNewStigmataRuneRsp
|
||||||
{
|
{
|
||||||
|
SelectUniqueId = selectUniqueId,
|
||||||
|
IsSelect = isSelect
|
||||||
};
|
};
|
||||||
|
|
||||||
SetData(proto);
|
SetData(proto);
|
||||||
|
|||||||
Reference in New Issue
Block a user