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

44
Assets/BitWise.cs Normal file
View File

@@ -0,0 +1,44 @@
using System.Collections.Generic;
public class BitWise
{
public static int HammingWeight(long x)
{
const long h01 = 0x0101010101010101;
const long m1 = 0x5555555555555555; // 0101...
const long m2 = 0x3333333333333333; // 00110011..
const long m4 = 0x0f0f0f0f0f0f0f0f;
x -= (x >> 1) & m1; // put count of each 2 bits into those 2 bits
x = (x & m2) + ((x >> 2) & m2); // put count of each 4 bits into those 4 bits
x = (x + (x >> 4)) & m4; // put count of each 8 bits into those 8 bits
return (int)((x * h01) >> 56);
}
/// <summary>
/// return all the permutation of n choose p, long output are bitflags were 1 bit represent selected.
/// Exactly n bits are set to 1, among the p first bits.
/// n parmi p
/// </summary>
/// <param name="totalNumberOfElement"></param>
/// <param name="numberOfElementToSelect"></param>
/// <returns></returns>
public static HashSet<long> GetAllPermutation(int numberOfElementToSelect, int totalNumberOfElement)
{
HashSet<long> result = new HashSet<long>();
if (numberOfElementToSelect>totalNumberOfElement)
{
return result;
}
long v = (1L << numberOfElementToSelect) - 1;
long end = 1L << totalNumberOfElement;
while (v < end)
{
result.Add(v);
long t = (v | (v - 1)) + 1;
v = t | ((((t & -t) / (v & -v)) >> 1) - 1);
}
return result;
}
}

2
Assets/BitWise.cs.meta Normal file
View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2a6dff4eb0cc0aa44a847ee093734b7a

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,77 @@
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
namespace Assets.Data
{
[TestFixture]
public class TestBitWise
{
[Test]
[TestCaseSource(typeof(BitwiseCase), "BitwiseCombination")]
public void TestBitwiseCombination(int n, int p, HashSet<long> expected)
{
HashSet<long> output = BitWise.GetAllPermutation(n, p);
Assert.IsTrue(output.SetEquals(expected));
}
}
public class BitwiseCase
{
public static IEnumerable BitwiseCombination
{
get
{
yield return new TestCaseData(
3,
5,
new HashSet<long>()
{
0b11100,
0b11010,
0b10110,
0b01110,
0b11001,
0b10101,
0b01101,
0b10011,
0b01011,
0b00111,
}
);
yield return new TestCaseData(
1,
1,
new HashSet<long>()
{
0b001
}
);
yield return new TestCaseData(
2,
3,
new HashSet<long>()
{
0b011,
0b110,
0b101
}
);
yield return new TestCaseData(
2,
4,
new HashSet<long>()
{
0b0011,
0b0101,
0b1001,
0b0110,
0b1010,
0b1100
}
);
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 82274463f1eeb5a4daa090c4c6de1d51

View File

@@ -0,0 +1,76 @@
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
namespace Assets.Data
{
[TestFixture]
public class TestChampionUtils
{
[Test]
[TestCaseSource(typeof(ChampionCase), "championsEnum")]
public void TestIntChampion(long champlong)
{
var champs = ChampionUtils.FromLong(champlong);
long output = ChampionUtils.ToLong(champs);
Assert.IsTrue(champlong == output);
}
[Test]
[TestCaseSource(typeof(ChampionCase), "championsNth")]
public void TestGetNthChampion(long champlons, int n, long expected)
{
long output = ChampionUtils.GetNthChampion(champlons, n);
Assert.IsTrue(output == expected);
}
}
public class ChampionCase
{
public static IEnumerable championsEnum
{
get
{
yield return 1223456L;
yield return 3422L;
yield return 97352L;
yield return 67855324254L;
yield return 432742125L;
yield return 76578256785L;
yield return 12345678912345678L;
}
}
public static IEnumerable championsNth
{
get
{
yield return new TestCaseData(
ChampionUtils.ToLong(ChampionsEnum.ASHE),
0,
ChampionUtils.ToLong(ChampionsEnum.ASHE)
);
yield return new TestCaseData(
ChampionUtils.ToLong(ChampionsEnum.SMOLDER),
0,
ChampionUtils.ToLong(ChampionsEnum.SMOLDER)
);
yield return new TestCaseData(
ChampionUtils.ToLong(new HashSet<ChampionsEnum>() { ChampionsEnum.AHRI }),
0,
ChampionUtils.ToLong(ChampionsEnum.AHRI)
);
yield return new TestCaseData(
ChampionUtils.ToLong(new HashSet<ChampionsEnum>() {
ChampionsEnum.AHRI,
ChampionsEnum.POPPY,
ChampionsEnum.SORAKA,
ChampionsEnum.HWEI }),
1,
ChampionUtils.ToLong(ChampionsEnum.SORAKA)
);
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5a66db3ba63d3984aa0460ad3ec3852a

View File

@@ -0,0 +1,168 @@
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
namespace Assets.Data
{
[TestFixture]
public class TestTraitsMapping
{
[Test]
[TestCaseSource(typeof(TraitsMappingCase), "ChampCombination")]
public void TestChampCombination(
long mandatoryChamps,
long possibleChamps,
int n,
List<long> expected
)
{
List<long> output = TraitsMapping.GenerateCombinations(
mandatoryChamps,
possibleChamps,
n
);
foreach (long champ in expected)
{
Assert.IsTrue(output.Contains(champ));
}
foreach (long champ in output)
{
Assert.IsTrue(expected.Contains(champ));
}
}
}
public class TraitsMappingCase
{
public static IEnumerable ChampCombination
{
get
{
yield return new TestCaseData(
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.ASHE,
ChampionsEnum.BLITZCRANK,
}
),
ChampionUtils.ToLong(new HashSet<ChampionsEnum>() { ChampionsEnum.ELISE }),
3,
new List<long>()
{
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.ASHE,
ChampionsEnum.BLITZCRANK,
ChampionsEnum.ELISE,
}
),
}
);
yield return new TestCaseData(
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.ASHE,
ChampionsEnum.BLITZCRANK,
}
),
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.ELISE,
ChampionsEnum.AHRI,
ChampionsEnum.CASSIOPEIA,
ChampionsEnum.EZREAL
}
),
5,
new List<long>()
{
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.ASHE,
ChampionsEnum.BLITZCRANK,
ChampionsEnum.ELISE,
ChampionsEnum.AHRI,
ChampionsEnum.CASSIOPEIA
}
),
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.ASHE,
ChampionsEnum.BLITZCRANK,
ChampionsEnum.ELISE,
ChampionsEnum.AHRI,
ChampionsEnum.EZREAL
}
),
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.ASHE,
ChampionsEnum.BLITZCRANK,
ChampionsEnum.ELISE,
ChampionsEnum.CASSIOPEIA,
ChampionsEnum.EZREAL
}
),
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.ASHE,
ChampionsEnum.BLITZCRANK,
ChampionsEnum.AHRI,
ChampionsEnum.CASSIOPEIA,
ChampionsEnum.EZREAL
}
),
}
);
yield return new TestCaseData(
ChampionUtils.ToLong(new HashSet<ChampionsEnum>() { ChampionsEnum.ELISE }),
ChampionUtils.ToLong(new HashSet<ChampionsEnum>() { ChampionsEnum.AHRI }),
1,
new List<long>()
{
ChampionUtils.ToLong(new HashSet<ChampionsEnum>() { ChampionsEnum.ELISE }),
}
);
yield return new TestCaseData(
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.AHRI,
ChampionsEnum.POPPY,
ChampionsEnum.SORAKA,
ChampionsEnum.HWEI,
}
),
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>() { ChampionsEnum.SMOLDER, ChampionsEnum.XERATH }
),
4,
new List<long>()
{
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.AHRI,
ChampionsEnum.POPPY,
ChampionsEnum.SORAKA,
ChampionsEnum.HWEI,
}
),
}
);
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bfc2ba87bb8472c4d9164a522a57147f

View File

@@ -8,37 +8,26 @@ namespace Assets.Data
public class TestTraitsUtils
{
[Test]
[TestCaseSource(typeof(BinaryCases), "EmblemsSynergies")]
[TestCaseSource(typeof(TraitTestCases), "EmblemsSynergies")]
public void TestMergeEmblems(
Dictionary<TraitsEnum, int> emblem,
Dictionary<TraitsEnum, int> synergies,
Dictionary<TraitsEnum, int> expected
Dictionary<int, int> emblem,
Dictionary<int, int> synergies,
Dictionary<int, int> expected
)
{
var output = TraitsMapping.MergeEmblems(emblem, synergies);
foreach (KeyValuePair<TraitsEnum, int> pair in expected)
foreach (KeyValuePair<int, int> pair in expected)
{
Assert.IsTrue(output[pair.Key] == pair.Value);
}
}
[Test]
[TestCaseSource(typeof(BinaryCases), "ActiveTraits")]
public void TestActiveSynergyFilter(
Dictionary<TraitsEnum, int> synergies,
HashSet<TraitsEnum> expected
)
[TestCaseSource(typeof(TraitTestCases), "ActiveTraits")]
public void TestActiveSynergyFilter(Dictionary<int, int> synergies, int expected)
{
var output = TraitsMapping.FilterActiveTraits(synergies);
foreach (TraitsEnum trait in expected)
{
Assert.IsTrue(expected.Contains(trait));
}
foreach (TraitsEnum trait in output)
{
Assert.IsTrue(output.Contains(trait));
}
int output = TraitsMapping.FilterActiveTraits(synergies);
Assert.IsTrue(Equals(output, expected));
}
[Test]
@@ -46,68 +35,94 @@ namespace Assets.Data
{
foreach (var champTraits in TraitsMapping.ChampsTraits)
{
foreach (var trait in champTraits.Value)
var champion = champTraits.Key;
var traits = TraitUtils.FromInt(champTraits.Value);
foreach (var trait in traits)
{
Assert.IsTrue(TraitsMapping.TraitsChamp[trait].Contains(champTraits.Key));
var allChampofTrait = TraitsMapping.TraitsChamp[(int)trait];
HashSet<ChampionsEnum> champions = ChampionUtils.FromLong(allChampofTrait);
Assert.IsTrue(
ChampionUtils.ContainsChampion(
allChampofTrait,
champion
)
);
}
}
foreach (var traitChamps in TraitsMapping.TraitsChamp)
foreach (var traitChamp in TraitsMapping.TraitsChamp)
{
foreach (var champ in traitChamps.Value)
var trait = traitChamp.Key;
var champions = ChampionUtils.FromLong(traitChamp.Value);
foreach (var champion in champions)
{
Assert.IsTrue(TraitsMapping.ChampsTraits[champ].Contains(traitChamps.Key));
var allTraitsOfChamp = TraitsMapping.ChampsTraits[(long)champion];
Assert.IsTrue(
TraitUtils.ContainsTrait(
allTraitsOfChamp,
trait
)
);
}
}
}
[Test]
[TestCaseSource(typeof(BinaryCases), "con")]
public void TestChampionCombination(HashSet<ChampionsEnum> champList, int compositionSize, int expectedCombinationCount)
[TestCaseSource(typeof(TraitTestCases), "traitsEnum")]
public void TestIntTrait(int traitInt)
{
var combination = TraitsMapping.GetChampionSubsets(champList, compositionSize);
Assert.IsTrue(combination.Count == expectedCombinationCount);
var traits = TraitUtils.FromInt(traitInt);
long output = TraitUtils.ToInt(traits);
Assert.IsTrue(traitInt == output);
}
[Test]
[TestCaseSource(typeof(TraitTestCases), "traitsToInt")]
public void TestTraitToInt(HashSet<TraitsEnum> traits, int expectedInt)
{
int output = TraitUtils.ToInt(traits);
Assert.IsTrue(output == expectedInt);
}
}
public class BinaryCases
public class TraitTestCases
{
public static IEnumerable EmblemsSynergies
{
get
{
yield return new TestCaseData(
new Dictionary<TraitsEnum, int> { { TraitsEnum.ARCANA, 1 } },
new Dictionary<TraitsEnum, int> { { TraitsEnum.ARCANA, 1 } },
new Dictionary<TraitsEnum, int> { { TraitsEnum.ARCANA, 2 } }
new Dictionary<int, int> { { (int)TraitsEnum.ARCANA, 1 } },
new Dictionary<int, int> { { (int)TraitsEnum.ARCANA, 1 } },
new Dictionary<int, int> { { (int)TraitsEnum.ARCANA, 2 } }
);
yield return new TestCaseData(
new Dictionary<TraitsEnum, int>
new Dictionary<int, int>
{
{ TraitsEnum.ARCANA, 1 },
{ TraitsEnum.DRAGON, 2 },
{ TraitsEnum.FROST, 3 },
{ TraitsEnum.HONEYMANCY, 4 },
{ TraitsEnum.PYRO, 5 },
{ TraitsEnum.WARRIOR, 6 },
{ (int)TraitsEnum.ARCANA, 1 },
{ (int)TraitsEnum.DRAGON, 2 },
{ (int)TraitsEnum.FROST, 3 },
{ (int)TraitsEnum.HONEYMANCY, 4 },
{ (int)TraitsEnum.PYRO, 5 },
{ (int)TraitsEnum.WARRIOR, 6 },
},
new Dictionary<TraitsEnum, int>
new Dictionary<int, int>
{
{ TraitsEnum.ARCANA, 1 },
{ TraitsEnum.DRAGON, 2 },
{ TraitsEnum.FROST, 3 },
{ TraitsEnum.HONEYMANCY, 4 },
{ TraitsEnum.PYRO, 5 },
{ TraitsEnum.WARRIOR, 6 },
{ (int)TraitsEnum.ARCANA, 1 },
{ (int)TraitsEnum.DRAGON, 2 },
{ (int)TraitsEnum.FROST, 3 },
{ (int)TraitsEnum.HONEYMANCY, 4 },
{ (int)TraitsEnum.PYRO, 5 },
{ (int)TraitsEnum.WARRIOR, 6 },
},
new Dictionary<TraitsEnum, int>
new Dictionary<int, int>
{
{ TraitsEnum.ARCANA, 2 },
{ TraitsEnum.DRAGON, 4 },
{ TraitsEnum.FROST, 6 },
{ TraitsEnum.HONEYMANCY, 8 },
{ TraitsEnum.PYRO, 10 },
{ TraitsEnum.WARRIOR, 12 },
{ (int)TraitsEnum.ARCANA, 2 },
{ (int)TraitsEnum.DRAGON, 4 },
{ (int)TraitsEnum.FROST, 6 },
{ (int)TraitsEnum.HONEYMANCY, 8 },
{ (int)TraitsEnum.PYRO, 10 },
{ (int)TraitsEnum.WARRIOR, 12 },
}
);
/*
@@ -145,41 +160,107 @@ namespace Assets.Data
get
{
yield return new TestCaseData(
new Dictionary<TraitsEnum, int>
new Dictionary<int, int>
{
{ TraitsEnum.ARCANA, 1 },
{ TraitsEnum.DRAGON, 2 },
{ TraitsEnum.FROST, 3 },
{ TraitsEnum.HONEYMANCY, 4 },
{ TraitsEnum.PYRO, 1 },
{ TraitsEnum.WARRIOR, 1 },
{ (int)TraitsEnum.ARCANA, 1 },
{ (int)TraitsEnum.DRAGON, 2 },
{ (int)TraitsEnum.FROST, 3 },
{ (int)TraitsEnum.HONEYMANCY, 4 },
{ (int)TraitsEnum.PYRO, 1 },
{ (int)TraitsEnum.WARRIOR, 1 },
},
TraitUtils.ToInt(
new HashSet<TraitsEnum>
{
TraitsEnum.DRAGON,
TraitsEnum.FROST,
TraitsEnum.HONEYMANCY
}
)
);
yield return new TestCaseData(
new Dictionary<int, int>
{
{ (int)TraitsEnum.ARCANA, 5 },
{ (int)TraitsEnum.FROST, 2 },
{ (int)TraitsEnum.HONEYMANCY, 7 },
{ (int)TraitsEnum.PYRO, 4 },
{ (int)TraitsEnum.WARRIOR, 3 },
},
TraitUtils.ToInt(
new HashSet<TraitsEnum>
{
TraitsEnum.ARCANA,
TraitsEnum.HONEYMANCY,
TraitsEnum.PYRO,
TraitsEnum.WARRIOR,
}
)
);
}
}
public static IEnumerable traitsEnum
{
get
{
yield return 156;
yield return 621;
yield return 123456;
yield return 5;
yield return 4194303; // max value
yield return 4194302;
}
}
public static IEnumerable traitsToInt
{
get
{
yield return new TestCaseData(
new HashSet<TraitsEnum>
{
TraitsEnum.ARCANA,
TraitsEnum.DRAGON
},
1<<0 | 1<<2
);
yield return new TestCaseData(
new HashSet<TraitsEnum>
{
TraitsEnum.ARCANA,
TraitsEnum.DRAGON,
TraitsEnum.FROST,
TraitsEnum.HONEYMANCY,
TraitsEnum.PYRO,
}
);
yield return new TestCaseData(
new Dictionary<TraitsEnum, int>
{
{ TraitsEnum.ARCANA, 5 },
{ TraitsEnum.FROST, 2 },
{ TraitsEnum.HONEYMANCY, 7 },
{ TraitsEnum.PYRO, 4 },
{ TraitsEnum.WARRIOR, 3 },
TraitsEnum.WARRIOR
},
new HashSet<TraitsEnum>
{
TraitsEnum.ARCANA,
TraitsEnum.HONEYMANCY,
TraitsEnum.PYRO,
TraitsEnum.WARRIOR,
}
);
1<<0 | 1<<2 | 1<<6 | 1<<7 | 1<<9 | 1<<22
);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.ARCANA},1 << 0);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.CHRONO},1 << 1);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.DRAGON},1 << 2);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.DRUID},1 << 3);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.ELDRICHT},1 << 4);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.FAERIE},1 << 5);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.FROST},1 << 6);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.HONEYMANCY},1 << 7);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.PORTAL},1 << 8);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.PYRO},1 << 9);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.SUGARCRAFT},1 << 10);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.WITCHCRAFT},1 << 11);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.BASTION},1 << 12);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.BLASTER},1 << 13);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.HUNTER},1 << 14);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.INCANTATOR},1 << 15);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.MAGE},1 << 16);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.MULTISTRIKER},1 << 17);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.PRESERVER},1 << 18);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.SCHOLAR},1 << 19);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.SHAPESHIFTER},1 << 20);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.VANGUARD},1 << 21);
yield return new TestCaseData(new HashSet<TraitsEnum>{TraitsEnum.WARRIOR},1 << 22);
}
}
}

View File

@@ -4,6 +4,7 @@ using UnityEngine.UI;
public class ChampionSelector : MonoBehaviour
{
[SerializeField] private bool _defaultSelection = false;
[SerializeField]
Toggle _ASHESelector;
@@ -255,65 +256,65 @@ public class ChampionSelector : MonoBehaviour
public void Reset()
{
_ASHESelector.enabled = true;
_BLITZCRANKSelector.enabled = true;
_ELISESelector.enabled = true;
_JAXSelector.enabled = true;
_JAYCESelector.enabled = true;
_LILLIASelector.enabled = true;
_NOMSYSelector.enabled = true;
_POPPYSelector.enabled = true;
_SERAPHINESelector.enabled = true;
_SORAKASelector.enabled = true;
_TWITCHSelector.enabled = true;
_WARWICKSelector.enabled = true;
_ZIGGSSelector.enabled = true;
_ZOESelector.enabled = true;
_AHRISelector.enabled = true;
_AKALISelector.enabled = true;
_CASSIOPEIASelector.enabled = true;
_GALIOSelector.enabled = true;
_KASSADINSelector.enabled = true;
_KOGMAWSelector.enabled = true;
_NILAHSelector.enabled = true;
_NUNUSelector.enabled = true;
_RUMBLESelector.enabled = true;
_SHYVANASelector.enabled = true;
_SYNDRASelector.enabled = true;
_TRISTANASelector.enabled = true;
_ZILEANSelector.enabled = true;
_BARDSelector.enabled = true;
_EZREALSelector.enabled = true;
_HECARIMSelector.enabled = true;
_HWEISelector.enabled = true;
_JINXSelector.enabled = true;
_KATARINASelector.enabled = true;
_MORDEKAISERSelector.enabled = true;
_NEEKOSelector.enabled = true;
_SHENSelector.enabled = true;
_SWAINSelector.enabled = true;
_VEIGARSelector.enabled = true;
_VEXSelector.enabled = true;
_WUKONGSelector.enabled = true;
_FIORASelector.enabled = true;
_GWENSelector.enabled = true;
_KALISTASelector.enabled = true;
_KARMASelector.enabled = true;
_NAMISelector.enabled = true;
_NASUSSelector.enabled = true;
_OLAFSelector.enabled = true;
_RAKANSelector.enabled = true;
_RYZESelector.enabled = true;
_TAHMKENCHSelector.enabled = true;
_TARICSelector.enabled = true;
_VARUSSelector.enabled = true;
_BRIARSelector.enabled = true;
_CAMILLESelector.enabled = true;
_DIANASelector.enabled = true;
_MILLIOSelector.enabled = true;
_MORGANASelector.enabled = true;
_NORRASelector.enabled = true;
_SMOLDERSelector.enabled = true;
_XERATHSelector.enabled = true;
_ASHESelector.isOn = _defaultSelection;
_BLITZCRANKSelector.isOn = _defaultSelection;
_ELISESelector.isOn = _defaultSelection;
_JAXSelector.isOn = _defaultSelection;
_JAYCESelector.isOn = _defaultSelection;
_LILLIASelector.isOn = _defaultSelection;
_NOMSYSelector.isOn = _defaultSelection;
_POPPYSelector.isOn = _defaultSelection;
_SERAPHINESelector.isOn = _defaultSelection;
_SORAKASelector.isOn = _defaultSelection;
_TWITCHSelector.isOn = _defaultSelection;
_WARWICKSelector.isOn = _defaultSelection;
_ZIGGSSelector.isOn = _defaultSelection;
_ZOESelector.isOn = _defaultSelection;
_AHRISelector.isOn = _defaultSelection;
_AKALISelector.isOn = _defaultSelection;
_CASSIOPEIASelector.isOn = _defaultSelection;
_GALIOSelector.isOn = _defaultSelection;
_KASSADINSelector.isOn = _defaultSelection;
_KOGMAWSelector.isOn = _defaultSelection;
_NILAHSelector.isOn = _defaultSelection;
_NUNUSelector.isOn = _defaultSelection;
_RUMBLESelector.isOn = _defaultSelection;
_SHYVANASelector.isOn = _defaultSelection;
_SYNDRASelector.isOn = _defaultSelection;
_TRISTANASelector.isOn = _defaultSelection;
_ZILEANSelector.isOn = _defaultSelection;
_BARDSelector.isOn = _defaultSelection;
_EZREALSelector.isOn = _defaultSelection;
_HECARIMSelector.isOn = _defaultSelection;
_HWEISelector.isOn = _defaultSelection;
_JINXSelector.isOn = _defaultSelection;
_KATARINASelector.isOn = _defaultSelection;
_MORDEKAISERSelector.isOn = _defaultSelection;
_NEEKOSelector.isOn = _defaultSelection;
_SHENSelector.isOn = _defaultSelection;
_SWAINSelector.isOn = _defaultSelection;
_VEIGARSelector.isOn = _defaultSelection;
_VEXSelector.isOn = _defaultSelection;
_WUKONGSelector.isOn = _defaultSelection;
_FIORASelector.isOn = _defaultSelection;
_GWENSelector.isOn = _defaultSelection;
_KALISTASelector.isOn = _defaultSelection;
_KARMASelector.isOn = _defaultSelection;
_NAMISelector.isOn = _defaultSelection;
_NASUSSelector.isOn = _defaultSelection;
_OLAFSelector.isOn = _defaultSelection;
_RAKANSelector.isOn = _defaultSelection;
_RYZESelector.isOn = _defaultSelection;
_TAHMKENCHSelector.isOn = _defaultSelection;
_TARICSelector.isOn = _defaultSelection;
_VARUSSelector.isOn = _defaultSelection;
_BRIARSelector.isOn = _defaultSelection;
_CAMILLESelector.isOn = _defaultSelection;
_DIANASelector.isOn = _defaultSelection;
_MILLIOSelector.isOn = _defaultSelection;
_MORGANASelector.isOn = _defaultSelection;
_NORRASelector.isOn = _defaultSelection;
_SMOLDERSelector.isOn = _defaultSelection;
_XERATHSelector.isOn = _defaultSelection;
}
}

View File

@@ -3,8 +3,9 @@ using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class UIToLogic : MonoBehaviour
public class EmblemSelector : MonoBehaviour
{
[SerializeField] private int _defaultEmblemCount = 0;
[SerializeField]
private TMP_InputField _arcanaEmblems;
@@ -107,28 +108,28 @@ public class UIToLogic : MonoBehaviour
}
public void Reset()
{
_arcanaEmblems.text = "0";
_chronoEmblems.text = "0";
_dragonEmblems.text = "0";
_druidEmblems.text = "0";
_eldrichtEmblems.text = "0";
_faerieEmblems.text = "0";
_frostEmblems.text = "0";
_honeymancyEmblems.text = "0";
_portalEmblems.text = "0";
_pyroEmblems.text = "0";
_sugarcraftEmblems.text = "0";
_witchcraftEmblems.text = "0";
_bastionEmblems.text = "0";
_blasterEmblems.text = "0";
_hunterEmblems.text = "0";
_incantatorEmblems.text = "0";
_mageEmblems.text = "0";
_multistrikerEmblems.text = "0";
_preserverEmblems.text = "0";
_scholarEmblems.text = "0";
_shapeshifterEmblems.text = "0";
_vanguardEmblems.text = "0";
_warriorEmblems.text = "0";
_arcanaEmblems.text = _defaultEmblemCount.ToString();
_chronoEmblems.text = _defaultEmblemCount.ToString();
_dragonEmblems.text = _defaultEmblemCount.ToString();
_druidEmblems.text = _defaultEmblemCount.ToString();
_eldrichtEmblems.text = _defaultEmblemCount.ToString();
_faerieEmblems.text = _defaultEmblemCount.ToString();
_frostEmblems.text = _defaultEmblemCount.ToString();
_honeymancyEmblems.text = _defaultEmblemCount.ToString();
_portalEmblems.text = _defaultEmblemCount.ToString();
_pyroEmblems.text = _defaultEmblemCount.ToString();
_sugarcraftEmblems.text = _defaultEmblemCount.ToString();
_witchcraftEmblems.text = _defaultEmblemCount.ToString();
_bastionEmblems.text = _defaultEmblemCount.ToString();
_blasterEmblems.text = _defaultEmblemCount.ToString();
_hunterEmblems.text = _defaultEmblemCount.ToString();
_incantatorEmblems.text = _defaultEmblemCount.ToString();
_mageEmblems.text = _defaultEmblemCount.ToString();
_multistrikerEmblems.text = _defaultEmblemCount.ToString();
_preserverEmblems.text = _defaultEmblemCount.ToString();
_scholarEmblems.text = _defaultEmblemCount.ToString();
_shapeshifterEmblems.text = _defaultEmblemCount.ToString();
_vanguardEmblems.text = _defaultEmblemCount.ToString();
_warriorEmblems.text = _defaultEmblemCount.ToString();
}
}

View File

@@ -158,7 +158,8 @@ PlayerSettings:
androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1
androidMinAspectRatio: 1
applicationIdentifier: {}
applicationIdentifier:
Standalone: com.DefaultCompany.TraitTracker
buildNumber:
Bratwurst: 0
Standalone: 0
@@ -664,6 +665,7 @@ PlayerSettings:
platformArchitecture: {}
scriptingBackend:
Android: 1
Standalone: 0
il2cppCompilerConfiguration: {}
il2cppCodeGeneration: {}
il2cppStacktraceInformation: {}
@@ -691,7 +693,7 @@ PlayerSettings:
gcIncremental: 1
gcWBarrierValidation: 0
apiCompatibilityLevelPerPlatform: {}
editorAssembliesCompatibilityLevel: 1
editorAssembliesCompatibilityLevel: 3
m_RenderingPath: 1
m_MobileRenderingPath: 1
metroPackageName: TraitTracker

File diff suppressed because it is too large Load Diff