fixed bug in sass, may backtrack to modify player ui
This commit is contained in:
@@ -18,7 +18,9 @@ export default function Card({ data, state, setState, reserved = false, collapse
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='card' key={v4()}>
|
<div className='card' key={v4()}>
|
||||||
|
{ /*
|
||||||
{ collapsed ? <div className={`img-placeholder-${data.gemValue}`}></div> : <img src={data.image} loading="lazy" /> }
|
{ collapsed ? <div className={`img-placeholder-${data.gemValue}`}></div> : <img src={data.image} loading="lazy" /> }
|
||||||
|
*/ }
|
||||||
<div className={reserved ? `foreground-${data.gemValue}` : 'foreground'}>
|
<div className={reserved ? `foreground-${data.gemValue}` : 'foreground'}>
|
||||||
<section className="card-top-section">
|
<section className="card-top-section">
|
||||||
<p>{data.gemValue.toUpperCase()}</p>
|
<p>{data.gemValue.toUpperCase()}</p>
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
width: 35%;
|
width: 18%;
|
||||||
height: 40vh;
|
|
||||||
border: 2px solid black;
|
border: 2px solid black;
|
||||||
|
|
||||||
img {
|
img {
|
||||||
@@ -35,8 +34,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.foreground {
|
.foreground {
|
||||||
position: relative;
|
// position: relative;
|
||||||
top: -100%;
|
// top: -100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { Link } from 'react-router-dom';
|
|||||||
import initializeBoard, { setCardRows } from '../../util/setup/initializeBoard';
|
import initializeBoard, { setCardRows } from '../../util/setup/initializeBoard';
|
||||||
import { AppState, PlayerData, ResourceCost, UIState } from '../../util/types';
|
import { AppState, PlayerData, ResourceCost, UIState } from '../../util/types';
|
||||||
import { defaultUIState } from '../../util/setup/defaultUIState';
|
import { defaultUIState } from '../../util/setup/defaultUIState';
|
||||||
import { getChipsActions } from '../Player/ActionMethods';
|
|
||||||
import { StateProps } from '../../util/propTypes';
|
import { StateProps } from '../../util/propTypes';
|
||||||
import './Gameboard.scss';
|
import './Gameboard.scss';
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@ import CardRow from '../Card/CardRow';
|
|||||||
import { useCurrentPlayer } from '../../hooks/useCurrentPlayer';
|
import { useCurrentPlayer } from '../../hooks/useCurrentPlayer';
|
||||||
import usePreviousPlayer from '../../hooks/usePreviousPlayer';
|
import usePreviousPlayer from '../../hooks/usePreviousPlayer';
|
||||||
import { shouldRightSideCollapse } from '../../util/mechanics/shouldRightSideCollapse';
|
import { shouldRightSideCollapse } from '../../util/mechanics/shouldRightSideCollapse';
|
||||||
const { validateChips } = getChipsActions;
|
import { setStateUpdateSelection } from '../../hooks/stateSetters';
|
||||||
|
|
||||||
export default function Gameboard({ state, setState }: StateProps) {
|
export default function Gameboard({ state, setState }: StateProps) {
|
||||||
const [view, setView] = useState(<p>Loading...</p>);
|
const [view, setView] = useState(<p>Loading...</p>);
|
||||||
@@ -25,26 +24,7 @@ export default function Gameboard({ state, setState }: StateProps) {
|
|||||||
// callbacks for lifting state
|
// callbacks for lifting state
|
||||||
const liftSelection = useCallback((value: keyof ResourceCost) => {
|
const liftSelection = useCallback((value: keyof ResourceCost) => {
|
||||||
if (!state.actions.getChips.active) return;
|
if (!state.actions.getChips.active) return;
|
||||||
setState((prev: AppState) => {
|
setState((prev: AppState) => setStateUpdateSelection(prev, value));
|
||||||
let newSelection = prev.actions.getChips.selection;
|
|
||||||
newSelection?.push(value);
|
|
||||||
|
|
||||||
let newState = {
|
|
||||||
...prev,
|
|
||||||
actions: {
|
|
||||||
...state.actions,
|
|
||||||
getChips: {
|
|
||||||
active: true,
|
|
||||||
selection: newSelection,
|
|
||||||
valid: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = validateChips(newState);
|
|
||||||
newState.actions.getChips.valid = result;
|
|
||||||
return newState;
|
|
||||||
})
|
|
||||||
}, [state]);
|
}, [state]);
|
||||||
|
|
||||||
const liftCollapsed = useCallback((collapsed: boolean, tier = 5) => {
|
const liftCollapsed = useCallback((collapsed: boolean, tier = 5) => {
|
||||||
@@ -123,7 +103,9 @@ export default function Gameboard({ state, setState }: StateProps) {
|
|||||||
<CardRow tier={1} state={state} setState={setState} liftCollapsed={liftCollapsed} />
|
<CardRow tier={1} state={state} setState={setState} liftCollapsed={liftCollapsed} />
|
||||||
</section>
|
</section>
|
||||||
<section className={shouldRightSideCollapse(UICollapse) ? "gameboard-right-compact" : "gameboard-right"}>
|
<section className={shouldRightSideCollapse(UICollapse) ? "gameboard-right-compact" : "gameboard-right"}>
|
||||||
<AllPlayers state={state} setState={setState} liftSelection={liftSelection} UICollapse={UICollapse} />
|
<AllPlayers
|
||||||
|
state={state} setState={setState} liftSelection={liftSelection}
|
||||||
|
UICollapse={UICollapse} setUICollapse={setUICollapse} liftCollapsed={liftCollapsed} />
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,56 @@
|
|||||||
@import '../../sass/helper/variables';
|
@import '../../sass/helper/variables';
|
||||||
@import '../../sass/helper/placeholders';
|
@import '../../sass/helper/placeholders';
|
||||||
|
|
||||||
|
// local placeholder
|
||||||
|
%all-players-base {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column nowrap;
|
||||||
|
justify-content: space-around;
|
||||||
|
align-items: center;
|
||||||
|
background-color: rgb(188, 176, 146);
|
||||||
|
color: black;
|
||||||
|
|
||||||
|
.player-ui {
|
||||||
|
.subheader {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
background-color:rgb(172, 149, 94);
|
||||||
|
margin: 1rem 0;
|
||||||
|
padding: 0 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
img {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@each $gem in $gemlist {
|
||||||
|
@include map-gem-values('.foreground');
|
||||||
|
.foreground-#{$gem} {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 8px;
|
||||||
|
|
||||||
|
p {
|
||||||
|
display: inline;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.total-card-cost {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: row wrap;
|
||||||
|
justify-content: center;
|
||||||
|
@include map-gem-values(".card-cost");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.all-players {
|
.all-players {
|
||||||
@extend %all-players-base;
|
@extend %all-players-base;
|
||||||
.selection-view {
|
.selection-view {
|
||||||
|
|||||||
@@ -1,17 +1,60 @@
|
|||||||
import { useEffect, useState } from "react";
|
// framework
|
||||||
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import Player from "./Player";
|
|
||||||
import { useCurrentPlayer } from "../../hooks/useCurrentPlayer";
|
// util
|
||||||
|
import { shouldRightSideCollapse } from "../../util/mechanics/shouldRightSideCollapse";
|
||||||
import { AllPlayersProps } from "../../util/propTypes";
|
import { AllPlayersProps } from "../../util/propTypes";
|
||||||
|
import { useCurrentPlayer } from "../../hooks/useCurrentPlayer";
|
||||||
|
import { defaultUIState } from "../../util/setup/defaultUIState";
|
||||||
|
import { UIState } from "../../util/types";
|
||||||
|
|
||||||
|
// components
|
||||||
import AvailableChips from "../Resources/AvailableChips";
|
import AvailableChips from "../Resources/AvailableChips";
|
||||||
import SelectionView from "../Resources/SelectionView";
|
import SelectionView from "../Resources/SelectionView";
|
||||||
|
import Player from "./Player";
|
||||||
import "./AllPlayers.scss"
|
import "./AllPlayers.scss"
|
||||||
import { shouldRightSideCollapse } from "../../util/mechanics/shouldRightSideCollapse";
|
|
||||||
|
|
||||||
export default function AllPlayers({ state, setState, liftSelection, UICollapse }: AllPlayersProps) {
|
export default function AllPlayers({ state, setState, liftSelection, UICollapse, setUICollapse, liftCollapsed }: AllPlayersProps) {
|
||||||
const [playerView, setPlayerView] = useState<JSX.Element>();
|
const [playerView, setPlayerView] = useState<JSX.Element>();
|
||||||
const [collapseClass, setCollapseClass] = useState("all-players");
|
const [collapseClass, setCollapseClass] = useState("all-players");
|
||||||
|
|
||||||
|
const collapseAll = () => {
|
||||||
|
liftCollapsed(true);
|
||||||
|
liftCollapsed(true, 3);
|
||||||
|
liftCollapsed(true, 2);
|
||||||
|
liftCollapsed(true, 1);
|
||||||
|
// let value = UICollapse[each as keyof UIState];
|
||||||
|
// if (each === "playerUICollapsed") {
|
||||||
|
// continue;
|
||||||
|
// } else if (each === "noblesCollapsed") {
|
||||||
|
// console.log(each);
|
||||||
|
// liftCollapsed(value);
|
||||||
|
// } else {
|
||||||
|
// console.log(each, value);
|
||||||
|
// switch (each) {
|
||||||
|
// case "tierThreeCollapsed":
|
||||||
|
// liftCollapsed(value, 3);
|
||||||
|
// break;
|
||||||
|
// case "tierTwoCollapsed":
|
||||||
|
// liftCollapsed(value, 2);
|
||||||
|
// break;
|
||||||
|
// case "tierOneCollapsed":
|
||||||
|
// liftCollapsed(value, 1);
|
||||||
|
// break;
|
||||||
|
// default: break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
const allowCollapseAll = useMemo(() => {
|
||||||
|
for (let each of Object.keys(UICollapse)) {
|
||||||
|
if (each === "playerUICollapsed") continue;
|
||||||
|
if (!UICollapse[each as keyof UIState]) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}, [UICollapse]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const currentPlayer = useCurrentPlayer(state);
|
const currentPlayer = useCurrentPlayer(state);
|
||||||
if (!currentPlayer) return;
|
if (!currentPlayer) return;
|
||||||
@@ -24,6 +67,7 @@ export default function AllPlayers({ state, setState, liftSelection, UICollapse
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={collapseClass}>
|
<div className={collapseClass}>
|
||||||
|
{ allowCollapseAll && <button onClick={collapseAll}>Collapse All</button> }
|
||||||
<SelectionView state={state} setState={setState} UICollapse={UICollapse} />
|
<SelectionView state={state} setState={setState} UICollapse={UICollapse} />
|
||||||
<AvailableChips state={state} setState={setState} liftSelection={liftSelection} />
|
<AvailableChips state={state} setState={setState} liftSelection={liftSelection} />
|
||||||
{ playerView }
|
{ playerView }
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { setStateAwaitAction, setStateBuyCard, setStateGetChips, setStateReserveCard } from "../../hooks/stateSetters";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { PlayerProps } from "../../util/propTypes";
|
import { v4 } from "uuid";
|
||||||
import { CardData, PlayerData } from "../../util/types"
|
import { setStateAwaitAction, setStateBuyCard, setStateGetChips, setStateReserveCard } from "../../hooks/stateSetters";
|
||||||
import { hasMaxReserved } from "./ActionMethods/reserveCardActions";
|
import { hasMaxReserved } from "./ActionMethods/reserveCardActions";
|
||||||
import { hasMaxChips } from "./ActionMethods/getChipsActions";
|
import { hasMaxChips } from "./ActionMethods/getChipsActions";
|
||||||
import { v4 } from "uuid";
|
import { CardData, PlayerData } from "../../util/types"
|
||||||
|
import { PlayerProps } from "../../util/propTypes";
|
||||||
import Card from "../Card/Card";
|
import Card from "../Card/Card";
|
||||||
|
|
||||||
export default function Player({ player, state, setState }: PlayerProps) {
|
export default function Player({ player, state, setState }: PlayerProps) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { AppState, CardData, NobleData, PlayerData, ResourceCost } from "../util/types";
|
import { AppState, CardData, NobleData, PlayerData, ResourceCost, UIState } from "../util/types";
|
||||||
import CardDeck from '../data/cards.json';
|
import CardDeck from '../data/cards.json';
|
||||||
|
import { validateChips } from "../components/Player/ActionMethods/getChipsActions";
|
||||||
|
|
||||||
export const initialActions = {
|
export const initialActions = {
|
||||||
buyCard: { active: false },
|
buyCard: { active: false },
|
||||||
@@ -51,6 +52,27 @@ export const setStateGetChips = (prev: AppState) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const setStateUpdateSelection = (prev: AppState, value: keyof ResourceCost) => {
|
||||||
|
let newSelection = prev.actions.getChips.selection;
|
||||||
|
newSelection?.push(value);
|
||||||
|
|
||||||
|
let newState = {
|
||||||
|
...prev,
|
||||||
|
actions: {
|
||||||
|
...prev.actions,
|
||||||
|
getChips: {
|
||||||
|
active: true,
|
||||||
|
selection: newSelection,
|
||||||
|
valid: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = validateChips(newState);
|
||||||
|
newState.actions.getChips.valid = result;
|
||||||
|
return newState;
|
||||||
|
}
|
||||||
|
|
||||||
export const setStateBuyCard = (prev: AppState) => {
|
export const setStateBuyCard = (prev: AppState) => {
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
@import "./mixins";
|
|
||||||
@import "./variables";
|
|
||||||
|
|
||||||
// designed to extend a "p" element
|
// designed to extend a "p" element
|
||||||
%chip-design {
|
%chip-design {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -11,53 +8,4 @@
|
|||||||
width: 1rem;
|
width: 1rem;
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
|
||||||
|
|
||||||
%all-players-base {
|
|
||||||
display: flex;
|
|
||||||
flex-flow: column nowrap;
|
|
||||||
justify-content: space-around;
|
|
||||||
align-items: center;
|
|
||||||
background-color: rgb(188, 176, 146);
|
|
||||||
color: black;
|
|
||||||
|
|
||||||
.player-ui {
|
|
||||||
.subheader {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
background-color:rgb(172, 149, 94);
|
|
||||||
margin: 1rem 0;
|
|
||||||
padding: 0 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
img {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
@each $gem in $gemlist {
|
|
||||||
@include map-gem-values('.foreground');
|
|
||||||
.foreground-#{$gem} {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
padding: 8px;
|
|
||||||
|
|
||||||
p {
|
|
||||||
display: inline;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.total-card-cost {
|
|
||||||
display: flex;
|
|
||||||
flex-flow: row wrap;
|
|
||||||
justify-content: center;
|
|
||||||
@include map-gem-values(".card-cost");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Dispatch, SetStateAction } from "react";
|
||||||
import { AppState, CardData, PlayerData, ResourceCost, setStateType, UIState } from "./types";
|
import { AppState, CardData, PlayerData, ResourceCost, setStateType, UIState } from "./types";
|
||||||
|
|
||||||
export interface StateProps {
|
export interface StateProps {
|
||||||
@@ -29,7 +30,9 @@ export interface ResourceProps extends StateProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface AllPlayersProps extends ResourceProps {
|
export interface AllPlayersProps extends ResourceProps {
|
||||||
UICollapse: UIState
|
UICollapse: UIState,
|
||||||
|
setUICollapse: Dispatch<SetStateAction<UIState>>
|
||||||
|
liftCollapsed: (collapsed: boolean, tier?: number) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SelectionProps extends StateProps {
|
export interface SelectionProps extends StateProps {
|
||||||
|
|||||||
Reference in New Issue
Block a user