-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update player list to reflect new victory condition
- Loading branch information
1 parent
d80edd5
commit 1ab0294
Showing
10 changed files
with
154 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Nation, { getNationColour } from '../../types/enums/nation'; | ||
import { victoryRequiredCentreCount } from '../../utils/constants'; | ||
import ExpandButton from './common/ExpandButton'; | ||
|
||
type PlayerListItemProps = { | ||
player: Nation; | ||
centres: string[]; | ||
winner: Nation | null; | ||
isExpanded: boolean; | ||
toggleExpand: () => void; | ||
}; | ||
|
||
const PlayerListItem = ({ | ||
player, | ||
centres, | ||
winner, | ||
isExpanded, | ||
toggleExpand, | ||
}: PlayerListItemProps) => { | ||
const centreCount = centres.length; | ||
const isEliminated = centreCount === 0 || (winner && player !== winner); | ||
const colour = getNationColour(player); | ||
|
||
return ( | ||
<> | ||
<div | ||
className="text-lg flex items-center" | ||
style={{ | ||
opacity: isEliminated ? 0.3 : 1, | ||
color: colour, | ||
}} | ||
> | ||
<p className="min-w-20 text-start">{player}</p> | ||
<p className="min-w-16 font-bold text-end"> | ||
{`${centreCount}/${victoryRequiredCentreCount}`} | ||
</p> | ||
<ExpandButton colour={colour} isExpanded={isExpanded} toggleExpand={toggleExpand} /> | ||
</div> | ||
{isExpanded && | ||
centres.map((centre) => ( | ||
<p className="text-sm ml-2 -mt-1" style={{ color: colour }}> | ||
{centre} | ||
</p> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default PlayerListItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import colours from '../../../utils/colours'; | ||
|
||
type ExpandButtonProps = { | ||
colour: string; | ||
isExpanded: boolean; | ||
toggleExpand: () => void; | ||
}; | ||
|
||
const ExpandButton = ({ colour, isExpanded, toggleExpand }: ExpandButtonProps) => ( | ||
<button | ||
type="button" | ||
onClick={toggleExpand} | ||
className="relative w-3.5 h-3.5 rounded-full ml-4 opacity-30 hover:opacity-100 cursor-pointer" | ||
style={{ backgroundColor: colour }} | ||
aria-label="Expand item" | ||
> | ||
<div | ||
className={`absolute h-0.5 w-[5px] top-1.5 left-[3px] rounded ${isExpanded ? '-rotate-45' : 'rotate-45'}`} | ||
style={{ backgroundColor: colours.iconForeground }} | ||
/> | ||
<div | ||
className={`absolute h-0.5 w-[5px] top-1.5 right-[3px] rounded ${isExpanded ? 'rotate-45' : '-rotate-45'}`} | ||
style={{ backgroundColor: colours.iconForeground }} | ||
/> | ||
</button> | ||
); | ||
|
||
export default ExpandButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
// Gameplay | ||
|
||
export const startYear = 1901; | ||
export const victoryRequiredCentreCount = 18; | ||
|
||
// UI | ||
|
||
export const initialScale = 0.8; | ||
export const orderFocusScale = 1.5; | ||
|
||
export const majorBoardWidth = 1000; // TODO stop everything breaking if this changes | ||
export const minorBoardWidth = 650; | ||
export const boardSeparation = 400; | ||
export const boardBorderWidth = 32; // TODO stop everything breaking if this changes | ||
|
||
export const unitWidth = 28; | ||
export const boardArrowWidth = 200; | ||
export const orderArrowStartSeparation = 20; | ||
export const orderArrowEndSeparation = 10; | ||
|
||
// API | ||
|
||
// TODO change both of these for production | ||
export const refetchInterval = 2000; | ||
export const refetchAttempts = 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters