Commit ff75a890 authored by Chunchi Che's avatar Chunchi Che

add newPhase

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