Skip to content

Commit

Permalink
cleanup player_character selecting
Browse files Browse the repository at this point in the history
  • Loading branch information
salvoilmiosi committed Oct 28, 2024
1 parent 5e19076 commit 04b65df
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/Scenes/Game/Model/UseSelectorConfirm.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Dispatch, DispatchWithoutAction, createContext, useEffect, useMemo, useRef } from "react";
import { BangConnection } from "../../../Model/UseBangConnection";
import { GameAction } from "./GameAction";
import { Card, GameTable, Player, getCard, getPlayer } from "./GameTable";
import { Card, GameTable, Player } from "./GameTable";
import { TargetSelector, isResponse, isValidCardTarget, isValidEquipTarget, isValidPlayerTarget, selectorCanConfirm, selectorCanPlayCard, selectorCanUndo } from "./TargetSelector";
import { SelectorUpdate } from "./TargetSelectorReducer";
import { getCardOwner, getCardPocket } from "./Filters";

function getSelectorGameAction(selector: TargetSelector): GameAction | undefined {
const bypass_prompt = selector.prompt.type === 'yesno' && selector.prompt.response;
Expand Down Expand Up @@ -37,16 +36,11 @@ export function useSendGameAction(selector: TargetSelector, connection: BangConn
function getClickCardUpdate(table: GameTable, selector: TargetSelector, card: Card): SelectorUpdate | undefined {
switch (selector.mode) {
case 'target':
case 'modifier': {
let cardTarget = card;
if (getCardPocket(card) === 'player_character') {
cardTarget = getCard(table, getPlayer(table, getCardOwner(card)!).pockets.player_character[0]);
}
if (isValidCardTarget(table, selector, cardTarget)) {
return { addCardTarget: cardTarget };
case 'modifier':
if (isValidCardTarget(table, selector, card)) {
return { addCardTarget: card };
}
break;
}
case 'preselect': {
const canPlay = selectorCanPlayCard(selector, card);
const canPick = isValidCardTarget(table, selector, card);
Expand All @@ -60,12 +54,11 @@ function getClickCardUpdate(table: GameTable, selector: TargetSelector, card: Ca
break;
}
case 'start':
case 'middle': {
case 'middle':
if (selectorCanPlayCard(selector, card)) {
return { selectPlayingCard: card };
}
}
}
}

function getClickPlayerUpdate(table: GameTable, selector: TargetSelector, player: Player): SelectorUpdate | undefined {
Expand Down

0 comments on commit 04b65df

Please sign in to comment.