Merge pull request #47 from ButterCheezii/body-type-search
Body type search
This commit is contained in:
commit
105c2ac7fd
|
@ -171,11 +171,12 @@
|
||||||
furryprefs: [],
|
furryprefs: [],
|
||||||
roles: [],
|
roles: [],
|
||||||
positions: [],
|
positions: [],
|
||||||
species: []
|
species: [],
|
||||||
|
bodytypes: []
|
||||||
};
|
};
|
||||||
|
|
||||||
listItems: ReadonlyArray<keyof SearchData> = [
|
listItems: ReadonlyArray<keyof SearchData> = [
|
||||||
'genders', 'orientations', 'languages', 'furryprefs', 'roles', 'positions'
|
'genders', 'orientations', 'languages', 'furryprefs', 'roles', 'positions', 'bodytypes'
|
||||||
]; // SearchData is correct
|
]; // SearchData is correct
|
||||||
|
|
||||||
searchString = '';
|
searchString = '';
|
||||||
|
@ -197,7 +198,8 @@
|
||||||
furryprefs: options.listitems.filter((x) => x.name === 'furrypref').map((x) => x.value),
|
furryprefs: options.listitems.filter((x) => x.name === 'furrypref').map((x) => x.value),
|
||||||
roles: options.listitems.filter((x) => x.name === 'subdom').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),
|
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) => {
|
core.connection.onMessage('FKS', async (data) => {
|
||||||
const results = data.characters.map((x) => ({ character: core.characters.get(x), profile: null }))
|
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) => 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);
|
.sort(sort);
|
||||||
|
|
||||||
// pre-warm cache
|
// pre-warm cache
|
||||||
|
@ -346,7 +348,7 @@
|
||||||
private resort(results = this.results) {
|
private resort(results = this.results) {
|
||||||
this.results = (_.filter(
|
this.results = (_.filter(
|
||||||
results,
|
results,
|
||||||
(x) => this.isSpeciesMatch(x)
|
(x) => this.isSpeciesMatch(x) && this.isBodyTypeMatch(x)
|
||||||
) as SearchResult[]).sort(sort);
|
) 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[] {
|
getSpeciesOptions(): SearchSpecies[] {
|
||||||
const species = _.map(
|
const species = _.map(
|
||||||
speciesMapping,
|
speciesMapping,
|
||||||
|
@ -459,7 +476,7 @@
|
||||||
|
|
||||||
|
|
||||||
reset(): void {
|
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: []};
|
const data: Connection.ClientCommands['FKS'] & {[key: string]: (string | number)[]} = {kinks: []};
|
||||||
for(const key in this.data) {
|
for(const key in this.data) {
|
||||||
const item = this.data[<keyof SearchData>key]; // SearchData is correct
|
const item = this.data[<keyof SearchData>key]; // SearchData is correct
|
||||||
if(item.length > 0)
|
if(item.length > 0 && key !== 'bodytypes')
|
||||||
data[key] = key === 'kinks' ? (<SearchKink[]>item).map((x) => x.id) : (<string[]>item);
|
data[key] = key === 'kinks' ? (<SearchKink[]>item).map((x) => x.id) : (<string[]>item);
|
||||||
}
|
}
|
||||||
core.connection.send('FKS', data);
|
core.connection.send('FKS', data);
|
||||||
|
|
|
@ -160,6 +160,7 @@ export interface SearchData {
|
||||||
furryprefs: string[]
|
furryprefs: string[]
|
||||||
roles: string[]
|
roles: string[]
|
||||||
positions: string[]
|
positions: string[]
|
||||||
|
bodytypes: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExtendedSearchData extends SearchData {
|
export interface ExtendedSearchData extends SearchData {
|
||||||
|
|
|
@ -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.roles': 'Dom/sub roles',
|
||||||
'characterSearch.positions': 'Positions',
|
'characterSearch.positions': 'Positions',
|
||||||
'characterSearch.species': 'Species (beta)',
|
'characterSearch.species': 'Species (beta)',
|
||||||
|
'characterSearch.bodytypes': 'Body Types',
|
||||||
'characterSearch.error.noResults': 'There were no search results.',
|
'characterSearch.error.noResults': 'There were no search results.',
|
||||||
'characterSearch.error.throttle': 'You must wait five seconds between searches.',
|
'characterSearch.error.throttle': 'You must wait five seconds between searches.',
|
||||||
'characterSearch.error.tooManyResults': 'There are too many search results, please narrow your search.',
|
'characterSearch.error.tooManyResults': 'There are too many search results, please narrow your search.',
|
||||||
|
|
Loading…
Reference in New Issue