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

add ability to vary size of connections & sequences round #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 37 additions & 23 deletions src/js/components/Choose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,37 @@ import GardinerFont from '../../fonts/Gardiner-reduced.ttf';

const ChoosePanel = (props) => {
const rows = [];
for (let i = 0; i < 2; i++) {

let numColumns = (props.numChoices == 2) ? 1 : 3;
let numRows = Math.ceil(props.numChoices / numColumns);

for (let i = 0; i < numRows; i++) {
const row = [];
for (let j = 0; j < 3; j++) {
if (props.numChoices == 2 && (j == 0 || j == 2))
continue;
const index = i * 3 + j;
const chosenIndex =
(props.numChoices == 2) ? (index - 1) / 3 : index;
const disabled = props.chosen.includes(chosenIndex);
const handleClick = ((index, disabled) => ((e) => {
for (let j = 0; j < numColumns; j++) {
const index = i * numColumns + j;
if (index >= props.numChoices) {
break;
}
const disabled = props.chosen.includes(index);
const handleClick = (e) => {
e.target.blur();
props.onClick(index);
}))(chosenIndex, disabled);
};
row.push(
<div key={j} className="col p-0 m-1">
<button type="button" className={`btn btn-dark m-0 p-0 w-100${disabled ? ' disabled' : ''}`} onClick={handleClick} style={{
backgroundColor: 'navy'
}}>
<h1 style={{
fontSize: '100px',
fontFamily: 'Gardiner'
}}>{ChoosePanel.HIEROGLYPHS[index]}</h1>
</button>
</div>
<div key={j} className="col p-0 m-1" style={{maxWidth: (numColumns == 3 ? 'calc(33% - .5rem)' : undefined)}}>
<button
type="button"
className={`btn btn-dark m-0 p-0 w-100${disabled ? ' disabled' : ''}`}
onClick={handleClick}
style={{
backgroundColor: 'navy'
}}>
<h1 style={{
fontSize: '100px',
fontFamily: 'Gardiner'
}}>{ChoosePanel.HIEROGLYPHS[index % ChoosePanel.HIEROGLYPHS.length]}</h1>
</button>
</div>
);
}
rows.push(
Expand All @@ -42,8 +49,7 @@ const ChoosePanel = (props) => {
<div className="container">
<h1>{props.header}</h1>
</div>
{rows[0]}
{rows[1]}
{rows}
</div>
];
};
Expand All @@ -59,7 +65,15 @@ ChoosePanel.HIEROGLYPHS = [
'\ud80c\udf9b',
'\ud80c\udd91',
'\ud80c\ude17',
'\ud80c\udc80'
'\ud80c\udc80',

// Extended set... picked randomly from the set of Unicode hieroglyphs
'\uD80C\uDCFD',
'\uD80C\uDF70',
'\uD80C\uDD03',
'\uD80C\uDDEC',
'\uD80C\uDDD6',
'\uD80C\uDF8B',
];

export default ChoosePanel;
11 changes: 8 additions & 3 deletions src/js/components/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,16 @@ class GameUI extends Component {
: (stage == GameState.STAGE_WALL) ? 'Wall'
: '';
const isActive = timer.isRunning();
const numPanelChoices = (
stage == GameState.STAGE_CONNECTIONS ?
((game.game.meta.connectionsCount != undefined) ? game.game.meta.connectionsCount : 6)
: stage == GameState.STAGE_SEQUENCES ?
((game.game.meta.sequencesCount != undefined) ? game.game.meta.sequencesCount : 6)
: ((game.game.meta.wallsCount != undefined) ? game.game.meta.wallsCount : 2)
);
const panel =
(substage == GameState.SUBSTAGE_CHOOSE) ?
<ChoosePanel numChoices={
(stage == GameState.STAGE_WALL) ? 2 : 6
} chosen={game.chosen} header={chooseHeader} onClick={this.handleChooseClick} />
<ChoosePanel numChoices={numPanelChoices} chosen={game.chosen} header={chooseHeader} onClick={this.handleChooseClick} />
: (stage == GameState.STAGE_WALL) ?
<WallPanel data={game.game.walls[game.puzzleIndex]} index={game.clueIndex} progressVal={progressVal} isRevealed={game.isRevealed} strikes={game.wall.strikes} lifeToken={game.game.meta.wallLifeToken} selected={game.wall.selected} found={game.wall.found} onClick={this.handleWallClick} />
: (this.state.game.isConnectionsTypeStage()) ?
Expand Down