Commit c31b247b authored by timel's avatar timel

style: eqeqeq

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