mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
max cons and provs
This commit is contained in:
1 parent
1f0392681a
commit
eb0c35d6c6
3 files changed
+34
No files matched your search
@@ -16,6 +16,11 @@
|
|||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
&[data-disabled="true"] {
|
||||||
|
cursor: default;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
&[data-size="minor"] {
|
&[data-size="minor"] {
|
||||||
font-size: 0.7em;
|
font-size: 0.7em;
|
||||||
padding: var(--space-2) var(--space-3);
|
padding: var(--space-2) var(--space-3);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export function Button({
|
|||||||
|
|
||||||
listChild,
|
listChild,
|
||||||
parentListChild,
|
parentListChild,
|
||||||
|
disabled,
|
||||||
...props
|
...props
|
||||||
}: ButtonProps) {
|
}: ButtonProps) {
|
||||||
return (
|
return (
|
||||||
@@ -51,6 +52,8 @@ export function Button({
|
|||||||
data-size={size}
|
data-size={size}
|
||||||
data-list-child={listChild}
|
data-list-child={listChild}
|
||||||
data-parent-list-child={parentListChild}
|
data-parent-list-child={parentListChild}
|
||||||
|
data-disabled={disabled}
|
||||||
|
disabled={disabled}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -173,8 +173,15 @@ interface ProvisionEntryProps {
|
|||||||
|
|
||||||
function ProvisionEntry({ id, provision }: ProvisionEntryProps) {
|
function ProvisionEntry({ id, provision }: ProvisionEntryProps) {
|
||||||
const isSelected = useProvision("protagonist", id);
|
const isSelected = useProvision("protagonist", id);
|
||||||
|
const tank = useDuel("protagonist", DuelModule.Tank);
|
||||||
|
const selectedCount = Tankopedia.use(
|
||||||
|
(state) => state.protagonist.provisions.length,
|
||||||
|
);
|
||||||
|
|
||||||
const unwrap = useUnwrapper();
|
const unwrap = useUnwrapper();
|
||||||
|
|
||||||
|
const disabled = !isSelected && selectedCount >= tank.max_provisions;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip tooltip={unwrap(provision.name)}>
|
<Tooltip tooltip={unwrap(provision.name)}>
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -183,11 +190,16 @@ function ProvisionEntry({ id, provision }: ProvisionEntryProps) {
|
|||||||
variant={isSelected ? "surface" : "soft"}
|
variant={isSelected ? "surface" : "soft"}
|
||||||
color={isSelected ? undefined : "gray"}
|
color={isSelected ? undefined : "gray"}
|
||||||
className={styles.consumable}
|
className={styles.consumable}
|
||||||
|
disabled={disabled}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
const index = draft.protagonist.provisions.indexOf(id);
|
const index = draft.protagonist.provisions.indexOf(id);
|
||||||
|
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
|
if (draft.protagonist.provisions.length === tank.max_provisions) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
draft.protagonist.provisions.push(id);
|
draft.protagonist.provisions.push(id);
|
||||||
} else {
|
} else {
|
||||||
draft.protagonist.provisions.splice(index, 1);
|
draft.protagonist.provisions.splice(index, 1);
|
||||||
@@ -252,11 +264,18 @@ interface ConsumableProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ConsumableEntry({ id, consumable }: ConsumableProps) {
|
function ConsumableEntry({ id, consumable }: ConsumableProps) {
|
||||||
|
const tank = useDuel("protagonist", DuelModule.Tank);
|
||||||
const isSelected = Tankopedia.use((state) =>
|
const isSelected = Tankopedia.use((state) =>
|
||||||
state.protagonist.consumables.includes(id),
|
state.protagonist.consumables.includes(id),
|
||||||
);
|
);
|
||||||
|
const selectedCount = Tankopedia.use(
|
||||||
|
(state) => state.protagonist.consumables.length,
|
||||||
|
);
|
||||||
|
|
||||||
const unwrap = useUnwrapper();
|
const unwrap = useUnwrapper();
|
||||||
|
|
||||||
|
const disabled = !isSelected && selectedCount >= tank.max_consumables;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles["consumable-wrapper"]}>
|
<div className={styles["consumable-wrapper"]}>
|
||||||
<Tooltip tooltip={unwrap(consumable.name)}>
|
<Tooltip tooltip={unwrap(consumable.name)}>
|
||||||
@@ -265,11 +284,18 @@ function ConsumableEntry({ id, consumable }: ConsumableProps) {
|
|||||||
variant={isSelected ? "surface" : "soft"}
|
variant={isSelected ? "surface" : "soft"}
|
||||||
color={isSelected ? undefined : "gray"}
|
color={isSelected ? undefined : "gray"}
|
||||||
className={styles.consumable}
|
className={styles.consumable}
|
||||||
|
disabled={disabled}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
const index = draft.protagonist.consumables.indexOf(id);
|
const index = draft.protagonist.consumables.indexOf(id);
|
||||||
|
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
|
if (
|
||||||
|
draft.protagonist.consumables.length === tank.max_consumables
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
draft.protagonist.consumables.push(id);
|
draft.protagonist.consumables.push(id);
|
||||||
} else {
|
} else {
|
||||||
draft.protagonist.consumables.splice(index, 1);
|
draft.protagonist.consumables.splice(index, 1);
|
||||||
|
|||||||
Reference in new issue
Block a user