Esempio n. 1
0
        public PhaseInitial(BattleData data)
            : base(data)
        {
            if (RawData.api_active_deck())
            {
                FriendFleetID = (int)RawData.api_active_deck[0];
            }
            else
            {
                dynamic id = RawData.api_dock_id() ? RawData.api_dock_id : RawData.api_deck_id;
                FriendFleetID = id is string?int.Parse((string)id) : (int)id;
            }

            EnemyMembers         = ArraySkip((int[])RawData.api_ship_ke);
            EnemyMembersInstance = EnemyMembers.Select(id => KCDatabase.Instance.MasterShips[id]).ToArray();

            EnemyMembersEscort         = !RawData.api_ship_ke_combined() ? null : ArraySkip((int[])RawData.api_ship_ke_combined);
            EnemyMembersEscortInstance = EnemyMembersEscort == null ? null : EnemyMembersEscort.Select(id => KCDatabase.Instance.MasterShips[id]).ToArray();

            EnemyLevels       = ArraySkip((int[])RawData.api_ship_lv);
            EnemyLevelsEscort = !RawData.api_ship_lv_combined() ? null : ArraySkip((int[])RawData.api_ship_lv_combined);

            InitialHPs = GetHPArray((int[])RawData.api_nowhps, !RawData.api_nowhps_combined() ? null : (int[])RawData.api_nowhps_combined);
            MaxHPs     = GetHPArray((int[])RawData.api_maxhps, !RawData.api_maxhps_combined() ? null : (int[])RawData.api_maxhps_combined);

            EnemySlots         = ((dynamic[])RawData.api_eSlot).Select(d => (int[])d).ToArray();
            EnemySlotsInstance = EnemySlots.Select(part => part.Select(id => KCDatabase.Instance.MasterEquipments[id]).ToArray()).ToArray();

            EnemySlotsEscort         = !RawData.api_eSlot_combined() ? null : ((dynamic[])RawData.api_eSlot_combined).Select(d => (int[])d).ToArray();
            EnemySlotsEscortInstance = EnemySlotsEscort == null ? null : EnemySlotsEscort.Select(part => part.Select(id => KCDatabase.Instance.MasterEquipments[id]).ToArray()).ToArray();

            EnemyParameters       = ((dynamic[])RawData.api_eParam).Select(d => (int[])d).ToArray();
            EnemyParametersEscort = !RawData.api_eParam_combined() ? null : ((dynamic[])RawData.api_eParam_combined).Select(d => (int[])d).ToArray();
        }
        public PhaseInitial(BattleData data, string title)
            : base(data, title)
        {
            {
                dynamic id = RawData.api_dock_id() ? RawData.api_dock_id :
                             RawData.api_deck_id() ? RawData.api_deck_id : 1;
                FriendFleetID = id is string?int.Parse((string)id) : (int)id;
            }
            if (FriendFleetID <= 0)
            {
                FriendFleetID = 1;
            }

            EnemyMembers         = ArraySkip((int[])RawData.api_ship_ke);
            EnemyMembersInstance = EnemyMembers.Select(id => KCDatabase.Instance.MasterShips[id]).ToArray();

            EnemyMembersEscort         = !RawData.api_ship_ke_combined() ? null : ArraySkip((int[])RawData.api_ship_ke_combined);
            EnemyMembersEscortInstance = EnemyMembersEscort == null ? null : EnemyMembersEscort.Select(id => KCDatabase.Instance.MasterShips[id]).ToArray();

            AllEnemyMembers         = EnemyMembers.Concat(EnemyMembersEscort ?? Enumerable.Repeat(-1, 6)).ToArray();
            AllEnemyMembersInstance = EnemyMembersInstance.Concat(EnemyMembersEscortInstance ?? Enumerable.Repeat <ShipDataMaster>(null, 6)).ToArray();

            EnemyLevels       = ArraySkip((int[])RawData.api_ship_lv);
            EnemyLevelsEscort = !RawData.api_ship_lv_combined() ? null : ArraySkip((int[])RawData.api_ship_lv_combined);

            InitialHPs = GetHPArray((int[])RawData.api_nowhps, !RawData.api_nowhps_combined() ? null : (int[])RawData.api_nowhps_combined);
            MaxHPs     = GetHPArray((int[])RawData.api_maxhps, !RawData.api_maxhps_combined() ? null : (int[])RawData.api_maxhps_combined);

            EnemySlots         = ((dynamic[])RawData.api_eSlot).Select(d => (int[])d).ToArray();
            EnemySlotsInstance = EnemySlots.Select(part => part.Select(id => KCDatabase.Instance.MasterEquipments[id]).ToArray()).ToArray();

            EnemySlotsEscort         = !RawData.api_eSlot_combined() ? null : ((dynamic[])RawData.api_eSlot_combined).Select(d => (int[])d).ToArray();
            EnemySlotsEscortInstance = EnemySlotsEscort == null ? null : EnemySlotsEscort.Select(part => part.Select(id => KCDatabase.Instance.MasterEquipments[id]).ToArray()).ToArray();

            EnemyParameters       = !RawData.api_eParam() ? null : ((dynamic[])RawData.api_eParam).Select(d => (int[])d).ToArray();
            EnemyParametersEscort = !RawData.api_eParam_combined() ? null : ((dynamic[])RawData.api_eParam_combined).Select(d => (int[])d).ToArray();

            {
                var rations = new List <int>();
                if (RawData.api_combat_ration())
                {
                    rations.AddRange(((int[])RawData.api_combat_ration).Select(i => FriendFleet.Members.IndexOf(i)));
                }
                if (RawData.api_combat_ration_combined())
                {
                    rations.AddRange(((int[])RawData.api_combat_ration_combined).Select(i => FriendFleetEscort.Members.IndexOf(i) + 6));
                }
                RationIndexes = rations.ToArray();
            }
        }
Esempio n. 3
0
        public PhaseInitial(BattleData data, string title)
            : base(data, title)
        {
            {
                dynamic id = RawData.api_dock_id() ? RawData.api_dock_id :
                             RawData.api_deck_id() ? RawData.api_deck_id : 1;
                FriendFleetID = id is string?int.Parse((string)id) : (int)id;
            }
            if (FriendFleetID <= 0)
            {
                FriendFleetID = 1;
            }


            int[] GetArrayOrDefault(string objectName) => !RawData.IsDefined(objectName) ? null : FixedArray((int[])RawData[objectName]);

            int[][] GetArraysOrDefault(string objectName, int bottomLength)
            {
                if (!RawData.IsDefined(objectName))
                {
                    return(null);
                }

                int[][]   ret = new int[MemberCount][];
                dynamic[] raw = (dynamic[])RawData[objectName];
                for (int i = 0; i < ret.Length; i++)
                {
                    if (i < raw.Length)
                    {
                        ret[i] = FixedArray((int[])raw[i], bottomLength);
                    }
                    else
                    {
                        ret[i] = Enumerable.Repeat(-1, bottomLength).ToArray();
                    }
                }
                return(ret);
            }

            EnemyMembers         = GetArrayOrDefault("api_ship_ke");
            EnemyMembersInstance = EnemyMembers.Select(id => KCDatabase.Instance.MasterShips[id]).ToArray();

            EnemyMembersEscort         = GetArrayOrDefault("api_ship_ke_combined");
            EnemyMembersEscortInstance = EnemyMembersEscort?.Select(id => KCDatabase.Instance.MasterShips[id]).ToArray();

            EnemyLevels       = GetArrayOrDefault("api_ship_lv");
            EnemyLevelsEscort = GetArrayOrDefault("api_ship_lv_combined");

            FriendInitialHPs       = GetArrayOrDefault("api_f_nowhps");
            FriendInitialHPsEscort = GetArrayOrDefault("api_f_nowhps_combined");
            EnemyInitialHPs        = GetArrayOrDefault("api_e_nowhps");
            EnemyInitialHPsEscort  = GetArrayOrDefault("api_e_nowhps_combined");

            FriendMaxHPs       = GetArrayOrDefault("api_f_maxhps");
            FriendMaxHPsEscort = GetArrayOrDefault("api_f_maxhps_combined");
            EnemyMaxHPs        = GetArrayOrDefault("api_e_maxhps");
            EnemyMaxHPsEscort  = GetArrayOrDefault("api_e_maxhps_combined");


            EnemySlots         = GetArraysOrDefault("api_eSlot", 5);
            EnemySlotsInstance = EnemySlots.Select(part => part.Select(id => KCDatabase.Instance.MasterEquipments[id]).ToArray()).ToArray();

            EnemySlotsEscort         = GetArraysOrDefault("api_eSlot_combined", 5);
            EnemySlotsEscortInstance = EnemySlotsEscort?.Select(part => part.Select(id => KCDatabase.Instance.MasterEquipments[id]).ToArray()).ToArray();

            EnemyParameters       = GetArraysOrDefault("api_eParam", 4);
            EnemyParametersEscort = GetArraysOrDefault("api_eParam_combined", 4);

            {
                var rations = new List <int>();
                if (RawData.api_combat_ration())
                {
                    rations.AddRange(((int[])RawData.api_combat_ration).Select(i => FriendFleet.Members.IndexOf(i)));
                }
                if (RawData.api_combat_ration_combined())
                {
                    rations.AddRange(((int[])RawData.api_combat_ration_combined).Select(i => FriendFleetEscort.Members.IndexOf(i) + 6));
                }
                RationIndexes = rations.ToArray();
            }
        }