Commit 3092b26a authored by timel's avatar timel Committed by Chunchi Che

fix: updateData with optional operator

parent 36a4e395
...@@ -14,29 +14,29 @@ export default (updateData: MsgUpdateData) => { ...@@ -14,29 +14,29 @@ export default (updateData: MsgUpdateData) => {
if (target) { if (target) {
const meta = target.meta; const meta = target.meta;
// 目前只更新以下字段 // 目前只更新以下字段
if (action.code !== undefined && action.code >= 0) { if (action?.code >= 0) {
meta.id = action.code; meta.id = action.code;
meta.text.id = action.code; meta.text.id = action.code;
} }
if (action.location !== undefined) { if (action.location !== undefined) {
target.position = action.location.position; target.position = action.location.position;
} }
if (action.type_ !== undefined && action.type_ >= 0) { if (action?.type_ >= 0) {
meta.data.type = action.type_; meta.data.type = action.type_;
} }
if (action.level !== undefined && action.level >= 0) { if (action?.level >= 0) {
meta.data.level = action.level; meta.data.level = action.level;
} }
if (action.attribute !== undefined && action.attribute >= 0) { if (action?.attribute >= 0) {
meta.data.attribute = action.attribute; meta.data.attribute = action.attribute;
} }
if (action.race !== undefined && action.race >= 0) { if (action?.race >= 0) {
meta.data.race = action.race; meta.data.race = action.race;
} }
if (action.attack !== undefined && action.attack >= 0) { if (action?.attack >= 0) {
meta.data.atk = action.attack; meta.data.atk = action.attack;
} }
if (action.defense !== undefined && action.defense >= 0) { if (action?.defense >= 0) {
meta.data.def = action.defense; meta.data.def = action.defense;
} }
// TODO: counters // TODO: counters
......
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