public static string Dump(this ClanWarLeagueWar war) { var sb = new StringBuilder(); sb.Append(PSE(war.PreparationStartTime, war.StartTime, war.EndTime)); sb.Append(Environment.NewLine); sb.Append(war.Clan.Dump()); sb.Append(war.Opponent.Dump()); return(sb.ToString()); }
public async Task DisplayWarInfoAsync() { WarInformation clanCurrentWar; WarClanInformation friendlyClan; WarClanInformation opponentClan; if (_clanInformation.StoredClan == null) { await ReplyAsync("No clan selected"); return; } if (_clanInformation.StoredClanCurrentWar == null) { if (_clanInformation.StoredClanCurrentLeagueWar == null) { await Context.Channel.SendMessageAsync("Clan " + _clanInformation.StoredClan.Name + " is not currently at war."); return; } else { ClanWarLeagueWar currentLeagueWar = _clanInformation.StoredClanCurrentLeagueWar; friendlyClan = new WarClanInformation(currentLeagueWar.Clan, currentLeagueWar.Clan.BadgeUrls, currentLeagueWar.Clan.ClanLevel, currentLeagueWar.Clan.Attacks, currentLeagueWar.Clan.Stars, currentLeagueWar.Clan.DestructionPercentage, currentLeagueWar.Clan.Members); opponentClan = new WarClanInformation(currentLeagueWar.Opponent, currentLeagueWar.Opponent.BadgeUrls, currentLeagueWar.Opponent.ClanLevel, currentLeagueWar.Opponent.Attacks, currentLeagueWar.Opponent.Stars, currentLeagueWar.Opponent.DestructionPercentage, currentLeagueWar.Opponent.Members); clanCurrentWar = new WarInformation(currentLeagueWar, friendlyClan, opponentClan); } } else { CurrentWar currentWar = _clanInformation.StoredClanCurrentWar; friendlyClan = new WarClanInformation(currentWar.Clan, currentWar.Clan.BadgeUrls, currentWar.Clan.ClanLevel, currentWar.Clan.Attacks, currentWar.Clan.Stars, currentWar.Clan.DestructionPercentage, currentWar.Clan.Members); opponentClan = new WarClanInformation(currentWar.Opponent, currentWar.Opponent.BadgeUrls, currentWar.Opponent.ClanLevel, currentWar.Opponent.Attacks, currentWar.Opponent.Stars, currentWar.Opponent.DestructionPercentage, currentWar.Opponent.Members); clanCurrentWar = new WarInformation(currentWar, friendlyClan, opponentClan); } await Context.Channel.SendMessageAsync("", false, clanCurrentWar.BuildWarDescription()); }
private async Task <ClanWarLeagueWar> GetClanCurrentLeagueWar(Clan selectedClan, CurrentWarLeagueGroup currentWarLeagueGroup) { ClanWarLeagueWar currentLeagueWar = null; foreach (InlineModel0 model in currentWarLeagueGroup.Rounds) { foreach (string warTag in model.WarTags) { if (warTag.Contains("#0")) // #0 = Round not started { continue; } ClanWarLeagueWar war = await _clashClient.Clans.GetClanWarLeaguesWarsAsync(warTag); if (war.Clan.Tag == selectedClan.Tag) { if (war.State == State.InWar) { currentLeagueWar = war; break; } } else if (war.Opponent.Tag == selectedClan.Tag) { // If the opponent in the war is the selected clan, we want to switch the opponent and the main clan ClanWarLeagueWarClan tempMainClan = war.Clan; war.Clan = war.Opponent; war.Opponent = tempMainClan; if (war.State == State.InWar) { currentLeagueWar = war; break; } } } } return(currentLeagueWar); }