Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Flex strategy #242

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,33 @@ public override void OnSettingsDraw()
C.SecondFixIndex == C.ThirdFixIndex)
ImGuiEx.Text(EColor.RedBright, "Indexes must be different");
}

ImGui.Checkbox("Enabled Flex Priority", ref C.FlexEnabled);

ImGui.Unindent();
}

if (C.FlexEnabled)
{
ImGui.Indent();
if (C.PriorityData.PriorityLists.First().IsRole)
{
ImGuiEx.EnumCombo("1st Flex Role", ref C.FirstFlexRole);
ImGuiEx.EnumCombo("2nd Flex Role", ref C.SecondFlexRole);
ImGuiEx.EnumCombo("3rd Flex Role", ref C.ThirdFlexRole);
}
else
{
ImGui.SliderInt("1st Flex Index", ref C.FirstFlexIndex, 0, 5);
ImGui.SliderInt("2nd Flex Index", ref C.SecondFlexIndex, 0, 5);
ImGui.SliderInt("3rd Flex Index", ref C.ThirdFlexIndex, 0, 5);

if (C.FirstFlexIndex == C.SecondFlexIndex || C.FirstFlexIndex == C.ThirdFlexIndex ||
C.SecondFlexIndex == C.ThirdFlexIndex)
ImGuiEx.Text(EColor.RedBright, "Indexes must be different");
}
ImGui.Unindent();
}

if (ImGui.CollapsingHeader("Debug"))
{
Expand Down Expand Up @@ -155,22 +179,30 @@ public override void OnStartingCast(uint source, uint castId)
_state = State.Split;
var list = C.PriorityData.GetFirstValidList();
var players = C.PriorityData.GetPlayers(x => true);
var towers = _currentTowers.Where(x => x != null).Select(x => x!).ToList();
if (list is null || players is null)
{
DuoLog.Warning("[P1 Burn Strike Tower] Priority list is not setup");
return;
}

if (towers.Count != 3)
{
DuoLog.Warning("[P1 Burn Strike Tower] Tower is null");
return;
}

var roleList = list.List
.Select(x =>
x.IsInParty(list.IsRole, out var upm) ? (upm.Name, x.Role) : ("", RolePosition.Not_Selected))
.ToDictionary(x => x.Item1, x => x.Item2);


if (C.FixEnabled)
{
List<string> nonFixed;
if (list.IsRole)
{
var roleList = list.List
.Select(x =>
x.IsInParty(list.IsRole, out var upm) ? (upm.Name, x.Role) : ("", RolePosition.Not_Selected))
.ToDictionary(x => x.Item1, x => x.Item2);
var myRole = roleList[Player.Name];
if (C.FirstFixRole == myRole)
_myTower = _currentTowers[0];
Expand All @@ -191,45 +223,90 @@ public override void OnStartingCast(uint source, uint castId)
_myTower = _currentTowers[1];
else if (myIndex == C.ThirdFixIndex)
_myTower = _currentTowers[2];

nonFixed = players
.Where((_, i) => i != C.FirstFixIndex && i != C.SecondFixIndex && i != C.ThirdFixIndex)
.Select(x => x.Name).ToList();
}

foreach (var tower in _currentTowers)
if (C.FlexEnabled)
{
if (tower is null)
Queue<string> nonDecided = [];
List<string> flexPlayers;
if (list.IsRole)
{
DuoLog.Warning("[P1 Burn Strike Tower] Tower is null");
continue;
flexPlayers = roleList
.Where(x => x.Value == C.FirstFlexRole || x.Value == C.SecondFlexRole ||
x.Value == C.ThirdFlexRole).Select(x => x.Key).ToList();
}
else
{
flexPlayers = players
.Where((_, i) => i == C.FirstFlexIndex || i == C.SecondFlexIndex || i == C.ThirdFlexIndex)
.Select(x => x.Name).ToList();
}

var towerCount = TowerCastIds.First(x => x.Value.Contains(tower.CastActionId)).Key;
var remaining = towerCount - 1;

if (remaining == 0) continue;
for (int i = 0; i < towers.Count; i++)
{
var tower = towers[i];
var player = flexPlayers[i];

var towerCount = TowerCastIds.First(x => x.Value.Contains(tower.CastActionId)).Key;
if (towerCount == 2)
{
if (player == Player.Name)
_myTower = tower;
}
else
{
nonDecided.Enqueue(player);
}
}

for (var i = 0; i < remaining; i++)
foreach (var tower in towers)
{
if (nonFixed.First() == Player.Name)
_myTower = tower;
nonFixed.RemoveAt(0);

var towerCount = TowerCastIds.First(x => x.Value.Contains(tower.CastActionId)).Key;
switch (towerCount)
{
case 3:
{
var first = nonDecided.Dequeue();
if (first == Player.Name)
_myTower = tower;
break;
}
case 4:
{
var first = nonDecided.Dequeue();
var second = nonDecided.Dequeue();
if (first == Player.Name || second == Player.Name)
_myTower = tower;
break;
}
}
}
}
else
{
foreach (var tower in towers)
{
var towerCount = TowerCastIds.First(x => x.Value.Contains(tower.CastActionId)).Key;
var remaining = towerCount - 1;
if (remaining == 0) continue;
for (var i = 0; i < remaining; i++)
{
if (nonFixed.First() == Player.Name)
_myTower = tower;
nonFixed.RemoveAt(0);
}
}
}
}

else
{
var index = 0;
foreach (var tower in _currentTowers)
foreach (var tower in towers)
{
if (tower is null)
{
DuoLog.Warning("[P1 Burn Strike Tower] Tower is null");
continue;
}

var towerCount = TowerCastIds.First(x => x.Value.Contains(tower.CastActionId)).Key;
var lastIndex = index;
index += towerCount;
Expand Down Expand Up @@ -260,15 +337,22 @@ private class Config : IEzConfig
public readonly Vector4 BaitColor1 = 0xFFFF00FF.ToVector4();
public readonly Vector4 BaitColor2 = 0xFFFFFF00.ToVector4();

public int FirstFixIndex;
public int FirstFixIndex = 0;
public RolePosition FirstFixRole = RolePosition.H1;

public bool FixEnabled;
public bool FlexEnabled;
public PriorityData6 PriorityData = new();
public int SecondFixIndex = 1;
public RolePosition SecondFixRole = RolePosition.H2;
public int ThirdFixIndex = 5;
public RolePosition ThirdFixRole = RolePosition.R2;

public int FirstFlexIndex = 2;
public RolePosition FirstFlexRole = RolePosition.M1;
public int SecondFlexIndex = 3;
public RolePosition SecondFlexRole = RolePosition.M2;
public int ThirdFlexIndex = 4;
public RolePosition ThirdFlexRole = RolePosition.R1;
}

private class PriorityData6 : PriorityData
Expand Down