Commit 8fb09d50 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'fix/select_tribute' into 'main'

Fix/select tribute

See merge request !152
parents 9750ad07 84aa34c6
neos-protobuf @ 12d819b3
Subproject commit 3090fbcb9d0c51fa7aa20b3e313917d971cf15ca Subproject commit 12d819b3b0c69b334f475b01fdbf2f7fc6f5e2d9
This diff is collapsed.
...@@ -96,7 +96,7 @@ export default class GameMsgAdapter implements StocAdapter { ...@@ -96,7 +96,7 @@ export default class GameMsgAdapter implements StocAdapter {
break; break;
} }
case GAME_MSG.MSG_SELECT_TRIBUTE: { case GAME_MSG.MSG_SELECT_TRIBUTE: {
gameMsg.select_card = MsgSelectTributeAdapter(gameData); gameMsg.select_tribute = MsgSelectTributeAdapter(gameData);
break; break;
} }
......
...@@ -50,13 +50,15 @@ export default (data: Uint8Array) => { ...@@ -50,13 +50,15 @@ export default (data: Uint8Array) => {
const code = reader.inner.readInt32(); const code = reader.inner.readInt32();
const location = reader.readCardShortLocation(); const location = reader.readCardShortLocation();
const para = reader.inner.readInt32(); const para = reader.inner.readInt32();
const level1 = para & 0xffff;
const level2 = para >> 16 > 0 ? para >> 16 : level1;
msg.selectable_cards.push( msg.selectable_cards.push(
new MsgSelectSum.Info({ new MsgSelectSum.Info({
code, code,
location, location,
level1: para & 0xffff, level1,
level2: para >> 16, level2,
response: i, response: i,
}) })
); );
......
import { ygopro } from "../../../idl/ocgcore"; import { ygopro } from "../../../idl/ocgcore";
import { BufferReaderExt } from "../../bufferIO"; import { BufferReaderExt } from "../../bufferIO";
import MsgSelectCard = ygopro.StocGameMessage.MsgSelectCard; import MsgSelectTribute = ygopro.StocGameMessage.MsgSelectTribute;
/* /*
* Msg Select Tribute * Msg Select Tribute
...@@ -10,7 +10,6 @@ import MsgSelectCard = ygopro.StocGameMessage.MsgSelectCard; ...@@ -10,7 +10,6 @@ import MsgSelectCard = ygopro.StocGameMessage.MsgSelectCard;
* */ * */
export default (data: Uint8Array) => { export default (data: Uint8Array) => {
// FIXME: handle it correctly
const reader = new BufferReaderExt(data); const reader = new BufferReaderExt(data);
const player = reader.inner.readUint8(); const player = reader.inner.readUint8();
...@@ -19,25 +18,25 @@ export default (data: Uint8Array) => { ...@@ -19,25 +18,25 @@ export default (data: Uint8Array) => {
const max = reader.inner.readUint8(); const max = reader.inner.readUint8();
const count = reader.inner.readUint8(); const count = reader.inner.readUint8();
const msg = new MsgSelectCard({ player, cancelable, min, max }); const msg = new MsgSelectTribute({
player,
cancelable,
min,
max,
selectable_cards: [],
});
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
const code = reader.inner.readUint32(); const code = reader.inner.readUint32();
const controler = reader.inner.readUint8(); const location = reader.readCardShortLocation();
const location = reader.inner.readUint8(); const level = reader.inner.readUint8();
const sequence = reader.inner.readUint8();
const release_param = reader.inner.readUint8();
msg.cards.push( msg.selectable_cards.push(
new MsgSelectCard.SelectAbleCard({ new MsgSelectTribute.Info({
code, code,
location: new ygopro.CardLocation({
controler,
location, location,
sequence, level,
}),
response: i, response: i,
release_param,
}) })
); );
} }
......
...@@ -25,6 +25,7 @@ import onUnimplemented from "./unimplemented"; ...@@ -25,6 +25,7 @@ import onUnimplemented from "./unimplemented";
import onMsgUpdateData from "./updateData"; import onMsgUpdateData from "./updateData";
import onMsgReloadField from "./reloadField"; import onMsgReloadField from "./reloadField";
import onMsgSelectSum from "./selectSum"; import onMsgSelectSum from "./selectSum";
import onMsgSelectTribute from "./selectTribute";
import { setWaiting } from "../../reducers/duel/mod"; import { setWaiting } from "../../reducers/duel/mod";
const ActiveList = [ const ActiveList = [
...@@ -169,6 +170,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) { ...@@ -169,6 +170,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break; break;
} }
case "select_tribute": {
onMsgSelectTribute(msg.select_tribute, dispatch);
break;
}
case "unimplemented": { case "unimplemented": {
onUnimplemented(msg.unimplemented, dispatch); onUnimplemented(msg.unimplemented, dispatch);
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import {
setCheckCardModalV3AllLevel,
setCheckCardModalV3IsOpen,
setCheckCardModalV3MinMax,
setCheckCardModalV3OverFlow,
} from "../../reducers/duel/mod";
import { fetchCheckCardMetasV3 } from "../../reducers/duel/modal/checkCardModalV3Slice";
import { AppDispatch } from "../../store";
import MsgSelectTribute = ygopro.StocGameMessage.MsgSelectTribute;
export default (selectTribute: MsgSelectTribute, dispatch: AppDispatch) => {
// TODO: 当玩家选择卡数大于`max`时,是否也合法?
dispatch(setCheckCardModalV3OverFlow(true));
dispatch(setCheckCardModalV3AllLevel(0));
dispatch(
setCheckCardModalV3MinMax({
min: selectTribute.min,
max: selectTribute.max,
})
);
dispatch(
fetchCheckCardMetasV3({
mustSelect: false,
options: selectTribute.selectable_cards.map((card) => {
return {
code: card.code,
level1: card.level,
level2: card.level,
response: card.response,
};
}),
})
);
dispatch(setCheckCardModalV3IsOpen(true));
};
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