Example #1
0
        public override void ApplyAvatarChange(LogicClientAvatar avatar)
        {
            LogicLegendSeasonEntry legendSeasonEntry = this.VillageType == 1 ? avatar.GetLegendSeasonEntryVillage2() : avatar.GetLegendSeasonEntry();

            if (legendSeasonEntry.GetLastSeasonState() != this.Entry.GetLastSeasonState())
            {
                if (this.VillageType == 1)
                {
                    avatar.SetDuelScore(avatar.GetDuelScore() - this.ScoreChange);
                    avatar.SetLegendaryScore(avatar.GetLegendaryScoreVillage2() + this.ScoreChange);
                }
                else
                {
                    avatar.SetScore(avatar.GetScore() - this.ScoreChange);
                    avatar.SetLegendaryScore(avatar.GetLegendaryScore() + this.ScoreChange);
                }

                legendSeasonEntry.SetLastSeasonState(this.Entry.GetLastSeasonState());
                legendSeasonEntry.SetLastSeasonDate(this.Entry.GetLastSeasonYear(), this.Entry.GetLastSeasonMonth());
                legendSeasonEntry.SetLastSeasonRank(this.Entry.GetLastSeasonRank());
                legendSeasonEntry.SetLastSeasonScore(this.Entry.GetLastSeasonScore());

                if (this.BestSeason)
                {
                    legendSeasonEntry.SetBestSeasonState(this.Entry.GetBestSeasonState());
                    legendSeasonEntry.SetBestSeasonDate(this.Entry.GetBestSeasonYear(), this.Entry.GetBestSeasonMonth());
                    legendSeasonEntry.SetBestSeasonRank(this.Entry.GetBestSeasonRank());
                    legendSeasonEntry.SetBestSeasonScore(this.Entry.GetBestSeasonScore());
                }
            }
        }
Example #2
0
        public override int Execute(LogicLevel level)
        {
            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

            if (playerAvatar != null)
            {
                LogicLegendSeasonEntry legendSeasonEntry;

                if (this.m_villageType == 1)
                {
                    legendSeasonEntry = playerAvatar.GetLegendSeasonEntryVillage2();
                }
                else
                {
                    if (this.m_villageType != 0)
                    {
                        return(-2);
                    }

                    legendSeasonEntry = playerAvatar.GetLegendSeasonEntry();
                }

                if (legendSeasonEntry.GetLastSeasonState() != this.m_lastSeasonState)
                {
                    if (this.m_villageType == 1)
                    {
                        playerAvatar.SetDuelScore(playerAvatar.GetDuelScore() - this.m_scoreChange);
                        playerAvatar.SetLegendaryScore(playerAvatar.GetLegendaryScoreVillage2() + this.m_scoreChange);
                    }
                    else
                    {
                        playerAvatar.SetScore(playerAvatar.GetScore() - this.m_scoreChange);
                        playerAvatar.SetLegendaryScore(playerAvatar.GetLegendaryScore() + this.m_scoreChange);
                    }

                    legendSeasonEntry.SetLastSeasonState(this.m_lastSeasonState);
                    legendSeasonEntry.SetLastSeasonDate(this.m_lastSeasonYear, this.m_lastSeasonMonth);
                    legendSeasonEntry.SetLastSeasonRank(this.m_lastSeasonRank);
                    legendSeasonEntry.SetLastSeasonScore(this.m_lastSeasonScore);

                    bool bestSeason = false;

                    if (legendSeasonEntry.GetBestSeasonState() == 0 ||
                        this.m_lastSeasonRank < legendSeasonEntry.GetBestSeasonRank() ||
                        this.m_lastSeasonRank == legendSeasonEntry.GetBestSeasonRank() &&
                        this.m_lastSeasonScore > legendSeasonEntry.GetBestSeasonScore())
                    {
                        legendSeasonEntry.SetBestSeasonState(this.m_lastSeasonState);
                        legendSeasonEntry.SetBestSeasonDate(this.m_lastSeasonYear, this.m_lastSeasonMonth);
                        legendSeasonEntry.SetBestSeasonRank(this.m_lastSeasonRank);
                        legendSeasonEntry.SetBestSeasonScore(this.m_lastSeasonScore);

                        bestSeason = true;
                    }

                    playerAvatar.GetChangeListener().LegendSeasonScoreChanged(this.m_lastSeasonState, this.m_lastSeasonScore, this.m_scoreChange, bestSeason, this.m_villageType);
                    level.GetGameListener().LegendSeasonScoreChanged(this.m_lastSeasonState, this.m_lastSeasonScore, this.m_scoreChange, bestSeason, this.m_villageType);

                    return(0);
                }
            }

            return(-1);
        }