@@ -174,13 +174,65 @@ export default class Game {
174174 this . api . playCard ( this . gameId , params )
175175 }
176176 handleClickPlayer = ( player : Player ) => {
177+ const handleHeavenlyDoubleHalberdTargetSelection = ( ) => {
178+ const selectedIndex = this . selectTargetPlayers . findIndex ( ( p ) => p . id === player . id )
179+ if ( selectedIndex >= 0 ) {
180+ player . setPlayerSelected ( false )
181+ this . selectTargetPlayers . splice ( selectedIndex , 1 )
182+ this . me . updateKillTargetSelectionHint ( this . selectTargetPlayers . length , 3 , true )
183+ return true
184+ }
185+ if ( this . selectTargetPlayers . length >= 3 ) {
186+ return true
187+ }
188+ player . setPlayerSelected ( true , 'from' )
189+ this . selectTargetPlayers . push ( player )
190+ this . me . updateKillTargetSelectionHint ( this . selectTargetPlayers . length , 3 , true )
191+ return true
192+ }
177193 if ( this . me . viperSpearMode ) {
178194 if ( ! player . isOutofDistance ) {
179195 this . me . handleViperSpearTarget ( player )
180196 }
181197 return
182198 }
199+ if ( this . me . heavenlyDoubleHalberdMode ) {
200+ if (
201+ ! this . me . selectedCard ||
202+ this . me . selectedCard . name !== '殺' ||
203+ player . isOutofDistance
204+ ) {
205+ return
206+ }
207+ handleHeavenlyDoubleHalberdTargetSelection ( )
208+ return
209+ }
183210 if ( ! this . me . selectedCard || player . isOutofDistance ) return
211+ if (
212+ this . me . selectedCard . name === '殺' &&
213+ this . me . canTriggerHeavenlyDoubleHalberd ( this . me . selectedCard )
214+ ) {
215+ // 保險:只要符合方天畫戟條件,永遠先進入多目標選擇模式,不能直接走一般殺流程。
216+ this . me . enableHeavenlyDoubleHalberdMode ( )
217+ handleHeavenlyDoubleHalberdTargetSelection ( )
218+ return
219+ }
220+ if ( this . me . selectedCard . name === '殺' ) {
221+ const selectedIndex = this . selectTargetPlayers . findIndex ( ( p ) => p . id === player . id )
222+ if ( selectedIndex >= 0 ) {
223+ player . setPlayerSelected ( false )
224+ this . selectTargetPlayers . splice ( selectedIndex , 1 )
225+ } else {
226+ this . selectTargetPlayers . forEach ( ( targetPlayer ) =>
227+ targetPlayer . setPlayerSelected ( false ) ,
228+ )
229+ player . setPlayerSelected ( true , 'from' )
230+ this . selectTargetPlayers = [ player ]
231+ }
232+ this . me . updateKillTargetSelectionHint ( this . selectTargetPlayers . length , 1 , false )
233+ this . me . mainInstanceMap . checkModal ?. setAlpha ( 1 )
234+ return
235+ }
184236 if ( this . me . selectedCard . name === '過河拆橋' ) {
185237 this . seats . forEach ( ( player ) => player . setOutOfDistance ( false ) )
186238 // 開啟選擇面板
@@ -199,24 +251,6 @@ export default class Game {
199251 this . me . askReaction ( 'useSnatchEffect' , event )
200252 return
201253 }
202- if ( this . me . selectedCard . name === '殺' ) {
203- const params = {
204- playerId : this . me . id ,
205- targetPlayerId : player . id ,
206- cardId : this . me . selectedCard . id ,
207- playType : 'active' ,
208- }
209- this . api . playCard ( this . gameId , params )
210- atkLine ( {
211- endPoint : new Phaser . Math . Vector2 ( player . instance . x , player . instance . y ) ,
212- scene : this . scene ,
213- } )
214- const card = this . me . selectedCard
215- card . playCard ( )
216- console . log ( player , this . me )
217- this . seats . forEach ( ( player ) => player . setOutOfDistance ( false ) )
218- this . me . selectedCard = null
219- }
220254 if ( this . me . selectedCard ?. name === '決鬥' || this . me . selectedCard ?. name === '樂不思蜀' ) {
221255 // 清除前一個選擇的玩家邊匡
222256 if ( this . selectTargetPlayers . length > 0 ) {
@@ -322,6 +356,23 @@ export default class Game {
322356 }
323357 return this . api . useViperSpearKill ( this . gameId , params )
324358 }
359+ playActiveKill = ( cardId : ThreeKingdomsCardIds , targetPlayerId : string ) => {
360+ const params = {
361+ playerId : this . me . id ,
362+ targetPlayerId,
363+ cardId,
364+ playType : 'active' as PlayType ,
365+ }
366+ return this . api . playCard ( this . gameId , params )
367+ }
368+ useHeavenlyDoubleHalberdKill = ( cardId : ThreeKingdomsCardIds , targetPlayerIds : string [ ] ) => {
369+ const params = {
370+ playerId : this . me . id ,
371+ cardId,
372+ targetPlayerIds,
373+ }
374+ return this . api . useHeavenlyDoubleHalberdKill ( this . gameId , params )
375+ }
325376 useDismantleEffect = async (
326377 targetPlayerId : string ,
327378 cardId : ThreeKingdomsCardIds | undefined ,
@@ -629,6 +680,43 @@ export default class Game {
629680 }
630681 break
631682 }
683+ case 'HeavenlyDoubleHalberdKillTriggerEvent' : {
684+ const allPlayers = [ ...this . seats , this . me ]
685+ const attacker = allPlayers . find ( ( player ) => player . id === data . attackerPlayerId )
686+ const targetPlayerIds : string [ ] = data . targetPlayerIds || [ ]
687+ const targetNames = targetPlayerIds
688+ . map ( ( id ) => allPlayers . find ( ( player ) => player . id === id ) ?. general ?. name || id )
689+ . join ( '、' )
690+ if ( this . hintInstance ) {
691+ const hintText : Phaser . GameObjects . Text = this . hintInstance . getAt ( 0 )
692+ hintText ?. setText (
693+ `${
694+ attacker ?. general ?. name || data . attackerPlayerId
695+ } 發動方天畫戟,對 ${ targetNames } 出殺`,
696+ )
697+ this . hintInstance . setAlpha ( 1 )
698+ this . scene . tweens . killTweensOf ( this . hintInstance )
699+ this . scene . tweens . add ( {
700+ targets : this . hintInstance ,
701+ alpha : 0 ,
702+ duration : 1200 ,
703+ delay : 1000 ,
704+ ease : 'Power2' ,
705+ } )
706+ }
707+ if ( ! attacker ) break
708+ const startPoint = new Phaser . Math . Vector2 ( attacker . instance . x , attacker . instance . y )
709+ targetPlayerIds . forEach ( ( targetPlayerId ) => {
710+ const target = allPlayers . find ( ( player ) => player . id === targetPlayerId )
711+ if ( ! target ) return
712+ atkLine ( {
713+ startPoint,
714+ endPoint : new Phaser . Math . Vector2 ( target . instance . x , target . instance . y ) ,
715+ scene : this . scene ,
716+ } )
717+ } )
718+ break
719+ }
632720 case 'PlayerDamagedEvent' :
633721 // 血量直接從data更新
634722 // const damage = data.from - data.to
0 commit comments