Skip to content

Commit

Permalink
Merge pull request #366 from BIDMCDigitalPsychiatry/issue-802
Browse files Browse the repository at this point in the history
Total levels changes
  • Loading branch information
sarithapillai8 authored Mar 1, 2024
2 parents add7fe1 + b8c4131 commit fa51beb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion BoxGame/src/components/box/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,10 @@ class Board extends React.Component<BoardProps, BoardState> {
<span>{i18n.t("PLEASE_REMEMBER_THE_SEQUENCE")}</span>
) : null;
// Game state
const total_level = 6;
level =
this.state.gameState > 0 ? (
<span>{i18n.t("LEVEL")} {this.state.gameState}</span>
<span>{i18n.t("LEVEL")} {this.state.gameState}/{total_level}</span>
) : null;
// Show the alert on bottom of game board
alertText = this.state.gameSequence ? (
Expand Down
21 changes: 17 additions & 4 deletions JewelsPro/src/components/jewels/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export interface BoardProps {
level: number;
language: string;
updateLevel: any;
updateRoutes: any
updateRoutes: any;
settings: any;
}

interface DiamondState {
Expand All @@ -46,7 +47,7 @@ interface DiamondState {
tapCount: number;
timeout: boolean;
showConfirmModal: boolean;

totalLevels: number;
}

class Board extends React.Component<BoardProps, DiamondState> {
Expand All @@ -68,8 +69,8 @@ class Board extends React.Component<BoardProps, DiamondState> {
stepNumber: 0,
tapCount: 0,
timeout: false,
showConfirmModal: false

showConfirmModal: false,
totalLevels: this.getTotalLevels()
};
i18n.changeLanguage(props.language);
}
Expand Down Expand Up @@ -298,6 +299,17 @@ class Board extends React.Component<BoardProps, DiamondState> {
}
this.setState({showConfirmModal: false})
}

getTotalLevels = () => {
const maxBonusPoints = 1000;
const bonusPointsPerLevel = this.props.settings?.bonus_point_count ?? 40; // Default value
if (!bonusPointsPerLevel || bonusPointsPerLevel <= 0) {
console.error("Invalid or missing bonus_point_count in settings");
return 0;
}
const totalLevels = Math.ceil(maxBonusPoints / bonusPointsPerLevel);
return totalLevels;
};
// Render the game board
render() {
let board;
Expand Down Expand Up @@ -362,6 +374,7 @@ class Board extends React.Component<BoardProps, DiamondState> {
{timer}
{negSection}
{confirmModal}
{this.props.level}/{this.state.totalLevels.toString()}
<br/>
</div>
{board}
Expand Down
1 change: 1 addition & 0 deletions JewelsPro/src/components/jewels/Jewels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ class Jewels extends React.Component<any, AppState> {
updateLevel={this.updateLevel}
handleClose={this.handleClose}
sendDataToDashboard={this.sendDataToDashboard}
settings={this.state.settings}
/>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions Maze_Game/src/containers/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Layout = ({...props} : any) =>{
useEffect(() => {
const configuration = props?.data?.configuration;
i18n.changeLanguage(!!configuration ? configuration.language : "en-US");
setFooterMsg(i18n.t("LEVEL")+" "+gameLevel)
setFooterMsg(i18n.t("LEVEL")+" "+gameLevel+"/"+(props.data.activity?.settings?.level ?? 12))
if(gameLevel === 1) {
if (
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
Expand Down Expand Up @@ -113,8 +113,8 @@ const Layout = ({...props} : any) =>{
handleConfirm={(e: any) => {
hideModal()

if(gameLevel < 12) {
setFooterMsg(i18n.t("LEVEL")+" "+(gameLevel+1).toString())
if(props.data.activity?.settings?.level ?? 12) {
setFooterMsg(i18n.t("LEVEL")+" "+(gameLevel+1).toString()+"/"+(props.data.activity?.settings?.level ?? 12).toString())
setGameLevel(gameLevel+1)
if(gameLevel=== 6){
setCircles(2)
Expand Down

0 comments on commit fa51beb

Please sign in to comment.