Skip to content

Commit

Permalink
👔 Enable hiding jutsus, i.e. for AI-only jutsu
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasGruber committed Aug 16, 2023
1 parent d3682cb commit c1f2e75
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/src/libs/combat/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ export const JutsuValidator = z
method: z.enum(AttackMethods),
target: z.enum(AttackTargets),
range: z.number().int().min(0).max(5),
hidden: z.number().int().min(0).max(1).optional(),
healthCostPerc: z.number().min(0).max(100).optional(),
chakraCostPerc: z.number().min(0).max(100).optional(),
staminaCostPerc: z.number().min(0).max(100).optional(),
Expand All @@ -746,7 +747,7 @@ export const BloodlineValidator = z.object({
rank: z.enum(LetterRanks),
regenIncrease: z.number().int().min(1).max(100),
village: z.string(),
hidden: z.number().min(0).max(1).optional(),
hidden: z.number().int().min(0).max(1).optional(),
effects: z
.array(
z.union([
Expand Down Expand Up @@ -785,6 +786,7 @@ export const ItemValidator = z
healthCostPerc: z.number().int().min(0).max(100).optional(),
staminaCostPerc: z.number().int().min(0).max(100).optional(),
actionCostPerc: z.number().int().min(1).max(100).optional(),
hidden: z.number().int().min(0).max(1).optional(),
cooldown: z.number().int().min(0).max(300),
cost: z.number().int().min(1),
range: z.number().int().min(0).max(10).optional(),
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/cpanel/bloodline/edit/[bloodlineid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const BloodlinePanel: NextPage = () => {
{ id: "image", label: "Image", type: "avatar", href: imageUrl },
{ id: "description", label: "Description", type: "text" },
{ id: "regenIncrease", type: "number" },
{ id: "hidden", type: "number" },
{ id: "hidden", type: "number", label: "Hidden [hide AI bloodline]" },
{ id: "village", label: "Village", type: "db_values", values: villages },
{ id: "rank", type: "str_array", values: LetterRanks },
];
Expand Down
1 change: 1 addition & 0 deletions app/src/pages/cpanel/item/edit/[itemid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const ItemPanel: NextPage = () => {
{ id: "staminaCostPerc", type: "number" },
{ id: "actionCostPerc", type: "number" },
{ id: "healthCostPerc", type: "number" },
{ id: "hidden", type: "number", label: "Hidden [hide AI item]" },
];

// Icon for adding tag
Expand Down
1 change: 1 addition & 0 deletions app/src/pages/cpanel/jutsu/edit/[jutsuid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const JutsuPanel: NextPage = () => {
{ id: "staminaCostPerc", label: "Stamina Cost [%]", type: "number" },
{ id: "chakraCostPerc", label: "Chakra Cost [%]", type: "number" },
{ id: "healthCostPerc", label: "Health Cost [%]", type: "number" },
{ id: "hidden", type: "number", label: "Hidden [hide AI jutsu]" },
{ id: "jutsuType", type: "str_array", values: JutsuTypes },
{ id: "bloodlineId", label: "Bloodline", type: "db_values", values: bloodlines },
{ id: "villageId", label: "Village", type: "db_values", values: villages },
Expand Down
3 changes: 3 additions & 0 deletions app/src/server/api/routers/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ export const itemRouter = createTRPCRouter({
if (!info) {
throw serverError("PRECONDITION_FAILED", "Item not found");
}
if (info.hidden === 1) {
throw serverError("PRECONDITION_FAILED", "Item can not be bought");
}
const cost = info.cost * input.stack;
const result = await ctx.drizzle
.update(userData)
Expand Down
3 changes: 3 additions & 0 deletions app/src/server/api/routers/jutsu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ export const jutsuRouter = createTRPCRouter({
if (!info) {
return { success: false, message: "Jutsu not found" };
}
if (info.hidden === 1) {
return { success: false, message: "Jutsu can not be trained" };
}
if (!canTrainJutsu(info, user)) {
return { success: false, message: "You cannot train this jutsu" };
}
Expand Down

1 comment on commit c1f2e75

@vercel
Copy link

@vercel vercel bot commented on c1f2e75 Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.