Commit c39108a1 authored by Chunchi Che's avatar Chunchi Che

fix small

parent 05aaa932
Pipeline #21074 passed with stages
in 24 minutes
...@@ -2,7 +2,7 @@ import axios from "axios"; ...@@ -2,7 +2,7 @@ import axios from "axios";
import NeosConfig from "../../neos.config.json"; import NeosConfig from "../../neos.config.json";
import { getCardStr, fetchCard } from "./cards"; import { getCardStr, fetchCard } from "./cards";
const DESCRIPTION_LIMIT = 10000; export const DESCRIPTION_LIMIT = 10000;
export async function initStrings() { export async function initStrings() {
const strings = (await axios.get<string>(NeosConfig.stringsUrl)).data; const strings = (await axios.get<string>(NeosConfig.stringsUrl)).data;
......
import { createAsyncThunk, ActionReducerMapBuilder } from "@reduxjs/toolkit"; import { createAsyncThunk, ActionReducerMapBuilder } from "@reduxjs/toolkit";
import { DuelState } from "./mod"; import { DuelState } from "./mod";
import { RootState } from "../../store"; import { RootState } from "../../store";
import { fetchStrings, getStrings } from "../../api/strings"; import { DESCRIPTION_LIMIT, fetchStrings, getStrings } from "../../api/strings";
import { judgeSelf } from "./util"; import { judgeSelf } from "./util";
import { fetchCard } from "../../api/cards";
export interface HintState { export interface HintState {
code: number; code: number;
...@@ -24,14 +25,24 @@ export const fetchCommonHintMeta = createAsyncThunk( ...@@ -24,14 +25,24 @@ export const fetchCommonHintMeta = createAsyncThunk(
); );
export const fetchSelectHintMeta = createAsyncThunk( export const fetchSelectHintMeta = createAsyncThunk(
"duel/fetchSelectPlaceHintMeta", "duel/fetchSelectHintMeta",
async (param: [number, number]) => { async (param: [number, number]) => {
const player = param[0]; const player = param[0];
const hintData = param[1]; const hintData = param[1];
const hintMeta = await getStrings(hintData); let hintMeta = "";
const response: [number, string] = [player, hintMeta]; if (hintData > DESCRIPTION_LIMIT) {
// 针对`MSG_SELECT_PLACE`的特化逻辑
const cardMeta = await fetchCard(hintData, true);
hintMeta = fetchStrings("!system", 569).replace(
"[%ls]",
cardMeta.text.name || "[?]"
);
} else {
hintMeta = await getStrings(hintData);
}
const response: [number, string] = [player, hintMeta];
return response; return response;
} }
); );
...@@ -69,11 +80,16 @@ export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => { ...@@ -69,11 +80,16 @@ export const hintCase = (builder: ActionReducerMapBuilder<DuelState>) => {
}); });
builder.addCase(fetchSelectHintMeta.fulfilled, (state, action) => { builder.addCase(fetchSelectHintMeta.fulfilled, (state, action) => {
const player = action.payload[0]; const player = action.payload[0];
const hintMsg = action.payload[1]; let hintMsg = action.payload[1];
const hint = judgeSelf(player, state) ? state.meHint : state.opHint; const hint = judgeSelf(player, state) ? state.meHint : state.opHint;
if (hint) { if (hint) {
hint.esSelectHint = hintMsg; if (hint.code > DESCRIPTION_LIMIT) {
// 针对`MSG_SELECT_PLACE`的特化逻辑
hint.msg = hintMsg;
} else {
hint.esSelectHint = hintMsg;
}
} }
}); });
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment