Your Name vor 4 Jahren
Ursprung
Commit
2b7eab3121
1 geänderte Dateien mit 16 neuen und 16 gelöschten Zeilen
  1. 16
    16
      src/util/football_price.js

+ 16
- 16
src/util/football_price.js Datei anzeigen

@@ -1,7 +1,7 @@
1 1
 import { descartes } from './math'
2 2
 
3 3
 // 模拟比赛得分
4
-const matches = [
4
+const matchResultMockes = [
5 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 6
   [0, 0], [1, 1], [2, 2], [3, 3], [99, 99], 
7 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,8 +22,8 @@ function getPrice(allParts, rq) {
22 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 27
     if (min < minPrice || minPrice === undefined) {
28 28
       minPrice = min
29 29
     }
@@ -36,7 +36,7 @@ function getPrice(allParts, rq) {
36 36
   return [minPrice, maxPrice]
37 37
 }
38 38
 
39
-function getMinAndMax(allParts, match, rq) {
39
+function getMinAndMax(allParts, matchResultMock, rq) {
40 40
   let minPrice = 0
41 41
   let maxPrice = 0
42 42
   
@@ -48,7 +48,7 @@ function getMinAndMax(allParts, match, rq) {
48 48
       return part.map(grp => {
49 49
         const { wayCode } = grp.rules
50 50
         const fn = playWayFunc[wayCode]
51
-        return fn(grp, match, rq)
51
+        return fn(grp, matchResultMock, rq)
52 52
       }).filter(Boolean).reduce((acc, x) => acc * x, 1)
53 53
 
54 54
     }).reduce((acc, x) => acc + x, 0)
@@ -64,8 +64,8 @@ function getMinAndMax(allParts, match, rq) {
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 69
   const {ruleCode, odds} = part.rules
70 70
 
71 71
   switch (ruleCode) {
@@ -79,8 +79,8 @@ function computeWDL(part, match, rq) {
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 84
   const {ruleCode, odds} = part.rules
85 85
 
86 86
   switch (ruleCode) {
@@ -94,8 +94,8 @@ function computeWDLS(part, match, rq) {
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 99
   const {ruleCode, odds} = part.rules
100 100
 
101 101
   switch (ruleCode) {
@@ -165,8 +165,8 @@ function computeScore(part, match, rq) {
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 170
   const {ruleCode, odds} = part.rules
171 171
 
172 172
   switch (ruleCode) {
@@ -190,8 +190,9 @@ function computePoints(part, match, rq) {
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 196
   const {ruleCode, odds} = part.rules
196 197
 
197 198
   switch (ruleCode) {
@@ -207,4 +208,3 @@ function computeDouble(part, match, rq) {
207 208
       return x < y ? odds : 0
208 209
   }
209 210
 }
210
-