@everymatrix/lottery-program-wof 1.13.22 → 1.13.24

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/lottery-program-wof",
3
- "version": "1.13.22",
3
+ "version": "1.13.24",
4
4
  "main": "dist/lottery-program-wof.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "07a124adef4703b4a19619953a0221dbd6299859"
42
+ "gitHead": "cde0044a9c4c9152ef07e47cb9284338748f0078"
43
43
  }
@@ -11,7 +11,7 @@
11
11
  import { _, setLocale, setLocaleWhenInit } from './i18n';
12
12
 
13
13
  // types
14
- import { Lang } from './types';
14
+ import { ContentDirection, Lang } from './types';
15
15
  import { api } from './business';
16
16
 
17
17
  import { _postMessage } from './message';
@@ -30,6 +30,7 @@
30
30
  export let currentinfo: CurrentInfo = CurrentInfo.RemainingTimes
31
31
  export let giftimagesrc: string = ''
32
32
  export let isshowhistory: string = 'true'
33
+ export let contentdirection: keyof typeof ContentDirection = 'anticlockwise'
33
34
 
34
35
  let rootContainer: HTMLElement
35
36
  $: clientstyling && rootContainer && setClientStyling(rootContainer, clientstyling);
@@ -111,6 +112,7 @@
111
112
  id: _l.program.id,
112
113
  currentinfo,
113
114
  giftimagesrc,
115
+ contentdirection,
114
116
  }} />
115
117
  {/each}
116
118
  {:else}
package/src/business.ts CHANGED
@@ -84,6 +84,14 @@ const fetcherApi = async <T extends Api>(api: T, endpoint: string, config: ApiCo
84
84
  return await fetcher(args)
85
85
  }
86
86
 
87
+ export const getSumProbability = (partitions) => {
88
+ let probabilityAll = 0
89
+ partitions.map(partition => {
90
+ probabilityAll += Number(partition.probability)
91
+ })
92
+ return probabilityAll
93
+ }
94
+
87
95
  export const getOptionsFromPartitions = (partitions: WheelOfFortunePartition[], lang: Lang): Option[] => {
88
96
  let options = partitions.map((_partition, index) => {
89
97
  const partitionLang = {}
@@ -100,9 +108,7 @@ export const getOptionsFromPartitions = (partitions: WheelOfFortunePartition[],
100
108
  return option
101
109
  })
102
110
 
103
- let probabilityAll = 0
104
- partitions.map(partition => probabilityAll += Number(partition.probability))
105
- if(probabilityAll < 1){
111
+ if(getSumProbability(partitions) < 1){
106
112
  options.push({
107
113
  image: Thankyou1Svg,
108
114
  name: 'Thank you'
@@ -193,11 +199,20 @@ export const api = {
193
199
 
194
200
  if(!index){
195
201
  index = options.length - 1
196
- message = _('wof.Loss')
202
+ message = {
203
+ mode: 'nogift',
204
+ modeValue: {
205
+ image: options[index].image?.href?.baseVal
206
+ }
207
+ }
197
208
  }else{
198
209
  message = {
199
210
  mode: 'gift',
200
- modeValue: options[index].name,
211
+ modeValue: {
212
+ index,
213
+ name: options[index].name,
214
+ image: options[index].image?.href?.baseVal
215
+ },
201
216
  }
202
217
  }
203
218
 
@@ -5,7 +5,7 @@ import { renderSvgImageProps, themedImageProps } from "./themes.image.base"
5
5
  import { themedCenterImagesUpdater } from "./themes.image.center"
6
6
  import { themedPointerImagesUpdater } from "./themes.image.pointer"
7
7
  import { partitionStrokeSteps } from "./themes.partitions"
8
- import { ArrowMode, Point, PointerMode } from "./types"
8
+ import { ArrowMode, Point, PointerMode, ContentDirection } from "./types"
9
9
  import { mapObjectValueToTuple } from "./util"
10
10
 
11
11
  // @ts-ignore
@@ -34,17 +34,22 @@ export class SvgCalc {
34
34
  rRingOuter
35
35
  theme
36
36
  themeIndex
37
+ options
38
+ contentdirection: keyof typeof ContentDirection
37
39
 
38
40
  constructor({
39
41
  size,
40
- length,
42
+ options,
41
43
  themeIndex,
44
+ contentdirection,
42
45
  }){
46
+ this.contentdirection = contentdirection || 'anticlockwise'
43
47
  // size
44
48
  this.center = size / 2
45
49
  this.ratio = size / 375
46
50
  // options
47
- this.length = length
51
+ this.options = options
52
+ this.length = options.length
48
53
  // theme
49
54
  this.themeIndex = themeIndex
50
55
  this.theme = themes[themeIndex]
@@ -66,17 +71,37 @@ export class SvgCalc {
66
71
  }
67
72
  }
68
73
 
74
+ getSizeImageByPartition(index) {
75
+ if(this.options[index].name){
76
+ return this.sizeImage / 2
77
+ }else{
78
+ return this.sizeImage
79
+ }
80
+ }
81
+
69
82
  getSvgImageProps (index){
83
+ const sizeImage = this.getSizeImageByPartition(index)
84
+
85
+ let baseRadius = this.radius - sizeImage / 2 - 3 * this.ratio
70
86
  return {
71
- ...this.getPropsForPartitionInfo(index, this.offsetImage, this.radius - this.sizeImage / 2 - 12 * this.ratio),
72
- width: this.sizeImage,
73
- height: this.sizeImage,
87
+ ...this.getPropsForPartitionInfo(index, this.getOffsetImage(sizeImage), baseRadius),
88
+ width: sizeImage,
89
+ height: sizeImage,
74
90
  }
75
91
  }
76
92
 
77
93
  getSvgTextProps(index) {
94
+ const sizeImage = this.getSizeImageByPartition(index)
95
+
96
+ let baseRadius
97
+ if(this.options[index].image){
98
+ baseRadius = this.radius - sizeImage - 6 * this.ratio
99
+ }else{
100
+ baseRadius = this.radius - 6 * this.ratio
101
+ }
102
+
78
103
  return {
79
- ...this.getPropsForPartitionInfo(index, this.offsetText),
104
+ ...this.getPropsForPartitionInfo(index, this.offsetText, baseRadius),
80
105
  }
81
106
  }
82
107
 
@@ -95,18 +120,18 @@ export class SvgCalc {
95
120
  }
96
121
  }
97
122
 
98
- get offsetImage () {
123
+ getOffsetImage (sizeImage) {
99
124
 
100
125
  return {
101
126
  center: 0,
127
+ position: {
128
+ x: -1 * sizeImage / 2,
129
+ y: -1 * sizeImage / 2,
130
+ },
102
131
  transform: {
103
132
  x: 0,
104
133
  y: 0,
105
134
  },
106
- position: {
107
- x: this.sizeImage / 2,
108
- y: this.sizeImage / 2,
109
- }
110
135
  }
111
136
  }
112
137
 
@@ -114,28 +139,43 @@ export class SvgCalc {
114
139
  return RotateDirection.clockwise
115
140
  }
116
141
 
117
- getPropsForPartitionInfo (
118
- index: number,
119
- offset: any,
120
- baseRadius?: number
121
- ) {
142
+ getAngleSelf (index) {
143
+ return 360 * index / this.length * this.direction + 90 * ContentDirection[this.contentdirection]
144
+ }
145
+
146
+ getPartitionPositions (index, baseRadius, offset) {
122
147
 
123
148
  const angle =
124
149
  this.angleTransform(this.arrowmode) +
125
150
  this.direction * index * 2 * Math.PI / this.length
126
151
 
127
152
  const point = getPointOnCircle(baseRadius || this.radius - 9 * this.ratio, angle, this.center + offset.center)
128
-
129
- const angleSelf = 360 * index / this.length * this.direction -90
130
153
 
131
154
  const transformOrigin: Point = pointPlus(point, offset.transform)
155
+ const pointResult = pointPlus(point, offset.position)
156
+ return {
157
+ transformOrigin,
158
+ point: pointResult,
159
+ }
160
+ }
161
+
162
+ getPropsForPartitionInfo (
163
+ index: number,
164
+ offset: any,
165
+ baseRadius?: number
166
+ ) {
167
+
168
+ const { point, transformOrigin } = this.getPartitionPositions(index, baseRadius, offset)
169
+ const getTransformOriginString =
170
+ (vector: Point) =>
171
+ Object.keys(vector).map(axis => `${vector[axis]}px`).join(' ')
132
172
 
133
173
  return {
134
- ...pointMinus(point, offset.position),
174
+ ...point,
135
175
  style: [
136
176
  `font-size: ${13 * this.ratio}px`,
137
- `transform: rotate(${angleSelf}deg)`,
138
- `transform-origin: ${transformOrigin.x}px ${transformOrigin.y}px`,
177
+ `transform: rotate(${this.getAngleSelf(index)}deg)`,
178
+ `transform-origin: ${getTransformOriginString(transformOrigin)}`,
139
179
  ].join(';')
140
180
  }
141
181
  }
@@ -314,13 +354,21 @@ export class SvgCalc {
314
354
  }
315
355
 
316
356
  getShadowImage(){
317
- const size = (this.rRingInner - 3.2 * this.ratio) * 2
357
+ const size = (this.rRingInner) * 2
318
358
  return renderSvgImageProps(this.center, backgroundShadowSvg, {
319
359
  width: size,
320
360
  height: size,
321
361
  })
322
362
  }
323
363
 
364
+ getShadowSize(){
365
+ return {
366
+ cx: this.center,
367
+ cy: this.center,
368
+ r: (this.rRingInner)
369
+ }
370
+ }
371
+
324
372
  getPartitionBackgroundProp(index) {
325
373
  return {
326
374
  ...this.getPartitionDraw(index),
@@ -1,7 +1,7 @@
1
1
  <svg width="250" height="250" viewBox="0 0 250 250" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path
3
- style="mix-blend-mode:multiply"
4
- d="M125 250C191.718 250 250 193.271 250 125C250 55.7438 191.718 0 125 0C55.296 0 0 55.7438 0 125C0 193.271 55.296 250 125 250Z" fill="url(#paint0_radial_4318_321)"/>
2
+
3
+ <circle cx="125" cy="125" r="125" fill="url(#paint0_radial_4318_321)" style="mix-blend-mode:multiply" />
4
+
5
5
  <defs>
6
6
  <radialGradient id="paint0_radial_4318_321" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(125 125) scale(125 125)">
7
7
  <!-- <stop offset="0.81" stop-color="white"/>
@@ -7,7 +7,7 @@
7
7
  import './private.item.svg.svelte'
8
8
 
9
9
  // types
10
- import { Lang } from './types';
10
+ import { ContentDirection, Lang } from './types';
11
11
  import { getCurrentInfo } from './business';
12
12
  import { api } from './business';
13
13
  import { onMountMessageLifeCycle, _postMessage } from './message';
@@ -22,6 +22,7 @@
22
22
  export let clientstyling:string = ''
23
23
  export let currentinfo: string = CurrentInfo.RemainingTimes
24
24
  export let giftimagesrc: string = ''
25
+ export let contentdirection: keyof typeof ContentDirection = 'anticlockwise'
25
26
 
26
27
  // properties
27
28
  export let id: string = ''
@@ -81,6 +82,7 @@
81
82
  ...commonProps,
82
83
  id,
83
84
  size,
85
+ contentdirection,
84
86
  }} />
85
87
 
86
88
  <lottery-program-wof-private-message-panel {...{
@@ -122,5 +122,8 @@ svg {
122
122
 
123
123
  .PartitionTextEntity {
124
124
  width: 100%;
125
+ }
126
+
127
+ .PartitionTextEntity.Anticlockwise {
125
128
  text-align: end;
126
- }
129
+ }
@@ -3,12 +3,12 @@
3
3
  <script lang="ts">
4
4
 
5
5
  // types
6
- import { PointerMode, Lang } from './types';
6
+ import { PointerMode, Lang, ContentDirection } from './types';
7
7
  import { getOptions, getSpinCondition, getSpinContainerSelector, Option } from './business';
8
8
  import { api } from './business';
9
9
  import { onMountMessageLifeCycle, _postMessage } from './message';
10
10
  import type { LotteryProgramForPlayer } from './types.business';
11
- import { themes } from './themes';
11
+ import { shadowSteps, themes } from './themes';
12
12
  import { setProps } from './util';
13
13
  import { Spinner } from './class.spinner';
14
14
  import { SvgCalc } from './class.svgcalc';
@@ -21,6 +21,7 @@
21
21
  export let endpoint: string = ''
22
22
  export let session: string = ''
23
23
  export let clientstyling:string = ''
24
+ export let contentdirection: keyof typeof ContentDirection = 'anticlockwise'
24
25
 
25
26
  let rootContainer: HTMLElement
26
27
  $: clientstyling && rootContainer && setClientStyling(rootContainer, clientstyling);
@@ -64,12 +65,34 @@
64
65
  $: theme = themes[themeIndex]
65
66
  $: calc = new SvgCalc({
66
67
  size,
67
- length: options.length,
68
+ options,
68
69
  themeIndex,
70
+ contentdirection,
69
71
  })
72
+ $: options && updateCalcOptions()
73
+ $: (contentdirection || !contentdirection) && updateCalcContentDirection()
70
74
 
71
75
  $: bonus && checkSpinable()
72
76
 
77
+ const updateCalcOptions = () => {
78
+ calc.options = options
79
+ }
80
+ const updateCalcContentDirection = () => {
81
+ calc.contentdirection = contentdirection || 'anticlockwise'
82
+ setImageProps()
83
+ }
84
+
85
+ const setImageProps = () => {
86
+ if(!rootContainer) return;
87
+
88
+ for ( let index = 0; index <= options.length; index++ ) {
89
+ const image = rootContainer.querySelector(`.PartitionImage.PartitionImage${index} image`)
90
+ if(image) {
91
+ setProps(image, calc.getSvgImageProps(index))
92
+ }
93
+ }
94
+ }
95
+
73
96
  const checkSpinable = () => {
74
97
  if(shownFirstCheck) return;
75
98
  shownFirstCheck = true
@@ -172,36 +195,58 @@
172
195
 
173
196
  {#if option.image}
174
197
  <g
198
+ class={`PartitionImage PartitionImage${index}`}
175
199
  use:renderImage={index}
176
200
  style:filter={optionFilter}
177
201
  />
178
- {:else if option.name}
202
+ {/if}
203
+
204
+ {#if option.name}
179
205
  <foreignObject
180
206
  class="PartitionText"
181
207
  {...(() => {
182
208
  const props = calc.getSvgTextProps(index)
209
+ const size = option.image ? 80 : 100
210
+
211
+ const objectSize = {
212
+ width: size,
213
+ height: size,
214
+ }
215
+
183
216
  return {
184
217
  ...props,
185
- x: props.x - 100,
186
- y: props.y - 50,
218
+ ...objectSize,
219
+ x: calc.contentdirection === 'clockwise' ? props.x : props.x - objectSize.width,
220
+ y: props.y - objectSize.height / 2,
187
221
  }
188
222
  })()}
189
223
  style:filter={optionFilter}
190
- width={100}
191
- height={100}
192
224
  >
193
225
  <div class="PartitionTextEntityContainer">
194
- <p class="PartitionTextEntity">{option.name}</p>
226
+ <p class={`PartitionTextEntity${calc.contentdirection === 'clockwise' ? '' : ' Anticlockwise'}`}>{option.name}</p>
195
227
  </div>
196
228
  </foreignObject>
197
229
  {/if}
198
230
  {/each}
199
231
  </g>
200
232
 
201
- <image {...{
202
- class: "PartitionsShadow",
203
- ...calc.getShadowImage()
204
- }} />
233
+ <defs>
234
+ <radialGradient
235
+ id="shadow-fill"
236
+ gradientUnits="userSpaceOnUse"
237
+ {...calc.getShadowSize()}
238
+ >
239
+ {#each shadowSteps as step}
240
+ <stop offset={step.offset} stop-color={step.color}/>
241
+ {/each}
242
+ </radialGradient>
243
+ </defs>
244
+ <circle
245
+ {...calc.getShadowSize()}
246
+ fill="url(#shadow-fill)"
247
+ style="mix-blend-mode:multiply"
248
+ />
249
+
205
250
  </g>
206
251
 
207
252
  {#if theme.pointerMode === PointerMode.Partition}
@@ -67,6 +67,9 @@
67
67
 
68
68
  $: startTime = modeValue?.startTime && getTimeString(modeValue?.startTime)
69
69
 
70
+ $: prize = modeValue?.name || 'prize'
71
+ $: prizeSrc = giftimagesrc || modeValue?.image || giftSvg
72
+
70
73
  </script>
71
74
 
72
75
 
@@ -97,10 +100,16 @@
97
100
 
98
101
  {#if mode === 'gift'}
99
102
  <p>
100
- <img src={giftimagesrc || giftSvg} alt="" class="GiftImage">
103
+ <img src={prizeSrc} alt="" class="GiftImage">
104
+ </p>
105
+ <p>{@html $_('wof.Congratulation', {values: { prize }})}</p>
106
+ {/if}
107
+
108
+ {#if mode === 'nogift'}
109
+ <p>
110
+ <img src={modeValue.image} alt="" class="GiftImage">
101
111
  </p>
102
- <p>{$_('wof.Congratulation')}</p>
103
- <!-- <p>{modeValue}</p> -->
112
+ <p>{@html $_('wof.Loss')}</p>
104
113
  {/if}
105
114
 
106
115
  {#if mode !== 'init-failed'}
@@ -139,6 +148,7 @@
139
148
 
140
149
  .GiftImage {
141
150
  max-width: 80%;
151
+ height: 100px;
142
152
  }
143
153
 
144
154
  .MessagePanel {
package/src/themes.ts CHANGED
@@ -210,4 +210,66 @@ export const themes = [
210
210
  partitions: partitions3,
211
211
  pointerMode: PointerMode.Arrow,
212
212
  },
213
- ]
213
+ ]
214
+
215
+ export const shadowSteps1 = [
216
+ {
217
+ offset: "0.41",
218
+ color: "white",
219
+ },
220
+ {
221
+ offset: "0.57",
222
+ color: "#FCFCFD",
223
+ },
224
+ {
225
+ offset: "0.61",
226
+ color: "#F3F4F6",
227
+ },
228
+ {
229
+ offset: "0.74",
230
+ color: "#E9ECF0",
231
+ },
232
+ {
233
+ offset: "0.87",
234
+ color: "#B9C3CE",
235
+ },
236
+ {
237
+ offset: "1",
238
+ color: "#899BAD",
239
+ },
240
+ ]
241
+
242
+ export const shadowSteps = [
243
+ {
244
+ offset: "0.81",
245
+ color: "white",
246
+ },
247
+ {
248
+ offset: "0.87",
249
+ color: "#FCFCFD",
250
+ },
251
+ {
252
+ offset: "0.91",
253
+ color: "#F3F4F6",
254
+ },
255
+ {
256
+ offset: "0.94",
257
+ color: "#E9ECF0",
258
+ },
259
+ {
260
+ offset: "0.97",
261
+ color: "#B9C3CE",
262
+ },
263
+ {
264
+ offset: "1",
265
+ color: "#899BAD",
266
+ },
267
+ ]
268
+
269
+
270
+ // <stop offset="0.81"
271
+ // <stop offset="0.87"
272
+ // <stop offset="0.91"
273
+ // <stop offset="0.94"
274
+ // <stop offset="0.97"
275
+ // <stop offset="1"
@@ -11,7 +11,7 @@ export const translations = {
11
11
  RemainingTimes: `Remaining Times`,
12
12
  ShowNext: `The Wheel will be available on <strong>{startTime}</strong>. please wait till it is open.`,
13
13
  SpinFaild: `We are sorry that you don't have any Wheels available, please <strong>check T&C</strong> here to get a chance!`,
14
- Congratulation: `Congratulations! You won a prize!`,
14
+ Congratulation: `Congratulations! You won a {prize}!`,
15
15
  OK: `OK`,
16
16
  Rewards: `Rewards`,
17
17
  Status: `Status`,
package/src/types.ts CHANGED
@@ -68,7 +68,10 @@ export enum Tab {
68
68
  History = 'History'
69
69
  }
70
70
 
71
-
71
+ export enum ContentDirection {
72
+ clockwise = 1,
73
+ anticlockwise = -1,
74
+ }
72
75
 
73
76
 
74
77