forked from csarkar373/python-games
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringGameEngine.jsx
More file actions
59 lines (53 loc) · 1.65 KB
/
StringGameEngine.jsx
File metadata and controls
59 lines (53 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import React, { Component } from "react";
import GameEngine from "../components/GameEngine";
import * as StringConstants from "./stringconstants";
import { StringQuestionFactory } from "./stringquestionfactory";
const STRINGOPTIONS = [
{ id: StringConstants.NEGATIVESOPTIONID, label: "Negatives", checked: false },
];
class StringGameEngine extends Component {
state = {};
constructor(props) {
super(props);
this.state = {
options: STRINGOPTIONS,
qf: StringQuestionFactory,
labels: StringConstants.DEFAULTLABELSOPTION,
maxtime: StringConstants.MAXTIME,
addtime: StringConstants.ADDTIME,
};
}
handleOptions = (options, id, checked) => {
console.log("options have changed", options, id, checked);
// timer and label options are handled here.
// other options are used by the question factory
switch (id) {
case StringConstants.LABELSOPTIONID:
let labels = checked;
this.setState({ labels, options });
return;
default:
console.log("other option in string game engine");
break;
}
this.setState({ options });
};
render() {
//console.log("disarray game engine render labels = ", this.state.labels);
return (
<div>
<GameEngine
title={StringConstants.STRINGGAMETITLE}
options={this.state.options}
handleOptions={this.handleOptions}
labels={this.state.labels}
qf={this.state.qf}
maxtime={this.state.maxtime}
addtime={this.state.addtime}
/>
<h6>Select all the letters that are printed.</h6>
</div>
);
}
}
export default StringGameEngine;