Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
daierGame
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
node_server
daierGame
Commits
3f46088c
Commit
3f46088c
authored
Dec 03, 2024
by
chenjinjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
部署V2版本
parent
d2c64498
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
535 additions
and
1095 deletions
+535
-1095
ROI.json
json/1730970187744/ROI.json
+2
-4
SWOT.json
json/1730970187744/SWOT.json
+2
-39
全部线索.json
json/1730970187744/全部线索.json
+55
-240
基础数据.json
json/1730970187744/基础数据.json
+12
-136
提交分数.json
json/1730970187744/提交分数.json
+5
-34
竞合.json
json/1730970187744/竞合.json
+3
-5
细分线索.json
json/1730970187744/细分线索.json
+3
-76
雇佣选择.json
json/1730970187744/雇佣选择.json
+3
-17
广州府介绍.json
json/广州府介绍.json
+0
-0
瓷器制造.json
json/瓷器制造.json
+24
-24
用户.json
json/用户.json
+2
-3
剧情表.xlsx
res/剧情表.xlsx
+0
-0
线索表.xlsx
res/线索表.xlsx
+0
-0
clue.ts
src/biz/clue.ts
+57
-126
jinhe.ts
src/biz/jinhe.ts
+21
-21
play.ts
src/biz/play.ts
+95
-183
roi.ts
src/biz/roi.ts
+27
-26
swot.ts
src/biz/swot.ts
+22
-22
task.ts
src/biz/task.ts
+24
-30
user.ts
src/biz/user.ts
+33
-39
main.ts
src/main.ts
+1
-1
router.ts
src/routers/router.ts
+57
-63
tools.ts
src/util/tools.ts
+87
-6
No files found.
json/1730970187744/ROI.json
View file @
3f46088c
{
"1730970187744"
:
{}
}
\ No newline at end of file
{}
\ No newline at end of file
json/1730970187744/SWOT.json
View file @
3f46088c
{
"1727399696222"
:
{
"isSubmit"
:
false
,
"S"
:
[
{
"xsid"
:
"C002"
,
"xsnr"
:
"熟悉整套生产运输流程"
,
"isChoice"
:
false
},
{
"xsid"
:
"C003"
,
"xsnr"
:
"有瓷器的实际设计成功经验"
,
"isChoice"
:
false
}
],
"W"
:
[],
"O"
:
[],
"T"
:
[]
},
"1730970187744"
:
{
"isSubmit"
:
false
,
"S"
:
[],
"W"
:
[],
"O"
:
[
{
"xsid"
:
"C003"
,
"xsnr"
:
"有瓷器的实际设计成功经验"
,
"isChoice"
:
false
},
{
"xsid"
:
"C004"
,
"xsnr"
:
"在多地有熟识的好友可以提供咨询协助"
,
"isChoice"
:
false
}
],
"T"
:
[]
}
}
\ No newline at end of file
{}
\ No newline at end of file
json/1730970187744/全部线索.json
View file @
3f46088c
{
{
{
"1730970187744"
:
{
"普通线索"
:
[
{
"xsid"
:
"C001"
,
"xsnr"
:
"马可波罗要定制1000只瓷器"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
}
],
"SWOT"
:
[
{
"xsid"
:
"C002"
,
"xsnr"
:
"熟悉整套生产运输流程"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C003"
,
"xsnr"
:
"有瓷器的实际设计成功经验"
,
"isChoice"
:
true
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C004"
,
"xsnr"
:
"在多地有熟识的好友可以提供咨询协助"
,
"isChoice"
:
true
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C005"
,
"xsnr"
:
"有景德镇瓷胚的进货渠道"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C006"
,
"xsnr"
:
"资金匮乏"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C007"
,
"xsnr"
:
"没有外贸经验"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C008"
,
"xsnr"
:
"没有成熟团队"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C015"
,
"xsnr"
:
"广州气候适宜"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C013"
,
"xsnr"
:
"西洋有大量的瓷器进口需求"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
}
],
"竞合"
:
[
{
"xsid"
:
"C023"
,
"xsnr"
:
"从马可波罗口中得知,西洋订单大增"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C024"
,
"xsnr"
:
"西洋订单货品质量和交货时限有严格要求"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
}
],
"ROI"
:
[
{
"xsid"
:
"C046"
,
"xsnr"
:
"定制精美瓷器售价"
,
"isChoice"
:
false
,
"sfbx"
:
"制成瓷器"
},
{
"xsid"
:
"C047"
,
"xsnr"
:
"定制普通瓷器售价"
,
"isChoice"
:
false
,
"sfbx"
:
"制成瓷器"
},
{
"xsid"
:
"C048"
,
"xsnr"
:
"通用精美瓷器售价"
,
"isChoice"
:
false
,
"sfbx"
:
"制成瓷器"
},
{
"xsid"
:
"C049"
,
"xsnr"
:
"通用普通瓷器售价"
,
"isChoice"
:
false
,
"sfbx"
:
"制成瓷器"
},
{
"xsid"
:
"C027"
,
"xsnr"
:
"工人甲"
,
"isChoice"
:
false
,
"sfbx"
:
"工人"
},
{
"xsid"
:
"C028"
,
"xsnr"
:
"工人乙"
,
"isChoice"
:
false
,
"sfbx"
:
"工人"
},
{
"xsid"
:
"C029"
,
"xsnr"
:
"工人丙"
,
"isChoice"
:
false
,
"sfbx"
:
"工人"
},
{
"xsid"
:
"C030"
,
"xsnr"
:
"工人丁"
,
"isChoice"
:
false
,
"sfbx"
:
"工人"
},
{
"xsid"
:
"C031"
,
"xsnr"
:
"工人戊"
,
"isChoice"
:
false
,
"sfbx"
:
"工人"
},
{
"xsid"
:
"C032"
,
"xsnr"
:
"工人己"
,
"isChoice"
:
false
,
"sfbx"
:
"工人"
},
{
"xsid"
:
"C033"
,
"xsnr"
:
"工人庚"
,
"isChoice"
:
false
,
"sfbx"
:
"工人"
},
{
"xsid"
:
"C034"
,
"xsnr"
:
"工人辛"
,
"isChoice"
:
false
,
"sfbx"
:
"工人"
},
{
"xsid"
:
"C035"
,
"xsnr"
:
"画师1"
,
"isChoice"
:
false
,
"sfbx"
:
"画师"
},
{
"xsid"
:
"C036"
,
"xsnr"
:
"画师2"
,
"isChoice"
:
false
,
"sfbx"
:
"画师"
},
{
"xsid"
:
"C037"
,
"xsnr"
:
"画师3"
,
"isChoice"
:
false
,
"sfbx"
:
"画师"
},
{
"xsid"
:
"C038"
,
"xsnr"
:
"掌柜A"
,
"isChoice"
:
false
,
"sfbx"
:
"掌柜"
},
{
"xsid"
:
"C039"
,
"xsnr"
:
"掌柜B"
,
"isChoice"
:
false
,
"sfbx"
:
"掌柜"
}
]
},
"1727399696222"
:
{
"普通线索"
:
[],
"SWOT"
:
[
{
"xsid"
:
"C002"
,
"xsnr"
:
"熟悉整套生产运输流程"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C003"
,
"xsnr"
:
"有瓷器的实际设计成功经验"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C004"
,
"xsnr"
:
"在多地有熟识的好友可以提供咨询协助"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C005"
,
"xsnr"
:
"有景德镇瓷胚的进货渠道"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C006"
,
"xsnr"
:
"资金匮乏"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C007"
,
"xsnr"
:
"没有外贸经验"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C008"
,
"xsnr"
:
"没有成熟团队"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C015"
,
"xsnr"
:
"广州气候适宜"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
}
],
"竞合"
:
[],
"ROI"
:
[]
}
"普通线索"
:
[],
"SWOT"
:
[
{
"xsid"
:
"C002"
,
"xsnr"
:
"熟悉整套生产运输流程"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C003"
,
"xsnr"
:
"有瓷器的实际设计成功经验"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C004"
,
"xsnr"
:
"在多地有熟识的好友可以提供咨询协助"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C005"
,
"xsnr"
:
"有景德镇瓷胚的进货渠道"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C006"
,
"xsnr"
:
"资金匮乏"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C007"
,
"xsnr"
:
"没有外贸经验"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C008"
,
"xsnr"
:
"没有成熟团队"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
},
{
"xsid"
:
"C015"
,
"xsnr"
:
"广州气候适宜"
,
"isChoice"
:
false
,
"sfbx"
:
"否"
}
],
"竞合"
:
[],
"ROI"
:
[]
}
\ No newline at end of file
json/1730970187744/基础数据.json
View file @
3f46088c
{
{
{
"1727399696222"
:
{
"初始资金"
:
500
,
"天数"
:
215
,
"结算"
:
500
,
"广州府介绍"
:
false
,
"酒馆剧情"
:
2
,
"当前线索确认"
:
1
,
"商行选择"
:
false
,
"SWOT"
:
true
,
"ROI"
:
false
,
"竞合"
:
false
,
"码头"
:
{
"S011"
:
{
"当前对话id"
:
"17"
,
"已获得的线索"
:
[
"C023"
,
"C013"
,
"C046"
,
"C047"
,
"C048"
,
"C049"
,
"C001"
,
"C024"
]
}
},
"酒馆"
:
{
"S023"
:
{
"当前对话id"
:
1
,
"已获得的线索"
:
[]
},
"S024"
:
{
"当前对话id"
:
1
},
"S022"
:
{
"当前对话id"
:
"2"
},
"S021"
:
{
"当前对话id"
:
1
}
}
},
"1729153582461"
:
{
"初始资金"
:
500
,
"天数"
:
112
,
"结算"
:
500
,
"广州府介绍"
:
false
,
"酒馆剧情"
:
0
,
"当前线索确认"
:
0
,
"商行选择"
:
false
,
"SWOT"
:
false
,
"ROI"
:
false
,
"竞合"
:
false
},
"1730359559228"
:
{
"初始资金"
:
500
,
"天数"
:
0
,
"结算"
:
500
,
"广州府介绍"
:
true
,
"酒馆剧情"
:
0
,
"当前线索确认"
:
0
,
"商行选择"
:
false
,
"SWOT"
:
false
,
"ROI"
:
false
,
"竞合"
:
false
},
"1730970187744"
:
{
"初始资金"
:
500
,
"天数"
:
3
,
"结算"
:
-112700
,
"广州府介绍"
:
false
,
"酒馆剧情"
:
2
,
"当前线索确认"
:
1
,
"商行选择"
:
true
,
"SWOT"
:
true
,
"ROI"
:
true
,
"竞合"
:
false
,
"码头"
:
{
"S011"
:
{
"当前对话id"
:
"17"
,
"已获得的线索"
:
[
"C023"
,
"C013"
,
"C046"
,
"C047"
,
"C048"
,
"C049"
,
"C001"
,
"C024"
]
}
},
"酒馆"
:
{
"S021"
:
{
"当前对话id"
:
1
,
"已获得的线索"
:
[]
}
}
},
"1730359573927"
:
{
"初始资金"
:
500
,
"天数"
:
0
,
"结算"
:
500
,
"广州府介绍"
:
true
,
"酒馆剧情"
:
0
,
"当前线索确认"
:
0
,
"商行选择"
:
false
,
"SWOT"
:
false
,
"ROI"
:
false
,
"竞合"
:
false
},
"1730970810891"
:
{
"初始资金"
:
500
,
"天数"
:
0
,
"结算"
:
500
,
"广州府介绍"
:
true
,
"酒馆剧情"
:
0
,
"当前线索确认"
:
0
,
"商行选择"
:
false
,
"SWOT"
:
false
,
"ROI"
:
false
,
"竞合"
:
false
},
"1732604118825"
:
{
"初始资金"
:
500
,
"天数"
:
0
,
"结算"
:
500
,
"广州府介绍"
:
true
,
"酒馆剧情"
:
0
,
"当前线索确认"
:
0
,
"商行选择"
:
false
,
"SWOT"
:
false
,
"ROI"
:
false
,
"竞合"
:
false
}
"初始资金"
:
500
,
"天数"
:
73
,
"结算"
:
500
,
"广州府介绍"
:
false
,
"酒馆剧情"
:
0
,
"当前线索确认"
:
0
,
"商行选择"
:
false
,
"SWOT"
:
false
,
"ROI"
:
false
,
"竞合"
:
false
}
\ No newline at end of file
json/1730970187744/提交分数.json
View file @
3f46088c
{
{
{
"1727399696222"
:
{
"SWOT"
:
7.6923076923076925
,
"ROI"
:
0
,
"竞合"
:
0
},
"1729153582461"
:
{
"SWOT"
:
0
,
"ROI"
:
0
,
"竞合"
:
0
},
"1730359559228"
:
{
"SWOT"
:
0
,
"ROI"
:
0
,
"竞合"
:
0
},
"1730970187744"
:
{
"SWOT"
:
0
},
"1730359573927"
:
{
"SWOT"
:
0
,
"ROI"
:
0
,
"竞合"
:
0
},
"1730970810891"
:
{
"SWOT"
:
0
,
"ROI"
:
0
,
"竞合"
:
0
},
"1732604118825"
:
{
"SWOT"
:
0
,
"ROI"
:
0
,
"竞合"
:
0
}
"SWOT"
:
0
,
"ROI"
:
0
,
"竞合"
:
0
}
\ No newline at end of file
json/1730970187744/竞合.json
View file @
3f46088c
{
{}
{
"1730970187744"
:
{}
}
\ No newline at end of file
{}
\ No newline at end of file
json/1730970187744/细分线索.json
View file @
3f46088c
{
{}
{
"SWOT"
:
{
"S"
:
[
"C002"
,
"C003"
,
"C004"
,
"C005"
],
"W"
:
[
"C006"
,
"C007"
,
"C008"
],
"O"
:
[
"C012"
,
"C013"
,
"C014"
],
"T"
:
[
"C009"
,
"C010"
,
"C011"
]
},
"ROI"
:
{
"R"
:
[
"C046"
,
"C047"
,
"C048"
,
"C049"
],
"I"
:
[
"C027"
,
"C028"
,
"C029"
,
"C030"
,
"C031"
,
"C032"
,
"C033"
,
"C034"
,
"C035"
,
"C036"
,
"C037"
,
"C038"
,
"C039"
,
"C040"
,
"C041"
,
"C042"
,
"C043"
,
"C044"
,
"C045"
]
},
"竞合"
:
{
"供方"
:
[
"C017"
,
"C018"
],
"现有竞争"
:
[
"C019"
],
"潜在竞争"
:
[
"C020"
],
"替代竞争"
:
[
"C021"
,
"C022"
],
"买方"
:
[
"C023"
,
"C024"
]
}
}
\ No newline at end of file
{}
\ No newline at end of file
json/1730970187744/雇佣选择.json
View file @
3f46088c
{
{}
{
"1730970187744"
:
{
"人工"
:
{
"工人"
:
"C025"
,
"画师"
:
"C032"
,
"掌柜"
:
"C035"
},
"原材料"
:
{
"瓷器"
:
"C041"
,
"颜料"
:
"C039"
},
"运输"
:
"C037"
,
"制成瓷器"
:
"C045"
}
}
\ No newline at end of file
{}
\ No newline at end of file
json/
1730970187744/
广州府介绍.json
→
json/广州府介绍.json
View file @
3f46088c
File moved
json/
1730970187744/
瓷器制造.json
→
json/瓷器制造.json
View file @
3f46088c
{
{
{
"瓷器"
:
{
"定制精美瓷器"
:
{
"瓷器"
:
"C04
0
"
,
"颜料"
:
"C0
38
"
,
"瓷器"
:
"C04
4
"
,
"颜料"
:
"C0
42
"
,
"单价"
:
300
,
"固定成本"
:
200
},
"定制普通瓷器"
:
{
"瓷器"
:
"C04
0
"
,
"颜料"
:
"C0
39
"
,
"瓷器"
:
"C04
4
"
,
"颜料"
:
"C0
43
"
,
"单价"
:
270
,
"固定成本"
:
190
},
"通用精美瓷器"
:
{
"瓷器"
:
"C04
1
"
,
"颜料"
:
"C0
38
"
,
"瓷器"
:
"C04
5
"
,
"颜料"
:
"C0
42
"
,
"单价"
:
170
,
"固定成本"
:
120
},
"通用普通瓷器"
:
{
"瓷器"
:
"C04
1
"
,
"颜料"
:
"C0
39
"
,
"瓷器"
:
"C04
5
"
,
"颜料"
:
"C0
43
"
,
"单价"
:
150
,
"固定成本"
:
110
}
},
"人员成本"
:
{
"C02
3
"
:
{
"C02
7
"
:
{
"ycl"
:
360
,
"gz"
:
150
,
"fjcb"
:
0.42
},
"C02
4
"
:
{
"C02
8
"
:
{
"ycl"
:
450
,
"gz"
:
150
,
"fjcb"
:
0.33
},
"C02
5
"
:
{
"C02
9
"
:
{
"ycl"
:
510
,
"gz"
:
150
,
"fjcb"
:
0.29
},
"C0
26
"
:
{
"C0
30
"
:
{
"ycl"
:
840
,
"gz"
:
300
,
"fjcb"
:
0.36
},
"C0
27
"
:
{
"C0
31
"
:
{
"ycl"
:
960
,
"gz"
:
300
,
"fjcb"
:
0.31
},
"C0
28
"
:
{
"C0
32
"
:
{
"ycl"
:
1050
,
"gz"
:
300
,
"fjcb"
:
0.29
},
"C0
29
"
:
{
"C0
33
"
:
{
"ycl"
:
1350
,
"gz"
:
450
,
"fjcb"
:
0.33
},
"C03
0
"
:
{
"C03
4
"
:
{
"ycl"
:
1650
,
"gz"
:
450
,
"fjcb"
:
0.27
},
"C03
1
"
:
{
"C03
5
"
:
{
"ycl"
:
500
,
"gz"
:
1000
,
"fjcb"
:
2
},
"C03
2
"
:
{
"C03
6
"
:
{
"ycl"
:
1320
,
"gz"
:
2000
,
"fjcb"
:
1.52
},
"C03
3
"
:
{
"C03
7
"
:
{
"ycl"
:
1900
,
"gz"
:
3000
,
"fjcb"
:
1.58
},
"C03
4
"
:
{
"C03
8
"
:
{
"ycl"
:
1000
,
"gz"
:
1000
,
"fjcb"
:
1
},
"C03
5
"
:
{
"C03
9
"
:
{
"ycl"
:
1100
,
"gz"
:
1050
,
"fjcb"
:
0.95
}
},
"运输成本"
:
{
"C0
36
"
:
{
"C0
40
"
:
{
"sjmc"
:
"车路"
,
"xjb"
:
1.33
},
"C0
37
"
:
{
"C0
41
"
:
{
"sjmc"
:
"水路"
,
"xjb"
:
1
}
...
...
json/用户.json
View file @
3f46088c
[
[
...
...
@@ -19,8 +19,7 @@
{
"userId"
:
"1730970187744"
,
"loginId"
:
"111"
,
"pwd"
:
"123456"
,
"name"
:
"小陈"
"pwd"
:
"123456"
},
{
"userId"
:
"1730359573927"
,
...
...
res/剧情表.xlsx
View file @
3f46088c
No preview for this file type
res/线索表.xlsx
View file @
3f46088c
No preview for this file type
src/biz/clue.ts
View file @
3f46088c
...
...
@@ -6,16 +6,16 @@
import
{
HARITYPE
,
NOWCLUE
}
from
"../config/enum"
;
import
{
xiansuoTableData
,
guyongTableData
}
from
"../data/table/tableData"
;
import
{
successResult
}
from
"../tools/systemTools"
;
import
{
change
JsonData
,
get
JsonData
}
from
"../util/tools"
;
import
{
change
UserJsonData
,
getUser
JsonData
}
from
"../util/tools"
;
/**
* 是否启用线索
* @param userId
*/
export
function
isEnabled
(
userId
:
string
)
{
export
async
function
isEnabled
(
userId
:
string
)
{
//获取已有json数据
let
baseData
=
getJsonData
(
"json/基础数据.json"
)[
userId
]
;
let
baseData
:
any
=
await
getUserJsonData
(
`基础数据.json`
,
userId
)
;
let
isEnabled
=
{
"SWOT"
:
baseData
.
SWOT
,
"ROI"
:
baseData
.
ROI
,
...
...
@@ -27,37 +27,9 @@ export function isEnabled(userId:string) {
/**
* 弃用
* 添加线索 todo线索改为剧情走过才添加
* @param userId
*/
export
function
addClue
(
userId
:
string
)
{
let
excelData
=
xiansuoTableData
();
let
clueExcelData
=
excelData
[
"线索表"
].
dataList
;
let
writeClueAll
=
{};
/**添加全部线索 */
let
clueData
=
{};
clueExcelData
.
forEach
(
info
=>
{
let
{
xsid
,
xsnr
,
xslx
,
xslxxf
,
zs
,
dhgl
,
sfbx
}
=
info
;
if
(
!
clueData
[
xslx
])
clueData
[
xslx
]
=
[];
clueData
[
xslx
].
push
({
xsid
,
xsnr
});
if
(
!
writeClueAll
[
userId
])
writeClueAll
[
userId
]
=
[];
writeClueAll
[
userId
].
push
({
xsid
,
xsnr
,
isChoice
:
false
});
})
let
allClueJson
=
getJsonData
(
"json/全部线索.json"
);
if
(
!
allClueJson
[
userId
]
||
allClueJson
[
userId
].
length
==
0
)
addAllClue
(
writeClueAll
);
console
.
log
(
`
${
userId
}
全部线索添加成功`
);
}
/**
* 添加细分线索 todo线索改为剧情走过才添加
*/
export
function
xfxxClue
(
)
{
export
async
function
xfxxClue
(
userId
)
{
let
excelData
=
xiansuoTableData
();
let
clueExcelData
=
excelData
[
"线索表"
].
dataList
;
...
...
@@ -86,9 +58,7 @@ export function xfxxClue() {
"竞合"
:
jinheClue
};
changeJsonData
(
"json/细分线索.json"
,
xfxxClueJson
);
// let xfClueJson = getJsonData("json/细分线索.json");
// if(!xfClueJson || Object.keys(xfxxClueJson).length === 0) changeJsonData("json/细分线索.json", xfxxClueJson);
await
changeUserJsonData
(
"细分线索.json"
,
userId
,
xfxxClueJson
);
console
.
log
(
`细分线索添加成功`
);
}
...
...
@@ -98,47 +68,26 @@ export function xfxxClue() {
* 提交线索
* @param clueType 线索类型【SWOT、ROI、竞合】
*/
export
function
submitClue
(
userId
,
clueType
)
{
let
jsonData
=
getJsonData
(
`json/
${
clueType
}
.json`
);
export
async
function
submitClue
(
userId
,
clueType
)
{
let
jsonData
=
await
getUserJsonData
(
`
${
clueType
}
.json`
,
userId
);
let
baseData
=
jsonData
;
//isSubmit:false【未提交】、true【提交】
baseData
[
userId
][
"isSubmit"
]
=
true
;
changeJsonData
(
"json/已提交线索.json"
,
baseData
);
baseData
[
"isSubmit"
]
=
true
;
await
changeUserJsonData
(
"已提交线索.json"
,
userId
,
baseData
);
console
.
log
(
"已提交线索"
);
/**清空原有剧情和线索 */
// restart(userId);
return
successResult
();
}
/**
* 弃用
* 添加全部线索
* @param data
*/
export
function
addAllClue
(
data
)
{
let
jsonData
=
getJsonData
(
"json/全部线索.json"
);
let
baseData
=
jsonData
;
//isChoice:false【未选择】、true【已选择】
if
(
Object
.
keys
(
baseData
).
length
===
0
||
!
baseData
)
{
changeJsonData
(
"json/全部线索.json"
,
data
);
console
.
log
(
"已添加全部线索"
);
}
}
/**
* 线索
* 有参数返回对应线索类型数据,没有参数返回已走过剧情的全部线索数据
* @param clueType 线索类型
* @returns
*/
export
function
getClue
(
userId
,
clueType
?)
{
export
async
function
getClue
(
userId
,
clueType
?)
{
let
excelData
=
xiansuoTableData
();
let
clueExcelData
=
excelData
[
"线索表"
].
dataList
;
...
...
@@ -149,26 +98,13 @@ export function getClue(userId, clueType?) {
clueData
[
xslx
].
push
({
xsid
,
xsnr
,
sfbx
});
})
/**如果登录的账号没有全部线索数据,则写入json */
// let allClueJson = getJsonData("json/全部线索.json");
// let writeClueAll = allClueJson;
// if (Object.keys(allClueJson[userId]).length == 0) {
// writeClueAll[userId] = {};
// clueExcelData.forEach( info => {
// let {xsid, xsnr, xslx, xslxxf, sfbx} = info;
// if (!writeClueAll[userId][xslx]) writeClueAll[userId][xslx] = [];
// writeClueAll[userId][xslx].push({xsid, xsnr, isChoice:false, sfbx});
// })
// //写入json
// changeJsonData("json/全部线索.json", writeClueAll);
// }
let
clueList
=
[];
let
guyongJson
=
getJsonData
(
"json/雇佣选择.json"
);
let
guyongUserJson
=
guyongJson
[
userId
]
;
let
guyongJson
=
await
getUserJsonData
(
"雇佣选择.json"
,
userId
);
let
guyongUserJson
=
guyongJson
;
let
grData
:
any
=
{
"工人"
:[],
"画师"
:[],
"掌柜"
:[],
"运输"
:[],
"颜料"
:[],
"瓷器"
:[],
"是"
:[],
"否"
:[],
"制成瓷器"
:[]};
/**特化ROI线索列表,返回已选择的工人、画师、掌柜 */
/**特化ROI线索列表,返回已选择的工人、画师、掌柜
、运输等
*/
if
(
clueType
==
"ROI"
)
{
//根据原材料选择出制作的是哪个款式的瓷器
let
gyExcelData
=
guyongTableData
();
...
...
@@ -183,8 +119,7 @@ export function getClue(userId, clueType?) {
guyongUserJson
[
"制成瓷器"
]
=
xsid
;
}
})
guyongJson
[
userId
]
=
guyongUserJson
;
changeJsonData
(
"json/雇佣选择.json"
,
guyongJson
);
await
changeUserJsonData
(
"雇佣选择.json"
,
userId
,
guyongUserJson
);
let
ROI
=
[];
clueData
[
clueType
].
forEach
(
info
=>
{
...
...
@@ -219,21 +154,18 @@ export function getClue(userId, clueType?) {
clueData
[
"ROI"
]
=
ROI
;
}
let
allClueChange
=
getJsonData
(
"json/全部线索.json"
);
let
allClueChange
=
await
getUserJsonData
(
"全部线索.json"
,
userId
);
if
(
clueType
)
{
clueData
[
clueType
].
forEach
(
info
=>
{
// for(let key in allClueChange[userId]) {
// }
allClueChange
[
userId
][
clueType
].
forEach
(
thisClue
=>
{
allClueChange
[
clueType
].
forEach
(
thisClue
=>
{
if
(
info
.
xsid
==
thisClue
.
xsid
)
{
clueList
.
push
(
thisClue
);
}
})
})
}
else
{
for
(
let
key
in
allClueChange
[
userId
]
)
{
allClueChange
[
userId
][
key
].
forEach
(
thisClue
=>
{
for
(
let
key
in
allClueChange
)
{
allClueChange
[
key
].
forEach
(
thisClue
=>
{
clueList
.
push
(
thisClue
);
})
}
...
...
@@ -249,7 +181,6 @@ export function getClue(userId, clueType?) {
return
0
;
});
}
return
clueList
;
}
...
...
@@ -259,11 +190,11 @@ export function getClue(userId, clueType?) {
* 回显细分线索
* @param clueType 线索类型【SWOT、ROI、竞合】
*/
export
function
getChoiceClue
(
userId
,
clueType
)
{
let
jsonData
=
getJsonData
(
`json/
${
clueType
}
.json`
);
export
async
function
getChoiceClue
(
userId
,
clueType
)
{
let
jsonData
=
await
getUserJsonData
(
`
${
clueType
}
.json`
,
userId
);
let
baseData
=
{};
if
(
Object
.
keys
(
jsonData
).
length
===
0
)
baseData
=
{};
else
baseData
=
jsonData
[
userId
]
;
else
baseData
=
jsonData
;
return
baseData
;
}
...
...
@@ -276,39 +207,39 @@ export function getChoiceClue(userId, clueType) {
* @param xsid 线索id: C001
* @returns
*/
export
function
delClue
(
userId
,
clueType
,
xxType
,
xsid
)
{
let
jsonData
=
getJsonData
(
`json/
${
clueType
}
.json`
);
export
async
function
delClue
(
userId
,
clueType
,
xxType
,
xsid
)
{
let
jsonData
=
await
getUserJsonData
(
`
${
clueType
}
.json`
,
userId
);
let
baseData
=
jsonData
;
let
clueData
=
baseData
[
userId
][
xxType
];
let
clueData
=
baseData
[
xxType
];
/**过滤掉xsid的元素 */
let
clueDelData
=
clueData
.
filter
(
x
=>
!
[
xsid
].
includes
(
x
.
xsid
));
baseData
[
userId
][
xxType
]
=
clueDelData
;
changeJsonData
(
`json/
${
clueType
}
.json`
,
baseData
);
baseData
[
xxType
]
=
clueDelData
;
await
changeUserJsonData
(
`
${
clueType
}
.json`
,
userId
,
baseData
);
console
.
log
(
baseData
);
let
allClueJson
=
getJsonData
(
"json/全部线索.json"
);
let
allClueJson
=
await
getUserJsonData
(
"全部线索.json"
,
userId
);
// let allClueData = allClueJson;
for
(
let
key
in
allClueJson
[
userId
]
)
{
allClueJson
[
userId
][
key
].
forEach
(
thisClue
=>
{
for
(
let
key
in
allClueJson
)
{
allClueJson
[
key
].
forEach
(
thisClue
=>
{
if
(
xsid
==
thisClue
.
xsid
)
thisClue
.
isChoice
=
false
;
});
}
changeJsonData
(
"json/全部线索.json"
,
allClueJson
);
await
changeUserJsonData
(
`全部线索.json`
,
userId
,
allClueJson
);
if
(
xxType
==
"R"
)
{
let
excelData
=
guyongTableData
();
let
ciqiExcel
=
excelData
[
'制作瓷器'
].
dataList
;
let
ciqiMoney
=
0
;
let
baseClueJson
=
getJsonData
(
"json/基础数据.json"
);
let
baseClueJson
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
ciqiExcel
.
forEach
(
info
=>
{
if
(
info
.
xsid
==
xsid
)
ciqiMoney
=
info
.
sj
;
});
//加上定制瓷器金额
let
jsje
=
baseClueJson
[
userId
][
"结算"
]
||
0
;
baseClueJson
[
userId
][
"结算"
]
=
jsje
-
ciqiMoney
*
1000
;
changeJsonData
(
"json/基础数据.json"
,
baseClueJson
);
let
jsje
=
baseClueJson
[
"结算"
]
||
0
;
baseClueJson
[
"结算"
]
=
jsje
-
ciqiMoney
*
1000
;
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
baseClueJson
);
}
return
successResult
();
...
...
@@ -319,8 +250,8 @@ export function delClue(userId, clueType, xxType, xsid) {
* 提交线索
* @param userId
*/
export
function
checkClue
(
userId
)
{
let
jsonData
=
getJsonData
(
"json/提交分数.json"
)[
userId
]
;
export
async
function
checkClue
(
userId
)
{
let
jsonData
=
await
getUserJsonData
(
"提交分数.json"
,
userId
)
;
let
swot
=
jsonData
[
"SWOT"
]
||
0
;
let
roi
=
jsonData
[
"ROI"
]
||
0
;
...
...
@@ -372,11 +303,11 @@ export function checkClue(userId) {
* 只需清空已选择线索,剧情不需要重新玩
* @param userId
*/
export
function
againAnswer
(
userId
)
{
export
async
function
againAnswer
(
userId
)
{
//根据原材料选择出制作的是哪个款式的瓷器
let
baseClueJson
=
getJsonData
(
"json/基础数据.json"
);
let
guyongJson
=
getJsonData
(
"json/雇佣选择.json"
);
let
guyongUserJson
=
guyongJson
[
userId
]
;
let
baseClueJson
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
let
guyongJson
=
await
getUserJsonData
(
"雇佣选择.json"
,
userId
);
let
guyongUserJson
=
guyongJson
;
let
gyExcelData
=
guyongTableData
();
let
zzcqExcelData
=
gyExcelData
[
"制作瓷器"
].
dataList
;
...
...
@@ -394,27 +325,27 @@ export function againAnswer(userId) {
})
//删去结算金额上的定制瓷器金额
let
jsje
=
baseClueJson
[
userId
][
"结算"
]
||
0
;
baseClueJson
[
userId
][
"结算"
]
=
jsje
-
ciqiMoney
*
1000
;
changeJsonData
(
"json/基础数据.json"
,
baseClueJson
);
let
jsje
=
baseClueJson
[
"结算"
]
||
0
;
baseClueJson
[
"结算"
]
=
jsje
-
ciqiMoney
*
1000
;
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
baseClueJson
);
let
againJson
=
[
"SWOT"
,
"ROI"
,
"竞合"
];
for
(
let
i
=
0
;
i
<
againJson
.
length
;
i
++
)
{
let
allJson
=
getJsonData
(
`json/
${
againJson
[
i
]}
.json`
);
allJson
[
userId
]
=
{};
changeJsonData
(
`json/
${
againJson
[
i
]}
.json`
,
allJson
);
let
allJson
=
await
getUserJsonData
(
`
${
againJson
[
i
]}
.json`
,
userId
);
allJson
=
{};
await
changeUserJsonData
(
`
${
againJson
[
i
]}
.json`
,
userId
,
allJson
);
}
/**修改全部线索的已选中 */
let
allClueJson
=
getJsonData
(
"json/全部线索.json"
);
let
allClueJson
=
await
getUserJsonData
(
"全部线索.json"
,
userId
);
// let allClueData = allClueJson;
for
(
let
key
in
allClueJson
[
userId
]
)
{
allClueJson
[
userId
][
key
].
forEach
(
thisClue
=>
{
for
(
let
key
in
allClueJson
)
{
allClueJson
[
key
].
forEach
(
thisClue
=>
{
thisClue
.
isChoice
=
false
;
});
}
changeJsonData
(
"json/全部线索.json"
,
allClueJson
);
await
changeUserJsonData
(
"全部线索.json"
,
userId
,
allClueJson
);
return
successResult
();
}
...
...
@@ -425,18 +356,18 @@ export function againAnswer(userId) {
* 当前用户数据全部清空
* @param userId
*/
export
function
againStart
(
userId
)
{
export
async
function
againStart
(
userId
)
{
let
againJson
=
[
"雇佣选择"
,
"全部线索"
,
"提交分数"
,
"细分线索"
,
"SWOT"
,
"ROI"
,
"竞合"
];
for
(
let
i
=
0
;
i
<
againJson
.
length
;
i
++
)
{
let
allJson
=
getJsonData
(
`json/
${
againJson
[
i
]}
.json`
);
allJson
[
userId
]
=
{};
changeJsonData
(
`json/
${
againJson
[
i
]}
.json`
,
allJson
);
let
allJson
=
await
getUserJsonData
(
`
${
againJson
[
i
]}
.json`
,
userId
);
allJson
=
{};
await
changeUserJsonData
(
`
${
againJson
[
i
]}
.json`
,
userId
,
allJson
);
}
let
userJson
=
getJsonData
(
"json/基础数据.json"
);
let
userJson
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
let
writeBaseAll
=
userJson
;
writeBaseAll
[
userId
]
=
{
writeBaseAll
=
{
"初始资金"
:
500
,
"天数"
:
1
,
"结算"
:
500
,
...
...
@@ -451,7 +382,7 @@ export function againStart(userId) {
}
//写入json
changeJsonData
(
"json/基础数据.json"
,
writeBaseAll
);
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
writeBaseAll
);
return
successResult
();
}
...
...
src/biz/jinhe.ts
View file @
3f46088c
...
...
@@ -9,7 +9,7 @@
import
{
NOWCLUE
}
from
"../config/enum"
;
import
{
successResult
}
from
"../tools/systemTools"
;
import
{
change
JsonData
,
get
JsonData
}
from
"../util/tools"
;
import
{
change
UserJsonData
,
getUser
JsonData
}
from
"../util/tools"
;
/**
...
...
@@ -17,14 +17,14 @@ import { changeJsonData, getJsonData } from "../util/tools";
* @param subdivide 细分线索类型【供方、现有竞争、潜在竞争、替代竞争、买方】
* @param xs [{xsid:"", xsnr:""}, ...]
*/
export
function
submitJinheClue
(
userId
,
subdivide
,
xs
)
{
let
jsonData
=
getJsonData
(
"json/竞合.json"
);
export
async
function
submitJinheClue
(
userId
,
subdivide
,
xs
)
{
let
jsonData
=
await
getUserJsonData
(
"竞合.json"
,
userId
);
/**处理确认选择的线索 */
let
jinheClueData
=
jsonData
;
//没有对应用户数据先添加一个基础格式,有的话直接push
if
(
!
jinheClueData
[
userId
]
||
Object
.
keys
(
jinheClueData
[
userId
]
).
length
===
0
)
{
jinheClueData
[
userId
]
=
{
if
(
!
jinheClueData
||
Object
.
keys
(
jinheClueData
).
length
===
0
)
{
jinheClueData
=
{
"isSubmit"
:
false
,
"供方"
:
[],
"现有竞争"
:
[],
...
...
@@ -36,35 +36,35 @@ export function submitJinheClue(userId, subdivide, xs) {
//isSubmit:false【未提交】、true【提交】
/**当前线索类型未提交时,可以修改添加线索 */
if
(
!
jinheClueData
[
userId
][
"isSubmit"
])
{
if
(
!
jinheClueData
[
"isSubmit"
])
{
for
(
let
i
=
0
;
i
<
xs
.
length
;
i
++
)
{
// let xsInfo = xs[i];
jinheClueData
[
userId
][
subdivide
].
push
(
xs
[
i
]);
jinheClueData
[
subdivide
].
push
(
xs
[
i
]);
}
changeJsonData
(
"json/竞合.json"
,
jinheClueData
);
await
changeUserJsonData
(
"竞合.json"
,
userId
,
jinheClueData
);
console
.
log
(
"添加ROI线索成功"
);
}
else
{
console
.
log
(
"线索已提交,无法重复提交"
);
}
/**修改全部线索.json的对应线索为已选择 isChoice:true */
let
allClueJson
=
getJsonData
(
"json/全部线索.json"
);
let
allClueJson
=
await
getUserJsonData
(
"全部线索.json"
,
userId
);
let
allClueData
=
allClueJson
;
xs
.
forEach
(
info
=>
{
let
{
xsid
,
xsnr
}
=
info
;
for
(
let
key
in
allClueData
[
userId
]
)
{
allClueData
[
userId
][
key
].
forEach
(
thisClue
=>
{
for
(
let
key
in
allClueData
)
{
allClueData
[
key
].
forEach
(
thisClue
=>
{
if
(
xsid
==
thisClue
.
xsid
)
thisClue
.
isChoice
=
true
;
})
}
});
changeJsonData
(
"json/全部线索.json"
,
allClueData
);
await
changeUserJsonData
(
"全部线索.json"
,
userId
,
allClueData
);
let
baseJsonData
=
getJsonData
(
"json/基础数据.json"
);
baseJsonData
[
userId
][
"当前线索确认"
]
=
NOWCLUE
.
竞合
;
changeJsonData
(
"json/基础数据.json"
,
baseJsonData
);
let
baseJsonData
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
baseJsonData
[
"当前线索确认"
]
=
NOWCLUE
.
竞合
;
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
baseJsonData
);
return
successResult
();
}
...
...
@@ -75,10 +75,10 @@ export function submitJinheClue(userId, subdivide, xs) {
* 计算选择正确的竞合线索
* @param userId
*/
export
function
checkJinhe
(
userId
)
{
export
async
function
checkJinhe
(
userId
)
{
/**获取细分线索 */
let
xfclueJson
=
getJsonData
(
"json/细分线索.json"
);
let
clueJson
=
getJsonData
(
"json/竞合.json"
)[
userId
]
;
let
xfclueJson
=
await
getUserJsonData
(
"细分线索.json"
,
userId
);
let
clueJson
=
await
getUserJsonData
(
"竞合.json"
,
userId
)
;
let
sumClue
=
0
;
//线索总数
let
rightClue
=
0
;
//选对线索数
...
...
@@ -103,10 +103,10 @@ export function checkJinhe(userId) {
/**计算分数 */
// score = rightClue/sumClue*(1/5)*20;
score
=
(
rightClue
/
sumClue
)
*
20
;
let
submitJsonData
=
getJsonData
(
"json/提交分数.json"
);
let
submitJsonData
=
await
getUserJsonData
(
"提交分数.json"
,
userId
);
let
submitScore
=
submitJsonData
;
submitScore
[
userId
][
"竞合"
]
=
score
;
changeJsonData
(
"json/提交分数.json"
,
submitScore
);
submitScore
[
"竞合"
]
=
score
;
await
changeUserJsonData
(
"提交分数.json"
,
userId
,
submitScore
);
return
successResult
();
}
...
...
src/biz/play.ts
View file @
3f46088c
...
...
@@ -3,13 +3,11 @@
*/
import
{
HARITYPE
,
NOWCLUE
}
from
"../config/enum"
;
import
{
ERRORENUM
}
from
"../config/errorEnum"
;
import
{
systemConfig
}
from
"../config/serverConfig"
;
import
{
guyongTableData
,
juqingTableData
,
NPCTableData
,
xiansuoTableData
}
from
"../data/table/tableData"
;
import
{
successErrorResult
,
successResult
}
from
"../tools/systemTools"
;
import
{
BizError
}
from
"../util/bizError"
;
import
{
changeJsonData
,
getJsonData
}
from
"../util/tools"
;
import
{
addAllClue
,
xfxxClue
}
from
"./clue"
;
import
{
changeUserJsonData
,
getJsonData
,
getUserJsonData
}
from
"../util/tools"
;
import
{
xfxxClue
}
from
"./clue"
;
/**
...
...
@@ -19,21 +17,21 @@ import { addAllClue, xfxxClue } from "./clue";
* @param dhId 对话id(后置剧情id)
* @returns
*/
export
function
getPlayData
(
userId
:
string
,
type
:
string
,
playId
:
string
,
dhId
:
string
)
{
let
allClueJson
=
getJsonData
(
"json/基础数据.json"
);
let
hireData
=
getJsonData
(
"json/雇佣选择.json"
);
export
async
function
getPlayData
(
userId
:
string
,
type
:
string
,
playId
:
string
,
dhId
:
string
)
{
let
allClueJson
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
let
hireData
=
await
getUserJsonData
(
"雇佣选择.json"
,
userId
);
let
hireWorker
=
hireData
;
let
duihua
=
playId
;
if
(
playId
==
"S021"
||
playId
==
"S025"
)
{
duihua
=
`
${
playId
}
_1`
;
if
(
allClueJson
[
userId
][
"酒馆剧情"
]
>
HARITYPE
.
未开始
)
{
duihua
=
`
${
playId
}
_
${
allClueJson
[
userId
][
"酒馆剧情"
]}
`
;
if
(
allClueJson
[
"酒馆剧情"
]
>
HARITYPE
.
未开始
)
{
duihua
=
`
${
playId
}
_
${
allClueJson
[
"酒馆剧情"
]}
`
;
}
}
/**获取玩家昵称 */
let
userData
=
getJsonData
(
"json/
用户.json"
);
let
userData
=
await
getJsonData
(
"
用户.json"
);
let
name
=
""
;
userData
.
forEach
(
info
=>
{
if
(
info
.
userId
==
userId
)
{
...
...
@@ -47,7 +45,7 @@ export function getPlayData(userId:string, type:string, playId:string, dhId:stri
let
playData
=
excelData
[
duihua
].
dataList
;
let
nextStory
:
any
=
{};
playData
.
forEach
(
info
=>
{
playData
.
forEach
(
async
info
=>
{
let
{
dhid
,
dh
,
jqlx
,
hzjqid
,
glnpc
,
glxsid
}
=
info
;
if
(
dhid
==
dhId
)
{
...
...
@@ -57,9 +55,9 @@ export function getPlayData(userId:string, type:string, playId:string, dhId:stri
if
(
nextStory
.
dhlx
==
"玩家"
)
nextStory
.
glnpc
=
name
;
//记录当前走到的剧情
plotClues
(
userId
,
type
,
playId
,
dhId
,
glxsid
);
await
plotClues
(
userId
,
type
,
playId
,
dhId
,
glxsid
);
//剧情走完添加对应用户的对应线索数据
addAllClueByPlan
(
userId
,
glxsid
);
a
wait
a
ddAllClueByPlan
(
userId
,
glxsid
);
}
});
...
...
@@ -69,15 +67,12 @@ export function getPlayData(userId:string, type:string, playId:string, dhId:stri
nextStory
.
hzjqid
=
JSON
.
parse
(
nextStory
.
hzjqid
);
for
(
let
i
=
0
;
i
<
nextStory
.
hzjqid
.
length
;
i
++
)
{
let
dhData
=
playData
.
find
(
s
=>
s
.
dhid
==
nextStory
.
hzjqid
[
i
]);
addAllClueByPlan
(
userId
,
dhData
.
glxsid
);
a
wait
a
ddAllClueByPlan
(
userId
,
dhData
.
glxsid
);
dhData
[
"ispop"
]
=
false
;
if
(
dhData
.
jqlx
==
"工人"
||
dhData
.
jqlx
==
"画师"
||
dhData
.
jqlx
==
"掌柜"
)
{
dhData
.
ispop
=
true
;
}
else
if
(
dhData
.
jqlx
==
"运输"
)
{
if
(
!
hireWorker
[
userId
])
hireWorker
[
userId
]
=
{};
hireWorker
[
userId
][
"运输"
]
=
dhData
.
glxsid
;
changeJsonData
(
"json/雇佣选择.json"
,
hireWorker
);
}
if
(
dhData
)
dhStory
.
push
(
dhData
);
}
nextStory
.
hzjq
=
dhStory
;
...
...
@@ -85,102 +80,27 @@ export function getPlayData(userId:string, type:string, playId:string, dhId:stri
if
(
nextStory
.
dhlx
==
"玩家"
)
nextStory
.
glnpc
=
name
;
}
/**运输选择 */
if
(
nextStory
.
glnpc
==
"邢万里"
&&
nextStory
.
hzjqid
==
"999"
)
{
if
(
!
hireWorker
)
hireWorker
=
{};
hireWorker
[
"运输"
]
=
nextStory
.
glxsid
;
await
changeUserJsonData
(
"雇佣选择.json"
,
userId
,
hireWorker
);
}
if
(
nextStory
.
hzjqid
==
'999'
)
{
xfxxClue
(
);
await
xfxxClue
(
userId
);
/**剧情完成可添加SWOT线索 */
if
(
type
==
"码头"
)
{
allClueJson
[
userId
][
"SWOT"
]
=
true
;
allClueJson
[
"SWOT"
]
=
true
;
}
else
if
(
type
==
"酒馆"
)
{
allClueJson
[
userId
][
"酒馆剧情"
]
=
HARITYPE
.
已选择
;
//酒馆剧情观看完毕、颜料瓷器已选择、SWOT已确认、工人已选择
if
(
allClueJson
[
userId
][
"酒馆剧情"
]
==
HARITYPE
.
已选择
&&
allClueJson
[
userId
][
"商行选择"
])
allClueJson
[
userId
]
[
"ROI"
]
=
true
;
allClueJson
[
"酒馆剧情"
]
=
HARITYPE
.
已选择
;
//酒馆剧情观看完毕、颜料瓷器已选择、SWOT已确认、工人已选择
、运输方式已选择
if
(
allClueJson
[
"酒馆剧情"
]
==
HARITYPE
.
已选择
&&
allClueJson
[
"商行选择"
]
&&
hireWorker
[
"运输"
])
allClueJson
[
"ROI"
]
=
true
;
}
//更新json数据
changeJsonData
(
"json/基础数据.json"
,
allClueJson
);
}
}
return
nextStory
;
}
/**
* 弃用
* 酒馆剧情
* @param type 酒馆
* @param playId SO12
* @param dhId 对话id(后置剧情id)
* @returns
*/
export
function
getJGPlayData
(
userId
:
string
,
type
:
string
,
playId
:
string
,
dhId
:
string
)
{
let
allClueJson
=
getJsonData
(
"json/基础数据.json"
);
/**获取玩家昵称 */
let
userData
=
getJsonData
(
"json/用户.json"
);
let
name
=
""
;
userData
.
forEach
(
info
=>
{
if
(
info
.
userId
==
userId
)
{
if
(
info
[
"name"
])
name
=
info
[
"name"
]
else
name
=
info
.
loginId
;
}
})
let
duihua
=
`
${
playId
}
_1`
;
if
(
allClueJson
[
userId
][
"酒馆剧情"
]
>
HARITYPE
.
未开始
)
{
duihua
=
`
${
playId
}
_
${
allClueJson
[
userId
][
"酒馆剧情"
]}
`
;
}
/**剧情完成可添加ROI线索 */
let
excelData
=
juqingTableData
(
type
,
duihua
);
if
(
!
excelData
||
Object
.
keys
(
excelData
).
length
===
0
)
return
successErrorResult
(
"该NPC暂未开通剧情"
);
//剧情走完添加对应用户的对应线索数据
let
playData
=
excelData
[
duihua
].
dataList
;
let
nextStory
:
any
=
{};
playData
.
forEach
(
info
=>
{
let
{
dhid
,
dh
,
jqlx
,
hzjqid
,
glnpc
,
glxsid
}
=
info
;
if
(
dhid
==
dhId
)
{
//根据传入的id查找对应对话
nextStory
=
info
;
nextStory
[
"img"
]
=
`
${
systemConfig
.
ipUrl
}
NPC/
${
glnpc
}
.png`
;
if
(
nextStory
.
dhlx
==
"玩家"
)
nextStory
.
glnpc
=
name
;
//记录当前走到的剧情
plotClues
(
userId
,
type
,
duihua
,
dhId
,
glxsid
);
//剧情走完添加对应用户的对应线索数据
addAllClueByPlan
(
userId
,
glxsid
);
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
allClueJson
);
}
});
if
(
nextStory
)
{
let
dhStory
=
[];
if
(
nextStory
.
jqlx
==
"选择"
)
{
nextStory
.
hzjqid
=
JSON
.
parse
(
nextStory
.
hzjqid
);
for
(
let
i
=
0
;
i
<
nextStory
.
hzjqid
.
length
;
i
++
)
{
let
dhData
=
playData
.
find
(
s
=>
s
.
dhid
==
nextStory
.
hzjqid
[
i
]);
dhData
[
"ispop"
]
=
false
;
if
(
dhData
.
jqlx
==
"工人"
||
dhData
.
jqlx
==
"画师"
||
dhData
.
jqlx
==
"掌柜"
)
{
dhData
.
ispop
=
true
;
}
if
(
dhData
)
dhStory
.
push
(
dhData
);
}
nextStory
.
hzjq
=
dhStory
;
nextStory
.
img
=
`
${
systemConfig
.
ipUrl
}
NPC/
${
nextStory
.
glnpc
}
.png`
;
if
(
nextStory
.
dhlx
==
"玩家"
)
nextStory
.
glnpc
=
name
;
}
}
if
(
nextStory
.
hzjqid
==
'999'
)
{
xfxxClue
();
allClueJson
[
userId
][
"酒馆剧情"
]
=
HARITYPE
.
已选择
;
//酒馆剧情观看完毕、颜料瓷器已选择、SWOT已确认、工人已选择
if
(
allClueJson
[
userId
][
"酒馆剧情"
]
==
HARITYPE
.
已选择
&&
allClueJson
[
userId
][
"商行选择"
])
allClueJson
[
userId
][
"ROI"
]
=
true
;
//更新json数据
changeJsonData
(
"json/基础数据.json"
,
allClueJson
);
}
return
nextStory
;
...
...
@@ -192,7 +112,7 @@ export function getJGPlayData(userId:string, type:string, playId:string, dhId:st
* @param type
* @returns
*/
export
function
getNPCData
(
type
)
{
export
async
function
getNPCData
(
type
)
{
let
excelData
=
NPCTableData
();
let
npcData
=
excelData
[
'NPC'
].
dataList
;
...
...
@@ -211,9 +131,9 @@ export function getNPCData(type) {
/**
* 剧情相关线索
*/
export
function
plotClues
(
userId
:
string
,
type
:
string
,
playId
:
string
,
dhId
:
string
,
glxsid
:
string
)
{
export
async
function
plotClues
(
userId
:
string
,
type
:
string
,
playId
:
string
,
dhId
:
string
,
glxsid
:
string
)
{
//获取已有json数据
let
baseData
=
getJsonData
(
"json/基础数据.json"
);
let
baseData
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
let
userData
=
{};
if
(
Object
.
keys
(
baseData
).
length
===
0
)
{
//没有对应数据的情况
...
...
@@ -249,8 +169,7 @@ export function plotClues(userId:string, type:string, playId:string, dhId:string
}
}
}
else
{
//已经有对应数据
userData
=
baseData
[
userId
];
// userData["结算"] = baseData["1727399696222"]["结算"] + 50; //暂时一个剧情对话回合加50银两
userData
=
baseData
;
if
(
!
userData
[
type
])
{
userData
[
type
]
=
{};
if
(
!
userData
[
type
][
playId
])
userData
[
type
][
playId
]
=
{
"当前对话id"
:
""
,
"已获得的线索"
:[]};
...
...
@@ -294,12 +213,8 @@ export function plotClues(userId:string, type:string, playId:string, dhId:string
}
}
}
let
changeData
=
baseData
;
changeData
[
userId
]
=
userData
//更新json数据
changeJsonData
(
"json/基础数据.json"
,
changeData
);
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
userData
);
console
.
log
(
"基础数据更新成功"
);
}
...
...
@@ -309,7 +224,7 @@ export function plotClues(userId:string, type:string, playId:string, dhId:string
* @param playType 剧情类型
* @returns
*/
export
function
pubHire
(
playType
)
{
export
async
function
pubHire
(
playType
)
{
let
excelData
=
guyongTableData
();
let
hireData
=
excelData
[
'雇佣表'
].
dataList
;
...
...
@@ -334,17 +249,17 @@ export function pubHire(playType) {
* @param playType 剧情类型
* @param xsId 线索id
*/
export
function
submitHire
(
userId
,
playType
,
xsId
)
{
export
async
function
submitHire
(
userId
,
playType
,
xsId
)
{
//获取已有json数据
let
hireData
=
getJsonData
(
"json/雇佣选择.json"
);
let
hireData
=
await
getUserJsonData
(
"雇佣选择.json"
,
userId
);
let
hireWorker
=
hireData
;
let
oldxsid
=
""
;
if
(
!
hireWorker
[
userId
])
hireWorker
[
userId
]
=
{};
if
(
!
hireWorker
[
userId
][
"人工"
])
hireWorker
[
userId
]
[
"人工"
]
=
{};
else
oldxsid
=
hireWorker
[
userId
][
"人工"
][
playType
];
hireWorker
[
userId
][
"人工"
][
playType
]
=
xsId
;
if
(
!
hireWorker
)
hireWorker
=
{};
if
(
!
hireWorker
[
"人工"
])
hireWorker
[
"人工"
]
=
{};
else
oldxsid
=
hireWorker
[
"人工"
][
playType
];
hireWorker
[
"人工"
][
playType
]
=
xsId
;
changeJsonData
(
"json/雇佣选择.json"
,
hireWorker
);
await
changeUserJsonData
(
"雇佣选择.json"
,
userId
,
hireWorker
);
console
.
log
(
`雇佣
${
playType
}
添加成功,线索id
${
xsId
}
`
);
/**雇佣工人成功,扣除工资部分 */
...
...
@@ -357,22 +272,22 @@ export function submitHire(userId, playType, xsId) {
if
(
info
.
xsid
==
oldxsid
)
oldgz
=
parseInt
(
info
.
gz
);
});
//扣除雇佣工人工资
let
baseData
=
getJsonData
(
"json/基础数据.json"
);
let
jisuan
=
baseData
[
userId
][
"结算"
]
||
0
;
baseData
[
userId
][
"结算"
]
=
jisuan
+
oldgz
-
hireMoney
;
changeJsonData
(
"json/基础数据.json"
,
baseData
);
let
baseData
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
let
jisuan
=
baseData
[
"结算"
]
||
0
;
baseData
[
"结算"
]
=
jisuan
+
oldgz
-
hireMoney
;
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
baseData
);
return
successResult
();
}
/**回显雇佣工人 */
export
function
displayHire
(
userId
)
{
export
async
function
displayHire
(
userId
)
{
//获取已有json数据
let
hireData
=
getJsonData
(
"json/雇佣选择.json"
);
let
hireData
=
await
getUserJsonData
(
"雇佣选择.json"
,
userId
);
let
hireWorker
=
{};
if
(
!
hireData
[
userId
]
||
Object
.
keys
(
hireData
[
userId
]).
length
===
0
)
hireData
[
userId
]
=
{
"人工"
:{
"工人"
:
""
,
"画师"
:
""
,
"掌柜"
:
""
}};
hireWorker
=
hireData
[
userId
][
"人工"
];
if
(
!
hireData
||
Object
.
keys
(
hireData
).
length
===
0
)
hireData
=
{
"人工"
:{
"工人"
:
""
,
"画师"
:
""
,
"掌柜"
:
""
}};
hireWorker
=
hireData
[
"人工"
];
return
hireWorker
;
}
...
...
@@ -383,7 +298,7 @@ export function displayHire(userId) {
* @param type 类型
* @returns
*/
export
function
rawMaterial
(
type
)
{
export
async
function
rawMaterial
(
type
)
{
let
excelData
=
guyongTableData
();
let
rawMaterialData
=
excelData
[
'原材料'
].
dataList
;
...
...
@@ -407,21 +322,21 @@ export function rawMaterial(type) {
* @param type 剧情类型
* @param xsId 线索id
*/
export
function
submitRawMaterial
(
userId
,
type
,
xsId
)
{
export
async
function
submitRawMaterial
(
userId
,
type
,
xsId
)
{
//获取已有json数据
let
rawMaterialData
=
getJsonData
(
"json/雇佣选择.json"
);
let
rawMaterialData
=
await
getUserJsonData
(
"雇佣选择.json"
,
userId
);
let
rawMaterial
=
rawMaterialData
;
let
oldxsid
=
""
;
if
(
!
rawMaterial
[
userId
])
rawMaterial
[
userId
]
=
{};
if
(
!
rawMaterial
[
userId
][
"原材料"
])
rawMaterial
[
userId
]
[
"原材料"
]
=
{};
else
oldxsid
=
rawMaterial
[
userId
][
"原材料"
][
type
];
if
(
!
rawMaterial
)
rawMaterial
=
{};
if
(
!
rawMaterial
[
"原材料"
])
rawMaterial
[
"原材料"
]
=
{};
else
oldxsid
=
rawMaterial
[
"原材料"
][
type
];
rawMaterial
[
userId
][
"原材料"
][
type
]
=
xsId
;
rawMaterial
[
"原材料"
][
type
]
=
xsId
;
//运输类型默认水路 todo
rawMaterial
[
userId
]
[
"运输"
]
=
"C037"
;
// rawMaterial
["运输"] = "C037";
changeJsonData
(
"json/雇佣选择.json"
,
rawMaterial
);
await
changeUserJsonData
(
"雇佣选择.json"
,
userId
,
rawMaterial
);
console
.
log
(
`选择
${
type
}
添加成功,线索id
${
xsId
}
`
);
/**购买原材料成功,扣除原材料价格 */
...
...
@@ -435,14 +350,14 @@ export function submitRawMaterial(userId, type, xsId) {
});
//扣除100个瓷器和颜料的价格 todo
let
baseData
=
getJsonData
(
"json/基础数据.json"
);
let
jsje
=
baseData
[
userId
][
"结算"
]
||
0
;
baseData
[
userId
][
"结算"
]
=
jsje
+
oldgz
*
1000
-
rawMaterialMoney
*
1000
;
let
baseData
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
let
jsje
=
baseData
[
"结算"
]
||
0
;
baseData
[
"结算"
]
=
jsje
+
oldgz
*
1000
-
rawMaterialMoney
*
1000
;
baseData
[
userId
][
"商行选择"
]
=
true
;
baseData
[
"商行选择"
]
=
true
;
//酒馆剧情观看完毕、颜料瓷器已选择、SWOT已确认、工人已选择
if
(
baseData
[
userId
][
"酒馆剧情"
]
==
HARITYPE
.
已选择
&&
baseData
[
userId
][
"商行选择"
])
baseData
[
userId
]
[
"ROI"
]
=
true
;
changeJsonData
(
"json/基础数据.json"
,
baseData
);
if
(
baseData
[
"酒馆剧情"
]
==
HARITYPE
.
已选择
&&
baseData
[
"商行选择"
])
baseData
[
"ROI"
]
=
true
;
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
baseData
);
return
successResult
();
}
...
...
@@ -453,12 +368,12 @@ export function submitRawMaterial(userId, type, xsId) {
* @param userId
* @returns
*/
export
function
displayRawMaterial
(
userId
)
{
export
async
function
displayRawMaterial
(
userId
)
{
//获取已有json数据
let
hireData
=
getJsonData
(
"json/雇佣选择.json"
);
let
hireData
=
await
getUserJsonData
(
"雇佣选择.json"
,
userId
);
let
hireWorker
=
{};
if
(
!
hireData
[
userId
]
||
Object
.
keys
(
hireData
[
userId
]).
length
===
0
)
hireData
[
userId
]
=
{
"原材料"
:{
"瓷器"
:
""
,
"颜料"
:
""
}};
hireWorker
=
hireData
[
userId
][
"原材料"
];
if
(
!
hireData
||
Object
.
keys
(
hireData
).
length
===
0
)
hireData
=
{
"原材料"
:{
"瓷器"
:
""
,
"颜料"
:
""
}};
hireWorker
=
hireData
[
"原材料"
];
return
hireWorker
;
}
...
...
@@ -468,14 +383,14 @@ export function displayRawMaterial(userId) {
* 广州府是否第一次阅读
* @param userId
*/
export
function
getGzf
(
userId
)
{
export
async
function
getGzf
(
userId
)
{
//获取已有json数据
let
baseJsonData
=
getJsonData
(
"json/基础数据.json"
);
let
firstGzf
=
baseJsonData
[
userId
][
"广州府介绍"
];
let
baseJsonData
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
let
firstGzf
=
baseJsonData
[
"广州府介绍"
];
let
writeBaseAll
=
baseJsonData
;
writeBaseAll
[
userId
][
"广州府介绍"
]
=
false
;
writeBaseAll
[
"广州府介绍"
]
=
false
;
changeJsonData
(
"json/基础数据.json"
,
writeBaseAll
);
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
writeBaseAll
);
return
{
firstGzf
};
}
...
...
@@ -485,37 +400,36 @@ export function getGzf(userId) {
* 广州府介绍
* @param userId
*/
export
function
getIntroduceGzf
(
userId
)
{
export
async
function
getIntroduceGzf
(
userId
)
{
//获取已有json数据
let
baseJsonData
=
getJsonData
(
"json/
广州府介绍.json"
);
let
baseJsonData
=
await
getJsonData
(
"
广州府介绍.json"
);
//获取已有json数据
let
baseData
=
getJsonData
(
"json/全部线索.json"
);
let
baseData
=
await
getUserJsonData
(
"全部线索.json"
,
userId
);
/**获取表格数据 */
let
excelData
=
xiansuoTableData
();
let
clueExcelData
=
excelData
[
"线索表"
].
dataList
;
let
userData
=
baseData
;
if
(
Object
.
keys
(
baseData
).
length
===
0
)
{
//没有对应数据的情况
userData
[
userId
]
=
{};
}
//没有对应数据的情况
if
(
!
baseData
||
Object
.
keys
(
baseData
).
length
===
0
)
userData
=
{};
clueExcelData
.
forEach
(
info
=>
{
let
{
xsid
,
xsnr
,
xslx
,
xslxxf
,
dhgl
,
sfbx
}
=
info
;
if
(
!
userData
[
userId
])
userData
[
userId
]
=
{};
if
(
!
userData
[
userId
][
xslx
])
userData
[
userId
]
[
xslx
]
=
[];
if
(
!
userData
)
userData
=
{};
if
(
!
userData
[
xslx
])
userData
[
xslx
]
=
[];
//匹配线索id
if
(
dhgl
==
"开篇1"
||
dhgl
==
"开篇2"
)
{
//检查数组中是否已经有对象的xsid等于当前xsid
let
exists
=
userData
[
userId
][
xslx
].
find
(
s
=>
s
.
xsid
==
xsid
);
let
exists
=
userData
[
xslx
].
find
(
s
=>
s
.
xsid
==
xsid
);
//如果不存在,则添加该线索
if
(
!
exists
)
{
userData
[
userId
][
xslx
].
push
({
xsid
,
xsnr
,
isChoice
:
false
,
sfbx
});
userData
[
xslx
].
push
({
xsid
,
xsnr
,
isChoice
:
false
,
sfbx
});
}
}
})
changeJsonData
(
"json/全部线索.json"
,
userData
);
await
changeUserJsonData
(
"全部线索.json"
,
userId
,
userData
);
console
.
log
(
"已添加全部线索"
);
return
baseJsonData
;
...
...
@@ -526,11 +440,11 @@ export function getIntroduceGzf(userId) {
* 是否能进入酒馆剧情
* @param userId
*/
export
function
firstPubHire
(
userId
)
{
let
baseJsonData
=
getJsonData
(
"json/基础数据.json"
);
export
async
function
firstPubHire
(
userId
)
{
let
baseJsonData
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
let
isEnabled
=
false
;
/**判断是否确认SWOT线索 */
if
(
baseJsonData
[
userId
][
"酒馆剧情"
]
>
HARITYPE
.
未开始
)
isEnabled
=
true
;
if
(
baseJsonData
[
"酒馆剧情"
]
>
HARITYPE
.
未开始
)
isEnabled
=
true
;
return
{
isEnabled
};
}
...
...
@@ -541,18 +455,17 @@ export function firstPubHire(userId) {
* @param userId
* @param glxsid
*/
export
function
addAllClueByPlan
(
userId
,
glxsid
)
{
export
async
function
addAllClueByPlan
(
userId
,
glxsid
)
{
//获取已有json数据
let
baseData
=
getJsonData
(
"json/全部线索.json"
);
let
baseData
=
await
getUserJsonData
(
"全部线索.json"
,
userId
);
/**获取表格数据 */
let
excelData
=
xiansuoTableData
();
let
clueExcelData
=
excelData
[
"线索表"
].
dataList
;
let
userData
=
baseData
;
if
(
Object
.
keys
(
baseData
).
length
===
0
)
{
//没有对应数据的情况
userData
[
userId
]
=
{};
}
//没有对应数据的情况
if
(
Object
.
keys
(
baseData
).
length
===
0
)
userData
=
{};
/**关联的线索 */
if
(
glxsid
)
{
let
fruitsEmpty
;
...
...
@@ -564,10 +477,10 @@ export function addAllClueByPlan(userId, glxsid) {
}
let
distinctMap
=
{};
//用于去重线索的map
if
(
!
userData
[
userId
])
userData
[
userId
]
=
{};
for
(
let
xslx
in
userData
[
userId
]
)
{
if
(
!
userData
)
userData
=
{};
for
(
let
xslx
in
userData
)
{
distinctMap
[
xslx
]
=
{};
userData
[
userId
][
xslx
].
forEach
(
info
=>
{
userData
[
xslx
].
forEach
(
info
=>
{
let
{
xsid
}
=
info
;
distinctMap
[
xslx
][
xsid
]
=
info
;
});
...
...
@@ -579,17 +492,16 @@ export function addAllClueByPlan(userId, glxsid) {
//命中
if
(
distinctMap
[
xslx
][
xsid
])
return
;
//去重之后的并且需要添加到用户里面的
if
(
!
userData
[
userId
])
userData
[
userId
]
=
{};
if
(
!
userData
[
userId
][
xslx
])
userData
[
userId
][
xslx
]
=
[];
userData
[
userId
][
info
.
xslx
].
push
({
xsid
,
xsnr
,
isChoice
:
false
,
sfbx
});
//去重之后的并且需要添加
if
(
!
userData
[
xslx
])
userData
[
xslx
]
=
[];
userData
[
info
.
xslx
].
push
({
xsid
,
xsnr
,
isChoice
:
false
,
sfbx
});
}
});
}
changeJsonData
(
"json/全部线索.json"
,
userData
);
await
changeUserJsonData
(
"全部线索.json"
,
userId
,
userData
);
console
.
log
(
"已添加全部线索"
);
}
...
...
src/biz/roi.ts
View file @
3f46088c
...
...
@@ -10,7 +10,7 @@
import
{
NOWCLUE
}
from
"../config/enum"
;
import
{
guyongTableData
}
from
"../data/table/tableData"
;
import
{
successResult
}
from
"../tools/systemTools"
;
import
{
change
JsonData
,
get
JsonData
}
from
"../util/tools"
;
import
{
change
UserJsonData
,
getJsonData
,
getUser
JsonData
}
from
"../util/tools"
;
/**
...
...
@@ -18,15 +18,15 @@ import { changeJsonData, getJsonData } from "../util/tools";
* @param subdivide 细分线索类型【R、O、I】
* @param xs [{xsid:"", xsnr:""}, ...]
*/
export
function
submitROIClue
(
userId
,
subdivide
,
xs
)
{
let
jsonData
=
getJsonData
(
"json/ROI.json"
);
let
baseClueJson
=
getJsonData
(
"json/基础数据.json"
);
export
async
function
submitROIClue
(
userId
,
subdivide
,
xs
)
{
let
jsonData
=
await
getUserJsonData
(
"ROI.json"
,
userId
);
let
baseClueJson
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
/**处理确认选择的线索 */
let
ROIClueData
=
jsonData
;
//没有对应用户数据先添加一个基础格式,有的话直接push
if
(
!
ROIClueData
[
userId
]
||
Object
.
keys
(
ROIClueData
[
userId
]
).
length
===
0
)
{
ROIClueData
[
userId
]
=
{
if
(
!
ROIClueData
||
Object
.
keys
(
ROIClueData
).
length
===
0
)
{
ROIClueData
=
{
"isSubmit"
:
false
,
"R"
:
[],
"I"
:
[]
...
...
@@ -35,25 +35,25 @@ import { changeJsonData, getJsonData } from "../util/tools";
//isSubmit:false【未提交】、true【提交】
/**当前线索类型未提交时,可以修改添加线索 */
if
(
!
ROIClueData
[
userId
][
"isSubmit"
])
{
if
(
!
ROIClueData
[
"isSubmit"
])
{
for
(
let
i
=
0
;
i
<
xs
.
length
;
i
++
)
{
// let xsInfo = xs[i];
ROIClueData
[
userId
][
subdivide
].
push
(
xs
[
i
]);
ROIClueData
[
subdivide
].
push
(
xs
[
i
]);
}
changeJsonData
(
"json/ROI.json"
,
ROIClueData
);
await
changeUserJsonData
(
"ROI.json"
,
userId
,
ROIClueData
);
console
.
log
(
"添加ROI线索成功"
);
}
else
{
console
.
log
(
"线索已提交,无法重复提交"
);
}
/**修改全部线索.json的对应线索为已选择 isChoice:true */
let
allClueJson
=
getJsonData
(
"json/全部线索.json"
);
let
allClueJson
=
await
getUserJsonData
(
"全部线索.json"
,
userId
);
let
allClueData
=
allClueJson
;
xs
.
forEach
(
info
=>
{
let
{
xsid
,
xsnr
}
=
info
;
for
(
let
key
in
allClueData
[
userId
]
)
{
allClueData
[
userId
][
key
].
forEach
(
thisClue
=>
{
for
(
let
key
in
allClueData
)
{
allClueData
[
key
].
forEach
(
thisClue
=>
{
if
(
xsid
==
thisClue
.
xsid
)
thisClue
.
isChoice
=
true
;
})
}
...
...
@@ -69,19 +69,19 @@ import { changeJsonData, getJsonData } from "../util/tools";
if
(
info
.
xsid
==
xsid
)
ciqiMoney
=
info
.
sj
;
});
//加上定制瓷器金额
baseClueJson
[
userId
][
"结算"
]
=
baseClueJson
[
userId
]
[
"结算"
]
+
ciqiMoney
*
1000
;
baseClueJson
[
"结算"
]
=
baseClueJson
[
"结算"
]
+
ciqiMoney
*
1000
;
}
});
changeJsonData
(
"json/全部线索.json"
,
allClueData
);
await
changeUserJsonData
(
"全部线索.json"
,
userId
,
allClueData
);
/**ROI线索选择完成可添加竞合线索 */
baseClueJson
[
userId
][
"竞合"
]
=
true
;
baseClueJson
[
userId
][
"当前线索确认"
]
=
NOWCLUE
.
ROI
;
baseClueJson
[
"竞合"
]
=
true
;
baseClueJson
[
"当前线索确认"
]
=
NOWCLUE
.
ROI
;
//更新json数据
changeJsonData
(
"json/基础数据.json"
,
baseClueJson
);
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
baseClueJson
);
return
successResult
();
}
...
...
@@ -91,10 +91,10 @@ import { changeJsonData, getJsonData } from "../util/tools";
* 计算选择正确的ROI线索
* @param userId
*/
export
function
checkROI
(
userId
)
{
let
gygrJson
=
getJsonData
(
"json/雇佣选择.json"
);
//获取雇佣工人表
let
雇佣选择
=
gygrJson
[
userId
]
;
let
cqzzJson
=
getJsonData
(
"json/
瓷器制造.json"
);
export
async
function
checkROI
(
userId
)
{
let
gygrJson
=
await
getUserJsonData
(
"雇佣选择.json"
,
userId
);
//获取雇佣工人表
let
雇佣选择
=
gygrJson
;
let
cqzzJson
=
await
getJsonData
(
"
瓷器制造.json"
);
/**
* 计算工人、画师、掌柜一起的人员成本
...
...
@@ -126,8 +126,9 @@ export function checkROI(userId) {
/**
* 计算运输成本
*/
let
运输成本
=
cqzzJson
[
"运输成本"
];
let
yscb
=
运输成本
[
雇佣选择
[
"运输"
]].
xjb
;
let
运输成本
=
cqzzJson
[
"运输成本"
];
let
yscb
=
0
;
if
(
运输成本
[
雇佣选择
[
"运输"
]].
xjb
)
yscb
=
运输成本
[
雇佣选择
[
"运输"
]].
xjb
;
let
净利润
=
(
瓷器利润
-
rycb
-
yscb
)
/
瓷器单价
;
...
...
@@ -138,10 +139,10 @@ export function checkROI(userId) {
if
(
净利润
>
20
&&
净利润
<
25
)
score
=
10
;
if
(
净利润
<
20
)
score
=
0
;
let
submitJsonData
=
getJsonData
(
"json/提交分数.json"
);
let
submitJsonData
=
await
getUserJsonData
(
"提交分数.json"
,
userId
);
let
submitScore
=
submitJsonData
;
submitScore
[
userId
][
"ROI"
]
=
score
;
changeJsonData
(
"json/提交分数.json"
,
submitScore
);
submitScore
[
"ROI"
]
=
score
;
await
changeUserJsonData
(
"提交分数.json"
,
userId
,
submitScore
);
return
successResult
();
}
...
...
src/biz/swot.ts
View file @
3f46088c
...
...
@@ -9,7 +9,7 @@
import
{
HARITYPE
,
NOWCLUE
}
from
"../config/enum"
;
import
{
successResult
}
from
"../tools/systemTools"
;
import
{
change
JsonData
,
get
JsonData
}
from
"../util/tools"
;
import
{
change
UserJsonData
,
getUser
JsonData
}
from
"../util/tools"
;
/**
...
...
@@ -17,14 +17,14 @@ import { changeJsonData, getJsonData } from "../util/tools";
* @param subdivide 细分线索类型【S、W、O、T】
* @param xs [{xsid:"", xsnr:""}, ...]
*/
export
function
submitSWOTClue
(
userId
,
subdivide
,
xs
)
{
let
jsonData
=
getJsonData
(
"json/SWOT.json"
);
export
async
function
submitSWOTClue
(
userId
,
subdivide
,
xs
)
{
let
jsonData
=
await
getUserJsonData
(
"SWOT.json"
,
userId
);
/**处理确认选择的线索 */
let
SWOTClueData
=
jsonData
;
//没有对应用户数据先添加一个基础格式,有的话直接push
if
(
!
SWOTClueData
[
userId
]
||
Object
.
keys
(
SWOTClueData
[
userId
]
).
length
===
0
)
{
SWOTClueData
[
userId
]
=
{
if
(
!
SWOTClueData
||
Object
.
keys
(
SWOTClueData
).
length
===
0
)
{
SWOTClueData
=
{
"isSubmit"
:
false
,
"S"
:
[],
"W"
:
[],
...
...
@@ -35,36 +35,36 @@ import { changeJsonData, getJsonData } from "../util/tools";
//isSubmit:false【未提交】、true【提交】
/**当前线索类型未提交时,可以修改添加线索 */
if
(
!
SWOTClueData
[
userId
][
"isSubmit"
])
{
if
(
!
SWOTClueData
[
"isSubmit"
])
{
for
(
let
i
=
0
;
i
<
xs
.
length
;
i
++
)
{
// let xsInfo = xs[i];
SWOTClueData
[
userId
][
subdivide
].
push
(
xs
[
i
]);
SWOTClueData
[
subdivide
].
push
(
xs
[
i
]);
}
changeJsonData
(
"json/SWOT.json"
,
SWOTClueData
);
await
changeUserJsonData
(
"SWOT.json"
,
userId
,
SWOTClueData
);
console
.
log
(
"添加SWOT线索成功"
);
}
else
{
console
.
log
(
"线索已提交,无法重复提交"
);
}
/**修改全部线索.json的对应线索为已选择 isChoice:true */
let
allClueJson
=
getJsonData
(
"json/全部线索.json"
);
let
allClueJson
=
await
getUserJsonData
(
"全部线索.json"
,
userId
);
let
allClueData
=
allClueJson
;
xs
.
forEach
(
info
=>
{
let
{
xsid
,
xsnr
}
=
info
;
for
(
let
key
in
allClueData
[
userId
]
)
{
allClueData
[
userId
][
key
].
forEach
(
thisClue
=>
{
for
(
let
key
in
allClueData
)
{
allClueData
[
key
].
forEach
(
thisClue
=>
{
if
(
xsid
==
thisClue
.
xsid
)
thisClue
.
isChoice
=
true
;
})
}
});
changeJsonData
(
"json/全部线索.json"
,
allClueData
);
await
changeUserJsonData
(
"全部线索.json"
,
userId
,
allClueData
);
let
baseJsonData
=
getJsonData
(
"json/基础数据.json"
);
baseJsonData
[
userId
][
"当前线索确认"
]
=
NOWCLUE
.
SWOT
;
if
(
baseJsonData
[
userId
][
"酒馆剧情"
]
<
HARITYPE
.
已开始
)
baseJsonData
[
userId
]
[
"酒馆剧情"
]
=
HARITYPE
.
已开始
;
changeJsonData
(
"json/基础数据.json"
,
baseJsonData
);
let
baseJsonData
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
baseJsonData
[
"当前线索确认"
]
=
NOWCLUE
.
SWOT
;
if
(
baseJsonData
[
"酒馆剧情"
]
<
HARITYPE
.
已开始
)
baseJsonData
[
"酒馆剧情"
]
=
HARITYPE
.
已开始
;
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
baseJsonData
);
return
successResult
();
}
...
...
@@ -74,10 +74,10 @@ import { changeJsonData, getJsonData } from "../util/tools";
* 计算选择正确的SWOT线索
* @param userId
*/
export
function
checkSWOT
(
userId
)
{
export
async
function
checkSWOT
(
userId
)
{
/**获取细分线索 */
let
xfclueJson
=
getJsonData
(
"json/细分线索.json"
);
let
clueJson
=
getJsonData
(
"json/SWOT.json"
)[
userId
]
;
let
xfclueJson
=
await
getUserJsonData
(
"细分线索.json"
,
userId
);
let
clueJson
=
await
getUserJsonData
(
"SWOT.json"
,
userId
)
;
let
sumClue
=
0
;
//线索总数
let
rightClue
=
0
;
//选对线索数
...
...
@@ -100,10 +100,10 @@ export function checkSWOT(userId) {
let
score
=
0
;
// score = rightClue/sumClue*(1/4)*50;
score
=
(
rightClue
/
sumClue
)
*
50
;
let
submitJsonData
=
getJsonData
(
"json/提交分数.json"
);
let
submitJsonData
=
await
getUserJsonData
(
"提交分数.json"
,
userId
);
let
submitScore
=
submitJsonData
;
submitScore
[
userId
][
"SWOT"
]
=
score
;
changeJsonData
(
"json/提交分数.json"
,
submitScore
);
submitScore
[
"SWOT"
]
=
score
;
await
changeUserJsonData
(
"提交分数.json"
,
userId
,
submitScore
);
return
successResult
();
}
...
...
src/biz/task.ts
View file @
3f46088c
...
...
@@ -4,7 +4,7 @@
import
{
HARITYPE
,
NOWCLUE
}
from
"../config/enum"
;
import
{
guyongTableData
,
xiansuoTableData
}
from
"../data/table/tableData"
;
import
{
changeJsonData
,
get
JsonData
}
from
"../util/tools"
;
import
{
addJson
,
changeJsonData
,
changeUserJsonData
,
getJsonData
,
getUser
JsonData
}
from
"../util/tools"
;
/**
...
...
@@ -12,36 +12,30 @@ import { changeJsonData, getJsonData } from "../util/tools";
* 基础数据没有的话也写入
* todo线索改为剧情走过才添加
*/
export
function
initAllClue
(
userId
)
{
let
excelData
=
xiansuoTableData
(
);
let
clueExcelData
=
excelData
[
"线索表"
].
dataList
;
export
async
function
initAllClue
(
userId
)
{
let
baseJsonData
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
let
submitJsonData
=
await
getUserJsonData
(
"提交分数.json"
,
userId
)
;
let
userJsonData
=
getJsonData
(
"json/用户.json"
);
let
allClueJsonData
=
getJsonData
(
"json/全部线索.json"
);
let
baseJsonData
=
getJsonData
(
"json/基础数据.json"
);
let
submitJsonData
=
getJsonData
(
"json/提交分数.json"
);
let
writeClueAll
=
allClueJsonData
;
let
writeBaseAll
=
baseJsonData
;
let
submitClue
=
submitJsonData
;
/**如果登录的账号没有全部线索数据,则写入json
* 弃用,改为走过相关剧情添加对应线索
*/
// if (!allClueJsonData
[userId] || Object.keys(allClueJsonData[userId]
).length === 0) {
// writeClueAll
[userId]
= {};
// if (!allClueJsonData
|| Object.keys(allClueJsonData
).length === 0) {
// writeClueAll = {};
// clueExcelData.forEach( info => {
// let {xsid, xsnr, xslx, xslxxf, sfbx} = info;
// if (!writeClueAll[
userId][xslx]) writeClueAll[userId]
[xslx] = [];
// writeClueAll[
userId][
xslx].push({xsid, xsnr, isChoice:false, sfbx});
// if (!writeClueAll[
xslx]) writeClueAll
[xslx] = [];
// writeClueAll[xslx].push({xsid, xsnr, isChoice:false, sfbx});
// })
// //写入json
//
changeJsonData("json/全部线索.json"
, writeClueAll);
//
await changeUserJsonData("全部线索.json", userId
, writeClueAll);
// }
/**如果登录的账号没有基础数据,则写入json */
if
(
!
baseJsonData
[
userId
]
||
Object
.
keys
(
baseJsonData
[
userId
]
).
length
===
0
)
{
writeBaseAll
[
userId
]
=
{
if
(
!
baseJsonData
||
Object
.
keys
(
baseJsonData
).
length
===
0
)
{
writeBaseAll
=
{
"初始资金"
:
500
,
"天数"
:
0
,
"结算"
:
500
,
...
...
@@ -55,17 +49,17 @@ export function initAllClue(userId) {
"竞合"
:
false
}
//写入json
changeJsonData
(
"json/基础数据.json"
,
writeBaseAll
);
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
writeBaseAll
);
}
/**如果登录的账号没有初始化分数数据,则写入json */
if
(
!
submitJsonData
[
userId
]
||
Object
.
keys
(
submitJsonData
[
userId
]
).
length
===
0
)
{
submitClue
[
userId
]
=
{
if
(
!
submitJsonData
||
Object
.
keys
(
submitJsonData
).
length
===
0
)
{
submitClue
=
{
SWOT
:
0
,
ROI
:
0
,
竞合
:
0
};
//写入json
changeJsonData
(
"json/提交分数.json"
,
submitClue
);
await
changeUserJsonData
(
"提交分数.json"
,
userId
,
submitClue
);
}
}
...
...
@@ -73,7 +67,7 @@ export function initAllClue(userId) {
/**
* 初始化制作瓷器成本数据
*/
export
function
initCiqi
()
{
export
async
function
initCiqi
()
{
let
excelData
=
guyongTableData
();
let
雇佣
Data
=
excelData
[
'雇佣表'
].
dataList
;
let
运输
Data
=
excelData
[
'运输'
].
dataList
;
...
...
@@ -133,7 +127,7 @@ export function initCiqi() {
let
成本
=
{
瓷器
,
人员成本
,
运输成本
}
changeJsonData
(
"json/
瓷器制造.json"
,
成本
);
await
changeJsonData
(
"
瓷器制造.json"
,
成本
);
}
...
...
@@ -142,16 +136,16 @@ export function initCiqi() {
* 登录开始计算 30分钟加一天
* @param userId
*/
export
function
gameLoop
(
userId
)
{
let
baseJsonData
=
getJsonData
(
"json/基础数据.json"
);
// let baseData = baseJsonData[userId];
baseJsonData
[
userId
][
"天数"
]
++
;
export
async
function
gameLoop
(
userId
)
{
let
baseJsonData
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
// let baseData = baseJsonData;
if
(
baseJsonData
)
baseJsonData
[
"天数"
]
++
;
//60000毫秒 = 1分钟,设定30分钟游戏内天数+1
setTimeout
(
gameLoop
,
60000
*
30
,
userId
);
setTimeout
(
await
gameLoop
,
60000
*
30
,
userId
);
changeJsonData
(
"json/基础数据.json"
,
baseJsonData
);
await
changeUserJsonData
(
"基础数据.json"
,
userId
,
baseJsonData
);
}
...
...
src/biz/user.ts
View file @
3f46088c
...
...
@@ -7,7 +7,7 @@ import { ERRORENUM } from "../config/errorEnum";
import
{
xiansuoTableData
}
from
"../data/table/tableData"
;
import
{
successErrorResult
,
successResult
}
from
"../tools/systemTools"
;
import
{
BizError
}
from
"../util/bizError"
;
import
{
change
JsonData
,
getJsonData
}
from
"../util/tools"
;
import
{
change
UserJsonData
,
getUserJsonData
,
getJsonData
,
changeJsonData
,
addJson
}
from
"../util/tools"
;
import
{
gameLoop
,
initAllClue
}
from
"./task"
;
let
fs
=
require
(
'fs'
);
let
path
=
require
(
'path'
);
...
...
@@ -17,26 +17,26 @@ let path = require('path');
* @param loginId 账号
* @param pwd 密码
*/
export
function
login
(
loginId
,
pwd
)
{
let
userData
=
getJsonData
(
"json/
用户.json"
);
export
async
function
login
(
loginId
,
pwd
)
{
let
userData
=
await
getJsonData
(
"
用户.json"
);
let
dataInfo
=
{};
/**判断是否有对应账号 */
let
hasUser
=
userData
.
some
(
item
=>
item
.
loginId
===
loginId
);
if
(
!
hasUser
)
throw
new
BizError
(
ERRORENUM
.
账号不存在
);
let
firstLogin
=
false
;
userData
.
forEach
(
info
=>
{
initAllClue
(
info
.
userId
);
for
(
let
i
=
0
;
i
<
userData
.
length
;
i
++
)
{
let
info
=
userData
[
i
];
if
(
info
.
loginId
==
loginId
)
{
await
addJson
(
info
.
userId
);
if
(
info
.
pwd
!=
pwd
)
throw
new
BizError
(
ERRORENUM
.
账号或密码错误
);
await
initAllClue
(
info
.
userId
);
if
(
!
info
.
name
)
firstLogin
=
true
;
dataInfo
=
{
userId
:
info
.
userId
,
loginId
:
info
.
loginId
,
firstLogin
};
gameLoop
(
info
.
userId
);
await
gameLoop
(
info
.
userId
);
}
// dataInfo["firstlogin"] = initAllClue(info.userId);
})
}
return
dataInfo
;
}
...
...
@@ -47,8 +47,8 @@ export function login(loginId, pwd) {
* @param loginId 账号
* @param pwd 密码
*/
export
function
register
(
loginId
,
pwd
)
{
let
userData
=
getJsonData
(
"json/
用户.json"
);
export
async
function
register
(
loginId
,
pwd
)
{
let
userData
=
await
getJsonData
(
"
用户.json"
);
const
NowMs
=
new
Date
().
valueOf
();
...
...
@@ -60,15 +60,9 @@ export function register(loginId, pwd) {
}
);
changeJsonData
(
"json/用户.json"
,
userData
);
await
changeUserJsonData
(
"用户.json"
,
userData
,
NowMs
);
let
dirPath
=
path
.
join
(
__dirname
.
substring
(
0
,
__dirname
.
indexOf
(
"out"
)),
`json/
${
NowMs
}
`
);
try
{
fs
.
mkdirSync
(
dirPath
,
{
recursive
:
true
});
console
.
log
(
`文件夹
${
dirPath
}
已成功创建`
);
}
catch
(
err
)
{
console
.
error
(
`文件夹
${
dirPath
}
创建失败
${
err
.
message
}
`
);
}
addJson
(
NowMs
);
return
successResult
();
}
...
...
@@ -78,14 +72,14 @@ export function register(loginId, pwd) {
* 基础数据【当前天数、银两数】
* @returns
*/
export
function
getBaseData
(
userId
)
{
let
baseData
=
getJsonData
(
"json/基础数据.json"
);
export
async
function
getBaseData
(
userId
)
{
let
baseData
=
await
getUserJsonData
(
"基础数据.json"
,
userId
);
let
basicsData
=
{
day
:
0
,
tael
:
500
}
basicsData
.
day
=
baseData
[
userId
][
"天数"
]
||
0
;
// basicsData.tael = baseData[
userId][
"结算"] || 0; //todo第一幕不计算金额,直接使用500金
basicsData
.
day
=
baseData
[
"天数"
]
||
0
;
// basicsData.tael = baseData["结算"] || 0; //todo第一幕不计算金额,直接使用500金
return
basicsData
;
}
...
...
@@ -96,12 +90,12 @@ export function register(loginId, pwd) {
* @param clueType
* @returns
*/
export
function
getCount
(
userId
)
{
export
async
function
getCount
(
userId
)
{
let
excelData
=
xiansuoTableData
();
let
clueExcelData
=
excelData
[
"线索表"
].
dataList
;
let
jsonData
=
getJsonData
(
"json/全部线索.json"
);
let
clueData
=
jsonData
[
userId
]
;
let
jsonData
=
await
getUserJsonData
(
"全部线索.json"
,
userId
);
let
clueData
=
jsonData
;
let
personalData
=
{
clue
:
""
,
...
...
@@ -118,19 +112,19 @@ export function getCount(userId) {
// if (info.isChoice) clue++
// })
}
personalData
.
clue
=
`
${
allClue
}
/
${
c
lue
}
`
;
//总线索数(线索配置表里的所有线索)/当前解锁的线索数
personalData
.
clue
=
`
${
clue
}
/
${
allC
lue
}
`
;
//总线索数(线索配置表里的所有线索)/当前解锁的线索数
// 银两数 todo 第一幕不计算银两数,默认展示500金
// let baseData =
getJsonData("json/基础数据.json"
);
// personalData.tael = baseData[
userId][
"结算"];
// let baseData =
await getUserJsonData("基础数据.json", userId
);
// personalData.tael = baseData["结算"];
// 雇佣人数
let
hireData
=
getJsonData
(
"json/雇佣选择.json"
);
if
(
hireData
[
userId
]
)
{
if
(
Object
.
keys
(
hireData
[
userId
]
).
length
!=
0
)
{
if
(
!
hireData
[
userId
][
"人工"
])
hireData
[
userId
]
[
"人工"
]
=
{}
if
(
Object
.
keys
(
hireData
[
userId
][
"人工"
]).
length
!=
0
)
{
personalData
.
hire
=
Object
.
keys
(
hireData
[
userId
][
"人工"
]).
length
;
let
hireData
=
await
getUserJsonData
(
"雇佣选择.json"
,
userId
);
if
(
hireData
)
{
if
(
Object
.
keys
(
hireData
).
length
!=
0
)
{
if
(
!
hireData
[
"人工"
])
hireData
[
"人工"
]
=
{}
if
(
Object
.
keys
(
hireData
[
"人工"
]).
length
!=
0
)
{
personalData
.
hire
=
Object
.
keys
(
hireData
[
"人工"
]).
length
;
}
}
}
...
...
@@ -179,8 +173,8 @@ const nicknameRegex = /^[a-zA-Z0-9_\u4e00-\u9fa5]+$/;
* 修改昵称
* @param userId
*/
export
function
updateName
(
userId
,
name
)
{
let
userData
=
getJsonData
(
"json/
用户.json"
);
export
async
function
updateName
(
userId
,
name
)
{
let
userData
=
await
getJsonData
(
"
用户.json"
);
let
isOk
=
true
;
let
result
;
userData
.
forEach
(
info
=>
{
...
...
@@ -201,7 +195,7 @@ const nicknameRegex = /^[a-zA-Z0-9_\u4e00-\u9fa5]+$/;
})
if
(
isOk
)
{
changeJsonData
(
"
json/
用户.json"
,
userData
);
changeJsonData
(
"用户.json"
,
userData
);
result
=
successResult
();
}
...
...
src/main.ts
View file @
3f46088c
...
...
@@ -9,7 +9,7 @@ async function lanuch() {
await
initConfig
();
httpServer
.
createServer
(
systemConfig
.
port
);
console
.
log
(
'This indicates that the server is started successfully.'
);
initCiqi
();
await
initCiqi
();
// let key = crypto.randomBytes(32).toString('hex'); //"4fa9998e3be1bd3fa7b8def3969115858c6f19f9ef36e2e71f61645e9767764c"
// let iv = crypto.randomBytes(16).toString('hex'); //"db2be0c856f44e68b818ff6ef7f018c1"
// await initConfiguration();
...
...
src/routers/router.ts
View file @
3f46088c
...
...
@@ -51,11 +51,11 @@ export function setRouter(httpServer){
* @param req
* @param res
*/
function
login
(
req
,
res
)
{
async
function
login
(
req
,
res
)
{
let
reqConf
=
{
loginId
:
'String'
,
pwd
:
'String'
};
let
{
loginId
,
pwd
}
=
eccReqParamater
(
reqConf
,
req
.
body
);
let
result
=
userBiz
.
login
(
loginId
,
pwd
);
let
result
=
await
userBiz
.
login
(
loginId
,
pwd
);
res
.
success
(
result
);
}
...
...
@@ -63,11 +63,11 @@ function login(req, res) {
/**
* 修改昵称
*/
function
updateName
(
req
,
res
)
{
async
function
updateName
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
{
name
}
=
req
.
body
;
let
result
=
userBiz
.
updateName
(
userId
,
name
);
let
result
=
await
userBiz
.
updateName
(
userId
,
name
);
res
.
success
(
result
);
}
...
...
@@ -77,27 +77,27 @@ function updateName(req, res) {
* @param req
* @param res
*/
function
register
(
req
,
res
)
{
async
function
register
(
req
,
res
)
{
let
reqConf
=
{
loginId
:
'String'
,
pwd
:
'String'
};
let
{
loginId
,
pwd
}
=
eccReqParamater
(
reqConf
,
req
.
body
);
let
result
=
userBiz
.
register
(
loginId
,
pwd
);
let
result
=
await
userBiz
.
register
(
loginId
,
pwd
);
res
.
success
(
result
);
}
/**基础数据 */
function
getBaseData
(
req
,
res
)
{
async
function
getBaseData
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
userBiz
.
getBaseData
(
userId
);
let
result
=
await
userBiz
.
getBaseData
(
userId
);
res
.
success
(
result
);
}
/**统计获得线索数 */
function
getCount
(
req
,
res
)
{
async
function
getCount
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
userBiz
.
getCount
(
userId
);
let
result
=
await
userBiz
.
getCount
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -107,17 +107,11 @@ function getCount(req, res) {
* @param req
* @param res
*/
function
getPlay
(
req
,
res
)
{
async
function
getPlay
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
// 商行、SO11、对话Id(后置剧情id)
let
{
type
,
playId
,
dhId
}
=
req
.
body
;
let
result
;
// if (type == "酒馆") {
// result = playBiz.getJGPlayData(userId, type, playId, dhId);
// } else {
// }
result
=
playBiz
.
getPlayData
(
userId
,
type
,
playId
,
dhId
);
let
result
=
await
playBiz
.
getPlayData
(
userId
,
type
,
playId
,
dhId
);
res
.
success
(
result
);
}
...
...
@@ -127,11 +121,11 @@ function getPlay(req, res) {
* @param req
* @param res
*/
function
pubHire
(
req
,
res
)
{
async
function
pubHire
(
req
,
res
)
{
// 剧情type
let
{
playType
}
=
req
.
body
;
let
result
=
playBiz
.
pubHire
(
playType
);
let
result
=
await
playBiz
.
pubHire
(
playType
);
res
.
success
(
result
);
}
...
...
@@ -141,12 +135,12 @@ function pubHire(req, res) {
* @param req
* @param res
*/
function
submitHire
(
req
,
res
)
{
async
function
submitHire
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
// 剧情type
let
{
playType
,
xsId
}
=
req
.
body
;
let
result
=
playBiz
.
submitHire
(
userId
,
playType
,
xsId
);
let
result
=
await
playBiz
.
submitHire
(
userId
,
playType
,
xsId
);
res
.
success
(
result
);
}
...
...
@@ -156,10 +150,10 @@ function submitHire(req, res) {
* @param req
* @param res
*/
function
displayHire
(
req
,
res
)
{
async
function
displayHire
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
playBiz
.
displayHire
(
userId
);
let
result
=
await
playBiz
.
displayHire
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -169,11 +163,11 @@ function displayHire(req, res) {
* @param req
* @param res
*/
function
rawMaterial
(
req
,
res
)
{
async
function
rawMaterial
(
req
,
res
)
{
// 颜料、瓷器
let
{
type
}
=
req
.
body
;
let
result
=
playBiz
.
rawMaterial
(
type
);
let
result
=
await
playBiz
.
rawMaterial
(
type
);
res
.
success
(
result
);
}
...
...
@@ -183,11 +177,11 @@ function displayHire(req, res) {
* @param req
* @param res
*/
function
submitRawMaterial
(
req
,
res
)
{
async
function
submitRawMaterial
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
{
type
,
xsId
}
=
req
.
body
;
let
result
=
playBiz
.
submitRawMaterial
(
userId
,
type
,
xsId
);
let
result
=
await
playBiz
.
submitRawMaterial
(
userId
,
type
,
xsId
);
res
.
success
(
result
);
}
...
...
@@ -197,10 +191,10 @@ function submitRawMaterial(req, res) {
* @param req
* @param res
*/
function
displayRawMaterial
(
req
,
res
)
{
async
function
displayRawMaterial
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
playBiz
.
displayRawMaterial
(
userId
);
let
result
=
await
playBiz
.
displayRawMaterial
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -210,10 +204,10 @@ function displayRawMaterial(req, res) {
* @param req
* @param res
*/
function
getGzf
(
req
,
res
)
{
async
function
getGzf
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
playBiz
.
getGzf
(
userId
);
let
result
=
await
playBiz
.
getGzf
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -223,10 +217,10 @@ function getGzf(req, res) {
* @param req
* @param res
*/
function
getIntroduceGzf
(
req
,
res
)
{
async
function
getIntroduceGzf
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
playBiz
.
getIntroduceGzf
(
userId
);
let
result
=
await
playBiz
.
getIntroduceGzf
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -236,10 +230,10 @@ function getIntroduceGzf(req, res) {
* @param req
* @param res
*/
function
firstPubHire
(
req
,
res
)
{
async
function
firstPubHire
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
playBiz
.
firstPubHire
(
userId
);
let
result
=
await
playBiz
.
firstPubHire
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -249,10 +243,10 @@ function getIntroduceGzf(req, res) {
* @param req
* @param res
*/
function
getNPC
(
req
,
res
)
{
async
function
getNPC
(
req
,
res
)
{
let
{
type
}
=
req
.
body
;
let
result
=
playBiz
.
getNPCData
(
type
);
let
result
=
await
playBiz
.
getNPCData
(
type
);
res
.
success
(
result
);
}
...
...
@@ -262,10 +256,10 @@ function getNPC(req, res) {
* @param req
* @param res
*/
function
isEnabled
(
req
,
res
)
{
async
function
isEnabled
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
clueBiz
.
isEnabled
(
userId
);
let
result
=
await
clueBiz
.
isEnabled
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -276,24 +270,24 @@ function getNPC(req, res) {
* @param req
* @param res
*/
function
getClue
(
req
,
res
)
{
async
function
getClue
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
{
clueType
}
=
req
.
body
;
let
result
;
if
(
clueType
)
result
=
clueBiz
.
getClue
(
userId
,
clueType
);
else
result
=
clueBiz
.
getClue
(
userId
);
if
(
clueType
)
result
=
await
clueBiz
.
getClue
(
userId
,
clueType
);
else
result
=
await
clueBiz
.
getClue
(
userId
);
res
.
success
(
result
);
}
/**取消选中线索 */
function
delClue
(
req
,
res
)
{
async
function
delClue
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
{
clueType
,
xxType
,
xsid
}
=
req
.
body
;
let
result
=
clueBiz
.
delClue
(
userId
,
clueType
,
xxType
,
xsid
);
let
result
=
await
clueBiz
.
delClue
(
userId
,
clueType
,
xxType
,
xsid
);
res
.
success
(
result
);
}
...
...
@@ -303,10 +297,10 @@ function delClue(req, res) {
* @param req
* @param res
*/
function
checkClue
(
req
,
res
)
{
async
function
checkClue
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
clueBiz
.
checkClue
(
userId
);
let
result
=
await
clueBiz
.
checkClue
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -316,10 +310,10 @@ function checkClue(req, res) {
* @param req
* @param res
*/
function
againAnswer
(
req
,
res
)
{
async
function
againAnswer
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
clueBiz
.
againAnswer
(
userId
);
let
result
=
await
clueBiz
.
againAnswer
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -329,10 +323,10 @@ function checkClue(req, res) {
* @param req
* @param res
*/
function
againStart
(
req
,
res
)
{
async
function
againStart
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
clueBiz
.
againStart
(
userId
);
let
result
=
await
clueBiz
.
againStart
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -342,11 +336,11 @@ function checkClue(req, res) {
* @param req
* @param res
*/
function
getChoiceClue
(
req
,
res
)
{
async
function
getChoiceClue
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
{
clueType
}
=
req
.
body
;
let
result
=
clueBiz
.
getChoiceClue
(
userId
,
clueType
);
let
result
=
await
clueBiz
.
getChoiceClue
(
userId
,
clueType
);
res
.
success
(
result
);
}
...
...
@@ -356,17 +350,17 @@ function getChoiceClue(req, res) {
* @param req
* @param res
*/
function
submitClue
(
req
,
res
)
{
async
function
submitClue
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
{
clueType
,
subdivide
,
xs
}
=
req
.
body
;
let
result
;
if
(
clueType
==
"SWOT"
)
{
result
=
swotBiz
.
submitSWOTClue
(
userId
,
subdivide
,
xs
);
result
=
await
swotBiz
.
submitSWOTClue
(
userId
,
subdivide
,
xs
);
}
else
if
(
clueType
==
"ROI"
)
{
result
=
roiBiz
.
submitROIClue
(
userId
,
subdivide
,
xs
);
result
=
await
roiBiz
.
submitROIClue
(
userId
,
subdivide
,
xs
);
}
else
if
(
clueType
==
"竞合"
)
{
result
=
jinheBiz
.
submitJinheClue
(
userId
,
subdivide
,
xs
);
result
=
await
jinheBiz
.
submitJinheClue
(
userId
,
subdivide
,
xs
);
}
res
.
success
(
result
);
}
...
...
@@ -377,10 +371,10 @@ function submitClue(req, res) {
* @param req
* @param res
*/
function
checkSWOT
(
req
,
res
)
{
async
function
checkSWOT
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
swotBiz
.
checkSWOT
(
userId
);
let
result
=
await
swotBiz
.
checkSWOT
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -390,10 +384,10 @@ function checkSWOT(req, res) {
* @param req
* @param res
*/
function
checkROI
(
req
,
res
)
{
async
function
checkROI
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
roiBiz
.
checkROI
(
userId
);
let
result
=
await
roiBiz
.
checkROI
(
userId
);
res
.
success
(
result
);
}
...
...
@@ -403,10 +397,10 @@ function checkROI(req, res) {
* @param req
* @param res
*/
function
checkJinhe
(
req
,
res
)
{
async
function
checkJinhe
(
req
,
res
)
{
let
userId
=
req
.
headers
.
userid
;
let
result
=
jinheBiz
.
checkJinhe
(
userId
);
let
result
=
await
jinheBiz
.
checkJinhe
(
userId
);
res
.
success
(
result
);
}
...
...
src/util/tools.ts
View file @
3f46088c
...
...
@@ -41,14 +41,30 @@ export function getRandomInt(min, max) {
* @param jsonName json文件名称
* @returns
*/
export
function
getJsonData
(
jsonName
)
{
let
filename
=
path
.
join
(
__dirname
.
substring
(
0
,
__dirname
.
indexOf
(
"out"
)),
jsonName
);
export
async
function
getJsonData
(
jsonName
)
{
let
filename
=
path
.
join
(
__dirname
.
substring
(
0
,
__dirname
.
indexOf
(
`out`
)),
`json/
${
jsonName
}
`
);
let
jsonObject
=
fs
.
readFileSync
(
filename
,
'utf-8'
);
let
baseData
;
if
(
jsonObject
)
baseData
=
JSON
.
parse
(
jsonObject
);
console
.
log
(
baseData
);
return
baseData
;
}
/**
* 获取对应登录用户的数据json
* @param jsonName json文件名称
* @returns
*/
export
async
function
getUserJsonData
(
jsonName
,
userId
)
{
let
filename
=
path
.
join
(
__dirname
.
substring
(
0
,
__dirname
.
indexOf
(
`out`
)),
`json/
${
userId
}
/
${
jsonName
}
`
);
let
baseData
=
JSON
.
parse
(
jsonObject
);
let
jsonObject
=
fs
.
readFileSync
(
filename
,
'utf-8'
);
let
baseData
;
if
(
jsonObject
)
baseData
=
JSON
.
parse
(
jsonObject
);
console
.
log
(
baseData
);
return
baseData
;
}
...
...
@@ -57,12 +73,77 @@ export function getJsonData(jsonName) {
* 更新json数据
* @param jsonName json文件名称
*/
export
function
changeJsonData
(
jsonName
,
data
)
{
export
async
function
changeJsonData
(
jsonName
,
data
)
{
let
jsonData
=
JSON
.
stringify
(
data
,
null
,
2
);
let
filename
=
path
.
join
(
__dirname
.
substring
(
0
,
__dirname
.
indexOf
(
`out`
)),
`json/
${
jsonName
}
`
);
fs
.
writeFileSync
(
filename
,
jsonData
);
console
.
log
(
'文件写入成功'
);
// fs.writeFile(filename, jsonData, (err) => {
// if (err) {
// console.log(`写入${jsonName}文件失败`);
// }
// console.log('文件写入成功');
// });
}
/**
* 更新对应用户json数据
* @param jsonName json文件名称
*/
export
async
function
changeUserJsonData
(
jsonName
,
userId
,
data
)
{
let
jsonData
=
JSON
.
stringify
(
data
,
null
,
2
);
let
filename
=
path
.
join
(
__dirname
.
substring
(
0
,
__dirname
.
indexOf
(
"out"
)),
jsonName
);
let
filename
=
path
.
join
(
__dirname
.
substring
(
0
,
__dirname
.
indexOf
(
`out`
)),
`json/
${
userId
}
/
${
jsonName
}
`
);
fs
.
writeFileSync
(
filename
,
jsonData
);
console
.
log
(
'文件写入成功'
);
// fs.writeFile(filename, jsonData, (err) => {
// if (err) {
// console.log(`写入${jsonName}文件失败`);
// }
// console.log('文件写入成功');
// });
}
/**
* 添加对应user的文件夹
* @param userId
*/
export
function
addJson
(
userId
)
{
/**判断没有当前登录用户的文件夹则新建一个 */
let
dirPath
=
path
.
join
(
__dirname
.
substring
(
0
,
__dirname
.
indexOf
(
"out"
)),
`json/
${
userId
}
`
);
if
(
!
fs
.
existsSync
(
dirPath
))
{
try
{
fs
.
mkdirSync
(
dirPath
,
{
recursive
:
true
});
console
.
log
(
`文件夹
${
dirPath
}
已成功创建`
);
// 指定你要创建的 JSON 文件的路径和名称
let
jsonName
=
[
"雇佣选择.json"
,
"基础数据.json"
,
"竞合.json"
,
"全部线索.json"
,
"提交分数.json"
,
"细分线索.json"
,
"ROI.json"
,
"SWOT.json"
];
for
(
let
i
=
0
;
i
<
jsonName
.
length
;
i
++
)
{
let
jsonFilePath
=
path
.
join
(
dirPath
,
`
${
jsonName
[
i
]}
`
);
// 转换为 JSON 字符串
let
jsonData
=
''
;
let
jsonString
=
JSON
.
stringify
(
jsonData
,
null
,
2
)
// 文件夹创建成功后,写入 JSON 文件
fs
.
writeFileSync
(
jsonFilePath
,
jsonString
);
console
.
log
(
'文件写入成功'
);
}
}
catch
(
err
)
{
console
.
error
(
`文件夹
${
dirPath
}
创建失败
${
err
.
message
}
`
);
}
}
else
{
console
.
log
(
`文件夹
${
dirPath
}
已存在`
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment