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 {
break;
}
case GAME_MSG.MSG_SELECT_TRIBUTE: {
gameMsg.select_card = MsgSelectTributeAdapter(gameData);
gameMsg.select_tribute = MsgSelectTributeAdapter(gameData);
break;
}
......
......@@ -50,13 +50,15 @@ export default (data: Uint8Array) => {
const code = reader.inner.readInt32();
const location = reader.readCardShortLocation();
const para = reader.inner.readInt32();
const level1 = para & 0xffff;
const level2 = para >> 16 > 0 ? para >> 16 : level1;
msg.selectable_cards.push(
new MsgSelectSum.Info({
code,
location,
level1: para & 0xffff,
level2: para >> 16,
level1,
level2,
response: i,
})
);
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReaderExt } from "../../bufferIO";
import MsgSelectCard = ygopro.StocGameMessage.MsgSelectCard;
import MsgSelectTribute = ygopro.StocGameMessage.MsgSelectTribute;
/*
* Msg Select Tribute
......@@ -10,7 +10,6 @@ import MsgSelectCard = ygopro.StocGameMessage.MsgSelectCard;
* */
export default (data: Uint8Array) => {
// FIXME: handle it correctly
const reader = new BufferReaderExt(data);
const player = reader.inner.readUint8();
......@@ -19,25 +18,25 @@ export default (data: Uint8Array) => {
const max = 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++) {
const code = reader.inner.readUint32();
const controler = reader.inner.readUint8();
const location = reader.inner.readUint8();
const sequence = reader.inner.readUint8();
const release_param = reader.inner.readUint8();
const location = reader.readCardShortLocation();
const level = reader.inner.readUint8();
msg.cards.push(
new MsgSelectCard.SelectAbleCard({
msg.selectable_cards.push(
new MsgSelectTribute.Info({
code,
location: new ygopro.CardLocation({
controler,
location,
sequence,
}),
level,
response: i,
release_param,
})
);
}
......
......@@ -25,6 +25,7 @@ import onUnimplemented from "./unimplemented";
import onMsgUpdateData from "./updateData";
import onMsgReloadField from "./reloadField";
import onMsgSelectSum from "./selectSum";
import onMsgSelectTribute from "./selectTribute";
import { setWaiting } from "../../reducers/duel/mod";
const ActiveList = [
......@@ -169,6 +170,11 @@ export default function handleGameMsg(pb: ygopro.YgoStocMsg) {
break;
}
case "select_tribute": {
onMsgSelectTribute(msg.select_tribute, dispatch);
break;
}
case "unimplemented": {
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