Implementation of /vs/:char/:step
This commit is contained in:
parent
d1c91abcc3
commit
6bd94e49e8
3 changed files with 12 additions and 5 deletions
|
@ -22,7 +22,7 @@ createRoot(document.getElementById('root')).render(
|
|||
<Route path="/sprite" element={<Animation />} />
|
||||
<Route path='/video' element={<PlayVideo />} />
|
||||
<Route path="/introduction" element={<IntroductionPage />} />
|
||||
<Route path='/vs/:step' element={<VitualNovelHandler />} />
|
||||
<Route path='/vs/:char/:step' element={<VitualNovelHandler />} />
|
||||
<Route path='/end' element={<EndPage />} />
|
||||
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
|
|
|
@ -35,7 +35,9 @@ function IntroductionPage() {
|
|||
|
||||
const handleClickedButton = () => {
|
||||
console.log(character.name(numChar))
|
||||
if(character.name(numChar)=='Porsche') navigate(`/vs/0`);
|
||||
if(character.name(numChar)=='Porsche') navigate(`/vs/Porsche/0`);
|
||||
if(character.name(numChar)=='Pie') navigate(`/vs/Pie/0`);
|
||||
if(character.name(numChar)=='Patt') navigate(`/vs/Pat/0`);
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -14,12 +14,13 @@ function VitualNovelHandler() {
|
|||
const [error, setError] = useState(null);
|
||||
const [currentStep, setCurrentStep] = useState(0);
|
||||
const navigate = useNavigate();
|
||||
const { step } = useParams();
|
||||
const { char, step } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
const loadData = async () => {
|
||||
try {
|
||||
const parsedData = await fetchYamlData({ src: '/yml/DialogPorsche.yml' });
|
||||
const yamlPath = `/yml/Dialog${char}.yml`;
|
||||
const parsedData = await fetchYamlData({ src: yamlPath });
|
||||
if (!Array.isArray(parsedData)) {
|
||||
throw new Error('YAML data is not an array');
|
||||
}
|
||||
|
@ -51,10 +52,14 @@ function VitualNovelHandler() {
|
|||
console.log(nextstep)
|
||||
if (typeof nextstep !== 'number' || Number.isNaN(nextstep)) {
|
||||
navigate(`/end`);//44 is last page
|
||||
console.log("currentStep:", currentStep);
|
||||
console.log("data at currentStep:", data[currentStep]);
|
||||
}
|
||||
else{
|
||||
setCurrentStep(nextstep);
|
||||
navigate(`/vs/${nextstep}`);
|
||||
navigate(`/vs/${char}/${nextstep}`);
|
||||
// console.log("currentStep:", currentStep);
|
||||
// console.log("data at currentStep:", data[currentStep]);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue