Commit ff75a890 authored by Chunchi Che's avatar Chunchi Che

add newPhase

parent 43b00a01
Pipeline #18312 passed with stages
in 2 minutes and 20 seconds
......@@ -29,7 +29,7 @@ export class BufferReader {
}
readUint16(): number {
const ret = this.dataView.getUint16(this.offset);
const ret = this.dataView.getUint16(this.offset, this.littleEndian);
this.offset += OFFSET_UINT16;
return ret;
......
......@@ -14,10 +14,10 @@ const LITTLE_ENDIAN = true;
export default (data: Uint8Array) => {
const reader = new BufferReader(data, LITTLE_ENDIAN);
const player = reader.readUint16();
const phase = reader.readUint16();
let phaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType.UNKNOWN;
switch (player) {
switch (phase) {
case 0x01: {
phaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType.DRAW;
......
......@@ -42,8 +42,14 @@ const duelSlice = createSlice({
},
});
export const { meInfoInit, opInfoInit, meAddHands, opAddHands, updateTurn } =
duelSlice.actions;
export const {
meInfoInit,
opInfoInit,
meAddHands,
opAddHands,
updateTurn,
updatePhase,
} = duelSlice.actions;
export const selectDuelHsStart = (state: RootState) => {
return state.duel.meInitInfo != null;
};
......
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { AppDispatch } from "../../store";
import { updatePhase } from "../../reducers/duel/mod";
export default (
newPhase: ygopro.StocGameMessage.MsgNewPhase,
dispatch: AppDispatch
) => {
// TODO
dispatch(updatePhase(newPhase.phase_type.toString()));
};
......@@ -19,6 +19,7 @@ import renderField from "./field";
import * as CONFIG from "../../../config/ui";
import { Card } from "../../../api/cards";
import { selectCurrentPlayer } from "../../../reducers/duel/turnSlice";
import { selectCurrentPhase } from "../../../reducers/duel/phaseSlice";
// CONFIG
......@@ -36,6 +37,7 @@ export default class SimpleDuelPlateImpl implements IDuelPlate {
};
const hands = useAppSelector(this.handsSelector || defaultHandsSelector);
const currentPlayer = useAppSelector(selectCurrentPlayer);
const currentPhase = useAppSelector(selectCurrentPhase);
// ----- WebGL渲染 -----
const canvasRef = useRef<HTMLCanvasElement>(null);
......@@ -107,6 +109,8 @@ export default class SimpleDuelPlateImpl implements IDuelPlate {
// 当前操作玩家
console.log(`currentPlayer:` + currentPlayer);
// 当前阶段
console.log(`currentPhase:` + currentPhase);
// 渲染循环
engine.runRenderLoop(() => {
......
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