@everymatrix/lottery-program-wof 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +30 -0
  2. package/dist/lottery-program-wof.js +7278 -0
  3. package/dist/lottery-program-wof.js.map +1 -0
  4. package/index.html +42 -0
  5. package/index.js +1 -0
  6. package/package.json +41 -0
  7. package/public/favicon.png +0 -0
  8. package/public/reset.css +48 -0
  9. package/rollup.config.js +61 -0
  10. package/src/LotteryProgramWof.svelte +129 -0
  11. package/src/api/api.ts +2011 -0
  12. package/src/api/configuration.ts +65 -0
  13. package/src/api/custom.d.ts +2 -0
  14. package/src/api/index.ts +15 -0
  15. package/src/business.dom.ts +130 -0
  16. package/src/business.fake.ts +17 -0
  17. package/src/business.ts +276 -0
  18. package/src/calc.image.ts +13 -0
  19. package/src/calc.point.ts +315 -0
  20. package/src/calc.temp.ts +29 -0
  21. package/src/calc.ts +34 -0
  22. package/src/class.spinable.ts +65 -0
  23. package/src/class.spinable.util.ts +10 -0
  24. package/src/class.spinner.ts +145 -0
  25. package/src/class.spinner.util.ts +92 -0
  26. package/src/css.state.ts +13 -0
  27. package/src/fakeDraw.ts +9 -0
  28. package/src/fakeResult.ts +49 -0
  29. package/src/images/area.svg +11 -0
  30. package/src/images/areaSec.svg +11 -0
  31. package/src/images/areaV1.svg +18 -0
  32. package/src/images/areaV2.svg +17 -0
  33. package/src/images/background.svg +27 -0
  34. package/src/images/background3.svg +13 -0
  35. package/src/images/backgroundShadow.svg +22 -0
  36. package/src/images/centerArrow.svg +50 -0
  37. package/src/images/centerArrow1.svg +18 -0
  38. package/src/images/centerArrow2.svg +5 -0
  39. package/src/images/centerArrow3.svg +46 -0
  40. package/src/images/centerArrowBg.svg +12 -0
  41. package/src/images/centerBackground2.svg +24 -0
  42. package/src/images/centerCircle.svg +24 -0
  43. package/src/images/centerPack.svg +16 -0
  44. package/src/images/centerText3.svg +3 -0
  45. package/src/images/gift.svg +964 -0
  46. package/src/images/light.svg +19 -0
  47. package/src/images/partition1.svg +10 -0
  48. package/src/images/pointerArrow.svg +24 -0
  49. package/src/images/pointerArrow3.svg +25 -0
  50. package/src/images/spin.svg +13 -0
  51. package/src/index.ts +4 -0
  52. package/src/message.ts +28 -0
  53. package/src/private.item.svelte +279 -0
  54. package/src/private.item.svg.svelte +791 -0
  55. package/src/private.message.svelte +167 -0
  56. package/src/private.outcomes.svelte +163 -0
  57. package/src/private.tabs.svelte +92 -0
  58. package/src/themes.partitions.ts +174 -0
  59. package/src/themes.ts +206 -0
  60. package/src/types.business.ts +4 -0
  61. package/src/types.ts +74 -0
  62. package/src/util.ts +83 -0
  63. package/stories/LotteryProgramWof.stories.js +13 -0
  64. package/svelte.config.js +7 -0
  65. package/tsconfig.json +6 -0
@@ -0,0 +1,167 @@
1
+ <svelte:options tag={'lottery-program-wof-private-message-panel'} />
2
+
3
+ <script lang="ts">
4
+ // @ts-ignore
5
+ import giftSvg from './images/gift.svg'
6
+ import { onMountMessageLifeCycle, _postMessage } from './message';
7
+
8
+ export let x = 0
9
+ export let r = 0
10
+ export let id: string = undefined
11
+
12
+ let topOffset: number = 0
13
+
14
+ let renderValue: any = ''
15
+ let icon: string = ''
16
+ let isShown: boolean = false
17
+ let mode: string = ''
18
+ let modeValue: any
19
+
20
+ let root: HTMLElement;
21
+
22
+ onMountMessageLifeCycle({
23
+ 'wof-private-message-open': (data) => {
24
+ if(data.id !== id) return;
25
+
26
+ mode = data.mode
27
+ modeValue = data.modeValue
28
+
29
+ isShown = true
30
+ }
31
+ })
32
+
33
+ const _postMessageScoped = (props) => _postMessage({ ...props, id })
34
+
35
+ const eventButton = () => {
36
+ isShown = false
37
+ _postMessageScoped({ type: 'wof-private-message-close' })
38
+ }
39
+
40
+ const getTimeString = (_d) => {
41
+ const d: Date = new Date(_d)
42
+
43
+ return [
44
+ [
45
+ d.toLocaleString('en-us', {year: 'numeric'}),
46
+ d.toLocaleString('en-us', {month: '2-digit'}),
47
+ d.toLocaleString('en-us', {day: '2-digit'}),
48
+ ].join('-'),
49
+ d.toLocaleString('en-GB', { hour: 'numeric', minute: 'numeric', second: 'numeric' }),
50
+ ].join(' ')
51
+ }
52
+
53
+ const setTopOffset = () => {
54
+ setTimeout(() => {
55
+ topOffset = root.offsetHeight / 2 * -1
56
+
57
+ }, 1)
58
+ }
59
+
60
+ $: mode && setTopOffset()
61
+
62
+ $: width = r*2 + 5
63
+ $: left = x
64
+
65
+ </script>
66
+
67
+
68
+ {#if isShown}
69
+ <div
70
+ bind:this={root}
71
+ class="MessagePanel"
72
+ style={[
73
+ `margin-top: ${r + topOffset}px`,
74
+ `left: ${left}px`,
75
+ `width: ${width}px`,
76
+ isShown ? 'opacity: 1' : '',
77
+ ].join(';')}
78
+ >
79
+
80
+ {#if mode === 'normal' || mode === 'init-failed'}
81
+ <p>{modeValue}</p>
82
+ {/if}
83
+
84
+ {#if mode === 'spin-failed'}
85
+ <p>We are sorry that you</p>
86
+ <p>don't have any Wheels available, </p>
87
+ <p>please <strong>check T&C</strong> here </p>
88
+ <p>to get a chance!</p>
89
+ {/if}
90
+
91
+ {#if mode === 'show-next'}
92
+ <p>The Wheel will be available on</p>
93
+ <p>
94
+ <strong>
95
+ {getTimeString(modeValue?.startTime)}
96
+ </strong>
97
+ </p>
98
+ <p>please wait till it is open</p>
99
+ {/if}
100
+
101
+ {#if mode === 'gift'}
102
+ <p>
103
+ <img src={giftSvg} alt="">
104
+ </p>
105
+ <p>Congratulations! You won a prize!</p>
106
+ <!-- <p>{modeValue}</p> -->
107
+ {/if}
108
+
109
+ {#if mode !== 'init-failed'}
110
+ <div>
111
+ <button class="MessagePanelButton" on:click={eventButton}>OK</button>
112
+ </div>
113
+ {/if}
114
+ </div>
115
+ {/if}
116
+
117
+ <style lang="scss">
118
+
119
+ :host {
120
+ font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
121
+ position: absolute;
122
+ width: 100%;
123
+ }
124
+
125
+ *,
126
+ *::before,
127
+ *::after {
128
+ margin: 0;
129
+ padding: 0;
130
+ list-style: none;
131
+ text-decoration: none;
132
+ outline: none;
133
+ box-sizing: border-box;
134
+ }
135
+ $outlineColor: rgb(150, 54, 88);
136
+ $outlineWidth: 2px;
137
+
138
+ .MessagePanel {
139
+ position: absolute;
140
+ background-color: #FFFFFF;
141
+ padding: 15px 30px;
142
+ border-radius: 8px;
143
+ text-align: center;
144
+ font-size: 16px;
145
+ opacity: .3;
146
+
147
+ // border: 3px solid rgb(80, 80, 80);
148
+ box-shadow: 0 0 1px #a1a1a1;
149
+
150
+ transform: translateX(-50%);
151
+ transition: margin-top opacity .3s ease-out;
152
+ }
153
+
154
+ .MessagePanelButton {
155
+ padding: 4px 24px;
156
+ margin-top: 40px;
157
+ font-size: 16px;
158
+ line-height: 24px;
159
+ color: #FFFFFF;
160
+ background: #FF0000;
161
+ border-radius: 5px;
162
+ font-weight: 700;
163
+ border: 0;
164
+ box-shadow: 0 0 3px #ff0000;
165
+ cursor: pointer;
166
+ }
167
+ </style>
@@ -0,0 +1,163 @@
1
+ <svelte:options tag={'lottery-program-wof-private-outcomes'} />
2
+
3
+ <script lang="ts">
4
+ import type { WheelOfFortunePartition } from "./api";
5
+ import { api } from "./business";
6
+ import { onMountMessageLifeCycle } from "./message";
7
+ import type { LotteryProgramForPlayer } from "./types.business";
8
+ import { classWithPart } from "./util";
9
+
10
+ export let endpoint: string = ''
11
+ export let session: string = ''
12
+
13
+ interface RenderReady {
14
+ id: string,
15
+ }
16
+
17
+ interface PartitionsRenderReady extends RenderReady {
18
+ partitions: WheelOfFortunePartition[]
19
+ }
20
+
21
+ let lotteryProgramsForPlayer: LotteryProgramForPlayer[]
22
+ let partitionsList: PartitionsRenderReady[] = []
23
+ let ids: string[] = []
24
+ let outcomesAll: any[] = [];
25
+
26
+ const getName = (objectI18n: any) => objectI18n.name['*']
27
+
28
+ const getPrize = (outcome, id) => {
29
+ const partitions = partitionsList.filter(partitionsItem => partitionsItem.id === id)[0].partitions
30
+ const index = outcome.draw.result?.wheelOfFortunePartitionIndex
31
+
32
+ return !index ? 'Loss' : getName(partitions[index])
33
+ }
34
+
35
+ const eventShowOutcome = async () => {
36
+
37
+ outcomesAll = []
38
+ ids.map(id => {
39
+ outcomesAll.push({
40
+ id,
41
+ outcomes: []
42
+ })
43
+ })
44
+
45
+ ids.map(async id => {
46
+ const result = await api.outcome(endpoint, session, id)
47
+ const outcomes = result.items
48
+ outcomesAll = outcomesAll.map(o => {
49
+ if(o.id === id){
50
+ return {
51
+ ...o,
52
+ outcomes,
53
+ }
54
+ }else{
55
+ return o
56
+ }
57
+ })
58
+ })
59
+
60
+
61
+ }
62
+
63
+ onMountMessageLifeCycle({
64
+ 'wof-private-message-lotteryProgramsForPlayer': (data) => {
65
+ lotteryProgramsForPlayer = data.lotteryProgramsForPlayer
66
+ ids = lotteryProgramsForPlayer.map(l => l.program.id)
67
+ partitionsList = lotteryProgramsForPlayer.map(l => ({
68
+ id: l.program.id,
69
+ partitions: l.program.wheelOfFortune.partitions,
70
+ }))
71
+ },
72
+ 'wof-private-message-outcomes': () => {
73
+ eventShowOutcome()
74
+ }
75
+ })
76
+
77
+ </script>
78
+
79
+ <section>
80
+ {#each outcomesAll as outcomesItem}
81
+ <div {...classWithPart("Outcomes")}>
82
+ <div {...classWithPart("OutcomeTitle")}>{getName(lotteryProgramsForPlayer.filter(l => l.program.id === outcomesItem.id)[0].program)}</div>
83
+
84
+ <div {...classWithPart("TableContainer")}>
85
+ {#if !outcomesItem.outcomes || outcomesItem.outcomes.length === 0}
86
+ <div {...classWithPart("OutcomeNoContent")}>No outcomes</div>
87
+ {:else}
88
+ <table>
89
+ <thead>
90
+ <tr>
91
+ <th>Prize</th>
92
+ <th>Status</th>
93
+ <th>Time</th>
94
+ </tr>
95
+ </thead>
96
+ <tbody>
97
+ {#each outcomesItem.outcomes as outcome}
98
+ <tr>
99
+ <td>{getPrize(outcome, outcomesItem.id)}</td>
100
+ <td>{outcome.draw.state}</td>
101
+ <td>{(new Date(outcome.draw.time).toLocaleString(undefined, { timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone }))}</td>
102
+ </tr>
103
+ {/each}
104
+ </tbody>
105
+ </table>
106
+ {/if}
107
+ </div>
108
+ </div>
109
+ {/each}
110
+ </section>
111
+
112
+ <style lang="scss">
113
+
114
+ :host {
115
+ font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
116
+ width: 100%;
117
+ }
118
+
119
+ *,
120
+ *::before,
121
+ *::after {
122
+ margin: 0;
123
+ padding: 0;
124
+ list-style: none;
125
+ text-decoration: none;
126
+ outline: none;
127
+ box-sizing: border-box;
128
+ }
129
+
130
+ .Outcomes {
131
+
132
+ width: 80%;
133
+ margin: 30px auto;
134
+ }
135
+
136
+ .OutcomeTitle {
137
+ color: #FFF;
138
+ font-weight: 700;
139
+ padding: 20px 0;
140
+ }
141
+ .OutcomeNoContent {
142
+ color: #FFF;
143
+ font-weight: 700;
144
+ padding: 20px 20px;
145
+ }
146
+
147
+ .TableContainer {
148
+ max-height: 300px;
149
+ overflow-y: auto;
150
+ }
151
+
152
+ table {
153
+
154
+ color: #FFFFFF;
155
+ width: 100%;
156
+ text-align: center;
157
+ tr {
158
+ margin-top: 10px;
159
+ line-height: normal;
160
+ }
161
+
162
+ }
163
+ </style>
@@ -0,0 +1,92 @@
1
+ <svelte:options tag={'lottery-program-wof-private-tabs'} />
2
+
3
+ <script lang="ts">
4
+ import { _postMessage } from "./message";
5
+ import { Tab } from "./types";
6
+
7
+ let tab: Tab = Tab.Program;
8
+
9
+ </script>
10
+
11
+ <section id="TabBar" part="TabBar">
12
+ <ul>
13
+ {#each Object.keys(Tab) as _tab, i}
14
+ <li class={_tab === tab ? 'active' : ''}>
15
+ <span
16
+ on:click={() => {
17
+ switch(_tab){
18
+ case Tab.Program:
19
+ break;
20
+ case Tab.Outcomes:
21
+ _postMessage({type: 'wof-private-message-outcomes'})
22
+ break;
23
+ }
24
+
25
+ //@ts-ignore
26
+ tab = _tab
27
+ }}
28
+ >
29
+ {_tab}
30
+ </span>
31
+ </li>
32
+ {/each}
33
+ </ul>
34
+ </section>
35
+
36
+ {#each Object.keys(Tab) as _tab}
37
+ {#if tab === _tab}
38
+ <slot name={`tab-${_tab}`} />
39
+ {/if}
40
+ {/each}
41
+
42
+
43
+ <style lang="scss">
44
+
45
+ :host {
46
+ font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
47
+ width: 100%;
48
+ }
49
+
50
+ *,
51
+ *::before,
52
+ *::after {
53
+ margin: 0;
54
+ padding: 0;
55
+ list-style: none;
56
+ text-decoration: none;
57
+ outline: none;
58
+ box-sizing: border-box;
59
+ }
60
+
61
+ #TabBar {
62
+ width: 100%;
63
+ display: flex;
64
+ align-items: center;
65
+ flex-direction: column;
66
+ padding: 20px 0;
67
+
68
+ ul {
69
+ max-width: 600px;
70
+ width: 100%;
71
+
72
+ li {
73
+ color: #FFFFFF;
74
+ display: inline-block;
75
+ margin-right: 10px;
76
+ }
77
+ }
78
+
79
+ ul {
80
+ border-bottom: 3px #ccc solid;
81
+
82
+ li {
83
+ padding: 6px;
84
+ cursor: pointer;
85
+ &.active {
86
+ border-bottom: 3px #d46666 solid;
87
+ margin-bottom: -6px;
88
+ }
89
+ }
90
+ }
91
+ }
92
+ </style>
@@ -0,0 +1,174 @@
1
+ export const partitions1 = {
2
+ colorSchema: [
3
+ [
4
+ {
5
+ color: '#009C9C',
6
+ offset: 0,
7
+ },
8
+ {
9
+ color: '#002634',
10
+ offset: 1,
11
+ }
12
+ ],
13
+ [
14
+ {
15
+ color: '#AA00BF',
16
+ offset: 0,
17
+ },
18
+ {
19
+ color: '#3B0031',
20
+ offset: 1,
21
+ }
22
+ ],
23
+ [
24
+ {
25
+ color: '#0068CD',
26
+ offset: 0,
27
+ },
28
+ {
29
+ color: '#150D42',
30
+ offset: 1,
31
+ }
32
+ ],
33
+ [
34
+ {
35
+ color: '#DA005B',
36
+ offset: 0,
37
+ },
38
+ {
39
+ color: '#400021',
40
+ offset: 1,
41
+ }
42
+ ],
43
+ ]
44
+ }
45
+
46
+ export const partitions2 = {
47
+ colorSchema: [
48
+ [
49
+ {
50
+ color: '#006666',
51
+ offset: 0,
52
+ },
53
+ {
54
+ color: '#007F76',
55
+ offset: 0.13,
56
+ },
57
+ {
58
+ color: '#00B59B',
59
+ offset: 0.42,
60
+ },
61
+ {
62
+ color: '#00DDB5',
63
+ offset: 0.67,
64
+ },
65
+ {
66
+ color: '#00F6C6',
67
+ offset: 0.88,
68
+ },
69
+ {
70
+ color: '#00FFCC',
71
+ offset: 1,
72
+ }
73
+ ],
74
+ [
75
+ {
76
+ color: '#580065',
77
+ offset: 0.23,
78
+ },
79
+ {
80
+ color: '#D453FF',
81
+ offset: 0.91,
82
+ }
83
+ ],
84
+ [
85
+ {
86
+ color: '#FFE767',
87
+ offset: 0,
88
+ },
89
+ {
90
+ color: '#F28F00',
91
+ offset: 1,
92
+ }
93
+ ],
94
+ [
95
+ {
96
+ color: '#900A42',
97
+ offset: 1 / 100 * 22.59,
98
+ },
99
+ {
100
+ color: '#960A44',
101
+ offset: 1 / 100 * 23.94,
102
+ },
103
+ {
104
+ color: '#B60B53',
105
+ offset: 1 / 100 * 31.36,
106
+ },
107
+ {
108
+ color: '#D00C5E',
109
+ offset: 1 / 100 * 39.45,
110
+ },
111
+ {
112
+ color: '#E40D67',
113
+ offset: 1 / 100 * 48.22,
114
+ },
115
+ {
116
+ color: '#F30D6E',
117
+ offset: 1 / 100 * 57.66,
118
+ },
119
+ {
120
+ color: '#FB0D71',
121
+ offset: 1 / 100 * 69.8,
122
+ },
123
+ {
124
+ color: '#FE0E73',
125
+ offset: 1 / 100 * 90.03,
126
+ },
127
+ ]
128
+ ]
129
+ }
130
+
131
+ export const partitions3 = {
132
+ colorSchema: [
133
+ [
134
+ {
135
+ color: '#3B0031',
136
+ offset: 0,
137
+ },
138
+ {
139
+ color: '#7E008E',
140
+ offset: 1,
141
+ },
142
+ ],
143
+ [
144
+ {
145
+ color: '#5A005F',
146
+ offset: 0,
147
+ },
148
+ {
149
+ color: '#EA53FF',
150
+ offset: 1,
151
+ }
152
+ ],
153
+ [
154
+ {
155
+ color: '#B300C3',
156
+ offset: 0,
157
+ },
158
+ {
159
+ color: '#4D003B',
160
+ offset: 1,
161
+ }
162
+ ],
163
+ [
164
+ {
165
+ color: '#59007B',
166
+ offset: 0,
167
+ },
168
+ {
169
+ color: '#B753FF',
170
+ offset: 1,
171
+ },
172
+ ]
173
+ ]
174
+ }