public static bool DoesRewardWithoutWarHistoryExist(SquadController squadController, SquadMemberWarData memberWarData, uint serverTime) { if (memberWarData == null) { return(false); } Squad currentSquad = squadController.StateManager.GetCurrentSquad(); List <SquadWarRewardData> warRewards = memberWarData.WarRewards; int i = 0; int count = warRewards.Count; while (i < count) { SquadWarRewardData squadWarRewardData = warRewards[i]; if (squadWarRewardData.ExpireDate > serverTime) { bool flag = false; int j = 0; int count2 = currentSquad.WarHistory.Count; while (j < count2) { SquadWarHistoryEntry squadWarHistoryEntry = currentSquad.WarHistory[j]; if (squadWarHistoryEntry.WarId == squadWarRewardData.WarId) { flag = true; break; } j++; } if (!flag) { return(true); } } i++; } return(false); }
public override void RefreshView() { this.gridWarLog.Clear(); SquadController squadController = Service.SquadController; Squad currentSquad = squadController.StateManager.GetCurrentSquad(); if (currentSquad == null) { return; } uint serverTime = Service.ServerAPI.ServerTime; SquadMemberWarData currentMemberWarData = squadController.WarManager.GetCurrentMemberWarData(); int i = 0; int count = currentSquad.WarHistory.Count; while (i < count) { SquadWarHistoryEntry squadWarHistoryEntry = currentSquad.WarHistory[i]; UXElement uXElement = this.gridWarLog.CloneTemplateItem(squadWarHistoryEntry.WarId); this.gridWarLog.AddItem(uXElement, i); uXElement.Tag = squadWarHistoryEntry.WarId; SquadWarRewardData rewardForWar = SquadUtils.GetRewardForWar(squadWarHistoryEntry.WarId, currentMemberWarData); UXButton subElement = this.gridWarLog.GetSubElement <UXButton>(squadWarHistoryEntry.WarId, "BtnCollectWarReward"); UXLabel subElement2 = this.gridWarLog.GetSubElement <UXLabel>(squadWarHistoryEntry.WarId, "LabelBtnCollectWarReward"); subElement2.Text = this.lang.Get("SQUAD_WAR_LOG_COLLECT_REWARD", new object[0]); UXLabel subElement3 = this.gridWarLog.GetSubElement <UXLabel>(squadWarHistoryEntry.WarId, "LabelWarlogTimestamp"); subElement3.Text = this.lang.Get("TIME_AGO", new object[] { ChatTimeConversionUtils.GetFormattedAge(squadWarHistoryEntry.EndDate, this.lang) }); UXLabel subElement4 = this.gridWarLog.GetSubElement <UXLabel>(squadWarHistoryEntry.WarId, "LabelWarlogScore"); subElement4.Text = this.lang.Get("SQUAD_WAR_LOG_SCORE", new object[] { squadWarHistoryEntry.Score, squadWarHistoryEntry.OpponentScore }); UXLabel subElement5 = this.gridWarLog.GetSubElement <UXLabel>(squadWarHistoryEntry.WarId, "LabelWarlogOpponent"); string text = string.Empty; if (!string.IsNullOrEmpty(squadWarHistoryEntry.OpponentName)) { text = this.lang.Get("SQUAD_WAR_LOG_OPPONENT_VS", new object[] { squadWarHistoryEntry.OpponentName }); } subElement5.Text = text; UXLabel subElement6 = this.gridWarLog.GetSubElement <UXLabel>(squadWarHistoryEntry.WarId, "LabelWarlogExpires"); bool flag = rewardForWar != null && rewardForWar.ExpireDate > serverTime; if (flag) { int num = (int)(rewardForWar.ExpireDate - serverTime); string text2 = LangUtils.FormatTime((long)num); subElement6.Visible = true; text2 = this.lang.Get("expires_in", new object[] { text2 }); subElement6.Text = text2; subElement.Visible = true; subElement.OnClicked = new UXButtonClickedDelegate(this.OnCollectButtonClicked); subElement.Tag = rewardForWar.WarId; } else { subElement6.Visible = false; subElement.Visible = false; } UXSprite subElement7 = this.gridWarLog.GetSubElement <UXSprite>(squadWarHistoryEntry.WarId, "SpriteWarlogBgDraw"); subElement7.Visible = false; UXSprite subElement8 = this.gridWarLog.GetSubElement <UXSprite>(squadWarHistoryEntry.WarId, "SpriteWarlogBgLost"); subElement8.Visible = false; UXSprite subElement9 = this.gridWarLog.GetSubElement <UXSprite>(squadWarHistoryEntry.WarId, "SpriteWarlogBgWon"); subElement9.Visible = false; UXLabel subElement10 = this.gridWarLog.GetSubElement <UXLabel>(squadWarHistoryEntry.WarId, "LabelWarlogResult"); if (squadWarHistoryEntry.Score > squadWarHistoryEntry.OpponentScore) { subElement9.Visible = true; subElement10.Text = this.lang.Get("SQUAD_WAR_LOG_WIN", new object[0]); } else if (squadWarHistoryEntry.Score < squadWarHistoryEntry.OpponentScore) { subElement8.Visible = true; subElement10.Text = this.lang.Get("SQUAD_WAR_LOG_LOSS", new object[0]); } else { subElement7.Visible = true; subElement10.Text = this.lang.Get("SQUAD_WAR_LOG_DRAW", new object[0]); } i++; } this.gridWarLog.RepositionItemsFrameDelayed(); if (currentSquad.WarHistory.Count == 0) { this.labelEmptyWarlog.Visible = true; if (SquadUtils.SquadMeetsMatchmakingRequirements(squadController)) { this.labelEmptyWarlog.Text = this.lang.Get("SQUAD_WAR_LOG_EMPTY_HAS_REQUIREMENTS", new object[0]); } else { this.labelEmptyWarlog.Text = this.lang.Get("SQUAD_WAR_LOG_EMPTY_LACKS_REQUIREMENTS", new object[0]); } } else { this.labelEmptyWarlog.Visible = false; } this.RefreshBadge(); }