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

Manual exit changes #324

Merged
merged 2 commits into from
Aug 3, 2023
Merged
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
17 changes: 9 additions & 8 deletions BalloonRisk/src/components/BallonRisk/Balloon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,11 @@ class Balloons extends React.Component<AppProps, AppState> {
};


sendGameData = async () => {

sendGameData = async (status?:boolean) => {
const route = {'type': 'manual_exit', 'value': status ?? false}
this.setState((prevState) => ({
route: [...prevState.route, route],
}), () => {
const currentDate = this.dateFormating();

localStorage.setItem(
Expand All @@ -369,6 +372,7 @@ class Balloons extends React.Component<AppProps, AppState> {
}),
"*"
);
})
};

dateFormating = () => {
Expand Down Expand Up @@ -457,12 +461,9 @@ class Balloons extends React.Component<AppProps, AppState> {
};

clickBack = () => {
const route = {'type': 'manual_exit', 'value': true}
this.setState((prevState) => ({
route: [...prevState.route, route],
}), () => {
this.sendGameData()
});

this.sendGameData(true)

}

// Game render function
Expand Down
30 changes: 15 additions & 15 deletions BoxGame/src/components/box/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,19 @@ class Board extends React.Component<BoardProps, BoardState> {
};

// Call the API to pass game result
sendGameResult = () => {
sendGameResult = (status?: boolean) => {
const route = {'type': 'manual_exit', 'value': status ?? false}
const boxes = [];
if (this.state.boxes !== null) {
const r = JSON.parse(this.state.boxes);
Object.keys(r).forEach((key) => {
boxes.push(r[key]);
});
}
boxes.push(route);
this.setState({
boxes: JSON.stringify(boxes),
}, () => {
let points = 0;
const totalLevels = 5;
const totalStages = totalLevels + this.state.wrongStages;
Expand Down Expand Up @@ -343,6 +355,7 @@ class Board extends React.Component<BoardProps, BoardState> {
this.setState({
sendResponse: true,
});
})
};

// Set game state values
Expand Down Expand Up @@ -463,20 +476,7 @@ class Board extends React.Component<BoardProps, BoardState> {
};

clickBack = () => {
const route = {'type': 'manual_exit', 'value': true}
const boxes = [];
if (this.state.boxes !== null) {
const r = JSON.parse(this.state.boxes);
Object.keys(r).forEach((key) => {
boxes.push(r[key]);
});
}
boxes.push(route);
this.setState({
boxes: JSON.stringify(boxes),
}, () => {
this.sendGameResult()
});
this.sendGameResult(true)
}

// Render the game board
Expand Down
32 changes: 17 additions & 15 deletions CatsnDogs/src/components/catsndogs/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,19 @@ class Board extends React.Component<BoardProps, BoardState> {


// Call the API to pass game result
sendGameResult = () => {
sendGameResult = (status?: boolean) => {
const route = {'type': 'manual_exit', 'value': status ?? false}
const boxes = [];
if (this.state.boxes !== null) {
const r = JSON.parse(this.state.boxes);
Object.keys(r).forEach((key) => {
boxes.push(r[key]);
});
}
boxes.push(route);
this.setState({
boxes: JSON.stringify(boxes),
}, () => {
const gameScore = Math.round(
(this.state.stateSuccessTaps / 45) * 100
);
Expand Down Expand Up @@ -305,6 +317,7 @@ class Board extends React.Component<BoardProps, BoardState> {
this.setState({
sendResponse: true,
});
});

};

Expand Down Expand Up @@ -437,20 +450,9 @@ class Board extends React.Component<BoardProps, BoardState> {
};

clickBack = () => {
const route = {'type': 'manual_exit', 'value': true}
const boxes = [];
if (this.state.boxes !== null) {
const r = JSON.parse(this.state.boxes);
Object.keys(r).forEach((key) => {
boxes.push(r[key]);
});
}
boxes.push(route);
this.setState({
boxes: JSON.stringify(boxes),
}, () => {
this.sendGameResult()
});

this.sendGameResult(true)

}
// Render the game board
render() {
Expand Down
4 changes: 3 additions & 1 deletion Emotion_Recognition/src/containers/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Layout = ({...props} : any) =>{
}, [gameOver])

const sentResult = () => {
setTimeout(()=>{
setTimeout(()=>{
parent.postMessage(routes.length > 0 ? JSON.stringify({
timestamp: new Date().getTime(),
duration: new Date().getTime() - time,
Expand Down Expand Up @@ -80,6 +80,8 @@ const Layout = ({...props} : any) =>{
setLevel(level-1)
}
else if(text==="save"){
const route = {'type': 'manual_exit', 'value': false}
routes.push(route)
setGameOver(true)
}
else {
Expand Down
14 changes: 8 additions & 6 deletions JewelsPro/src/components/jewels/Jewels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,13 @@ class Jewels extends React.Component<{}, AppState> {
};

clickBack = () => {
const route = {'type': 'manual_exit', 'value': true}

this.sendDataToDashboard(2, true)

}

sendDataToDashboard = (pointVal : number, status?: boolean) => {
const route = {'type': 'manual_exit', 'value': status ?? false}
const routeData:any = []
if (this.state.routes.length > 0) {
const r = JSON.parse(this.state.routes);
Expand All @@ -321,11 +327,6 @@ class Jewels extends React.Component<{}, AppState> {
}
routeData.push(route);
this.setState({routes: JSON.stringify(routeData)}, () => {
this.sendDataToDashboard(2)
})
}

sendDataToDashboard = (pointVal : number) => {
const scoreVal = ((this.state.totalJewelsCollected / (this.state.totalAttempts)) * 100).toFixed(2);
parent.postMessage(
JSON.stringify({
Expand All @@ -342,6 +343,7 @@ class Jewels extends React.Component<{}, AppState> {
}),
"*"
);
})
}
handleClose = (status:boolean, pointVal: number) => {
if(status) {
Expand Down
2 changes: 2 additions & 0 deletions Maze_Game/src/containers/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const Layout = ({...props} : any) =>{
},[levelCompleted])

const sentResult = () => {
const route = {'type': 'manual_exit', 'value': false}
routes.push(route)
setTimeout(()=>{
parent.postMessage(JSON.stringify({
timestamp: new Date().getTime(),
Expand Down
33 changes: 16 additions & 17 deletions MemoryGame/src/components/box/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,19 @@ class Board extends React.Component<BoardProps, BoardState> {
};

// Call the API to pass game result
sendGameResult = () => {
sendGameResult = (status?: boolean) => {
const route = {'type': 'manual_exit', 'value': status?? false}
const states = [];
if (this.state.states !== null) {
const r = JSON.parse(this.state.states);
Object.keys(r).forEach((key) => {
states.push(r[key]);
});
}
states.push(route);
this.setState({
states: JSON.stringify(states),
}, () => {
let points = 0
const gameScore = (this.state.stateSuccessTaps/this.props.seqLength) * 100
if (gameScore === 100) {
Expand Down Expand Up @@ -492,6 +504,7 @@ class Board extends React.Component<BoardProps, BoardState> {
enableTap: false,
sendResponse: true,
});
})
};

// Set game state values
Expand Down Expand Up @@ -709,22 +722,8 @@ class Board extends React.Component<BoardProps, BoardState> {
window.location.reload();
};

clickBack = () => {
const route = {'type': 'manual_exit', 'value': true}
const states = [];
if (this.state.states !== null) {
const r = JSON.parse(this.state.states);
Object.keys(r).forEach((key) => {
states.push(r[key]);
});
}
states.push(route);
this.setState({
states: JSON.stringify(states),
}, () => {
this.sendGameResult()
})

clickBack = () => {
this.sendGameResult(true)
}

// To set the game board table size based on screen resolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ class PopTheBubbles extends React.Component<AppProps, AppState> {
this.setState({ timeDifference: dif });
}
if (levelVal === 3) {
const route = {'type': 'manual_exit', 'value': false}
const values:any = this.state.route
values[this.state.gameLevel-1].push(route)
const temporalSlices = [].concat.apply([], this.state.route);
setTimeout(() => {
parent.postMessage(
Expand Down Expand Up @@ -486,7 +489,6 @@ class PopTheBubbles extends React.Component<AppProps, AppState> {
clickBack = () => {
const route = {'type': 'manual_exit', 'value': true}
const values:any = this.state.route
console.log(values, this.state)
values[this.state.gameLevel-1].push(route)
const temporalSlices = [].concat.apply([], values);
parent.postMessage(
Expand Down
2 changes: 2 additions & 0 deletions Spin_Wheel/src/containers/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ const Layout = ({...props}) => {

useEffect(() => {
if(isGameOver) {
const route = {'type': 'manual_exit', 'value': false}
routes.push(route)
setTimeout(()=>{
parent.postMessage(routes.length > 0 ? JSON.stringify({
timestamp: new Date().getTime(),
Expand Down