-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (53 loc) · 1.86 KB
/
index.js
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
60
61
62
63
/**
* Poker App
* https://github.com/colin353/poker
* @flow
*
* The purpose of this app is to help you learn how to judge poker odds more accurately,
* by giving you different plausible situations and getting you to estimate the odds of
* winning. Over time, you start to generate some heuristics for quickly estimating the
* odds of winning/losing/tie, which can be a useful tool when playing actual poker.
*
* The game sets up a situation, for example, a early/mid/late-stage game, with between
* two and four players. You're quizzed on the probabilities of certain outcomes, and then
* the system runs 1000 simulations of the results of the game. You win or lose points based
* upon how close you were to guessing the right answer.
*
* Color scheme for this app:
* https://coolors.co/1a090d-4a314d-6b6570-a8ba9a-ace894
*/
import React, { Component } from 'react';
import {
AppRegistry
} from 'react-native';
import Game from './app/pages/game.js';
import Home from './app/pages/home.js';
import Intro from './app/pages/intro.js';
// The machinery to save the app state.
import State from './app/game/state';
class PokerApp extends Component {
state: {
page: string
}
gameState: State;
constructor(props) {
super(props);
this.state = {
page : "home",
};
// Load the saved game.
this.gameState = new State();
}
startGame() {
this.setState({page: "game"});
}
startIntro() {
this.setState({page: "intro"});
}
render() {
if(this.state.page == 'home') return <Home gameState={this.gameState} startIntro={this.startIntro.bind(this)} startGame={this.startGame.bind(this)} />;
if(this.state.page == 'intro') return <Intro startGame={this.startGame.bind(this)}/>;
else if(this.state.page == 'game') return <Game gameState={this.gameState} />;
}
}
AppRegistry.registerComponent('poker_app', () => PokerApp);