Commit 86ec6b1c authored by Chunchi Che's avatar Chunchi Che

fix update data

parent ca8a2c9a
......@@ -71,29 +71,30 @@ function _readUpdateAction(
const flag = reader.inner.readInt32();
if (flag == 0) return undefined;
let code;
const mask = -1;
let code = mask;
let location;
let alias;
let type_;
let level;
let rank;
let attribute;
let race;
let attack;
let defense;
let base_attack;
let base_defense;
let reason;
let reason_card;
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;
let status;
let lscale;
let rscale;
let link;
let owner = mask;
let status = mask;
let lscale = mask;
let rscale = mask;
let link = mask;
if (flag & QUERY_CODE) {
code = reader.inner.readInt32();
......
......@@ -294,33 +294,34 @@ export function updateCardData<T extends DuelFieldState>(
for (const payload of actions) {
const sequence = payload.location?.sequence;
if (typeof sequence !== "undefined") {
console.log(payload.type_);
const target = state?.inner.find((_, idx) => idx == sequence);
if (target && target.occupant) {
const occupant = target.occupant;
// 目前只更新以下字段
if (payload.code !== undefined) {
if (payload.code !== undefined && payload.code >= 0) {
occupant.id = payload.code;
occupant.text.id = payload.code;
}
if (payload.location !== undefined) {
target.location.position = payload.location.position;
}
if (payload.type_ !== undefined) {
if (payload.type_ !== undefined && payload.type_ >= 0) {
occupant.data.type = payload.type_;
}
if (payload.level !== undefined) {
if (payload.level !== undefined && payload.level >= 0) {
occupant.data.level = payload.level;
}
if (payload.attribute !== undefined) {
if (payload.attribute !== undefined && payload.attribute >= 0) {
occupant.data.attribute = payload.attribute;
}
if (payload.race !== undefined) {
if (payload.race !== undefined && payload.race >= 0) {
occupant.data.race = payload.race;
}
if (payload.attack !== undefined) {
if (payload.attack !== undefined && payload.attack >= 0) {
occupant.data.atk = payload.attack;
}
if (payload.defense !== undefined) {
if (payload.defense !== undefined && payload.defense >= 0) {
occupant.data.def = payload.defense;
}
}
......
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