Пример #1
0
        /// <summary>
        /// Update the header with the name of the given chapter
        /// </summary>
        public void UpdateHeaderChapter(Enums.Chapter chapterId)
        {
            var chapterData = Data.Database.Chapters.GetByID(chapterId);

            _chapterSave.Header.CurrentChapter = chapterId;
            _chapterSave.Header.ChapterName1   = chapterData.DisplayName1;
            _chapterSave.Header.ChapterName2   = chapterData.DisplayName2;
        }
Пример #2
0
        private void AddBattlefield(byte battlefieldId, Enums.Chapter chapterId)
        {
            var raw         = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF };
            var battlefield = new Battlefield(raw);

            battlefield.BattlefieldID = battlefieldId;
            battlefield.ChapterID     = chapterId;
            _chapterSave.BattlefieldRegion.Battlefields.Add(battlefield);
        }
Пример #3
0
        private void RemoveBattlefield(Enums.Chapter chapterId)
        {
            var battlefield = _chapterSave.BattlefieldRegion.Battlefields.Where(x => x.ChapterID == chapterId).FirstOrDefault();

            if (battlefield != null)
            {
                _chapterSave.BattlefieldRegion.Battlefields.Remove(battlefield);
            }
        }
Пример #4
0
        public Chapter GetByID(Enums.Chapter chapterId)
        {
            var row = _data
                      .Elements("chapter")
                      .Where((x) => x.Attribute("id").Value == ((byte)chapterId).ToString())
                      .First();

            return(FromElement(row));
        }
Пример #5
0
        public void UnplayChapter(Enums.Chapter chapterId)
        {
            _chapterSave.UserRegion.ChapterHistory.RemoveAll((x) => x.ChapterID == chapterId);

            var battlefields = _chapterSave.BattlefieldRegion.Battlefields.Where((x) => x.ChapterID == chapterId);

            foreach (var battlefield in battlefields)
            {
                battlefield.BattlefieldStatus = Enums.BattlefieldStatus.Available;
            }
        }
Пример #6
0
        /// <summary>
        /// Unlocks a chapter and sets it available if it's currently set to unavailable.
        /// Mainly for amiibo chapter unlocking.
        /// </summary>
        public void UnlockChapter(Enums.Chapter chapterId)
        {
            var battlefields = _chapterSave.BattlefieldRegion.Battlefields.Where((x) => x.ChapterID == chapterId);

            foreach (var battlefield in battlefields)
            {
                if (battlefield.BattlefieldStatus == Enums.BattlefieldStatus.Unavailable)
                {
                    battlefield.BattlefieldStatus = Enums.BattlefieldStatus.Available;
                }
            }
        }
Пример #7
0
        public bool CanUnplayChapter(Enums.Chapter chapterId)
        {
            var chapterData = Data.Database.Chapters.GetByID(chapterId);

            foreach (var unlockedChapterId in chapterData.UnlocksChapters)
            {
                if (_chapterSave.BattlefieldRegion.Battlefields
                    .Where(x => x.ChapterID == unlockedChapterId && x.BattlefieldStatus == Enums.BattlefieldStatus.Completed)
                    .Any())
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #8
0
 public bool CanUnplayChapter(Enums.Chapter chapterId)
 {
     return(_timeMachine.CanUnplayChapter(chapterId));
 }
Пример #9
0
 public void UnplayChapter(Enums.Chapter chapterId)
 {
     _timeMachine.UnplayChapter(chapterId);
     UpdateAvailableBattlefields();
 }
Пример #10
0
        public void UnplayChapter(Enums.Chapter chapterId)
        {
            // Set the newly unplayed chapter to available
            _chapterSave.UserRegion.ChapterHistory.RemoveAll((x) => x.ChapterID == chapterId);

            var battlefields = _chapterSave.BattlefieldRegion.Battlefields.Where((x) => x.ChapterID == chapterId);

            foreach (var battlefield in battlefields)
            {
                battlefield.BattlefieldStatus = Enums.BattlefieldStatus.Available;
            }

            // Set any chapters beating this chapter would unlock to unavailable
            var chapterData = Data.Database.Chapters.GetByID(chapterId);

            foreach (var unlockedChapterId in chapterData.UnlocksChapters)
            {
                var dependentBattlefield = _chapterSave.BattlefieldRegion.Battlefields.Where(x => x.ChapterID == unlockedChapterId).FirstOrDefault();
                if (dependentBattlefield != null)
                {
                    dependentBattlefield.BattlefieldStatus = Enums.BattlefieldStatus.Unavailable;
                }
            }

            // Update the header if we just unplayed a story chapter AND if we're not in battle or in a map save
            if (_chapterSave.GetSaveFileType() == Enums.SaveFileType.Chapter &&
                _chapterSave.Header.IsBattlePrepSave == false &&
                chapterData.Type == "Story")
            {
                UpdateHeaderChapter(chapterId);
            }

            // If we just unplayed chapter 6, do some special stuff to properly reset the branch of fate
            if (chapterId == Enums.Chapter.Birthright_Chapter6 ||
                chapterId == Enums.Chapter.Conquest_Chapter6 ||
                chapterId == Enums.Chapter.Revelation_Chapter6)
            {
                _chapterSave.UserRegion.Unknown_Block2_0xE6  = 0x00;
                _chapterSave.UserRegion.Unknown_Block2_0xE7  = 0x00;
                _chapterSave.UserRegion.Unknown_Block2_0xE8  = 0x00;
                _chapterSave.UserRegion.Unknown_Block2_0xEC  = 0x04;
                _chapterSave.UserRegion.Unknown_Block2_0x10A = 0x00;

                // This flag is also used to denote whether a path has been chosen
                _chapterSave.Header.UnitsGoAbsentWhenKilled     = true;
                _chapterSave.UserRegion.UnitsGoAbsentWhenKilled = true;

                // Set the game to the default (Birthright)
                _chapterSave.Header.Game     = Enums.Game.Birthright;
                _chapterSave.UserRegion.Game = Enums.Game.Birthright;

                // Set the branch of fate header
                UpdateHeaderChapter(Enums.Chapter.Chapter6);

                // Set the gameplay chapter
                _chapterSave.UserRegion.CurrentChapter = Enums.Chapter.Chapter6;

                // Kill the story battlefields
                RemoveRouteSpecificStoryBattlefields();
                AddBirthrightSpecificStoryBattlefields();
            }
        }