Commit c31b247b authored by timel's avatar timel

style: eqeqeq

parent 017477e5
......@@ -17,9 +17,9 @@ export default (data: Uint8Array) => {
const target_location = reader.readCardLocation();
if (
target_location.controller == 0 &&
target_location.zone == 0 &&
target_location.sequence == 0
target_location.controller === 0 &&
target_location.zone === 0 &&
target_location.sequence === 0
) {
// 全零表示直接攻击玩家
return new MsgAttack({
......
......@@ -44,7 +44,7 @@ export default (data: Uint8Array) => {
const directAttackAble = reader.inner.readUint8();
const attackData = new MsgSelectBattleCmd.BattleCmd.BattleData({
card_info: cardInfo,
direct_attackable: directAttackAble == 1,
direct_attackable: directAttackAble === 1,
response: (i << 16) + 1,
});
attackCmd.battle_datas.push(attackData);
......@@ -53,9 +53,9 @@ export default (data: Uint8Array) => {
msg.battle_cmds = [activateCmd, attackCmd];
// 是否可进入M2阶段
msg.enable_m2 = reader.inner.readUint8() == 1;
msg.enable_m2 = reader.inner.readUint8() === 1;
//时是否可结束回合
msg.enable_ep = reader.inner.readUint8() == 1;
msg.enable_ep = reader.inner.readUint8() === 1;
return msg;
};
......@@ -13,7 +13,7 @@ export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data);
const player = reader.inner.readUint8();
const cancelable = reader.inner.readUint8() != 0;
const cancelable = reader.inner.readUint8() !== 0;
const min = reader.inner.readUint8();
const max = reader.inner.readUint8();
const count = reader.inner.readUint8();
......
......@@ -17,7 +17,7 @@ export default (data: Uint8Array) => {
const player = reader.inner.readUint8();
const count = reader.inner.readUint8();
const spCount = reader.inner.readUint8();
const forced = reader.inner.readUint8() != 0;
const forced = reader.inner.readUint8() !== 0;
const hint0 = reader.inner.readUint32();
const hint1 = reader.inner.readUint32();
......
......@@ -19,7 +19,7 @@ export default (data: Uint8Array) => {
const _field = ~reader.readUint32();
// TODO: 暂时和`ygopro2`一样不支持取消操作,后续需要再考虑加上
if (count == 0) {
if (count === 0) {
count = 1;
}
......@@ -30,16 +30,16 @@ export default (data: Uint8Array) => {
});
for (let i = 0; i < 2; i++) {
const controller = i == 0 ? player : 1 - player;
const field = i == 0 ? _field & 0xffff : _field >> 16;
const controller = i === 0 ? player : 1 - player;
const field = i === 0 ? _field & 0xffff : _field >> 16;
if ((field & 0x7f) != 0) {
if ((field & 0x7f) !== 0) {
// 怪兽区
const zone = ygopro.CardZone.MZONE;
const filter = field & 0x7f;
for (let sequence = 0; sequence < 7; sequence++) {
if ((filter & (1 << sequence)) != 0) {
if ((filter & (1 << sequence)) !== 0) {
msg.places.push(
new MsgSelectPlace.SelectAblePlace({
controller,
......@@ -51,13 +51,13 @@ export default (data: Uint8Array) => {
}
}
if ((field & 0x1f00) != 0) {
if ((field & 0x1f00) !== 0) {
// 魔法陷阱区
const zone = ygopro.CardZone.SZONE;
const filter = (field >> 8) & 0x1f;
for (let sequence = 0; sequence < 5; sequence++) {
if ((filter & (1 << sequence)) != 0) {
if ((filter & (1 << sequence)) !== 0) {
msg.places.push(
new MsgSelectPlace.SelectAblePlace({
controller,
......@@ -69,12 +69,12 @@ export default (data: Uint8Array) => {
}
}
if ((field & 0xc000) != 0) {
if ((field & 0xc000) !== 0) {
// 灵摆区?
const zone = ygopro.CardZone.SZONE;
const filter = (field >> 14) & 0x3;
if ((filter & 0x1) != 0) {
if ((filter & 0x1) !== 0) {
msg.places.push(
new MsgSelectPlace.SelectAblePlace({
controller,
......@@ -84,7 +84,7 @@ export default (data: Uint8Array) => {
);
}
if ((filter & 0x2) != 0) {
if ((filter & 0x2) !== 0) {
msg.places.push(
new MsgSelectPlace.SelectAblePlace({
controller,
......
......@@ -13,7 +13,7 @@ export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data);
const player = reader.inner.readUint8();
const cancelable = reader.inner.readUint8() != 0;
const cancelable = reader.inner.readUint8() !== 0;
const min = reader.inner.readUint8();
const max = reader.inner.readUint8();
const count = reader.inner.readUint8();
......
......@@ -13,8 +13,8 @@ export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data);
const player = reader.inner.readUint8();
const finishable = reader.inner.readUint8() != 0;
const cancelable = reader.inner.readUint8() != 0;
const finishable = reader.inner.readUint8() !== 0;
const cancelable = reader.inner.readUint8() !== 0;
const min = reader.inner.readUint8();
const max = reader.inner.readUint8();
......
......@@ -50,7 +50,7 @@ export default (data: Uint8Array) => {
try {
while (true) {
const len = reader.inner.readInt32();
if (len == 4) continue;
if (len === 4) continue;
const pos = reader.inner.offset();
const action = _readUpdateAction(reader);
if (action) {
......@@ -69,7 +69,7 @@ function _readUpdateAction(
reader: BufferReaderExt,
): MsgUpdateData.Action | undefined {
const flag = reader.inner.readInt32();
if (flag == 0) return undefined;
if (flag === 0) return undefined;
const mask = -1;
let code = mask;
......
......@@ -17,7 +17,7 @@ export default class TypeChangeAdapter implements StocAdapter {
upcast(): ygopro.YgoStocMsg {
const type_ = new DataView(this.packet.exData.buffer).getUint8(0);
const isHost = ((type_ >> 4) & 0xf) != 0;
const isHost = ((type_ >> 4) & 0xf) !== 0;
let selfType = ygopro.StocTypeChange.SelfType.UNKNOWN;
switch (type_ & 0xf) {
......
......@@ -218,7 +218,7 @@ const chunkItems = <T>(items: T[]) =>
export function _cutoff_name(data: Uint8Array): Uint8Array {
let res: number[] = [];
for (const char of chunkItems(Array.from(data))) {
if (!char.every((item) => item == 0)) {
if (!char.every((item) => item === 0)) {
res = res.concat(char);
} else {
break;
......
......@@ -13,7 +13,7 @@ export default async (selectChain: MsgSelectChain) => {
const chains = selectChain.chains;
const chainSetting = matStore.chainSetting;
if (chainSetting == ChainSetting.CHAIN_IGNORE) {
if (chainSetting === ChainSetting.CHAIN_IGNORE) {
// 如果玩家配置了忽略连锁,直接回应后端并返回
sendSelectSingleResponse(-1);
return;
......@@ -28,7 +28,7 @@ export default async (selectChain: MsgSelectChain) => {
// 直接回答
handle_flag = 0;
} else {
if (chainSetting == ChainSetting.CHAIN_ALL) {
if (chainSetting === ChainSetting.CHAIN_ALL) {
// 配置了全部连锁,则处理多张
handle_flag = 2;
} else {
......
......@@ -4,7 +4,7 @@ import { InteractType, placeStore } from "@/stores";
type MsgSelectPlace = ygopro.StocGameMessage.MsgSelectPlace;
export default (selectPlace: MsgSelectPlace) => {
if (selectPlace.count != 1) {
if (selectPlace.count !== 1) {
console.warn(`Unhandled case: ${selectPlace}`);
return;
}
......
......@@ -7,11 +7,11 @@ import MsgShuffleSetCard = ygopro.StocGameMessage.MsgShuffleSetCard;
export default async (shuffleSetCard: MsgShuffleSetCard) => {
const from_locations = shuffleSetCard.from_locations;
const overlay_locations = shuffleSetCard.overlay_locations;
if (from_locations.length == 0) {
if (from_locations.length === 0) {
console.error("<ShuffleSetCard>from_locations is empty");
return;
}
if (from_locations.length != overlay_locations.length) {
if (from_locations.length !== overlay_locations.length) {
console.error(
"<ShuffleSetCard>length of from_locations and overlay_locations not matched",
);
......
......@@ -23,7 +23,7 @@ export default async (updateData: MsgUpdateData) => {
const meta = target.meta;
if (action.location !== undefined) {
if (target.location.position != action.location.position) {
if (target.location.position !== action.location.position) {
// Currently only update position
target.location.position = action.location.position;
// animation
......
......@@ -27,7 +27,7 @@ const helper = async (
) => {
const controller = location.controller;
const newID =
code != 0
code !== 0
? code
: cardStore.at(location.zone, controller, location.sequence)?.code || 0;
const meta = await fetchCard(newID);
......
......@@ -28,7 +28,7 @@ export const isMe = (controller: number): boolean => {
default:
// 自己是观战者
// 这里假设偶数方的玩家是自己
return controller % 2 == 0;
return controller % 2 === 0;
}
};
......
......@@ -186,7 +186,7 @@ const DeckUploader: React.FC<{ onLoaded: (deck: IDeck) => void }> = ({
name: "file",
multiple: true,
onChange(info) {
if (uploadState != "ERROR") {
if (uploadState !== "ERROR") {
info.file.status = "done";
}
},
......
......@@ -35,7 +35,7 @@ export const AnnounceModal = () => {
open={isOpen}
footer={
<Button
disabled={selected.length != min}
disabled={selected.length !== min}
onClick={() => {
let response = selected.reduce((res, current) => res | current, 0); // 多个选择求或
sendSelectOptionResponse(response);
......
......@@ -8,8 +8,8 @@ import { asyncStart } from "./utils";
export const focus = async (props: { card: CardType; api: SpringApi }) => {
const { card, api } = props;
if (
card.location.zone == ygopro.CardZone.HAND ||
card.location.zone == ygopro.CardZone.DECK
card.location.zone === ygopro.CardZone.HAND ||
card.location.zone === ygopro.CardZone.DECK
) {
const current = { ...api.current[0].get() };
await asyncStart(api)({
......
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