Files
TraitTracker/Assets/Data/TraitsMapping.cs
2024-09-22 17:35:29 +02:00

1154 lines
40 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using UnityEngine;
namespace Assets.Data
{
public class TraitsMapping : MonoBehaviour
{
// long for champion, int for traits
public static Dictionary<long, int> ChampsTraits = new Dictionary<long, int>
{
{
(long)ChampionsEnum.ASHE,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.ELDRICHT, TraitsEnum.MULTISTRIKER }
)
},
{
(long)ChampionsEnum.BLITZCRANK,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.HONEYMANCY, TraitsEnum.VANGUARD }
)
},
{
(long)ChampionsEnum.ELISE,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.ELDRICHT, TraitsEnum.SHAPESHIFTER }
)
},
{
(long)ChampionsEnum.JAX,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.CHRONO, TraitsEnum.MULTISTRIKER }
)
},
{
(long)ChampionsEnum.JAYCE,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.PORTAL, TraitsEnum.SHAPESHIFTER }
)
},
{
(long)ChampionsEnum.LILLIA,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.FAERIE, TraitsEnum.BASTION })
},
{
(long)ChampionsEnum.NOMSY,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.DRAGON, TraitsEnum.HUNTER })
},
{
(long)ChampionsEnum.POPPY,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.WITCHCRAFT, TraitsEnum.BASTION }
)
},
{
(long)ChampionsEnum.SERAPHINE,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.FAERIE, TraitsEnum.MAGE })
},
{
(long)ChampionsEnum.SORAKA,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.SUGARCRAFT, TraitsEnum.MAGE })
},
{
(long)ChampionsEnum.TWITCH,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.FROST, TraitsEnum.HUNTER })
},
{
(long)ChampionsEnum.WARWICK,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.FROST, TraitsEnum.VANGUARD })
},
{
(long)ChampionsEnum.ZIGGS,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.HONEYMANCY, TraitsEnum.INCANTATOR }
)
},
{
(long)ChampionsEnum.ZOE,
TraitUtils.ToInt(
new HashSet<TraitsEnum>
{
TraitsEnum.WITCHCRAFT,
TraitsEnum.SCHOLAR,
TraitsEnum.PORTAL,
}
)
},
{
(long)ChampionsEnum.AHRI,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.ARCANA, TraitsEnum.SCHOLAR })
},
{
(long)ChampionsEnum.AKALI,
TraitUtils.ToInt(
new HashSet<TraitsEnum>
{
TraitsEnum.PYRO,
TraitsEnum.MULTISTRIKER,
TraitsEnum.WARRIOR,
}
)
},
{
(long)ChampionsEnum.CASSIOPEIA,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.WITCHCRAFT, TraitsEnum.INCANTATOR }
)
},
{
(long)ChampionsEnum.GALIO,
TraitUtils.ToInt(
new HashSet<TraitsEnum>
{
TraitsEnum.PORTAL,
TraitsEnum.VANGUARD,
TraitsEnum.MAGE,
}
)
},
{
(long)ChampionsEnum.KASSADIN,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.PORTAL, TraitsEnum.MULTISTRIKER }
)
},
{
(long)ChampionsEnum.KOGMAW,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.HONEYMANCY, TraitsEnum.HUNTER }
)
},
{
(long)ChampionsEnum.NILAH,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.ELDRICHT, TraitsEnum.WARRIOR }
)
},
{
(long)ChampionsEnum.NUNU,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.HONEYMANCY, TraitsEnum.BASTION }
)
},
{
(long)ChampionsEnum.RUMBLE,
TraitUtils.ToInt(
new HashSet<TraitsEnum>
{
TraitsEnum.SUGARCRAFT,
TraitsEnum.BLASTER,
TraitsEnum.VANGUARD,
}
)
},
{
(long)ChampionsEnum.SHYVANA,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.DRAGON, TraitsEnum.SHAPESHIFTER }
)
},
{
(long)ChampionsEnum.SYNDRA,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.ELDRICHT, TraitsEnum.INCANTATOR }
)
},
{
(long)ChampionsEnum.TRISTANA,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.FAERIE, TraitsEnum.BLASTER })
},
{
(long)ChampionsEnum.ZILEAN,
TraitUtils.ToInt(
new HashSet<TraitsEnum>
{
TraitsEnum.FROST,
TraitsEnum.CHRONO,
TraitsEnum.PRESERVER,
}
)
},
{
(long)ChampionsEnum.BARD,
TraitUtils.ToInt(
new HashSet<TraitsEnum>
{
TraitsEnum.SUGARCRAFT,
TraitsEnum.SCHOLAR,
TraitsEnum.PRESERVER,
}
)
},
{
(long)ChampionsEnum.EZREAL,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.PORTAL, TraitsEnum.BLASTER })
},
{
(long)ChampionsEnum.HECARIM,
TraitUtils.ToInt(
new HashSet<TraitsEnum>
{
TraitsEnum.ARCANA,
TraitsEnum.MULTISTRIKER,
TraitsEnum.BASTION,
}
)
},
{
(long)ChampionsEnum.HWEI,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.FROST, TraitsEnum.BLASTER })
},
{
(long)ChampionsEnum.JINX,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.SUGARCRAFT, TraitsEnum.HUNTER }
)
},
{
(long)ChampionsEnum.KATARINA,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.FAERIE, TraitsEnum.WARRIOR })
},
{
(long)ChampionsEnum.MORDEKAISER,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.ELDRICHT, TraitsEnum.VANGUARD }
)
},
{
(long)ChampionsEnum.NEEKO,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.WITCHCRAFT, TraitsEnum.SHAPESHIFTER }
)
},
{
(long)ChampionsEnum.SHEN,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.PYRO, TraitsEnum.BASTION })
},
{
(long)ChampionsEnum.SWAIN,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.FROST, TraitsEnum.SHAPESHIFTER }
)
},
{
(long)ChampionsEnum.VEIGAR,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.HONEYMANCY, TraitsEnum.MAGE })
},
{
(long)ChampionsEnum.VEX,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.CHRONO, TraitsEnum.MAGE })
},
{
(long)ChampionsEnum.WUKONG,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.DRUID })
},
{
(long)ChampionsEnum.FIORA,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.WITCHCRAFT, TraitsEnum.WARRIOR }
)
},
{
(long)ChampionsEnum.GWEN,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.SUGARCRAFT, TraitsEnum.WARRIOR }
)
},
{
(long)ChampionsEnum.KALISTA,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.FAERIE, TraitsEnum.MULTISTRIKER }
)
},
{
(long)ChampionsEnum.KARMA,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.INCANTATOR, TraitsEnum.CHRONO }
)
},
{
(long)ChampionsEnum.NAMI,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.ELDRICHT, TraitsEnum.MAGE })
},
{
(long)ChampionsEnum.NASUS,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.SHAPESHIFTER, TraitsEnum.PYRO }
)
},
{
(long)ChampionsEnum.OLAF,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.FROST, TraitsEnum.HUNTER })
},
{
(long)ChampionsEnum.RAKAN,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.FAERIE, TraitsEnum.PRESERVER }
)
},
{
(long)ChampionsEnum.RYZE,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.PORTAL, TraitsEnum.SCHOLAR })
},
{
(long)ChampionsEnum.TAHMKENCH,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.ARCANA, TraitsEnum.VANGUARD })
},
{
(long)ChampionsEnum.TARIC,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.PORTAL, TraitsEnum.BASTION })
},
{
(long)ChampionsEnum.VARUS,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.PYRO, TraitsEnum.BLASTER })
},
{
(long)ChampionsEnum.BRIAR,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.ELDRICHT, TraitsEnum.SHAPESHIFTER }
)
},
{
(long)ChampionsEnum.CAMILLE,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.CHRONO, TraitsEnum.MULTISTRIKER }
)
},
{
(long)ChampionsEnum.DIANA,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.FROST, TraitsEnum.BASTION })
},
{
(long)ChampionsEnum.MILLIO,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.FAERIE, TraitsEnum.SCHOLAR })
},
{
(long)ChampionsEnum.MORGANA,
TraitUtils.ToInt(
new HashSet<TraitsEnum> { TraitsEnum.WITCHCRAFT, TraitsEnum.PRESERVER }
)
},
{
(long)ChampionsEnum.NORRA,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.PORTAL, TraitsEnum.MAGE })
},
{
(long)ChampionsEnum.SMOLDER,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.DRAGON, TraitsEnum.BLASTER })
},
{
(long)ChampionsEnum.XERATH,
TraitUtils.ToInt(new HashSet<TraitsEnum> { TraitsEnum.ARCANA })
},
};
// int for trait and long for list of champions
public static Dictionary<int, long> TraitsChamp = new Dictionary<int, long>
{
{
(int)TraitsEnum.ARCANA,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.AHRI,
ChampionsEnum.HECARIM,
ChampionsEnum.TAHMKENCH,
ChampionsEnum.XERATH,
}
)
},
{
(int)TraitsEnum.CHRONO,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.CAMILLE,
ChampionsEnum.JAX,
ChampionsEnum.KARMA,
ChampionsEnum.VEX,
ChampionsEnum.ZILEAN,
}
)
},
{
(int)TraitsEnum.DRAGON,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.SMOLDER,
ChampionsEnum.SHYVANA,
ChampionsEnum.NOMSY,
}
)
},
{
(int)TraitsEnum.DRUID,
ChampionUtils.ToLong(new HashSet<ChampionsEnum>() { ChampionsEnum.WUKONG })
},
{
(int)TraitsEnum.ELDRICHT,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.ASHE,
ChampionsEnum.BRIAR,
ChampionsEnum.ELISE,
ChampionsEnum.MORDEKAISER,
ChampionsEnum.NAMI,
ChampionsEnum.NILAH,
ChampionsEnum.SYNDRA,
}
)
},
{
(int)TraitsEnum.FAERIE,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.KALISTA,
ChampionsEnum.KATARINA,
ChampionsEnum.LILLIA,
ChampionsEnum.MILLIO,
ChampionsEnum.RAKAN,
ChampionsEnum.SERAPHINE,
ChampionsEnum.TRISTANA,
}
)
},
{
(int)TraitsEnum.FROST,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.DIANA,
ChampionsEnum.HWEI,
ChampionsEnum.OLAF,
ChampionsEnum.SWAIN,
ChampionsEnum.TWITCH,
ChampionsEnum.WARWICK,
ChampionsEnum.ZILEAN,
}
)
},
{
(int)TraitsEnum.HONEYMANCY,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.BLITZCRANK,
ChampionsEnum.KOGMAW,
ChampionsEnum.NUNU,
ChampionsEnum.VEIGAR,
ChampionsEnum.ZIGGS,
}
)
},
{
(int)TraitsEnum.PORTAL,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.EZREAL,
ChampionsEnum.GALIO,
ChampionsEnum.JAYCE,
ChampionsEnum.KASSADIN,
ChampionsEnum.NORRA,
ChampionsEnum.RYZE,
ChampionsEnum.TARIC,
ChampionsEnum.ZOE,
}
)
},
{
(int)TraitsEnum.PYRO,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.AKALI,
ChampionsEnum.NASUS,
ChampionsEnum.SHEN,
ChampionsEnum.VARUS,
}
)
},
{
(int)TraitsEnum.SUGARCRAFT,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.BARD,
ChampionsEnum.GWEN,
ChampionsEnum.JINX,
ChampionsEnum.RUMBLE,
ChampionsEnum.SORAKA,
}
)
},
{
(int)TraitsEnum.WITCHCRAFT,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.CASSIOPEIA,
ChampionsEnum.FIORA,
ChampionsEnum.MORGANA,
ChampionsEnum.NEEKO,
ChampionsEnum.POPPY,
ChampionsEnum.ZOE,
}
)
},
{
(int)TraitsEnum.BASTION,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.DIANA,
ChampionsEnum.HECARIM,
ChampionsEnum.LILLIA,
ChampionsEnum.NUNU,
ChampionsEnum.POPPY,
ChampionsEnum.SHEN,
ChampionsEnum.TARIC,
}
)
},
{
(int)TraitsEnum.BLASTER,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.EZREAL,
ChampionsEnum.HWEI,
ChampionsEnum.RUMBLE,
ChampionsEnum.SMOLDER,
ChampionsEnum.TRISTANA,
ChampionsEnum.VARUS,
}
)
},
{
(int)TraitsEnum.HUNTER,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.JINX,
ChampionsEnum.KOGMAW,
ChampionsEnum.NOMSY,
ChampionsEnum.OLAF,
ChampionsEnum.TWITCH,
}
)
},
{
(int)TraitsEnum.INCANTATOR,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.CASSIOPEIA,
ChampionsEnum.KARMA,
ChampionsEnum.SYNDRA,
ChampionsEnum.ZIGGS,
}
)
},
{
(int)TraitsEnum.MAGE,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.GALIO,
ChampionsEnum.NAMI,
ChampionsEnum.NORRA,
ChampionsEnum.SERAPHINE,
ChampionsEnum.SORAKA,
ChampionsEnum.VEIGAR,
ChampionsEnum.VEX,
}
)
},
{
(int)TraitsEnum.MULTISTRIKER,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.AKALI,
ChampionsEnum.ASHE,
ChampionsEnum.CAMILLE,
ChampionsEnum.HECARIM,
ChampionsEnum.JAX,
ChampionsEnum.KALISTA,
ChampionsEnum.KASSADIN,
}
)
},
{
(int)TraitsEnum.PRESERVER,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.BARD,
ChampionsEnum.MORGANA,
ChampionsEnum.RAKAN,
ChampionsEnum.ZILEAN,
}
)
},
{
(int)TraitsEnum.SCHOLAR,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.AHRI,
ChampionsEnum.BARD,
ChampionsEnum.MILLIO,
ChampionsEnum.RYZE,
ChampionsEnum.ZOE,
}
)
},
{
(int)TraitsEnum.SHAPESHIFTER,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.BRIAR,
ChampionsEnum.ELISE,
ChampionsEnum.JAYCE,
ChampionsEnum.NASUS,
ChampionsEnum.NEEKO,
ChampionsEnum.SHYVANA,
ChampionsEnum.SWAIN,
}
)
},
{
(int)TraitsEnum.VANGUARD,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>()
{
ChampionsEnum.BLITZCRANK,
ChampionsEnum.GALIO,
ChampionsEnum.MORDEKAISER,
ChampionsEnum.RUMBLE,
ChampionsEnum.TAHMKENCH,
ChampionsEnum.WARWICK,
}
)
},
{
(int)TraitsEnum.WARRIOR,
ChampionUtils.ToLong(
new HashSet<ChampionsEnum>
{
ChampionsEnum.AKALI,
ChampionsEnum.FIORA,
ChampionsEnum.GWEN,
ChampionsEnum.KATARINA,
ChampionsEnum.NILAH,
}
)
},
};
public Dictionary<long, int> ChampionCost = new Dictionary<long, int>()
{
{ (long)ChampionsEnum.ASHE, 1 },
{ (long)ChampionsEnum.BLITZCRANK, 1 },
{ (long)ChampionsEnum.ELISE, 1 },
{ (long)ChampionsEnum.JAX, 1 },
{ (long)ChampionsEnum.JAYCE, 1 },
{ (long)ChampionsEnum.LILLIA, 1 },
{ (long)ChampionsEnum.NOMSY, 1 },
{ (long)ChampionsEnum.POPPY, 1 },
{ (long)ChampionsEnum.SERAPHINE, 1 },
{ (long)ChampionsEnum.SORAKA, 1 },
{ (long)ChampionsEnum.TWITCH, 1 },
{ (long)ChampionsEnum.WARWICK, 1 },
{ (long)ChampionsEnum.ZIGGS, 1 },
{ (long)ChampionsEnum.ZOE, 1 },
{ (long)ChampionsEnum.AHRI, 2 },
{ (long)ChampionsEnum.AKALI, 2 },
{ (long)ChampionsEnum.CASSIOPEIA, 2 },
{ (long)ChampionsEnum.GALIO, 2 },
{ (long)ChampionsEnum.KASSADIN, 2 },
{ (long)ChampionsEnum.KOGMAW, 2 },
{ (long)ChampionsEnum.NILAH, 2 },
{ (long)ChampionsEnum.NUNU, 2 },
{ (long)ChampionsEnum.RUMBLE, 2 },
{ (long)ChampionsEnum.SHYVANA, 2 },
{ (long)ChampionsEnum.SYNDRA, 2 },
{ (long)ChampionsEnum.TRISTANA, 2 },
{ (long)ChampionsEnum.ZILEAN, 2 },
{ (long)ChampionsEnum.BARD, 3 },
{ (long)ChampionsEnum.EZREAL, 3 },
{ (long)ChampionsEnum.HECARIM, 3 },
{ (long)ChampionsEnum.HWEI, 3 },
{ (long)ChampionsEnum.JINX, 3 },
{ (long)ChampionsEnum.KATARINA, 3 },
{ (long)ChampionsEnum.MORDEKAISER, 3 },
{ (long)ChampionsEnum.NEEKO, 3 },
{ (long)ChampionsEnum.SHEN, 3 },
{ (long)ChampionsEnum.SWAIN, 3 },
{ (long)ChampionsEnum.VEIGAR, 3 },
{ (long)ChampionsEnum.VEX, 3 },
{ (long)ChampionsEnum.WUKONG, 3 },
{ (long)ChampionsEnum.FIORA, 4 },
{ (long)ChampionsEnum.GWEN, 4 },
{ (long)ChampionsEnum.KALISTA, 4 },
{ (long)ChampionsEnum.KARMA, 4 },
{ (long)ChampionsEnum.NAMI, 4 },
{ (long)ChampionsEnum.NASUS, 4 },
{ (long)ChampionsEnum.OLAF, 4 },
{ (long)ChampionsEnum.RAKAN, 4 },
{ (long)ChampionsEnum.RYZE, 4 },
{ (long)ChampionsEnum.TAHMKENCH, 4 },
{ (long)ChampionsEnum.TARIC, 4 },
{ (long)ChampionsEnum.VARUS, 4 },
{ (long)ChampionsEnum.BRIAR, 5 },
{ (long)ChampionsEnum.CAMILLE, 5 },
{ (long)ChampionsEnum.DIANA, 5 },
{ (long)ChampionsEnum.MILLIO, 5 },
{ (long)ChampionsEnum.MORGANA, 5 },
{ (long)ChampionsEnum.NORRA, 5 },
{ (long)ChampionsEnum.SMOLDER, 5 },
{ (long)ChampionsEnum.XERATH, 5 },
};
public static Dictionary<int, List<int>> TraitsSteps = new Dictionary<int, List<int>>
{
{
(int)TraitsEnum.ARCANA,
new List<int> { 2, 3, 4, 5 }
},
{
(int)TraitsEnum.CHRONO,
new List<int> { 2, 4, 6 }
},
{
(int)TraitsEnum.DRAGON,
new List<int> { 2, 3 }
},
{
(int)TraitsEnum.DRUID,
new List<int> { 1 }
},
{
(int)TraitsEnum.ELDRICHT,
new List<int> { 3, 5, 7, 10 }
},
{
(int)TraitsEnum.FAERIE,
new List<int> { 3, 5, 7, 9 }
},
{
(int)TraitsEnum.FROST,
new List<int> { 3, 5, 7, 9 }
},
{
(int)TraitsEnum.HONEYMANCY,
new List<int> { 3, 5, 7 }
},
{
(int)TraitsEnum.PORTAL,
new List<int> { 3, 6, 8, 10 }
},
{
(int)TraitsEnum.PYRO,
new List<int> { 2, 3, 4, 5 }
},
{
(int)TraitsEnum.SUGARCRAFT,
new List<int> { 2, 4, 6 }
},
{
(int)TraitsEnum.WITCHCRAFT,
new List<int> { 2, 4, 6, 8 }
},
{
(int)TraitsEnum.BASTION,
new List<int> { 2, 4, 6, 8 }
},
{
(int)TraitsEnum.BLASTER,
new List<int> { 2, 4, 6 }
},
{
(int)TraitsEnum.HUNTER,
new List<int> { 2, 4, 6 }
},
{
(int)TraitsEnum.INCANTATOR,
new List<int> { 2, 4 }
},
{
(int)TraitsEnum.MAGE,
new List<int> { 3, 5, 7, 10 }
},
{
(int)TraitsEnum.MULTISTRIKER,
new List<int> { 3, 5, 7, 9 }
},
{
(int)TraitsEnum.PRESERVER,
new List<int> { 2, 3, 4, 5 }
},
{
(int)TraitsEnum.SCHOLAR,
new List<int> { 2, 4, 6 }
},
{
(int)TraitsEnum.SHAPESHIFTER,
new List<int> { 2, 4, 6, 8 }
},
{
(int)TraitsEnum.VANGUARD,
new List<int> { 2, 4, 6 }
},
{
(int)TraitsEnum.WARRIOR,
new List<int> { 2, 4, 6 }
},
};
public static Dictionary<int, int> minimalActivation = TraitsSteps.ToDictionary(
kvp => kvp.Key,
kvp => kvp.Value[0]
);
public bool TraitEnabled(int trait, int traitChampCount)
{
return traitChampCount >= minimalActivation[trait];
}
/// <summary>
/// first int is the trait, second int is the number of champions with this trait
/// </summary>
/// <param name="compo"></param>
/// <returns></returns>
public static Dictionary<int, int> TraitCountInCompo(long compo)
{
Dictionary<int, int> synergies = new Dictionary<int, int>();
for (int i = 0; i < 64; i++)
{
if ((compo & (1L << i)) != 0)
{
var champ = (long)i;
var traits = ChampsTraits[champ];
// combine the traits within synergies using bitwise operation
for (int trait = 0; trait < 22; trait++)
{
if ((traits & (1 << trait)) != 0)
{
if (synergies.ContainsKey(trait))
{
synergies[trait]++;
}
else
{
synergies.Add(trait, 1);
}
}
}
}
}
return synergies;
}
/// <summary>
/// first int is trait, second int is the number of champions with this trait
/// output is int of the flag of active traits
/// </summary>
/// <param name="synergies"></param>
/// <returns></returns>
public static int FilterActiveTraits(Dictionary<int, int> synergies)
{
int output = 0;
foreach (var kvp in synergies)
{
if (kvp.Value >= minimalActivation[kvp.Key])
{
output |= kvp.Key;
}
}
return output;
}
/// <summary>
/// trait is the trait, count is the number of champions with this trait
/// </summary>
/// <param name="synergies"></param>
/// <param name="additionalEmblems"></param>
/// <returns></returns>
public static Dictionary<int, int> MergeEmblems(
Dictionary<int, int> synergies,
Dictionary<int, int> additionalEmblems
)
{
Dictionary<int, int> mergedEmblems = new Dictionary<int, int>();
mergedEmblems = synergies
.Concat(additionalEmblems)
.GroupBy(x => x.Key)
.ToDictionary(x => x.Key, x => x.Sum(y => y.Value));
return mergedEmblems;
}
void Start()
{
}
public void DisplayTraits(Dictionary<TraitsEnum, int> traits)
{
foreach (var kvp in traits)
{
Debug.Log($"{kvp.Key} : {kvp.Value}");
}
}
public string DisplayComposition(HashSet<ChampionsEnum> compo)
{
StringBuilder sb = new StringBuilder();
foreach (var champ in compo)
{
sb.Append(champ.ToString() + " / ");
}
return sb.ToString();
}
// public static IEnumerator GetChampionSubsetsAsync(
// long possibleChamp,
// long mandatoryChamps,
// int size,
// Dictionary<int, int> emblemList,
// System.Action<long> onCombinationGenerated
// )
// {
// List<long> possibleChampList = new List<long>();
// foreach (var champ in ChampsTraits.Keys)
// {
// if ((possibleChamp & champ) != 0)
// {
// possibleChampList.Add(champ);
// }
// }
// int n = possibleChampList.Count;
// }
/// <summary>
/// Create a list of compositions based on the possible champions, mandatory champions, size of the composition, and the list of emblems.
/// each composition much contain all mandatory champs, and can contain any number of possible champs.
/// No other champions are allowed in the composition.
/// Composition is stored in the shape of a long, where each bit represents a champion.
///
/// </summary>
/// <param name="possibleChamp"></param>
/// <param name="mandatoryChamps"></param>
/// <param name="size"></param>
/// <param name="emblemList"></param>
/// <param name="onCombinationGenerated"></param>
// /// <returns></returns>
// public static List<long> GetCompositionList(
// long possibleChamp,
// long mandatoryChamps,
// int size,
// Dictionary<int, int> emblemList,
// System.Action<long> onCombinationGenerated
// )
// {
// Dictionary<int,int> allTraits = emblemList;
// int alreadySelectionChampCount = mandatoryChamps.CountSetBits();
// }
public static List<HashSet<ChampionsEnum>> GetChampionSubsets(
HashSet<ChampionsEnum> champs,
int size
)
{
List<HashSet<ChampionsEnum>> result = new List<HashSet<ChampionsEnum>>();
if (size == 0)
{
result.Add(new HashSet<ChampionsEnum>());
return result;
}
List<ChampionsEnum> champList = champs.ToList();
// Handle the edge case when size is greater than the number of available champions.
if (size > champList.Count)
{
return result; // No valid subsets if size is too large.
}
// Use a bit mask approach to generate all subsets of the specified size.
int n = champList.Count;
int[] indices = new int[size];
for (int i = 0; i < size; i++)
indices[i] = i;
while (true)
{
HashSet<ChampionsEnum> subset = new HashSet<ChampionsEnum>();
foreach (int index in indices)
{
subset.Add(champList[index]);
}
result.Add(subset);
// Generate the next combination of indices
int i;
for (i = size - 1; i >= 0; i--)
{
if (indices[i] != i + n - size)
{
break;
}
}
if (i < 0)
{
break; // All combinations have been generated.
}
indices[i]++;
for (int j = i + 1; j < size; j++)
{
indices[j] = indices[j - 1] + 1;
}
}
return result;
}
public static List<HashSet<ChampionsEnum>> GetChampionSubsetsRec(
HashSet<ChampionsEnum> champs,
int size
)
{
List<HashSet<ChampionsEnum>> result = new List<HashSet<ChampionsEnum>>();
if (size == 0)
{
result.Add(new HashSet<ChampionsEnum>());
return result;
}
if (champs.Count == 0)
{
return result;
}
ChampionsEnum first = champs.First();
HashSet<ChampionsEnum> rest = new HashSet<ChampionsEnum>(champs);
rest.Remove(first);
List<HashSet<ChampionsEnum>> subResult = GetChampionSubsetsRec(rest, size - 1);
foreach (var set in subResult)
{
set.Add(first);
}
result.AddRange(subResult);
result.AddRange(GetChampionSubsetsRec(rest, size));
return result;
}
public static int MaxIntForCombinationOfn(int n)
{
return (1 << n) - 1;
}
internal static string CompositionToString(
HashSet<ChampionsEnum> composition
)
{
StringBuilder sb = new StringBuilder();
foreach (var champ in composition)
{
sb.Append(champ.ToString() + " / ");
}
sb.Append(" --------- ");
// HashSet<TraitsEnum> activeSynergies = FilterActiveTraits(ChampionUtils.ToLong(composition)));
// foreach (var trait in activeSynergies)
// {
// sb.Append(trait.ToString() + " / ");
// }
return sb.ToString();
}
/// <summary>
/// I have a list of champion that are fixed, in a long called mandatoryChamps.
/// I have a list of champions that are possible, in a long called possibleChamps.
/// I want to generate all possible combinations of champions that contain all mandatory champions.
/// I can use MaxIntForCombinationOfn to get the maximum number of possible combinations and iterate over all possible combination,
/// each bit of the combination will represent the nth champion in the list of possible champions, which is not a list but a long.
/// The composition will be composed of all the mandatory champs and some of the possible champs, to add up to the composition size exactly.
/// </summary>
/// <param name="composition"></param>
/// <param name="activeSynergies"></param>
/// <returns></returns>
///
public static List<long> GenerateCombinations(
long mandatoryChamps,
long possibleChamps,
int compositionSize
) {
Assert.IsTrue((mandatoryChamps & possibleChamps) == 0);
List<long> compositions = new List<long>();
int champToSelectCount = compositionSize - ChampionUtils.NumberOfChampions(mandatoryChamps);
int possibleChampCount = ChampionUtils.NumberOfChampions(possibleChamps);
Assert.IsTrue(champToSelectCount >= 0); // else we have too many mandatory champs
HashSet<long> combinations = BitWise.GetAllPermutation(champToSelectCount, possibleChampCount);
foreach (var combinationOfPossibleChamps in combinations)
{
// generating one composition based on the combination.
// combination 10010 will add the second and fifth champion of the possibleChamps list to the composition.
long composition = mandatoryChamps;
int possibleChampIterator = 0;
int kThChampFound = 0;
while (possibleChampIterator < champToSelectCount)
{
if ((combinationOfPossibleChamps & (1 << possibleChampIterator)) != 0)
{
long champ = ChampionUtils.GetNthChampion(possibleChamps,kThChampFound);
composition |= champ;
kThChampFound++;
}
possibleChampIterator++;
}
compositions.Add(composition);
}
return compositions;
}
public static IEnumerator DisplayCompositions(List<long> compositions)
{
Debug.Log("Number of compositions : " + compositions.Count);
yield return null;
foreach (var compo in compositions)
{
Debug.Log(CompositionToString(ChampionUtils.FromLong(compo)));
yield return null;
}
}
}
}