Commit 28b814f7 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'feat/card_disabled' into 'main'

Feat/card disabled

See merge request !402
parents 1a685aa3 c52620c7
Pipeline #28750 passed with stages
in 15 minutes and 38 seconds
...@@ -453,3 +453,36 @@ function ifSetCard(setCodeToAnalyse: number, setCodeFromCard: number): boolean { ...@@ -453,3 +453,36 @@ function ifSetCard(setCodeToAnalyse: number, setCodeFromCard: number): boolean {
return res; return res;
} }
export const STATUS_DISABLED = 0x0001;
// const STATUS_TO_ENABLE = 0x0002
// const STATUS_TO_DISABLE = 0x0004
// const STATUS_PROC_COMPLETE = 0x0008
// const STATUS_SET_TURN = 0x0010
// const STATUS_NO_LEVEL = 0x0020
// const STATUS_BATTLE_RESULT = 0x0040
// const STATUS_SPSUMMON_STEP = 0x0080
// const STATUS_FORM_CHANGED = 0x0100
// const STATUS_SUMMONING = 0x0200
// const STATUS_EFFECT_ENABLED = 0x0400
// const STATUS_SUMMON_TURN = 0x0800
// const STATUS_DESTROY_CONFIRMED = 0x1000
// const STATUS_LEAVE_CONFIRMED = 0x2000
// const STATUS_BATTLE_DESTROYED = 0x4000
// const STATUS_COPYING_EFFECT = 0x8000
// const STATUS_CHAINING = 0x10000
// const STATUS_SUMMON_DISABLED = 0x20000
// const STATUS_ACTIVATE_DISABLED = 0x40000
// const STATUS_EFFECT_REPLACED = 0x80000
// const STATUS_FLIP_SUMMONING = 0x100000
// const STATUS_ATTACK_CANCELED = 0x200000
// const STATUS_INITIALIZING = 0x400000
// const STATUS_TO_HAND_WITHOUT_CONFIRM = 0x800000
// const STATUS_JUST_POS = 0x1000000
// const STATUS_CONTINUOUS_POS = 0x2000000
export const STATUS_FORBIDDEN = 0x4000000;
// const STATUS_ACT_FROM_HAND = 0x8000000
// const STATUS_OPPO_BATTLE = 0x10000000
// const STATUS_FLIP_SUMMON_TURN = 0x20000000
// const STATUS_SPSUMMON_TURN = 0x40000000
// const STATUS_FLIP_SUMMON_DISABLED = 0x80000000
...@@ -41,6 +41,7 @@ export default (container: Container, field: MsgReloadField) => { ...@@ -41,6 +41,7 @@ export default (container: Container, field: MsgReloadField) => {
selectable: false, selectable: false,
selected: false, selected: false,
}, },
status: 0,
}), }),
), ),
) )
......
...@@ -77,6 +77,7 @@ export default async ( ...@@ -77,6 +77,7 @@ export default async (
selectable: false, selectable: false,
selected: false, selected: false,
}, },
status: 0,
}), }),
), ),
), ),
......
...@@ -53,6 +53,9 @@ export default async (container: Container, updateData: MsgUpdateData) => { ...@@ -53,6 +53,9 @@ export default async (container: Container, updateData: MsgUpdateData) => {
if (action?.defense >= 0) { if (action?.defense >= 0) {
meta.data.def = action.defense; meta.data.def = action.defense;
} }
if (action?.status >= 0) {
target.status = action.status;
}
// TODO: counters // TODO: counters
} else { } else {
console.warn( console.warn(
......
import type { ygopro } from "@/api"; import type { ygopro } from "@/api";
import { fetchCard, getCardStr } from "@/api/cards"; import { fetchCard, getCardStr } from "@/api/cards";
import { Context } from "@/container"; import { Context } from "@/container";
import { isCardDisabled } from "@/stores";
import type { Option } from "@/ui/Duel/Message"; import type { Option } from "@/ui/Duel/Message";
const helper = async ( const helper = async (
...@@ -52,6 +53,7 @@ const helper = async ( ...@@ -52,6 +53,7 @@ const helper = async (
effectDesc, effectDesc,
response, response,
targeted: target?.targeted, targeted: target?.targeted,
disabled: target ? isCardDisabled(target) : false,
}; };
if (selected) { if (selected) {
......
import { proxy } from "valtio"; import { proxy } from "valtio";
import { CardMeta, ygopro } from "@/api"; import { CardMeta, ygopro } from "@/api";
import { STATUS_DISABLED, STATUS_FORBIDDEN } from "@/common";
import type { Interactivity } from "./matStore/types"; import type { Interactivity } from "./matStore/types";
import { type NeosStore } from "./shared"; import { type NeosStore } from "./shared";
/** /**
* 场上某位置的状态 * Status of card on field
*
* TODO: use class
*/ */
export interface CardType { export interface CardType {
uuid: string; // 一张卡的唯一标识 uuid: string; // 一张卡的唯一标识
...@@ -22,6 +25,7 @@ export interface CardType { ...@@ -22,6 +25,7 @@ export interface CardType {
selected: boolean; // 是否已经被选择 selected: boolean; // 是否已经被选择
response?: number; // 被选择时发送给服务器的值 response?: number; // 被选择时发送给服务器的值
}; };
status: number; // Current status, STATUS_DISABLED, etc.
} }
export class CardStore implements NeosStore { export class CardStore implements NeosStore {
...@@ -93,4 +97,9 @@ export class CardStore implements NeosStore { ...@@ -93,4 +97,9 @@ export class CardStore implements NeosStore {
} }
} }
// TODO: provided in class
export function isCardDisabled(card: CardType): boolean {
return (card.status & (STATUS_DISABLED | STATUS_FORBIDDEN)) > 0;
}
export const cardStore = proxy(new CardStore()); export const cardStore = proxy(new CardStore());
...@@ -108,8 +108,8 @@ export const PositionModal = () => { ...@@ -108,8 +108,8 @@ export const PositionModal = () => {
footer={<></>} footer={<></>}
> >
<div className={styles.container}> <div className={styles.container}>
{positions.map((position) => ( {positions.map((position, idx) => (
<Button onClick={() => onSummit(position)}> <Button key={idx} onClick={() => onSummit(position)}>
{cardPosition(position)} {cardPosition(position)}
</Button> </Button>
))} ))}
......
...@@ -197,6 +197,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -197,6 +197,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
<YgoCard <YgoCard
code={card.meta.id} code={card.meta.id}
targeted={card.targeted} targeted={card.targeted}
disabled={card.disabled}
className={styles.card} className={styles.card}
/> />
} }
...@@ -286,6 +287,7 @@ export interface Option { ...@@ -286,6 +287,7 @@ export interface Option {
level2?: number; level2?: number;
response?: number; response?: number;
targeted?: boolean; targeted?: boolean;
disabled?: boolean;
// 便于直接返回这个信息 // 便于直接返回这个信息
// //
// 尽量不要用这个字段 // 尽量不要用这个字段
......
...@@ -14,7 +14,13 @@ import { ...@@ -14,7 +14,13 @@ import {
import { Container } from "@/container"; import { Container } from "@/container";
import { getUIContainer } from "@/container/compat"; import { getUIContainer } from "@/container/compat";
import { eventbus, Task } from "@/infra"; import { eventbus, Task } from "@/infra";
import { cardStore, CardType, Interactivity, InteractType } from "@/stores"; import {
cardStore,
CardType,
Interactivity,
InteractType,
isCardDisabled,
} from "@/stores";
import { showCardModal as displayCardModal } from "@/ui/Duel/Message/CardModal"; import { showCardModal as displayCardModal } from "@/ui/Duel/Message/CardModal";
import { YgoCard } from "@/ui/Shared"; import { YgoCard } from "@/ui/Shared";
...@@ -344,6 +350,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -344,6 +350,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
<YgoCard <YgoCard
className={styles.cover} className={styles.cover}
code={snap.code === 0 ? snap.meta.id : snap.code} code={snap.code === 0 ? snap.meta.id : snap.code}
disabled={isCardDisabled(snap as CardType)}
/> />
<YgoCard className={styles.back} isBack /> <YgoCard className={styles.back} isBack />
</div> </div>
......
...@@ -22,3 +22,12 @@ ...@@ -22,3 +22,12 @@
z-index: 2; z-index: 2;
pointer-events: none; pointer-events: none;
} }
.disabled {
position: relative;
display: flex;
width: 50%;
justify-content: center;
z-index: 2;
pointer-events: none;
}
...@@ -13,6 +13,7 @@ interface Props { ...@@ -13,6 +13,7 @@ interface Props {
isBack?: boolean; isBack?: boolean;
code?: number; code?: number;
targeted?: boolean; targeted?: boolean;
disabled?: boolean;
// cardName?: string; // cardName?: string;
style?: CSSProperties; style?: CSSProperties;
width?: number | string; width?: number | string;
...@@ -27,11 +28,13 @@ export const YgoCard: React.FC<Props> = (props) => { ...@@ -27,11 +28,13 @@ export const YgoCard: React.FC<Props> = (props) => {
// cardName, // cardName,
isBack = false, isBack = false,
targeted = false, targeted = false,
disabled = false,
width, width,
style, style,
onClick, onClick,
onLoad, onLoad,
} = props; } = props;
return useMemo( return useMemo(
() => ( () => (
<div <div
...@@ -56,8 +59,15 @@ export const YgoCard: React.FC<Props> = (props) => { ...@@ -56,8 +59,15 @@ export const YgoCard: React.FC<Props> = (props) => {
) : ( ) : (
<></> <></>
)} )}
{disabled ? (
<div className={styles.disabled}>
<img src={`${assetsPath}/disabled.png`} />
</div>
) : (
<></>
)}
</div> </div>
), ),
[code], [code, targeted, disabled],
); );
}; };
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