mirror of
https://github.com/BtbN/ClanServer.git
synced 2026-04-21 00:37:15 -05:00
Use random musicIDs instead of hardcoded ones
This commit is contained in:
parent
5a46b56591
commit
974ce2075c
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using eAmuseCore.KBinXML;
|
||||
|
||||
using ClanServer.Routing;
|
||||
using ClanServer.Data.L44;
|
||||
|
||||
namespace ClanServer.Controllers.L44
|
||||
{
|
||||
|
|
@ -43,25 +44,15 @@ namespace ClanServer.Controllers.L44
|
|||
}
|
||||
|
||||
[HttpPost, Route("8"), XrpcCall("demodata.get_hitchart")]
|
||||
public ActionResult<EamuseXrpcData> GetHitchart([FromBody] EamuseXrpcData data)
|
||||
public async Task<ActionResult<EamuseXrpcData>> GetHitchart([FromBody] EamuseXrpcData data)
|
||||
{
|
||||
int[] hitChart = new int[]
|
||||
{
|
||||
70000110,
|
||||
80000016,
|
||||
60000080,
|
||||
50000071,
|
||||
60000115,
|
||||
30000004,
|
||||
70000079,
|
||||
50000113,
|
||||
80000086,
|
||||
70000033
|
||||
};
|
||||
ClanMusicInfo mInfo = await ClanMusicInfo.Instance;
|
||||
|
||||
XElement orgElem = new XElement("hitchart_org", new XAttribute("count", hitChart.Length));
|
||||
List<int> hitChart = mInfo.GetRandomSongs(10);
|
||||
|
||||
for (short i = 0; i < hitChart.Length; ++i)
|
||||
XElement orgElem = new XElement("hitchart_org", new XAttribute("count", hitChart.Count));
|
||||
|
||||
for (short i = 0; i < hitChart.Count; ++i)
|
||||
{
|
||||
orgElem.Add(new XElement("rankdata",
|
||||
new KS32("music_id", hitChart[i]),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -11,6 +11,7 @@ using eAmuseCore.KBinXML;
|
|||
using ClanServer.Routing;
|
||||
using ClanServer.Helpers;
|
||||
using ClanServer.Models;
|
||||
using ClanServer.Data.L44;
|
||||
|
||||
namespace ClanServer.Controllers.L44
|
||||
{
|
||||
|
|
@ -350,22 +351,31 @@ namespace ClanServer.Controllers.L44
|
|||
GenClanCourseList(),
|
||||
new XElement("server"),
|
||||
new XElement("rivallist"),
|
||||
new XElement("fc_challenge",
|
||||
new XElement("today",
|
||||
new KS32("music_id", 40000057),
|
||||
new KU8("state", 0)
|
||||
),
|
||||
new XElement("whim",
|
||||
new KS32("music_id", 30000041),
|
||||
new KU8("state", 80)
|
||||
)
|
||||
),
|
||||
await GenFcChallenge(),
|
||||
new XElement("navi",
|
||||
new KU64("flag", freshProfile ? 0UL : 122UL)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private async Task<XElement> GenFcChallenge()
|
||||
{
|
||||
ClanMusicInfo mInfo = await ClanMusicInfo.Instance;
|
||||
|
||||
List<int> songs = mInfo.GetRandomSongs(2);
|
||||
|
||||
return new XElement("fc_challenge",
|
||||
new XElement("today",
|
||||
new KS32("music_id", songs[0]),
|
||||
new KU8("state", 0)
|
||||
),
|
||||
new XElement("whim",
|
||||
new KS32("music_id", songs[1]),
|
||||
new KU8("state", 80)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private XElement GenJubilityTargetMusicList(JubeatProfile profile)
|
||||
{
|
||||
XElement res = new XElement("target_music_list");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using eAmuseCore.KBinXML;
|
||||
|
||||
using ClanServer.Routing;
|
||||
using ClanServer.Data.L44;
|
||||
|
||||
namespace ClanServer.Controllers.L44
|
||||
{
|
||||
|
|
@ -15,33 +16,24 @@ namespace ClanServer.Controllers.L44
|
|||
public class RecommendController : ControllerBase
|
||||
{
|
||||
[HttpPost, Route("8"), XrpcCall("recommend.get_recommend")]
|
||||
public ActionResult<EamuseXrpcData> GetRecommend([FromBody] EamuseXrpcData data)
|
||||
public async Task<ActionResult<EamuseXrpcData>> GetRecommend([FromBody] EamuseXrpcData data)
|
||||
{
|
||||
XElement recommend = data.Document.Element("call").Element("recommend");
|
||||
XElement player = recommend.Element("data").Element("player");
|
||||
_ = int.Parse(player.Element("jid").Value);
|
||||
|
||||
int[] recommendedMusic = new int[]
|
||||
{
|
||||
80000016,
|
||||
60000080,
|
||||
50000113,
|
||||
70000110,
|
||||
80000126,
|
||||
60000115,
|
||||
80000050,
|
||||
80000086,
|
||||
30000048,
|
||||
70000079
|
||||
};
|
||||
ClanMusicInfo mInfo = await ClanMusicInfo.Instance;
|
||||
|
||||
List<int> recommendedMusic = mInfo.GetRandomSongs(10);
|
||||
Random rng = new Random();
|
||||
|
||||
XElement musicList = new XElement("music_list");
|
||||
|
||||
for (int i = 0; i < recommendedMusic.Length; ++i)
|
||||
for (int i = 0; i < recommendedMusic.Count; ++i)
|
||||
{
|
||||
musicList.Add(new XElement("music", new XAttribute("order", i),
|
||||
new KS32("music_id", recommendedMusic[i]),
|
||||
new KS8("seq", 0)
|
||||
new KS8("seq", (sbyte)rng.Next(3))
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,10 +73,9 @@ namespace ClanServer.Data.L44
|
|||
{
|
||||
HashSet<int> candidateIndexes = new HashSet<int>();
|
||||
while (candidateIndexes.Count < num)
|
||||
candidateIndexes.Add(rng.Next(0, musicIdList.Count));
|
||||
candidateIndexes.Add(rng.Next(musicIdList.Count));
|
||||
|
||||
List<int> result = new List<int>(num);
|
||||
result.AddRange(candidateIndexes.Select(i => musicIdList[i]));
|
||||
List<int> result = candidateIndexes.Select(i => musicIdList[i]).ToList();
|
||||
|
||||
for (int i = result.Count - 1; i > 0; --i)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user