Commit 2586a52b authored by Chunchi Che's avatar Chunchi Che

修复某些卡(比如神弓)攻击力展示不正确的问题

parent 551fc976
......@@ -24,9 +24,11 @@ npm_ci:
rs_check_lint:
stage: rs_check_lint
image: rust:latest
tags:
- linux
before_script:
- curl https://sh.rustup.rs -sSf | sh -s -- -y
- source "$HOME/.cargo/env"
script:
- cd rust-src
- cargo check
......@@ -36,11 +38,12 @@ rs_check_lint:
wasm_build:
tags:
- linux
image: rust:latest
stage: wasm
extends:
- .build_base
before_script:
- curl https://sh.rustup.rs -sSf | sh -s -- -y
- source "$HOME/.cargo/env"
- curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
script:
- wasm-pack build ./rust-src --target web
......
......@@ -58,6 +58,7 @@ export const MSG_PAY_LP_COST = 100;
export const MSG_WIN = 5;
export const MSG_WAITING = 3;
export const MSG_UPDATE_DATA = 6;
export const MSG_UPDATE_CARD = 7;
export const MSG_RELOAD_FIELD = 162;
export const MSG_SELECT_SUM = 23;
export const MSG_ADD_COUNTER = 101;
......
......@@ -41,6 +41,7 @@ import MsgSibylNameAdapter from "./sibylName";
import MsgSortCard from "./sortCard";
import MsgStartAdapter from "./start";
import MsgTossAdapter from "./toss";
import MsgUpdateCardAdapter from "./updateCard";
import MsgUpdateDataAdapter from "./updateData";
import MsgWaitAdapter from "./wait";
import MsgWin from "./win";
......@@ -72,159 +73,132 @@ export default class GameMsgAdapter implements StocAdapter {
switch (func) {
case GAME_MSG.MSG_START: {
gameMsg.start = MsgStartAdapter(gameData);
break;
}
case GAME_MSG.MSG_DRAW: {
gameMsg.draw = MsgDrawAdapter(gameData);
break;
}
case GAME_MSG.MSG_NEW_TURN: {
gameMsg.new_turn = MsgNewTurnAdapter(gameData);
break;
}
case GAME_MSG.MSG_NEW_PHASE: {
gameMsg.new_phase = MsgNewPhaseAdapter(gameData);
break;
}
case GAME_MSG.MSG_HINT: {
gameMsg.hint = MsgHintAdapter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_IDLE_CMD: {
gameMsg.select_idle_cmd = MsgSelectIdleCmdAdapter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_DISFIELD:
case GAME_MSG.MSG_SELECT_PLACE: {
gameMsg.select_place = MsgSelectPlaceAdapter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_CARD: {
gameMsg.select_card = MsgSelectCardAdapter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_TRIBUTE: {
gameMsg.select_tribute = MsgSelectTributeAdapter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_CHAIN: {
gameMsg.select_chain = MsgSelectChainAdapter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_EFFECTYN: {
gameMsg.select_effect_yn = MsgSelectEffectYnAdapter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_POSITION: {
gameMsg.select_position = MsgSelectPositionAdapter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_OPTION: {
gameMsg.select_option = MsgSelectOptionAdapter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_BATTLE_CMD: {
gameMsg.select_battle_cmd = MsgSelectBattleCmdAdapter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_UNSELECT_CARD: {
gameMsg.select_unselect_card = MsgSelectUnselectCardAdapter(gameData);
break;
}
case GAME_MSG.MSG_PAY_LP_COST:
case GAME_MSG.MSG_DAMAGE: {
gameMsg.update_hp = MsgDamage(gameData);
break;
}
case GAME_MSG.MSG_RECOVER: {
gameMsg.update_hp = MsgRecover(gameData);
break;
}
case GAME_MSG.MSG_WIN: {
gameMsg.win = MsgWin(gameData);
break;
}
case GAME_MSG.MSG_WAITING: {
gameMsg.wait = MsgWaitAdapter(gameData);
break;
}
case GAME_MSG.MSG_UPDATE_DATA: {
gameMsg.update_data = MsgUpdateDataAdapter(gameData);
break;
}
case GAME_MSG.MSG_UPDATE_CARD: {
gameMsg.update_data = MsgUpdateCardAdapter(gameData);
break;
}
case GAME_MSG.MSG_RELOAD_FIELD: {
gameMsg.reload_field = MsgReloadFieldAdapter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_SUM: {
gameMsg.select_sum = MsgSelectSum(gameData);
break;
}
case GAME_MSG.MSG_ADD_COUNTER: {
gameMsg.update_counter = MsgAddCounter(gameData);
break;
}
case GAME_MSG.MSG_REMOVE_COUNTER: {
gameMsg.update_counter = MsgRemoveCounter(gameData);
break;
}
case GAME_MSG.MSG_SELECT_COUNTER: {
gameMsg.select_counter = MsgSelectCounter(gameData);
break;
}
case GAME_MSG.MSG_SORT_CARD: {
gameMsg.sort_card = MsgSortCard(gameData);
break;
}
case GAME_MSG.MSG_ATTACK: {
gameMsg.attack = MsgAttack(gameData);
break;
}
case GAME_MSG.MSG_ANNOUNCE_RACE: {
gameMsg.announce = MsgAnnounceRace(gameData);
break;
}
case GAME_MSG.MSG_ANNOUNCE_ATTRIB: {
gameMsg.announce = MsgAnnounceAttribute(gameData);
break;
}
case GAME_MSG.MSG_ANNOUNCE_CARD: {
gameMsg.announce = MsgAnnounceCard(gameData);
break;
}
case GAME_MSG.MSG_ANNOUNCE_NUMBER: {
gameMsg.announce = MsgAnnounceNumber(gameData);
break;
}
case GAME_MSG.MSG_TOSS_COIN: {
......@@ -232,7 +206,6 @@ export default class GameMsgAdapter implements StocAdapter {
gameData,
ygopro.StocGameMessage.MsgToss.TossType.COIN,
);
break;
}
case GAME_MSG.MSG_TOSS_DICE: {
......@@ -240,22 +213,18 @@ export default class GameMsgAdapter implements StocAdapter {
gameData,
ygopro.StocGameMessage.MsgToss.TossType.DICE,
);
break;
}
case GAME_MSG.MSG_SHUFFLE_SET_CARD: {
gameMsg.shuffle_set_card = MsgShuffleSetCard(gameData);
break;
}
case GAME_MSG.MSG_FIELD_DISABLED: {
gameMsg.field_disabled = MsgFieldDisabledAdapter(gameData);
break;
}
case GAME_MSG.MSG_HAND_RES: {
gameMsg.hand_res = MsgHandResultAdapter(gameData);
break;
}
case GAME_MSG.MSG_SHUFFLE_HAND: {
......@@ -263,7 +232,6 @@ export default class GameMsgAdapter implements StocAdapter {
gameData,
false,
);
break;
}
case GAME_MSG.MSG_SHUFFLE_EXTRA: {
......@@ -271,19 +239,16 @@ export default class GameMsgAdapter implements StocAdapter {
gameData,
true,
);
break;
}
case GAME_MSG.MSG_SIBYL_NAME: {
gameMsg.sibyl_name = MsgSibylNameAdapter(gameData);
break;
}
default: {
gameMsg.unimplemented = new ygopro.StocGameMessage.MsgUnimplemented({
command: func,
});
break;
}
}
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReaderExt } from "../../bufferIO";
import { numberToCardZone, readUpdateAction } from "../../util";
import MsgUpdateData = ygopro.StocGameMessage.MsgUpdateData;
/*
* Msg UpdateCard
*
* @param - TODO
*
* @usage - ygopro后端通知前端更新单张卡片的元数据
* */
export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data);
const player = reader.inner.readUint8();
const zone = numberToCardZone(reader.inner.readUint8());
const sequence = reader.inner.readUint8();
// pending
reader.inner.readUint32();
const msg = new MsgUpdateData({ player, zone, actions: [] });
const action = readUpdateAction(reader);
if (action) {
if (action.location !== undefined && zone !== undefined) {
action.location.controller = player;
action.location.zone = zone;
action.location.sequence = sequence;
} else {
action.location = new ygopro.CardLocation({
controller: player,
zone,
sequence,
});
}
msg.actions.push(action);
}
return msg;
};
import {
QUERY_ALIAS,
QUERY_ATTACK,
QUERY_ATTRIBUTE,
QUERY_BASE_ATTACK,
QUERY_BASE_DEFENSE,
QUERY_CODE,
QUERY_COUNTERS,
QUERY_DEFENSE,
QUERY_EQUIP_CARD,
QUERY_LEVEL,
QUERY_LINK,
QUERY_LSCALE,
QUERY_OVERLAY_CARD,
QUERY_OWNER,
QUERY_POSITION,
QUERY_RACE,
QUERY_RANK,
QUERY_REASON,
QUERY_REASON_CARD,
QUERY_RSCALE,
QUERY_STATUS,
QUERY_TARGET_CARD,
QUERY_TYPE,
} from "../../../../../common";
import { ygopro } from "../../../idl/ocgcore";
import { BufferReaderExt } from "../../bufferIO";
import { numberToCardZone } from "../../util";
import { numberToCardZone, readUpdateAction } from "../../util";
import MsgUpdateData = ygopro.StocGameMessage.MsgUpdateData;
/*
......@@ -52,7 +27,7 @@ export default (data: Uint8Array) => {
const len = reader.inner.readInt32();
if (len === 4) continue;
const pos = reader.inner.offset();
const action = _readUpdateAction(reader);
const action = readUpdateAction(reader);
if (action) {
msg.actions.push(action);
}
......@@ -64,142 +39,3 @@ export default (data: Uint8Array) => {
return msg;
};
function _readUpdateAction(
reader: BufferReaderExt,
): MsgUpdateData.Action | undefined {
const flag = reader.inner.readInt32();
if (flag === 0) return undefined;
const mask = -1;
let code = mask;
let location;
let alias = mask;
let type_ = mask;
let level = mask;
let rank = mask;
let attribute = mask;
let race = mask;
let attack = mask;
let defense = mask;
let base_attack = mask;
let base_defense = mask;
let reason = mask;
let reason_card = mask;
let equip_card;
let target_cards = [];
let overlay_cards = [];
let counters = new Map<number, number>();
let owner = mask;
let status = mask;
let lscale = mask;
let rscale = mask;
let link = mask;
if (flag & QUERY_CODE) {
code = reader.inner.readInt32();
}
if (flag & QUERY_POSITION) {
location = reader.readCardLocation();
}
if (flag & QUERY_ALIAS) {
alias = reader.inner.readInt32();
}
if (flag & QUERY_TYPE) {
type_ = reader.inner.readInt32();
}
if (flag & QUERY_LEVEL) {
level = reader.inner.readInt32();
}
if (flag & QUERY_RANK) {
rank = reader.inner.readInt32();
}
if (flag & QUERY_ATTRIBUTE) {
attribute = reader.inner.readInt32();
}
if (flag & QUERY_RACE) {
race = reader.inner.readInt32();
}
if (flag & QUERY_ATTACK) {
attack = reader.inner.readInt32();
}
if (flag & QUERY_DEFENSE) {
defense = reader.inner.readInt32();
}
if (flag & QUERY_BASE_ATTACK) {
base_attack = reader.inner.readInt32();
}
if (flag & QUERY_BASE_DEFENSE) {
base_defense = reader.inner.readInt32();
}
if (flag & QUERY_REASON) {
reason = reader.inner.readInt32();
}
if (flag & QUERY_REASON_CARD) {
reason_card = reader.inner.readInt32();
}
if (flag & QUERY_EQUIP_CARD) {
equip_card = reader.readCardLocation();
}
if (flag & QUERY_TARGET_CARD) {
const count = reader.inner.readInt32();
for (let i = 0; i < count; i += 1) {
target_cards.push(reader.readCardLocation());
}
}
if (flag & QUERY_OVERLAY_CARD) {
const count = reader.inner.readInt32();
for (let i = 0; i < count; i += 1) {
overlay_cards.push(reader.inner.readInt32());
}
}
if (flag & QUERY_COUNTERS) {
const count = reader.inner.readInt32();
for (let i = 0; i < count; i += 1) {
const ctype = reader.inner.readUint16();
const ccount = reader.inner.readUint16();
counters.set(ctype, ccount);
}
}
if (flag & QUERY_OWNER) {
owner = reader.inner.readInt32();
}
if (flag & QUERY_STATUS) {
status = reader.inner.readInt32();
}
if (flag & QUERY_LSCALE) {
lscale = reader.inner.readInt32();
}
if (flag & QUERY_RSCALE) {
rscale = reader.inner.readInt32();
}
if (flag & QUERY_LINK) {
link = reader.inner.readInt32();
}
return new MsgUpdateData.Action({
code,
location,
alias,
type_,
level,
rank,
attribute,
race,
attack,
defense,
base_attack,
base_defense,
reason,
reason_card,
equip_card,
target_cards,
overlay_cards,
counters,
owner,
status,
lscale,
rscale,
link,
});
}
......@@ -3,7 +3,34 @@
*
* */
import {
QUERY_ALIAS,
QUERY_ATTACK,
QUERY_ATTRIBUTE,
QUERY_BASE_ATTACK,
QUERY_BASE_DEFENSE,
QUERY_CODE,
QUERY_COUNTERS,
QUERY_DEFENSE,
QUERY_EQUIP_CARD,
QUERY_LEVEL,
QUERY_LINK,
QUERY_LSCALE,
QUERY_OVERLAY_CARD,
QUERY_OWNER,
QUERY_POSITION,
QUERY_RACE,
QUERY_RANK,
QUERY_REASON,
QUERY_REASON_CARD,
QUERY_RSCALE,
QUERY_STATUS,
QUERY_TARGET_CARD,
QUERY_TYPE,
} from "../../../common";
import { ygopro } from "../idl/ocgcore";
import { BufferReaderExt } from "./bufferIO";
import MsgUpdateData = ygopro.StocGameMessage.MsgUpdateData;
export const UTF16_BUFFER_MAX_LEN = 20;
const FILLING_TOKEN: number = 0xcccc;
......@@ -226,3 +253,142 @@ export function _cutoff_name(data: Uint8Array): Uint8Array {
}
return Uint8Array.from(res);
}
export function readUpdateAction(
reader: BufferReaderExt,
): MsgUpdateData.Action | undefined {
const flag = reader.inner.readInt32();
if (flag === 0) return undefined;
const mask = -1;
let code = mask;
let location;
let alias = mask;
let type_ = mask;
let level = mask;
let rank = mask;
let attribute = mask;
let race = mask;
let attack = mask;
let defense = mask;
let base_attack = mask;
let base_defense = mask;
let reason = mask;
let reason_card = mask;
let equip_card;
let target_cards = [];
let overlay_cards = [];
let counters = new Map<number, number>();
let owner = mask;
let status = mask;
let lscale = mask;
let rscale = mask;
let link = mask;
if (flag & QUERY_CODE) {
code = reader.inner.readInt32();
}
if (flag & QUERY_POSITION) {
location = reader.readCardLocation();
}
if (flag & QUERY_ALIAS) {
alias = reader.inner.readInt32();
}
if (flag & QUERY_TYPE) {
type_ = reader.inner.readInt32();
}
if (flag & QUERY_LEVEL) {
level = reader.inner.readInt32();
}
if (flag & QUERY_RANK) {
rank = reader.inner.readInt32();
}
if (flag & QUERY_ATTRIBUTE) {
attribute = reader.inner.readInt32();
}
if (flag & QUERY_RACE) {
race = reader.inner.readInt32();
}
if (flag & QUERY_ATTACK) {
attack = reader.inner.readInt32();
}
if (flag & QUERY_DEFENSE) {
defense = reader.inner.readInt32();
}
if (flag & QUERY_BASE_ATTACK) {
base_attack = reader.inner.readInt32();
}
if (flag & QUERY_BASE_DEFENSE) {
base_defense = reader.inner.readInt32();
}
if (flag & QUERY_REASON) {
reason = reader.inner.readInt32();
}
if (flag & QUERY_REASON_CARD) {
reason_card = reader.inner.readInt32();
}
if (flag & QUERY_EQUIP_CARD) {
equip_card = reader.readCardLocation();
}
if (flag & QUERY_TARGET_CARD) {
const count = reader.inner.readInt32();
for (let i = 0; i < count; i += 1) {
target_cards.push(reader.readCardLocation());
}
}
if (flag & QUERY_OVERLAY_CARD) {
const count = reader.inner.readInt32();
for (let i = 0; i < count; i += 1) {
overlay_cards.push(reader.inner.readInt32());
}
}
if (flag & QUERY_COUNTERS) {
const count = reader.inner.readInt32();
for (let i = 0; i < count; i += 1) {
const ctype = reader.inner.readUint16();
const ccount = reader.inner.readUint16();
counters.set(ctype, ccount);
}
}
if (flag & QUERY_OWNER) {
owner = reader.inner.readInt32();
}
if (flag & QUERY_STATUS) {
status = reader.inner.readInt32();
}
if (flag & QUERY_LSCALE) {
lscale = reader.inner.readInt32();
}
if (flag & QUERY_RSCALE) {
rscale = reader.inner.readInt32();
}
if (flag & QUERY_LINK) {
link = reader.inner.readInt32();
}
return new MsgUpdateData.Action({
code,
location,
alias,
type_,
level,
rank,
attribute,
race,
attack,
defense,
base_attack,
base_defense,
reason,
reason_card,
equip_card,
target_cards,
overlay_cards,
counters,
owner,
status,
lscale,
rscale,
link,
});
}
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