forked from kedoska/engine-blackjack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.js
114 lines (99 loc) · 2.39 KB
/
actions.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// @flow
/*!
engine-blackjack
Copyright (C) 2016 Marco Casula
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import * as TYPES from './constants'
import type { Action, Card } from './types'
export const invalid = (action: Action, info: any): Action => {
return {
type: TYPES.INVALID,
payload: {
type: action.type,
payload: action.payload,
info: info
}
}
}
export const restore = (): Action => {
return {
type: TYPES.RESTORE
}
}
export const deal = ({ bet = 10, sideBets = { luckyLucky: 0 } }: { bet: number, sideBets: any } = {}): Action => {
return {
type: TYPES.DEAL,
payload: {
bet,
sideBets
}
}
}
export const insurance = ({ bet = 0 }: { bet: number }): Action => {
return {
type: TYPES.INSURANCE,
payload: {
bet
}
}
}
export const split = (): Action => {
return {
type: TYPES.SPLIT
}
}
export const hit = ({ position = 'right' }: { position: string }): Action => {
return {
type: TYPES.HIT,
payload: {
position
}
}
}
export const double = ({ position = 'right' }: { position: string }): Action => {
return {
type: TYPES.DOUBLE,
payload: {
position
}
}
}
export const stand = ({ position = 'right' }: { position: string }): Action => {
return {
type: TYPES.STAND,
payload: {
position
}
}
}
export const surrender = (): Action => {
return {
type: TYPES.SURRENDER
}
}
export const showdown = ({ dealerHoleCardOnly = false }: { dealerHoleCardOnly: boolean } = { }): Action => {
return {
type: TYPES.SHOWDOWN,
payload: {
dealerHoleCardOnly
}
}
}
export const dealerHit = ({ dealerHoleCard }: { dealerHoleCard: Card } = { }): Action => {
return {
type: TYPES.DEALER_HIT,
payload: {
dealerHoleCard
}
}
}