Skip to content

Commit

Permalink
Continue
Browse files Browse the repository at this point in the history
  • Loading branch information
Pythonic-Rainbow committed Oct 7, 2024
1 parent cbf7e5a commit 946f8de
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
37 changes: 15 additions & 22 deletions Bot/Clash/Coc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ private sealed class RaidAttackerComparer : IEqualityComparer<ClanCapitalRaidSea
private static ClashOfClansClient s_client;
private static ClanCapitalRaidSeason s_raidSeason;
internal static Clan s_clan;
internal static event Action<ClanMember, Main> EventMemberJoined;
internal static event Action<IEnumerable<Account>> EventMemberJoined;
internal static event Action<Account[]> EventMemberRejoined;
internal static event Action<Account[]> EventMemberLeft;
internal static event Action<ClanCapitalRaidSeason> EventInitRaid;
internal static event Action<ClanCapitalRaidSeason> EventRaidCompleted;
Expand All @@ -32,31 +33,16 @@ private sealed class RaidAttackerComparer : IEqualityComparer<ClanCapitalRaidSea
static Coc()
{
EventMemberLeft += MembersLeft;
EventMemberRejoined += MembersRejoined;
EventMemberJoined += MembersJoined;
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

private static void CheckMembersJoined(ClanUtil clan)
{
if (clan._joiningMembers.Count == 0)
{
return;
}
private static void MembersLeft(Account[] leftMembers) => Console.WriteLine($"{string.Join(",", leftMembers.Select(a => a.Id))} left");

Check notice on line 41 in Bot/Clash/Coc.cs

View workflow job for this annotation

GitHub Actions / inspect

"[IDE0320] Anonymous function can be made static" on /home/runner/work/Hyperstellar/Hyperstellar/Bot/Clash/Coc.cs(41,120)

string[] members = [.. clan._joiningMembers.Keys];
Account[] memberObjects = [.. members.Select(static memberId => new Account(memberId))];
Db.InsertAll(memberObjects);
string membersMsg = string.Join(", ", members);
Console.WriteLine($"{membersMsg} joined");
private static void MembersRejoined(Account[] leftMembers) => Console.WriteLine($"{string.Join(",", leftMembers.Select(a => a.Id))} rejoined");

Check notice on line 43 in Bot/Clash/Coc.cs

View workflow job for this annotation

GitHub Actions / inspect

"[IDE0320] Anonymous function can be made static" on /home/runner/work/Hyperstellar/Hyperstellar/Bot/Clash/Coc.cs(43,124)

foreach (ClanMember m in clan._joiningMembers.Values)
{
Main main = new(m.Tag);
EventMemberJoined(m, main);
main.Insert();
}
}

private static void MembersLeft(Account[] leftMembers) => Console.WriteLine($"{string.Join(",", leftMembers.Select(a => a.Id))} left");
private static void MembersJoined(IEnumerable<Account> leftMembers) => Console.WriteLine($"{string.Join(",", leftMembers.Select(a => a.Id))} joined");

Check notice on line 45 in Bot/Clash/Coc.cs

View workflow job for this annotation

GitHub Actions / inspect

"[IDE0320] Anonymous function can be made static" on /home/runner/work/Hyperstellar/Hyperstellar/Bot/Clash/Coc.cs(45,133)

private static async Task<Clan> GetClanAsync() => await s_client.Clans.GetClanAsync(ClanId);

Expand Down Expand Up @@ -102,7 +88,14 @@ private static async Task PollClanAsync()
{
EventMemberLeft(leftMembers);
}
CheckMembersJoined(clanUtil);
if (prevJoinAccounts.Length > 0)
{
EventMemberRejoined(prevJoinAccounts);
}
if (newJoinAccounts.Any())

Check warning on line 95 in Bot/Clash/Coc.cs

View workflow job for this annotation

GitHub Actions / inspect

"[PossibleMultipleEnumeration] Possible multiple enumeration" on /home/runner/work/Hyperstellar/Hyperstellar/Bot/Clash/Coc.cs(95,13)
{
EventMemberJoined(newJoinAccounts);

Check warning on line 97 in Bot/Clash/Coc.cs

View workflow job for this annotation

GitHub Actions / inspect

"[PossibleMultipleEnumeration] Possible multiple enumeration" on /home/runner/work/Hyperstellar/Hyperstellar/Bot/Clash/Coc.cs(97,31)
}
await Task.WhenAll([
CheckDonationsAsync(clanUtil)

Check failure on line 100 in Bot/Clash/Coc.cs

View workflow job for this annotation

GitHub Actions / inspect

"[.CSharpErrors] Cannot resolve symbol 'clanUtil'" on /home/runner/work/Hyperstellar/Hyperstellar/Bot/Clash/Coc.cs(100,33)

Check failure on line 100 in Bot/Clash/Coc.cs

View workflow job for this annotation

GitHub Actions / build

The name 'clanUtil' does not exist in the current context
]);
Expand Down
5 changes: 3 additions & 2 deletions Bot/Clash/Phaser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ private sealed class Node(long time)
static Phaser()
{
Coc.EventMemberJoined += MemberAdded;

Check failure on line 22 in Bot/Clash/Phaser.cs

View workflow job for this annotation

GitHub Actions / inspect

"[.CSharpErrors] Expected a method with 'void MemberAdded(IEnumerable<Account>)' signature" on /home/runner/work/Hyperstellar/Hyperstellar/Bot/Clash/Phaser.cs(22,34)

Check failure on line 22 in Bot/Clash/Phaser.cs

View workflow job for this annotation

GitHub Actions / build

No overload for 'MemberAdded' matches delegate 'Action<IEnumerable<Account>>'
Coc.EventMemberLeft += MemberLeft;
Coc.EventDonatedMaxFlow += DonationChanged;
Coc.EventInitRaid += InitRaid;
Coc.EventRaidCompleted += ProcessRaid;
Expand Down Expand Up @@ -146,8 +145,9 @@ private static void MemberAdded(ClanMember member, Main main)
}
}

private static void MemberLeft(ClanMember member, string? newMainId)
private static void MemberLeft(Account[] leftMembers)

Check warning on line 148 in Bot/Clash/Phaser.cs

View workflow job for this annotation

GitHub Actions / inspect

"[UnusedMember.Local] Method 'MemberLeft' is never used" on /home/runner/work/Hyperstellar/Hyperstellar/Bot/Clash/Phaser.cs(148,25)

Check warning on line 148 in Bot/Clash/Phaser.cs

View workflow job for this annotation

GitHub Actions / build

Remove unused parameter 'leftMembers' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)
{
/*
string id = member.Tag;
Console.WriteLine($"[Donate25] Removing {id} -> {newMainId}");
Node? node = s_queue.FirstOrDefault(n => n._ids.Remove(id));
Expand All @@ -160,6 +160,7 @@ private static void MemberLeft(ClanMember member, string? newMainId)
Console.WriteLine($"[Donate25] Added {newMainId} because it replaced {id} as main");
}
}
*/
}

private static void InitRaid(ClanCapitalRaidSeason season)
Expand Down

0 comments on commit 946f8de

Please sign in to comment.