@@ -12,7 +12,7 @@ import { useDrop } from "react-dnd";
1212import { CardColors , CardState } from "../../common/card.js" ;
1313import { cardHeight , cardWidth , combineColors , isCardPropsEqual } from "../Card.js" ;
1414import { CacheContext , CosmeticContext , HighlightContext , PlanContext } from "./Game.js" ;
15- import { getCard } from "../../common/gameSlice.js" ;
15+ import { findCard , getCard } from "../../common/gameSlice.js" ;
1616import { useClientSelector } from "../store.js" ;
1717import { hex } from "../color.js" ;
1818import util from "../../common/util.js" ;
@@ -58,20 +58,35 @@ export default React.memo(
5858 ( ) => ( {
5959 accept : "target" ,
6060 drop : ( state : CardState ) => {
61- setPlan ( ( plan ) => [
62- ...plan ,
63- {
64- type : "play" ,
65- card : state ,
66- action : { id : state . id , target : { id : props . state . id } } ,
67- } ,
68- ] ) ;
61+ const found = findCard ( game , state ) ;
62+ if ( ! found ) {
63+ return ;
64+ }
65+
66+ const info = cache . getCardInfo ( game , state ) ;
67+ if (
68+ ( found . zone == "deck" &&
69+ info . targets &&
70+ util . filter ( cache , game , info . targets ) . some ( ( c ) => c . id == props . state . id ) ) ||
71+ ( found . zone == "board" &&
72+ info . activateTargets &&
73+ util . filter ( cache , game , info . activateTargets ) . some ( ( c ) => c . id == props . state . id ) )
74+ ) {
75+ setPlan ( ( plan ) => [
76+ ...plan ,
77+ {
78+ type : found . zone == "deck" ? "play" : "activate" ,
79+ card : state ,
80+ action : { id : state . id , target : { id : props . state . id } } ,
81+ } ,
82+ ] ) ;
83+ }
6984 } ,
7085 collect : ( monitor ) => ( {
7186 isOver : monitor . isOver ( ) ,
7287 } ) ,
7388 } ) ,
74- [ ]
89+ [ game , props . state . id ]
7590 ) ;
7691
7792 useEffect ( ( ) => {
0 commit comments