diff --git a/chat/CharacterSearch.vue b/chat/CharacterSearch.vue index 743b533..146e5b9 100644 --- a/chat/CharacterSearch.vue +++ b/chat/CharacterSearch.vue @@ -171,11 +171,12 @@ furryprefs: [], roles: [], positions: [], - species: [] + species: [], + bodytypes: [] }; listItems: ReadonlyArray = [ - 'genders', 'orientations', 'languages', 'furryprefs', 'roles', 'positions' + 'genders', 'orientations', 'languages', 'furryprefs', 'roles', 'positions', 'bodytypes' ]; // SearchData is correct searchString = ''; @@ -197,7 +198,8 @@ furryprefs: options.listitems.filter((x) => x.name === 'furrypref').map((x) => x.value), roles: options.listitems.filter((x) => x.name === 'subdom').map((x) => x.value), positions: options.listitems.filter((x) => x.name === 'position').map((x) => x.value), - species: this.getSpeciesOptions() + species: this.getSpeciesOptions(), + bodytypes: options.listitems.filter((x) => x.name === 'bodytype').map((x) => x.value) }); @@ -268,7 +270,7 @@ core.connection.onMessage('FKS', async (data) => { const results = data.characters.map((x) => ({ character: core.characters.get(x), profile: null })) .filter((x) => core.state.hiddenUsers.indexOf(x.character.name) === -1 && !x.character.isIgnored) - .filter((x) => this.isSpeciesMatch(x)) + .filter((x) => this.isSpeciesMatch(x) && this.isBodyTypeMatch(x)) .sort(sort); // pre-warm cache @@ -346,7 +348,7 @@ private resort(results = this.results) { this.results = (_.filter( results, - (x) => this.isSpeciesMatch(x) + (x) => this.isSpeciesMatch(x) && this.isBodyTypeMatch(x) ) as SearchResult[]).sort(sort); } @@ -382,6 +384,21 @@ )); } + isBodyTypeMatch(result: SearchResult) { + if (this.data.bodytypes.length === 0) return true + + const knownCharacter = core.cache.profileCache.getSync(result.character.name) + if (!knownCharacter) return false + + result.profile = knownCharacter + + const bodytypeId = result.profile.character.character.infotags[51]?.list + if (bodytypeId === undefined) return false + + const bodytype = options!.listitems.filter(x => x.name === 'bodytype').find(x => +x.id === bodytypeId) + return this.data.bodytypes.indexOf(bodytype!.value) > -1 + } + getSpeciesOptions(): SearchSpecies[] { const species = _.map( speciesMapping, @@ -459,7 +476,7 @@ reset(): void { - this.data = {kinks: [], genders: [], orientations: [], languages: [], furryprefs: [], roles: [], positions: [], species: []}; + this.data = {kinks: [], genders: [], orientations: [], languages: [], furryprefs: [], roles: [], positions: [], species: [], bodytypes: []}; } @@ -504,7 +521,7 @@ const data: Connection.ClientCommands['FKS'] & {[key: string]: (string | number)[]} = {kinks: []}; for(const key in this.data) { const item = this.data[key]; // SearchData is correct - if(item.length > 0) + if(item.length > 0 && key !== 'bodytypes') data[key] = key === 'kinks' ? (item).map((x) => x.id) : (item); } core.connection.send('FKS', data); diff --git a/chat/interfaces.ts b/chat/interfaces.ts index f055624..747132b 100644 --- a/chat/interfaces.ts +++ b/chat/interfaces.ts @@ -160,6 +160,7 @@ export interface SearchData { furryprefs: string[] roles: string[] positions: string[] + bodytypes: string[] } export interface ExtendedSearchData extends SearchData { diff --git a/chat/localize.ts b/chat/localize.ts index dacdb05..926604b 100644 --- a/chat/localize.ts +++ b/chat/localize.ts @@ -231,6 +231,7 @@ Once this process has started, do not interrupt it or your logs will get corrupt 'characterSearch.roles': 'Dom/sub roles', 'characterSearch.positions': 'Positions', 'characterSearch.species': 'Species (beta)', + 'characterSearch.bodytypes': 'Body Types', 'characterSearch.error.noResults': 'There were no search results.', 'characterSearch.error.throttle': 'You must wait five seconds between searches.', 'characterSearch.error.tooManyResults': 'There are too many search results, please narrow your search.',