From b08843fcc58cda8ad82d68aba85af1cc1a33b79e Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 18 May 2023 19:30:39 -0700 Subject: [PATCH] Allow BDSP Slate/Shard to be given via "Give All" https://projectpokemon.org/home/forums/topic/63429-bdsp-slate/ The "Give All" cheat will skip adding unobtainable items. Since the BDSP-exclusive Treasure (slate/shard) are unable to held, they were also skipped. Revise the logic to allow them to be added via "Give All", but still disallowed as held items (separate arrays needed). Also condense the logic for BCAT-Dmax crystal IDs since they're all sequential. Just iterate a range instead of a span. --- PKHeX.Core/Items/ItemStorage5.cs | 2 +- PKHeX.Core/Items/ItemStorage8BDSP.cs | 5 +- PKHeX.Core/Items/ItemStorage8SWSH.cs | 315 +----------------- .../Legality/Restrictions/ItemRestrictions.cs | 26 +- 4 files changed, 43 insertions(+), 305 deletions(-) diff --git a/PKHeX.Core/Items/ItemStorage5.cs b/PKHeX.Core/Items/ItemStorage5.cs index 802090287..e7384e8b4 100644 --- a/PKHeX.Core/Items/ItemStorage5.cs +++ b/PKHeX.Core/Items/ItemStorage5.cs @@ -45,7 +45,7 @@ public abstract class ItemStorage5 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, }; - public static ReadOnlySpan Unreleased => new ushort[] + internal static ReadOnlySpan Unreleased => new ushort[] { 005, // Safari Ball 016, // Cherish Ball diff --git a/PKHeX.Core/Items/ItemStorage8BDSP.cs b/PKHeX.Core/Items/ItemStorage8BDSP.cs index f3c49edcb..2f350e1d5 100644 --- a/PKHeX.Core/Items/ItemStorage8BDSP.cs +++ b/PKHeX.Core/Items/ItemStorage8BDSP.cs @@ -36,7 +36,7 @@ public sealed class ItemStorage8BDSP : IItemStorage 055, 056, 057, 058, 059, 060, 061, 062, 063, }; - public static ReadOnlySpan Unreleased => new ushort[] + internal static ReadOnlySpan Unreleased => new ushort[] { 005, // Safari Ball 016, // Cherish Ball @@ -53,7 +53,10 @@ public sealed class ItemStorage8BDSP : IItemStorage 576, // Dream Ball 849, // Ice Stone 851, // Beast Ball + }; + internal static ReadOnlySpan DisallowHeldTreasure => new ushort[] + { // new BDSP items, but they can't be held 1808, // Mysterious Shard S 1809, // Mysterious Shard L diff --git a/PKHeX.Core/Items/ItemStorage8SWSH.cs b/PKHeX.Core/Items/ItemStorage8SWSH.cs index 592d5fc22..c0db7c7ec 100644 --- a/PKHeX.Core/Items/ItemStorage8SWSH.cs +++ b/PKHeX.Core/Items/ItemStorage8SWSH.cs @@ -165,309 +165,22 @@ public sealed class ItemStorage8SWSH : IItemStorage 500, // Park Ball // 644, // Pixie Plate - - 1279, // ★And458 (Jangmo-o) - 1280, // ★And15 (Larvitar) - 1281, // ★And337 (Corviknight) - 1282, // ★And603 (Eiscue) - 1283, // ★And390 (Stonjourner) - 1284, // ★Sgr6879 (Copperajah) - 1285, // ★Sgr6859 (Centiskorch) - 1286, // ★Sgr6913 (Flapple/Appletun) - 1287, // ★Sgr7348 (Sandaconda) - 1288, // ★Sgr7121 (Duraludon) - 1289, // ★Sgr6746 (Pikachu) - 1290, // ★Sgr7194 (Eevee) - 1291, // ★Sgr7337 - 1292, // ★Sgr7343 - 1293, // ★Sgr6812 - 1294, // ★Sgr7116 - 1295, // ★Sgr7264 - 1296, // ★Sgr7597 - 1297, // ★Del7882 - 1298, // ★Del7906 - 1299, // ★Del7852 - 1300, // ★Psc596 - 1301, // ★Psc361 - 1302, // ★Psc510 - 1303, // ★Psc437 - 1304, // ★Psc8773 - 1305, // ★Lep1865 - 1306, // ★Lep1829 - 1307, // ★Boo5340 - 1308, // ★Boo5506 - 1309, // ★Boo5435 - 1310, // ★Boo5602 - 1311, // ★Boo5733 - 1312, // ★Boo5235 - 1313, // ★Boo5351 - 1314, // ★Hya3748 - 1315, // ★Hya3903 - 1316, // ★Hya3418 - 1317, // ★Hya3482 - 1318, // ★Hya3845 - 1319, // ★Eri1084 - 1320, // ★Eri472 - 1321, // ★Eri1666 - 1322, // ★Eri897 - 1323, // ★Eri1231 - 1324, // ★Eri874 - 1325, // ★Eri1298 - 1326, // ★Eri1325 - 1327, // ★Eri984 - 1328, // ★Eri1464 - 1329, // ★Eri1393 - 1330, // ★Eri850 - 1331, // ★Tau1409 - 1332, // ★Tau1457 - 1333, // ★Tau1165 - 1334, // ★Tau1791 - 1335, // ★Tau1910 - 1336, // ★Tau1346 - 1337, // ★Tau1373 - 1338, // ★Tau1412 - 1339, // ★CMa2491 - 1340, // ★CMa2693 - 1341, // ★CMa2294 - 1342, // ★CMa2827 - 1343, // ★CMa2282 - 1344, // ★CMa2618 - 1345, // ★CMa2657 - 1346, // ★CMa2646 - 1347, // ★UMa4905 - 1348, // ★UMa4301 - 1349, // ★UMa5191 - 1350, // ★UMa5054 - 1351, // ★UMa4295 - 1352, // ★UMa4660 - 1353, // ★UMa4554 - 1354, // ★UMa4069 - 1355, // ★UMa3569 - 1356, // ★UMa3323 - 1357, // ★UMa4033 - 1358, // ★UMa4377 - 1359, // ★UMa4375 - 1360, // ★UMa4518 - 1361, // ★UMa3594 - 1362, // ★Vir5056 - 1363, // ★Vir4825 - 1364, // ★Vir4932 - 1365, // ★Vir4540 - 1366, // ★Vir4689 - 1367, // ★Vir5338 - 1368, // ★Vir4910 - 1369, // ★Vir5315 - 1370, // ★Vir5359 - 1371, // ★Vir5409 - 1372, // ★Vir5107 - 1373, // ★Ari617 - 1374, // ★Ari553 - 1375, // ★Ari546 - 1376, // ★Ari951 - 1377, // ★Ori1713 - 1378, // ★Ori2061 - 1379, // ★Ori1790 - 1380, // ★Ori1903 - 1381, // ★Ori1948 - 1382, // ★Ori2004 - 1383, // ★Ori1852 - 1384, // ★Ori1879 - 1385, // ★Ori1899 - 1386, // ★Ori1543 - 1387, // ★Cas21 - 1388, // ★Cas168 - 1389, // ★Cas403 - 1390, // ★Cas153 - 1391, // ★Cas542 - 1392, // ★Cas219 - 1393, // ★Cas265 - 1394, // ★Cnc3572 - 1395, // ★Cnc3208 - 1396, // ★Cnc3461 - 1397, // ★Cnc3449 - 1398, // ★Cnc3429 - 1399, // ★Cnc3627 - 1400, // ★Cnc3268 - 1401, // ★Cnc3249 - 1402, // ★Com4968 - 1403, // ★Crv4757 - 1404, // ★Crv4623 - 1405, // ★Crv4662 - 1406, // ★Crv4786 - 1407, // ★Aur1708 - 1408, // ★Aur2088 - 1409, // ★Aur1605 - 1410, // ★Aur2095 - 1411, // ★Aur1577 - 1412, // ★Aur1641 - 1413, // ★Aur1612 - 1414, // ★Pav7790 - 1415, // ★Cet911 - 1416, // ★Cet681 - 1417, // ★Cet188 - 1418, // ★Cet539 - 1419, // ★Cet804 - 1420, // ★Cep8974 - 1421, // ★Cep8162 - 1422, // ★Cep8238 - 1423, // ★Cep8417 - 1424, // ★Cen5267 - 1425, // ★Cen5288 - 1426, // ★Cen551 - 1427, // ★Cen5459 - 1428, // ★Cen5460 - 1429, // ★CMi2943 - 1430, // ★CMi2845 - 1431, // ★Equ8131 - 1432, // ★Vul7405 - 1433, // ★UMi424 - 1434, // ★UMi5563 - 1435, // ★UMi5735 - 1436, // ★UMi6789 - 1437, // ★Crt4287 - 1438, // ★Lyr7001 - 1439, // ★Lyr7178 - 1440, // ★Lyr7106 - 1441, // ★Lyr7298 - 1442, // ★Ara6585 - 1443, // ★Sco6134 - 1444, // ★Sco6527 - 1445, // ★Sco6553 - 1446, // ★Sco5953 - 1447, // ★Sco5984 - 1448, // ★Sco6508 - 1449, // ★Sco6084 - 1450, // ★Sco5944 - 1451, // ★Sco6630 - 1452, // ★Sco6027 - 1453, // ★Sco6247 - 1454, // ★Sco6252 - 1455, // ★Sco5928 - 1456, // ★Sco6241 - 1457, // ★Sco6165 - 1458, // ★Tri544 - 1459, // ★Leo3982 - 1460, // ★Leo4534 - 1461, // ★Leo4357 - 1462, // ★Leo4057 - 1463, // ★Leo4359 - 1464, // ★Leo4031 - 1465, // ★Leo3852 - 1466, // ★Leo3905 - 1467, // ★Leo3773 - 1468, // ★Gru8425 - 1469, // ★Gru8636 - 1470, // ★Gru8353 - 1471, // ★Lib5685 - 1472, // ★Lib5531 - 1473, // ★Lib5787 - 1474, // ★Lib5603 - 1475, // ★Pup3165 - 1476, // ★Pup3185 - 1477, // ★Pup3045 - 1478, // ★Cyg7924 - 1479, // ★Cyg7417 - 1480, // ★Cyg7796 - 1481, // ★Cyg8301 - 1482, // ★Cyg7949 - 1483, // ★Cyg7528 - 1484, // ★Oct7228 - 1485, // ★Col1956 - 1486, // ★Col2040 - 1487, // ★Col2177 - 1488, // ★Gem2990 - 1489, // ★Gem2891 - 1490, // ★Gem2421 - 1491, // ★Gem2473 - 1492, // ★Gem2216 - 1493, // ★Gem2777 - 1494, // ★Gem2650 - 1495, // ★Gem2286 - 1496, // ★Gem2484 - 1497, // ★Gem2930 - 1498, // ★Peg8775 - 1499, // ★Peg8781 - 1500, // ★Peg39 - 1501, // ★Peg8308 - 1502, // ★Peg8650 - 1503, // ★Peg8634 - 1504, // ★Peg8684 - 1505, // ★Peg8450 - 1506, // ★Peg8880 - 1507, // ★Peg8905 - 1508, // ★Oph6556 - 1509, // ★Oph6378 - 1510, // ★Oph6603 - 1511, // ★Oph6149 - 1512, // ★Oph6056 - 1513, // ★Oph6075 - 1514, // ★Ser5854 - 1515, // ★Ser7141 - 1516, // ★Ser5879 - 1517, // ★Her6406 - 1518, // ★Her6148 - 1519, // ★Her6410 - 1520, // ★Her6526 - 1521, // ★Her6117 - 1522, // ★Her6008 - 1523, // ★Per936 - 1524, // ★Per1017 - 1525, // ★Per1131 - 1526, // ★Per1228 - 1527, // ★Per834 - 1528, // ★Per941 - 1529, // ★Phe99 - 1530, // ★Phe338 - 1531, // ★Vel3634 - 1532, // ★Vel3485 - 1533, // ★Vel3734 - 1534, // ★Aqr8232 - 1535, // ★Aqr8414 - 1536, // ★Aqr8709 - 1537, // ★Aqr8518 - 1538, // ★Aqr7950 - 1539, // ★Aqr8499 - 1540, // ★Aqr8610 - 1541, // ★Aqr8264 - 1542, // ★Cru4853 - 1543, // ★Cru4730 - 1544, // ★Cru4763 - 1545, // ★Cru4700 - 1546, // ★Cru4656 - 1547, // ★PsA8728 - 1548, // ★TrA6217 - 1549, // ★Cap7776 - 1550, // ★Cap7754 - 1551, // ★Cap8278 - 1552, // ★Cap8322 - 1553, // ★Cap7773 - 1554, // ★Sge7479 - 1555, // ★Car2326 - 1556, // ★Car3685 - 1557, // ★Car3307 - 1558, // ★Car3699 - 1559, // ★Dra5744 - 1560, // ★Dra5291 - 1561, // ★Dra6705 - 1562, // ★Dra6536 - 1563, // ★Dra7310 - 1564, // ★Dra6688 - 1565, // ★Dra4434 - 1566, // ★Dra6370 - 1567, // ★Dra7462 - 1568, // ★Dra6396 - 1569, // ★Dra6132 - 1570, // ★Dra6636 - 1571, // ★CVn4915 - 1572, // ★CVn4785 - 1573, // ★CVn4846 - 1574, // ★Aql7595 - 1575, // ★Aql7557 - 1576, // ★Aql7525 - 1577, // ★Aql7602 - 1578, // ★Aql7235 }; + internal static Range DynamaxCrystalBCAT => new(DMAX_START, DMAX_END + 1); + + // 1279, // ★And458 (Jangmo-o) + // 1280, // ★And15 (Larvitar) + // 1281, // ★And337 (Corviknight) + // 1282, // ★And603 (Eiscue) + // 1283, // ★And390 (Stonjourner) + // 1284, // ★Sgr6879 (Copperajah) + // 1285, // ★Sgr6859 (Centiskorch) + // 1286, // ★Sgr6913 (Flapple/Appletun) + // 1287, // ★Sgr7348 (Sandaconda) + // 1288, // ★Sgr7121 (Duraludon) + // 1289, // ★Sgr6746 (Pikachu) + // 1290, // ★Sgr7194 (Eevee) private const int DMAX_START = 1279; private const int DMAX_END = 1578; private const int DMAX_LEGAL_END = 1290; // ★Sgr7194 (Eevee) diff --git a/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs b/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs index 037a24aaa..01ad89efe 100644 --- a/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs +++ b/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs @@ -54,8 +54,8 @@ public static bool IsHeldItemAllowed(int item, EntityContext context) private static readonly bool[] ReleasedHeldItems_5 = GetPermitList(MaxItemID_5_B2W2, HeldItems_BW, ItemStorage5.Unreleased); private static readonly bool[] ReleasedHeldItems_6 = GetPermitList(MaxItemID_6_AO, HeldItems_AO, ItemStorage6XY.Unreleased); private static readonly bool[] ReleasedHeldItems_7 = GetPermitList(MaxItemID_7_USUM, HeldItems_USUM, ItemStorage7SM.Unreleased); - private static readonly bool[] ReleasedHeldItems_8 = GetPermitList(MaxItemID_8, HeldItems_SWSH, ItemStorage8SWSH.Unreleased); - private static readonly bool[] ReleasedHeldItems_8b = GetPermitList(MaxItemID_8b, HeldItems_BS, ItemStorage8BDSP.Unreleased); + private static readonly bool[] ReleasedHeldItems_8 = GetPermitList(MaxItemID_8, HeldItems_SWSH, ItemStorage8SWSH.Unreleased, ItemStorage8SWSH.DynamaxCrystalBCAT); + private static readonly bool[] ReleasedHeldItems_8b = GetPermitList(MaxItemID_8b, HeldItems_BS, ItemStorage8BDSP.Unreleased, ItemStorage8BDSP.DisallowHeldTreasure); private static readonly bool[] ReleasedHeldItems_9 = GetPermitList(MaxItemID_9, HeldItems_SV, ItemStorage9SV.Unreleased); /// @@ -84,4 +84,26 @@ private static bool[] GetPermitList(int max, ReadOnlySpan allowed, ReadO result[index] = false; return result; } + + /// + private static bool[] GetPermitList(int max, ReadOnlySpan allowed, ReadOnlySpan disallow1, ReadOnlySpan disallow2) + { + var result = GetPermitList(max, allowed); + foreach (var index in disallow1) + result[index] = false; + foreach (var index in disallow2) + result[index] = false; + return result; + } + + /// + private static bool[] GetPermitList(int max, ReadOnlySpan allowed, ReadOnlySpan disallow1, Range disallow2) + { + var result = GetPermitList(max, allowed); + foreach (var index in disallow1) + result[index] = false; + for (int i = disallow2.Start.Value; i < disallow2.End.Value; i++) + result[i] = false; + return result; + } }