我正在制作匹配系统(玩家对玩家)我的目标是。我怎样才能确保键被附加到我的 div 中?
我之前已经用append制作了一个key。这是片段
const source = [{
entryID: 1,
entryName: 'player1',
weight: 1900,
},
{
entryID: 2,
entryName: 'player2',
weight: 1900,
},
{
entryID: 3,
entryName: 'player3',
weight: 1910,
},
{
entryID: 4,
entryName: 'player4',
weight: 1910,
},
{
entryID: 5,
entryName: 'player5',
weight: 1915,
},
{
entryID: 6,
entryName: 'player6',
weight: 1915,
},
{
entryID: 7,
entryName: 'player7',
weight: 1920,
},
{
entryID: 8,
entryName: 'player8',
weight: 1920,
},
{
entryID: 9,
entryName: 'player9',
weight: 1930,
},
{ …Run Code Online (Sandbox Code Playgroud)我正在创建一个匹配功能,将 2 个体重相同的玩家配对。
目前它正在基于相同的重量工作。现在,我的目标是为每场比赛添加一个序列。例如。
*如果玩家 1参加了第 1 场比赛,那么玩家 1 的下一场比赛应该是第 4 场或第 6 场比赛。玩家的每场比赛应该至少有 3 个、最多 6 个间隙,然后才能再次匹配该特定玩家。
我在下面提供了当前的输出和目标输出。
const source = [
{
entryID: 1,
entryName: "player1",
weight: 1900,
class:[],
},
{
entryID: 2,
entryName: "player1",
weight: 1900,
class:[],
},
{
entryID: 3,
entryName: "player2",
weight: 1900,
class:[],
},
{
entryID: 4,
entryName: "player3",
weight: 1900,
class:[],
},
{
entryID: 5,
entryName: "player4",
weight: 1900,
class:[],
},
{
entryID: 6,
entryName: "player5",
weight: 1900,
class:[],
},
{ …Run Code Online (Sandbox Code Playgroud)