本文整理汇总了TypeScript中@csegames/camelot-unchained.utils类的典型用法代码示例。如果您正苦于以下问题:TypeScript utils类的具体用法?TypeScript utils怎么用?TypeScript utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了utils类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: webAPIServerToPatcherServer
reducer: (s, a) => {
if (a.server.name === 'localhost') return {};
const servers = utils.clone(s.servers);
servers[a.server.name] = utils.merge(servers[a.server.name], webAPIServerToPatcherServer(a.server));
return {
servers,
};
},
示例2: updateCharacterCounts
reducer: (s, a) => {
const characters = utils.clone(s.characters);
delete characters[a.id];
const servers = updateCharacterCounts(utils.clone(s.servers), characters);
return {
characters,
servers,
};
},
示例3:
reducer: (s, a) => {
const servers = utils.clone(s.servers);
servers[a.id].available = false;
return {
servers,
};
},
示例4: shouldShowItem
export function shouldShowItem(item: InventoryItem.Fragment, activeFilters: ActiveFilters, searchValue: string) {
const hasFilter = hasActiveFilterButtons(activeFilters);
const hasSearch = hasFilterText(searchValue);
const itemName = getItemDefinitionName(item);
// Active filters compared to item gearSlots
const doActiveFiltersIncludeItem = _.findIndex(_.values(activeFilters), (filter) => {
return inventoryFilterButtons[filter.name].filter(item);
}) > -1;
// Search text compared to itemName
const doesSearchValueIncludeItem = utils.doesSearchInclude(searchValue, itemName);
// Do active filters and search include item?
if (hasFilter && hasSearch) {
return doActiveFiltersIncludeItem && doesSearchValueIncludeItem;
// Do active filters include item?
} else if (hasFilter && !hasSearch) {
return doActiveFiltersIncludeItem;
// Does search value include item?
} else if (!hasFilter && hasSearch) {
return doesSearchValueIncludeItem;
// If there are no filters or searchValue, every item should be shown.
} else {
return true;
}
}
示例5: dispatch
events.on(characterUpdatedEvent, (characterJSON: string) => {
const character = utils.tryParseJSON<webAPI.SimpleCharacter>(characterJSON, client.debug);
if (character !== null) {
if (controllerState && isEqual(controllerState.characters[character.id], character)) {
// No need to update character if already equal to what we have in state.
return;
}
// Update character
dispatch(characterUpdate(character));
}
});
示例6: getContainerColor
export function getContainerColor(item: InventoryItem.Fragment, alpha?: number) {
if (item && item.containerColor) {
const { containerColor } = item;
if (containerColor) {
return `rgba(${containerColor.r}, ${containerColor.g}, ${containerColor.b}, ${alpha || 1})`;
} else {
return utils.lightenColor(colors.filterBackgroundColor, 5);
}
}
if (!item) {
console.error('You provided an undefined item to getContainerColor() function');
}
}