Exemple #1
0
        public static GameStatus ExtractStatusFromMap(FF7SaveMap map, FF7BattleMap battleMap)
        {
            var time = map.LiveTotalSeconds;

            var t = $"{(time / 3600):00}:{((time % 3600) / 60):00}:{(time % 60):00}";

            var status = new GameStatus()
            {
                Gil              = map.LiveGil,
                Location         = map.LiveMapName,
                Party            = new Models.Character[3],
                ActiveBattle     = battleMap.IsActiveBattle,
                ColorTopLeft     = map.WindowColorTopLeft,
                ColorBottomLeft  = map.WindowColorBottomLeft,
                ColorBottomRight = map.WindowColorBottomRight,
                ColorTopRight    = map.WindowColorTopRight,
                TimeActive       = t
            };
            var party = battleMap.Party;

            var chars = map.LiveParty;

            for (var index = 0; index < chars.Length; ++index)
            {
                // Skip empty party
                if (chars[index].Id == 0xFF)
                {
                    continue;
                }

                var chr = new Models.Character()
                {
                    MaxHp         = chars[index].MaxHp,
                    MaxMp         = chars[index].MaxMp,
                    CurrentHp     = chars[index].CurrentHp,
                    CurrentMp     = chars[index].CurrentMp,
                    Name          = chars[index].Name,
                    Level         = chars[index].Level,
                    Weapon        = WeaponDatabase.FirstOrDefault(w => w.Id == chars[index].Weapon),
                    Armlet        = ArmletDatabase.FirstOrDefault(a => a.Id == chars[index].Armor),
                    Accessory     = AccessoryDatabase.FirstOrDefault(a => a.Id == chars[index].Accessory),
                    WeaponMateria = new Materia[8],
                    ArmletMateria = new Materia[8],
                    Face          = GetFaceForCharacter(chars[index]),
                    BackRow       = !chars[index].AtFront,
                };

                for (var m = 0; m < chars[index].WeaponMateria.Length; ++m)
                {
                    chr.WeaponMateria[m] = MateriaDatabase.FirstOrDefault(x => x.Id == chars[index].WeaponMateria[m]);
                }
                for (var m = 0; m < chars[index].ArmorMateria.Length; ++m)
                {
                    chr.ArmletMateria[m] = MateriaDatabase.FirstOrDefault(x => x.Id == chars[index].ArmorMateria[m]);
                }

                var effect = (StatusEffect)chars[index].Flags;

                if (battleMap.IsActiveBattle)
                {
                    chr.CurrentHp = party[index].CurrentHp;
                    chr.MaxHp     = party[index].MaxHp;
                    chr.CurrentMp = party[index].CurrentMp;
                    chr.MaxMp     = party[index].MaxMp;
                    chr.Level     = party[index].Level;
                    effect        = party[index].Status;
                    chr.BackRow   = party[index].IsBackRow;
                }

                var effs = effect.ToString()
                           .Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries)
                           .ToList();
                effs.RemoveAll(x => new[] { "None", "Death" }.Contains(x));
                chr.StatusEffects   = effs.ToArray();
                status.Party[index] = chr;
            }

            return(status);
        }