This commit is contained in:
2024-09-22 17:35:29 +02:00
parent 07556b4018
commit 4a6378dab0
23 changed files with 5554 additions and 1739 deletions

View File

@@ -1,63 +0,0 @@
public enum ChampionsEnum
{
ASHE = 0,
BLITZCRANK = 1 << 0,
ELISE = 1 << 1,
JAX = 1 << 2,
JAYCE = 1 << 3,
LILLIA = 1 << 4,
NOMSY = 1 << 5,
POPPY = 1 << 6,
SERAPHINE = 1 << 7,
SORAKA = 1 << 8,
TWITCH = 1 << 9,
WARWICK = 1 << 10,
ZIGGS = 1 << 11,
ZOE = 1 << 12,
AHRI = 1 << 13,
AKALI = 1 << 14,
CASSIOPEIA = 1 << 15,
GALIO = 1 << 16,
KASSADIN = 1 << 17,
KOGMAW = 1 << 18,
NILAH = 1 << 19,
NUNU = 1 << 20,
RUMBLE = 1 << 21,
SHYVANA = 1 << 22,
SYNDRA = 1 << 23,
TRISTANA = 1 << 24,
ZILEAN = 1 << 25,
BARD = 1 << 26,
EZREAL = 1 << 27,
HECARIM = 1 << 28,
HWEI = 1 << 29,
JINX = 1 << 30,
KATARINA = 1 << 31,
MORDEKAISER = 1 << 32,
NEEKO = 1 << 33,
SHEN = 1 << 34,
SWAIN = 1 << 35,
VEIGAR = 1 << 36,
VEX = 1 << 37,
WUKONG = 1 << 38,
FIORA = 1 << 39,
GWEN = 1 << 40,
KALISTA = 1 << 41,
KARMA = 1 << 42,
NAMI = 1 << 43,
NASUS = 1 << 44,
OLAF = 1 << 45,
RAKAN = 1 << 46,
RYZE = 1 << 47,
TAHMKENCH = 1 << 48,
TARIC = 1 << 49,
VARUS = 1 << 50,
BRIAR = 1 << 51,
CAMILLE = 1 << 52,
DIANA = 1 << 53,
MILLIO = 1 << 54,
MORGANA = 1 << 55,
NORRA = 1 << 56,
SMOLDER = 1 << 57,
XERATH = 1 << 58,
}

View File

@@ -0,0 +1,67 @@
using System.Collections.Generic;
namespace Assets.Data
{
public class ChampionUtils
{
public static HashSet<ChampionsEnum> FromLong(long champions)
{
HashSet<ChampionsEnum> result = new HashSet<ChampionsEnum>();
foreach (ChampionsEnum champion in System.Enum.GetValues(typeof(ChampionsEnum)))
{
if ((champions & (long)champion) != 0)
{
result.Add(champion);
}
}
return result;
}
public static long ToLong(HashSet<ChampionsEnum> champions)
{
long result = 0;
foreach (ChampionsEnum champion in champions)
{
result |= (long)champion;
}
return result;
}
public static long ToLong(ChampionsEnum champions)
{
return (long)champions;
}
public static bool ContainsChampion(long champions, ChampionsEnum champion)
{
return (champions & (long)champion) != 0;
}
public static bool ContainsChampion(long champions, long champion)
{
return (champions & champion) != 0;
}
public static int NumberOfChampions(long champions)
{
return BitWise.HammingWeight(champions);
}
public static long GetNthChampion(long champions, int n)
{
int kThFoundChampion = 0;
for (int i = 0; i < 64; i++)
{
if ((champions & (1L << i)) != 0)
{
if (kThFoundChampion == n)
{
return 1L << i;
}
kThFoundChampion++;
}
}
return 0;
}
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ae22ada17bccee84b817a24470d45e6a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,66 @@
using System;
[Flags]
public enum ChampionsEnum : long
{
ASHE = 1L << 0,
BLITZCRANK = 1L << 1,
ELISE = 1L << 2,
JAX = 1L << 3,
JAYCE = 1L << 4,
LILLIA = 1L << 5,
NOMSY = 1L << 6,
POPPY = 1L << 7,
SERAPHINE = 1L << 8,
SORAKA = 1L << 9,
TWITCH = 1L << 10,
WARWICK = 1L << 11,
ZIGGS = 1L << 12,
ZOE = 1L << 13,
AHRI = 1L << 14,
AKALI = 1L << 15,
CASSIOPEIA = 1L << 16,
GALIO = 1L << 17,
KASSADIN = 1L << 18,
KOGMAW = 1L << 19,
NILAH = 1L << 20,
NUNU = 1L << 21,
RUMBLE = 1L << 22,
SHYVANA = 1L << 23,
SYNDRA = 1L << 24,
TRISTANA = 1L << 25,
ZILEAN = 1L << 26,
BARD = 1L << 27,
EZREAL = 1L << 28,
HECARIM = 1L << 29,
HWEI = 1L << 30,
JINX = 1L << 31,
KATARINA = 1L << 32,
MORDEKAISER = 1L << 33,
NEEKO = 1L << 34,
SHEN = 1L << 35,
SWAIN = 1L << 36,
VEIGAR = 1L << 37,
VEX = 1L << 38,
WUKONG = 1L << 39,
FIORA = 1L << 40,
GWEN = 1L << 41,
KALISTA = 1L << 42,
KARMA = 1L << 43,
NAMI = 1L << 44,
NASUS = 1L << 45,
OLAF = 1L << 46,
RAKAN = 1L << 47,
RYZE = 1L << 48,
TAHMKENCH = 1L << 49,
TARIC = 1L << 50,
VARUS = 1L << 51,
BRIAR = 1L << 52,
CAMILLE = 1L << 53,
DIANA = 1L << 54,
MILLIO = 1L << 55,
MORGANA = 1L << 56,
NORRA = 1L << 57,
SMOLDER = 1L << 58,
XERATH = 1L << 59,
}

View File

@@ -9,10 +9,13 @@ public class TraitSelectorManager : MonoBehaviour
private TMP_InputField _compositionSize;
[SerializeField]
private ChampionSelector _championSelector;
private ChampionSelector _mandatorychampionSelector;
[SerializeField]
private UIToLogic _emblemSelector;
private ChampionSelector _acceptablechampionSelector;
[SerializeField]
private EmblemSelector _emblemSelector;
[SerializeField]
private int _traitThreshold = 7;
@@ -22,25 +25,28 @@ public class TraitSelectorManager : MonoBehaviour
public void ListAllActivableCompo()
{
emblemList = _emblemSelector.GetEmblems();
var champList = _championSelector.GetSelectedChampions();
var mandatoryChampions = ChampionUtils.ToLong(_mandatorychampionSelector.GetSelectedChampions());
var acceptableChampions = ChampionUtils.ToLong(_acceptablechampionSelector.GetSelectedChampions());
int compositionSize = _compositionSize.text == "" ? 1 : int.Parse(_compositionSize.text);
var coroutine = StartCoroutine(TraitsMapping.GetChampionSubsetsAsync(champList, compositionSize,emblemList, HandleCombination));
var composition = TraitsMapping.GenerateCombinations(mandatoryChampions, acceptableChampions, compositionSize);
Coroutine coroutine = StartCoroutine(TraitsMapping.DisplayCompositions(composition));
//var coroutine = StartCoroutine(TraitsMapping.GetChampionSubsetsAsync(champList, compositionSize,emblemList, HandleCombination));
}
private void HandleCombination(HashSet<ChampionsEnum> combination)
private void HandleCombination(long combination)
{
var synergies = TraitsMapping.MergeEmblems(
TraitsMapping.TraitCountInCompo(combination),
emblemList
);
var activeSynergies = TraitsMapping.FilterActiveTraits(synergies);
if (activeSynergies.Count >= _traitThreshold)
{
var s = TraitsMapping.CompositionToString(combination, activeSynergies);
Debug.Log(s);
} else {
Debug.LogWarning("Combination not valid");
}
// var synergies = TraitsMapping.MergeEmblems(
// TraitsMapping.TraitCountInCompo(combination),
// emblemList
// );
// var activeSynergies = TraitsMapping.FilterActiveTraits(synergies);
// if (TraitUtils.TraitCountFromInt(activeSynergies) >= _traitThreshold)
// {
// var s = TraitsMapping.CompositionToString(combination, activeSynergies);
// Debug.Log(s);
// } else {
// Debug.LogWarning("Combination not valid");
// }
}
}

View File

@@ -1,6 +1,52 @@
namespace Assets.Data
using System.Collections.Generic;
using System.Numerics;
namespace Assets.Data
{
public class TraitUtils
{
public static HashSet<TraitsEnum> FromInt(int traits)
{
HashSet<TraitsEnum> result = new HashSet<TraitsEnum>();
foreach (TraitsEnum trait in System.Enum.GetValues(typeof(TraitsEnum)))
{
if ((traits & (int)trait) != 0)
{
result.Add(trait);
}
}
return result;
}
public static int ToInt(HashSet<TraitsEnum> traits)
{
int result = 0;
foreach (TraitsEnum trait in traits)
{
result |= (int)trait;
}
return result;
}
public static int TraitCountFromInt(int traits)
{
int count = 0;
while (traits != 0)
{
count += traits & 1;
traits >>= 1;
}
return count;
}
public static bool ContainsTrait(int traits, TraitsEnum trait)
{
return (traits & (int)trait) != 0;
}
public static bool ContainsTrait(int traits, int trait)
{
return (traits & trait) != 0;
}
}
}

View File

@@ -1,26 +1,29 @@
public enum TraitsEnum
using System;
[Flags]
public enum TraitsEnum : int
{
ARCANA = 0,
CHRONO = 1 << 0,
DRAGON = 1 << 1,
DRUID = 1 << 2,
ELDRICHT = 1 << 3,
FAERIE = 1 << 4,
FROST = 1 << 5,
HONEYMANCY = 1 << 6,
PORTAL = 1 << 7,
PYRO = 1 << 8,
SUGARCRAFT = 1 << 9,
WITCHCRAFT = 1 << 10,
BASTION = 1 << 11,
BLASTER = 1 << 12,
HUNTER = 1 << 13,
INCANTATOR = 1 << 14,
MAGE = 1 << 15,
MULTISTRIKER = 1 << 16,
PRESERVER = 1 << 17,
SCHOLAR = 1 << 18,
SHAPESHIFTER = 1 << 19,
VANGUARD = 1 << 20,
WARRIOR = 1 << 21
ARCANA = 1 << 0,
CHRONO = 1 << 1,
DRAGON = 1 << 2,
DRUID = 1 << 3,
ELDRICHT = 1 << 4,
FAERIE = 1 << 5,
FROST = 1 << 6,
HONEYMANCY = 1 << 7,
PORTAL = 1 << 8,
PYRO = 1 << 9,
SUGARCRAFT = 1 << 10,
WITCHCRAFT = 1 << 11,
BASTION = 1 << 12,
BLASTER = 1 << 13,
HUNTER = 1 << 14,
INCANTATOR = 1 << 15,
MAGE = 1 << 16,
MULTISTRIKER = 1 << 17,
PRESERVER = 1 << 18,
SCHOLAR = 1 << 19,
SHAPESHIFTER = 1 << 20,
VANGUARD = 1 << 21,
WARRIOR = 1 << 22
}

File diff suppressed because it is too large Load Diff