add 1x pull support

This commit is contained in:
SELEKCJONER
2024-09-10 18:31:11 +02:00
parent 745e6ca164
commit e14ede5295

View File

@@ -2,7 +2,6 @@
using EpinelPS.StaticInfo; using EpinelPS.StaticInfo;
using EpinelPS.Utils; using EpinelPS.Utils;
namespace EpinelPS.LobbyServer.Msgs.Gacha namespace EpinelPS.LobbyServer.Msgs.Gacha
{ {
[PacketPath("/gacha/execute")] [PacketPath("/gacha/execute")]
@@ -17,6 +16,10 @@ namespace EpinelPS.LobbyServer.Msgs.Gacha
protected override async Task HandleAsync() protected override async Task HandleAsync()
{ {
var req = await ReadData<ReqExecuteGacha>(); var req = await ReadData<ReqExecuteGacha>();
// Count determines whether we select 1 or 10 characters
int numberOfPulls = req.Count == 1 ? 1 : 10;
var user = GetUser(); var user = GetUser();
var response = new ResExecuteGacha(); var response = new ResExecuteGacha();
@@ -35,17 +38,17 @@ namespace EpinelPS.LobbyServer.Msgs.Gacha
// Check if user has 'sickpulls' set to true to use old method // Check if user has 'sickpulls' set to true to use old method
if (user.sickpulls) if (user.sickpulls)
{ {
// Old selection method: Randomly select 10 characters without rarity-based selection, excluding characters in the sickPullsExclusionList // Old selection method: Randomly select characters based on req.Count value, excluding characters in the sickPullsExclusionList
selectedCharacters = allCharacterData selectedCharacters = allCharacterData
.Where(c => !sickPullsExclusionList.Contains(c.id)) // Exclude characters based on the exclusion list for sick pulls .Where(c => !sickPullsExclusionList.Contains(c.id)) // Exclude characters based on the exclusion list for sick pulls
.OrderBy(x => random.Next()) .OrderBy(x => random.Next())
.Take(10) .Take(numberOfPulls)
.ToList(); .ToList();
} }
else else
{ {
// New method: Select 10 characters, with each character having its category determined independently, excluding characters in the normalPullsExclusionList // New method: Select characters based on req.Count value, with each character having its category determined independently, excluding characters in the normalPullsExclusionList
for (int i = 0; i < 10; i++) for (int i = 0; i < numberOfPulls; i++)
{ {
var character = SelectRandomCharacter(rCharacters, srCharacters, ssrCharacters, pilgrimCharacters, normalPullsExclusionList); var character = SelectRandomCharacter(rCharacters, srCharacters, ssrCharacters, pilgrimCharacters, normalPullsExclusionList);
selectedCharacters.Add(character); selectedCharacters.Add(character);