Skip to content

Commit

Permalink
Fixed #91
Browse files Browse the repository at this point in the history
  • Loading branch information
evanwporter committed Dec 22, 2024
1 parent f76462e commit 25d915c
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 11 deletions.
46 changes: 46 additions & 0 deletions generate/generateTransferRestrictedForms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { PokemonData } from 'pokemon-species-data'
import { RadicalRedToNationalDexMap } from '../src/types/SAVTypes/radicalred/conversion/RadicalRedSpeciesMap'
import { TransferRestrictions } from '../src/types/TransferRestrictions'

const RR_TRANSFER_RESTRICTIONS: TransferRestrictions = {
excludedForms: {},
}

const supportedFormsMap: Record<number, Set<number>> = {}

for (const [key, mapEntry] of Object.entries(RadicalRedToNationalDexMap)) {
if (!mapEntry || !mapEntry.NationalDexIndex) continue

const dexNum = mapEntry.NationalDexIndex
const formIndex = mapEntry.FormIndex

if (!supportedFormsMap[dexNum]) {
supportedFormsMap[dexNum] = new Set()
}
supportedFormsMap[dexNum].add(formIndex)
}

for (const [key, mapEntry] of Object.entries(RadicalRedToNationalDexMap)) {
if (!mapEntry || !mapEntry.NationalDexIndex) continue

const dexNum = mapEntry.NationalDexIndex

const dbEntry = PokemonData[dexNum]

if (dbEntry) {
const allForms = dbEntry.formes.map((forme) => forme.formeNumber)

const supportedForms = supportedFormsMap[dexNum] || new Set()
const unsupportedForms = allForms.filter((formeNumber) => !supportedForms.has(formeNumber))

if (unsupportedForms.length > 0) {
// Not necessary but TS was giving me a warning.
if (!RR_TRANSFER_RESTRICTIONS.excludedForms) {
RR_TRANSFER_RESTRICTIONS.excludedForms = {}
}
RR_TRANSFER_RESTRICTIONS.excludedForms[dexNum] = unsupportedForms
}
}
}

console.log(RR_TRANSFER_RESTRICTIONS)
13 changes: 3 additions & 10 deletions src/types/SAVTypes/radicalred/G3RRSAV.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import { NationalDex } from 'pokemon-species-data'
import { ORIGIN, SPIKY_EAR } from '../../../consts/Formes'
import { bytesToUint32LittleEndian } from '../../../util/byteLogic'
import { CapPikachus, isRestricted, TransferRestrictions } from '../../TransferRestrictions'
import { isRestricted, TransferRestrictions } from '../../TransferRestrictions'
import { findFirstSectionOffset, G3CFRUSAV, SAVE_SIZES_BYTES } from '../cfru/G3CFRUSAV'
import { FRLG_SECURITY_COPY_OFFSET, FRLG_SECURITY_OFFSET } from '../G3SAV'
import { PathData } from '../path'
import { PluginSAV } from '../SAV'
import { RRTransferMon } from './conversion/RRTransferMons'
import { RRExcludedForms, RRTransferMon } from './conversion/RRTransferMons'
import PK3RR from './PK3RR'

// https://docs.google.com/spreadsheets/d/15mUFUcN8250hRL7iUOJPX0s1rMcgVuJPuHANioL4o2o/edit?gid=45654363#gid=962831839
const RR_TRANSFER_RESTRICTIONS: TransferRestrictions = {
transferableDexNums: RRTransferMon,
excludedForms: {
...CapPikachus,
[NationalDex.Pichu]: [SPIKY_EAR],
[NationalDex.Dialga]: [ORIGIN],
[NationalDex.Palkia]: [ORIGIN],
},
excludedForms: RRExcludedForms,
}

export class G3RRSAV extends G3CFRUSAV<PK3RR> implements PluginSAV<PK3RR> {
Expand Down
62 changes: 62 additions & 0 deletions src/types/SAVTypes/radicalred/conversion/RRTransferMons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,65 @@ export const RRTransferMon = [
1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020,
1021, 1022, 1023, 1024, 1025,
]

export const RRExcludedForms = {
'20': [2],
'25': [8, 9],
'83': [1],
'105': [2],
'122': [0, 1],
'128': [1, 2, 3],
'133': [1],
'172': [1],
'201': [27],
'250': [0],
'351': [1, 2, 3],
'412': [1, 2],
'422': [1],
'423': [1],
'550': [2],
'585': [1, 2, 3],
'586': [1, 2, 3],
'649': [1, 2, 3, 4],
'658': [2],
'664': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
'665': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
'666': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
'669': [1, 2, 3, 4],
'670': [1, 2, 3, 4],
'671': [1, 2, 3, 4],
'676': [6, 4, 3, 1, 8, 7, 5, 9, 2],
'678': [1],
'710': [1, 2, 3],
'711': [1, 2, 3],
'718': [4],
'735': [1],
'738': [1],
'743': [1],
'744': [1],
'752': [1],
'754': [1],
'758': [1],
'774': [8, 9, 10, 11, 12, 13],
'777': [1],
'778': [2, 3],
'784': [1],
'854': [1],
'855': [1],
'869': [64, 128, 192, 256, 320, 384, 448], // Alcremie
'876': [1],
'893': [1],
'898': [1, 2],
'902': [1],
'916': [1],
'925': [1],
'931': [1, 3],
'978': [1, 2],
'982': [1],
'1007': [1, 2, 3, 4],
'1008': [1, 2, 3, 4],
'1012': [1],
'1013': [1],
'1017': [1, 2, 3],
'1024': [1, 2],
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const RRSprites: Record<string, string> = {
const _RRSprites: Record<string, string> = {
'0': 'None.png',
'1': 'Bulbasaur.png',
'2': 'Ivysaur.png',
Expand Down Expand Up @@ -1331,3 +1331,10 @@ export const RRSprites: Record<string, string> = {
'1354': 'Walkingwake.png',
'1355': 'Squawkabilly2.png',
}

export const RRSprites = Object.fromEntries(
Object.entries(_RRSprites).map(([key, value]) => [
key,
value.replace(/\w+/g, (match) => match.charAt(0).toUpperCase() + match.slice(1).toLowerCase()),
])
)

0 comments on commit 25d915c

Please sign in to comment.