-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathtest-temp-modifiers.html
More file actions
131 lines (110 loc) · 5.4 KB
/
test-temp-modifiers.html
File metadata and controls
131 lines (110 loc) · 5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>临时增益系统测试 - 多天赋组合</title>
<style>
body { font-family: Arial, sans-serif; padding: 20px; }
h1 { color: #333; }
h2 { color: #666; border-bottom: 2px solid #ddd; padding-bottom: 5px; }
h3 { color: #888; }
p { margin: 5px 0; }
.success { color: green; font-weight: bold; }
.error { color: red; font-weight: bold; }
.info { color: blue; }
table { border-collapse: collapse; margin: 10px 0; }
td, th { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; }
</style>
</head>
<body>
<h1>临时增益系统测试 - 多天赋组合</h1>
<div id="output"></div>
<script src="lib/constants.js"></script>
<script src="lib/utils.js"></script>
<script src="lib/models.js"></script>
<script src="lib/talent.js"></script>
<script>
const output = document.getElementById('output');
function log(msg) {
output.innerHTML += `<p>${msg}</p>`;
console.log(msg);
}
function createTestStudent(name, talents) {
const student = new Student(name, 50, 50, 50);
for(const t of talents) {
student.talents.add(t);
}
// 添加触发天赋的方法
student.triggerTalents = function(eventName, ctx){
if(window.TalentManager){
return TalentManager.handleStudentEvent(this, eventName, ctx || {});
}
return [];
};
return student;
}
// 初始化天赋系统
if(window.TalentManager){
TalentManager.registerDefaultTalents(null, window);
}
// 测试1: 激进 + 原题机伪
log('<h2>测试1: 激进 + 原题机(伪)</h2>');
const student1 = createTestStudent('测试学生1', ['激进', '原题机(伪)']);
log('<h3>初始状态</h3>');
log(`基础值: thinking=${student1._base_thinking}, coding=${student1._base_coding}, mental=${student1._base_mental}`);
log(`显示值: thinking=${student1.thinking}, coding=${student1.coding}, mental=${student1.mental}`);
log('<h3>模拟赛开始</h3>');
student1.triggerTalents('mock_start', { contestName: '模拟赛' });
log(`显示值(应大幅增加): thinking=${student1.thinking}, coding=${student1.coding}, mental=${student1.mental}`);
log(`临时增益: thinking=${student1.getTempModifier('thinking')}, coding=${student1.getTempModifier('coding')}`);
log('<h3>模拟赛结束</h3>');
student1.triggerTalents('mock_end', {});
log(`显示值(应恢复): thinking=${student1.thinking}, coding=${student1.coding}, mental=${student1.mental}`);
log(`临时增益(应清零): thinking=${student1.getTempModifier('thinking')}, coding=${student1.getTempModifier('coding')}`);
if(student1.thinking === 50 && student1.coding === 50 && student1.mental === 50){
log('<span class="success">✓ 测试1通过:能力已正确恢复</span>');
} else {
log(`<span class="error">✗ 测试1失败:能力未正确恢复 (thinking=${student1.thinking}, coding=${student1.coding}, mental=${student1.mental})</span>`);
}
// 测试2: 冷静 + 原题机伪
log('<h2>测试2: 冷静 + 原题机(伪)</h2>');
const student2 = createTestStudent('测试学生2', ['冷静', '原题机(伪)']);
log('<h3>模拟赛开始</h3>');
student2.triggerTalents('mock_start', { contestName: '模拟赛' });
log(`显示值: thinking=${student2.thinking}, coding=${student2.coding}, mental=${student2.mental}`);
log('<h3>模拟赛结束</h3>');
student2.triggerTalents('mock_end', {});
log(`显示值: thinking=${student2.thinking}, coding=${student2.coding}, mental=${student2.mental}`);
if(student2.thinking === 50 && student2.coding === 50 && student2.mental === 50){
log('<span class="success">✓ 测试2通过</span>');
} else {
log(`<span class="error">✗ 测试2失败</span>`);
}
// 测试3: 激进 + 冷静 + 原题机伪(三天赋组合)
log('<h2>测试3: 激进 + 冷静 + 原题机(伪)</h2>');
const student3 = createTestStudent('测试学生3', ['激进', '冷静', '原题机(伪)']);
log('<h3>模拟赛开始</h3>');
student3.triggerTalents('mock_start', { contestName: '模拟赛' });
const mid = { thinking: student3.thinking, coding: student3.coding, mental: student3.mental };
log(`显示值(三重叠加): thinking=${mid.thinking}, coding=${mid.coding}, mental=${mid.mental}`);
log(`预期: thinking应约为 50×1.4×1.2×2 = 168`);
log('<h3>模拟赛结束</h3>');
student3.triggerTalents('mock_end', {});
log(`显示值: thinking=${student3.thinking}, coding=${student3.coding}, mental=${student3.mental}`);
if(student3.thinking === 50 && student3.coding === 50 && student3.mental === 50){
log('<span class="success">✓ 测试3通过:三天赋组合正确恢复</span>');
} else {
log(`<span class="error">✗ 测试3失败</span>`);
}
// 总结
log('<h2>测试总结</h2>');
const allPassed = (student1.thinking === 50 && student2.thinking === 50 && student3.thinking === 50);
if(allPassed){
log('<span class="success">✓✓✓ 所有测试通过!临时增益系统工作正常。</span>');
} else {
log('<span class="error">✗ 部分测试失败,请检查代码。</span>');
}
</script>
</body>
</html>