Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison of Enchant value #40

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 57 additions & 4 deletions src/components/option-renderer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";

import { ENCHANT_OPTIONS } from "../../constant/enchants";

interface OptionProps {
option_type: string;
option_sub_type?: string | null;
Expand Down Expand Up @@ -50,19 +52,70 @@ function OptionRenderer(option: OptionProps) {
</div>
);
}
case "인챈트":
case "인챈트": {
const enchantName = option.option_value?.split("(")[0].trim() || "";
const enchantInfo = enchantName
? ENCHANT_OPTIONS[enchantName]
: undefined;

console.log("enchantName:", enchantName);
console.log("enchantInfo:", enchantInfo);

return (
<div>
<strong>
{option.option_type} {"("} {option.option_sub_type}{" "}
{")"} :{" "}
{option.option_type} ({option.option_sub_type}) :{" "}
</strong>
{option.option_value}
<br />
{"("} {option.option_desc}
{"("}
{option.option_desc
?.split(",")
.map((stat, index, array) => {
const matches = stat.match(
/(.+?) (\d+%?|[\d.]+) (증가|감소)/
);
if (matches) {
const [, statType, valueStr, changeType] =
matches;
const value = valueStr.includes("%")
? valueStr
: parseInt(valueStr);

const enchantStat = enchantInfo?.stats.find(
s => s.type === statType.trim()
);
const difference =
enchantStat?.min && enchantStat?.max
? parseInt(valueStr) - enchantStat.max
: null;

return (
<span key={index}>
{statType} {value} {changeType}
{difference !== null && (
<span
className={`ml-1 ${
difference === 0
? "text-blue-500"
: difference < 0
? "text-red-500"
: ""
}`}
>
({difference})
</span>
)}
{index < array.length - 1 ? "," : ""}
</span>
);
}
return stat;
})}
{")"}
</div>
);
}
case "특별 개조":
return (
<div>
Expand Down
8 changes: 8 additions & 0 deletions src/constant/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,12 @@ export const changelogData = [
},
],
},
{
date: "2024-12-23",
changes: [
{
description: "인챈트 유동 옵션 수치 비교 기능 추가",
},
],
},
];
Loading
Loading