Your Name 4 years ago
parent
commit
2b7eab3121
1 changed files with 16 additions and 16 deletions
  1. 16
    16
      src/util/football_price.js

+ 16
- 16
src/util/football_price.js View File

1
 import { descartes } from './math'
1
 import { descartes } from './math'
2
 
2
 
3
 // 模拟比赛得分
3
 // 模拟比赛得分
4
-const matches = [
4
+const matchResultMockes = [
5
   [1, 0], [2, 0], [2, 1], [3, 0], [3, 1], [3, 2], [4, 0], [4, 1], [4, 2], [5, 0], [5, 1], [5, 2], [99, 0],
5
   [1, 0], [2, 0], [2, 1], [3, 0], [3, 1], [3, 2], [4, 0], [4, 1], [4, 2], [5, 0], [5, 1], [5, 2], [99, 0],
6
   [0, 0], [1, 1], [2, 2], [3, 3], [99, 99], 
6
   [0, 0], [1, 1], [2, 2], [3, 3], [99, 99], 
7
   [0, 1], [0, 2], [1, 2], [0, 3], [1, 3], [2, 3], [0, 4], [1, 4], [2, 4], [0, 5], [1, 5], [2, 5], [0, 99],
7
   [0, 1], [0, 2], [1, 2], [0, 3], [1, 3], [2, 3], [0, 4], [1, 4], [2, 4], [0, 5], [1, 5], [2, 5], [0, 99],
22
   let maxPrice = undefined
22
   let maxPrice = undefined
23
 
23
 
24
   // 遍历模拟比赛的各种可能
24
   // 遍历模拟比赛的各种可能
25
-  matches.forEach(match => {
26
-    const [min, max] = getMinAndMax(allParts, match, rq)
25
+  matchResultMockes.forEach(matchResultMock => {
26
+    const [min, max] = getMinAndMax(allParts, matchResultMock, rq)
27
     if (min < minPrice || minPrice === undefined) {
27
     if (min < minPrice || minPrice === undefined) {
28
       minPrice = min
28
       minPrice = min
29
     }
29
     }
36
   return [minPrice, maxPrice]
36
   return [minPrice, maxPrice]
37
 }
37
 }
38
 
38
 
39
-function getMinAndMax(allParts, match, rq) {
39
+function getMinAndMax(allParts, matchResultMock, rq) {
40
   let minPrice = 0
40
   let minPrice = 0
41
   let maxPrice = 0
41
   let maxPrice = 0
42
   
42
   
48
       return part.map(grp => {
48
       return part.map(grp => {
49
         const { wayCode } = grp.rules
49
         const { wayCode } = grp.rules
50
         const fn = playWayFunc[wayCode]
50
         const fn = playWayFunc[wayCode]
51
-        return fn(grp, match, rq)
51
+        return fn(grp, matchResultMock, rq)
52
       }).filter(Boolean).reduce((acc, x) => acc * x, 1)
52
       }).filter(Boolean).reduce((acc, x) => acc * x, 1)
53
 
53
 
54
     }).reduce((acc, x) => acc + x, 0)
54
     }).reduce((acc, x) => acc + x, 0)
64
 }
64
 }
65
 
65
 
66
 // 胜平负
66
 // 胜平负
67
-function computeWDL(part, match, rq) {
68
-  const [x, y] = match
67
+function computeWDL(part, matchResultMock, rq) {
68
+  const [x, y] = matchResultMock
69
   const {ruleCode, odds} = part.rules
69
   const {ruleCode, odds} = part.rules
70
 
70
 
71
   switch (ruleCode) {
71
   switch (ruleCode) {
79
 }
79
 }
80
 
80
 
81
 // 让球胜平负
81
 // 让球胜平负
82
-function computeWDLS(part, match, rq) {
83
-  const [x, y] = match
82
+function computeWDLS(part, matchResultMock, rq) {
83
+  const [x, y] = matchResultMock
84
   const {ruleCode, odds} = part.rules
84
   const {ruleCode, odds} = part.rules
85
 
85
 
86
   switch (ruleCode) {
86
   switch (ruleCode) {
94
 }
94
 }
95
 
95
 
96
 // 比分
96
 // 比分
97
-function computeScore(part, match, rq) {
98
-  const [x, y] = match
97
+function computeScore(part, matchResultMock, rq) {
98
+  const [x, y] = matchResultMock
99
   const {ruleCode, odds} = part.rules
99
   const {ruleCode, odds} = part.rules
100
 
100
 
101
   switch (ruleCode) {
101
   switch (ruleCode) {
165
 }
165
 }
166
 
166
 
167
 // 进球数
167
 // 进球数
168
-function computePoints(part, match, rq) {
169
-  const [x, y] = match
168
+function computePoints(part, matchResultMock, rq) {
169
+  const [x, y] = matchResultMock
170
   const {ruleCode, odds} = part.rules
170
   const {ruleCode, odds} = part.rules
171
 
171
 
172
   switch (ruleCode) {
172
   switch (ruleCode) {
190
 }
190
 }
191
 
191
 
192
 // 半全场
192
 // 半全场
193
-function computeDouble(part, match, rq) {
194
-  const [x, y] = match
193
+function computeDouble(part, matchResultMock, rq) {
194
+  const [x, y] = matchResultMock
195
+
195
   const {ruleCode, odds} = part.rules
196
   const {ruleCode, odds} = part.rules
196
 
197
 
197
   switch (ruleCode) {
198
   switch (ruleCode) {
207
       return x < y ? odds : 0
208
       return x < y ? odds : 0
208
   }
209
   }
209
 }
210
 }
210
-