Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/align game rule to released version #335

Draft
wants to merge 63 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
7357444
refactor(webapp): move score to table, remove force card and remove d…
ben196888 Jul 3, 2024
64d24df
chore(webapp): turn off react hooks linting rule in game
ben196888 Jul 4, 2024
9c974fe
feat(webapp): add tsconfig-paths to run node with path alias
ben196888 Jul 4, 2024
01c5519
refactor(webapp): mark card slice as deprecated
ben196888 Jul 4, 2024
e19589c
feat(webapp): add players selectors and mutators
ben196888 Jul 4, 2024
2a3fa39
refactor(webapp): remove force card
ben196888 Jul 4, 2024
6e36388
feat(webapp): add jobSlots slice to manage add&remove job card in play
ben196888 Jul 4, 2024
c89b61c
refactor(webapp): decouple project owner and contributor logic
ben196888 Jul 4, 2024
2ed266b
refactor(webapp): split game logic into stages
ben196888 Jul 4, 2024
1de68a3
fix(webapp): dev ui bug and missing job requirements
ben196888 Jul 4, 2024
4aa19dd
feat(webapp): add logs in setup
ben196888 Jul 4, 2024
975d501
fix(webapp): settle move should be settleProjects, end stage when out…
ben196888 Jul 4, 2024
76cfce1
fix(webapp): align max job cards
ben196888 Jul 4, 2024
0905e81
fix(webapp): remove discard stage on dev action and set onSettleProjects
ben196888 Jul 4, 2024
d158b98
fix(webapp): add missing node module cache files
ben196888 Jul 8, 2024
c52fc5b
feat(webapp): add rule slice to maintain game rules
ben196888 Jul 8, 2024
6fdf10d
refactor(webapp): generic the selector by action behavior
ben196888 Jul 12, 2024
6934dc4
refactor(webapp): apply rule state in game setup
ben196888 Jul 12, 2024
d1f3973
refactor(webapp): apply rule state in action stage moves
ben196888 Jul 12, 2024
495ddf8
refactor(webapp): apply rule state in refill stage moves
ben196888 Jul 12, 2024
c9a17ad
refactor(webapp): apply rule state in settle stage moves
ben196888 Jul 12, 2024
7b55f32
feat(webapp): add event card setup method to keep the end game in the…
ben196888 Jul 15, 2024
35fefc8
refactor(webapp): move project slot state management from client to s…
ben196888 Jul 15, 2024
1f6d7aa
fix event card shuffle
ben196888 Jul 15, 2024
4925223
feat(webapp): add event card state and handlers
ben196888 Jul 16, 2024
9f33b9f
refactor(webapp): migrate settle and refill stages to be on turn end …
ben196888 Jul 16, 2024
40aa55a
fix(webapp): type casting of project slot card
ben196888 Jul 16, 2024
1619d60
feat(webapp): add v2 card information
ben196888 Jul 18, 2024
12053b4
fix(webapp): remove project should remove the project from board
ben196888 Jul 18, 2024
6cecf04
feat(webapp): add end game event card handler
ben196888 Jul 19, 2024
0da9496
refactor(webapp): make it a 3 players game
ben196888 Jul 19, 2024
866d475
feat(webapp): add selectable project slots
ben196888 Jul 19, 2024
708fc65
refactor(webapp): replace selected state with redux store
ben196888 Jul 19, 2024
a4df922
feat(webapp): add new game header to summary players state
ben196888 Jul 19, 2024
2e07d61
fix: projectslot
ben196888 Jul 19, 2024
02076bc
fix project slot slice
ben196888 Jul 19, 2024
9bbde32
feat(webapp): add job board component to render job cards
ben196888 Jul 19, 2024
a2b1b95
refactor(webapp): move project board into table and align the design …
ben196888 Jul 19, 2024
49b5593
feat(webapp): add user panel on the left hand side to show player inf…
ben196888 Jul 20, 2024
a0560bf
feat(webapp): introduce game context and map game context to props he…
ben196888 Jul 21, 2024
dab7515
feat(webapp): add action bar as a workaround to replace full action b…
ben196888 Jul 21, 2024
29d06ec
refactor(webapp): use map game context to props in user panel
ben196888 Jul 21, 2024
3a0b5a7
refactor(webapp): wrap action bar with redux store to get ui state
ben196888 Jul 21, 2024
0a497bb
feat(webapp): add create project action
ben196888 Jul 21, 2024
da97128
feat(webapp): add recruit action
ben196888 Jul 21, 2024
7f1e5fe
feat(webapp): add remove and refill jobs action
ben196888 Jul 21, 2024
75a3957
style(webapp): apply avatar with badge on job requirements
ben196888 Jul 21, 2024
26dd109
fix(webapp): project card requirements typo
ben196888 Jul 22, 2024
e8ad7f1
feat(webapp): add action stepper to handle each action steps
ben196888 Jul 22, 2024
fd4f5c2
style(webapp): polish job contribution styles
ben196888 Jul 22, 2024
5cc3603
feat(webapp): add hand project, project slot, job slot interactive
ben196888 Jul 22, 2024
dd1cf59
feat(webapp): add contribution slice in game core
ben196888 Jul 26, 2024
6976e4e
refactor(webapp): replace project slot index with project slot id
ben196888 Jul 26, 2024
326744c
feat(webapp): add interactive contribution component
ben196888 Jul 26, 2024
bfd4879
feat(webapp): add material icons
ben196888 Jul 26, 2024
e6d8d79
feat(webapp): add contribution own and joined in action stepper
ben196888 Jul 26, 2024
1e30ec2
fix(webapp): Table should have playerID from game context
ben196888 Jul 26, 2024
917b455
feat(webapp): add css base line in webapp to align css styling
ben196888 Jul 26, 2024
78e8718
refactor(webapp): migrate dev view into tabs
ben196888 Jul 26, 2024
8c14373
refactor(webapp): remove legacy dev actions
ben196888 Jul 26, 2024
0f66b15
refactor(webapp): remove unused utils
ben196888 Jul 26, 2024
dd456ed
refactor(webapp): remove unused selector
ben196888 Jul 26, 2024
5fe2085
refactor(webapp): remove unused style component
ben196888 Jul 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 9 additions & 1 deletion packages/webapp/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"extends": "next/core-web-vitals"
"extends": "next/core-web-vitals",
"overrides": [
{
"files": ["src/game/**"],
"rules": {
"react-hooks/rules-of-hooks": "off",
},
}
]
}
8 changes: 5 additions & 3 deletions packages/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
"scripts": {
"dev": "concurrently \"yarn dev:next\" \"yarn dev:server\"",
"dev:next": "next dev",
"dev:server": "ts-node-dev -P tsconfig.server.json --respawn --transpile-only --ignore-watch .next src/server.ts",
"dev:server": "ts-node-dev -P tsconfig.server.json --respawn --transpile-only --ignore-watch .next -r tsconfig-paths/register src/server.ts",
"build": "yarn build:next && yarn build:server",
"build:next": "next build",
"build:server": "tsc -P tsconfig.server.json",
"start": "yarn start:next & yarn start:server",
"start:next": "next start",
"start:server": "node dist/server.js",
"start:server": "node -r tsconfig-paths/register dist/server.js",
"lint": "next lint",
"test": "jest"
},
"dependencies": {
"@emotion/cache": "^11.11.0",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/icons-material": "^5.16.4",
"@mui/lab": "^5.0.0-alpha.170",
"@mui/material": "^5.15.19",
"@mui/material-nextjs": "^5.15.11",
Expand All @@ -27,7 +28,8 @@
"next": "14.2.3",
"react": "^18",
"react-dom": "^18",
"react-redux": "^9.1.2"
"react-redux": "^9.1.2",
"tsconfig-paths": "^4.2.0"
},
"devDependencies": {
"@types/jest": "^29.5.12",
Expand Down
2 changes: 2 additions & 0 deletions packages/webapp/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Inter } from "next/font/google";
import { AppRouterCacheProvider } from '@mui/material-nextjs/v13-appRouter';
import "./globals.css";
import { CssBaseline } from "@mui/material";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -19,6 +20,7 @@ export default function RootLayout({
<html lang="en">
<body className={inter.className}>
<AppRouterCacheProvider>
<CssBaseline />
{children}
</AppRouterCacheProvider>
</body>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { ActionMoveName } from '@/game/core/stage/action/move/type';
import { GameContext } from '../../GameContextHelpers';
import { GameState } from '@/game/store/store';
import { RuleSelector } from '@/game/store/slice/rule';
import { ActionSlotSelector } from '@/game/store/slice/actionSlot';
import { AppDispatch } from '@/lib/store';
import { UserActionMoves, getCurrentAction, setCurrentAction } from '@/lib/reducers/actionStepSlice';
import { createSelector } from '@reduxjs/toolkit';

export interface StateProps {
isActionBarVisible: boolean;
}

export const mapStateToProps = createSelector(getCurrentAction, (currentAction) => ({
isActionBarVisible: currentAction === null,
}));

export interface DispatchProps {
onActionClick: (action: UserActionMoves) => void;
}

export const mapDispatchToProps = (dispatch: AppDispatch): DispatchProps => ({
onActionClick: (action: UserActionMoves) => dispatch(setCurrentAction(action)),
});

export enum ActionMoveState {
Available = 'available',
Occupied = 'occupied',
Disabled = 'disabled'
}

const getActionMoveState = (state: GameState, actionMove: ActionMoveName): ActionMoveState => {
if (!RuleSelector.isActionSlotAvailable(state.rules, actionMove)) {
return ActionMoveState.Disabled;
}
if (ActionSlotSelector.isOccupied(state.table.actionSlots[actionMove])) {
return ActionMoveState.Occupied;
}
return ActionMoveState.Available;
};

export interface GameContextProps {
actionsState: Record<UserActionMoves, ActionMoveState>;
}

export const mapGameContextToProps = ({ G }: GameContext) => {
const actionsState: Record<UserActionMoves, ActionMoveState> = {
[UserActionMoves.CreateProject]: getActionMoveState(G, UserActionMoves.CreateProject),
[UserActionMoves.Recruit]: getActionMoveState(G, UserActionMoves.Recruit),
[UserActionMoves.ContributeOwnedProjects]: getActionMoveState(G, UserActionMoves.ContributeOwnedProjects),
[UserActionMoves.ContributeJoinedProjects]: getActionMoveState(G, UserActionMoves.ContributeJoinedProjects),
[UserActionMoves.RemoveAndRefillJobs]: getActionMoveState(G, UserActionMoves.RemoveAndRefillJobs),
[UserActionMoves.Mirror]: getActionMoveState(G, UserActionMoves.Mirror),
[UserActionMoves.EndActionTurn]: ActionMoveState.Available,
};

return { actionsState };
};
73 changes: 73 additions & 0 deletions packages/webapp/src/components/ActionBoard/ActionBar/ActionBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React from 'react';
import { Box, Button, Grid } from '@mui/material';
import { styled } from '@mui/material/styles';
import { connectGameContext } from '../../GameContextHelpers';
import { connect } from 'react-redux';
import { ActionMoveState, mapGameContextToProps, mapDispatchToProps, GameContextProps, StateProps, DispatchProps, mapStateToProps } from './ActionBar.selectors';
import { UserActionMoves } from '@/lib/reducers/actionStepSlice';

type Props = GameContextProps & StateProps & DispatchProps;

const StyledButton = styled(Button)(({ theme }) => ({
margin: theme.spacing(1),
[`&.${ActionMoveState.Available}`]: {
backgroundColor: theme.palette.success.main,
color: theme.palette.common.white,
'&:hover': {
backgroundColor: theme.palette.success.dark,
},
},
[`&.${ActionMoveState.Occupied}`]: {
backgroundColor: theme.palette.warning.main,
color: theme.palette.common.white,
'&:hover': {
backgroundColor: theme.palette.warning.dark,
},
},
[`&.${ActionMoveState.Disabled}`]: {
backgroundColor: theme.palette.action.disabled,
color: theme.palette.text.disabled,
},
}));

const EndActionButton = styled(Button)(({ theme }) => ({
margin: theme.spacing(1),
backgroundColor: theme.palette.primary.main,
color: theme.palette.common.white,
'&:hover': {
backgroundColor: theme.palette.primary.dark,
},
}));

const ActionBar: React.FC<Props> = ({ isActionBarVisible, actionsState, onActionClick }) => {
if (!isActionBarVisible) {
return null;
}
return (
<Box sx={{ display: 'flex', justifyContent: 'center', padding: '8px', backgroundColor: '#f0f0f0', marginTop: '16px' }}>
<Grid container spacing={1} justifyContent="center">
{Object.entries(actionsState).map(([action, state]) => (
action === UserActionMoves.EndActionTurn ? (
<EndActionButton
key={action}
onClick={() => onActionClick(action)}
>
End Action Turn
</EndActionButton>
) : (
<StyledButton
key={action}
className={state}
onClick={() => state === ActionMoveState.Available && onActionClick(action as UserActionMoves)}
disabled={state === ActionMoveState.Disabled}
>
{action.replace(/([A-Z])/g, ' $1').replace(/^./, str => str.toUpperCase())}
</StyledButton>
)
))}
</Grid>
</Box>
);
};

export default connectGameContext(mapGameContextToProps)(connect(mapStateToProps, mapDispatchToProps)(ActionBar));
105 changes: 0 additions & 105 deletions packages/webapp/src/components/ActionBoard/ActionBoard.tsx

This file was deleted.

Loading
Loading