feat: add dialogue

This commit is contained in:
2023-12-10 12:05:57 +08:00
parent cf2705c501
commit 1d4ed66404
3 changed files with 52 additions and 17 deletions

View File

@@ -1,20 +1,33 @@
// Function to show an element
function showElement(selector) {
const element = document.querySelector(selector);
if (element) {
element.style.display = 'block';
}
function showElement(selector) {
const element = document.querySelector(selector);
if (element) {
element.style.display = 'block';
}
}
// Function to randomly select a customer
function showRandomCustomer() {
const customers = ['#customer1 img', '#customer2 img', '#customer3 img'];
const randomIndex = Math.floor(Math.random() * customers.length);
showElement(customers[randomIndex]);
}
var questions = [
"如何建立统一的度量衡体系以加强中央集权?",
"如何制定合理的税收政策来增强国库?",
"如何组织和动员资源建造长城以防御外敌?",
"如何执行禁止私人持有武器的政策?",
"如何推广统一的书写系统来加强文化统一?",
"如何合理征召士兵并保持军队的高效运作?",
"如何处理与儒家思想相关的政治异见?",
"如何加强皇帝的集权制度?",
"如何建立和维护一个有效的道路交通网络?",
"如何处理与周边国家的外交关系?"
];
document.addEventListener("DOMContentLoaded", function() {
// Function to randomly select a customer
function showRandomCustomer() {
const customers = ['#customer1 img', '#customer2 img', '#customer3 img'];
const randomIndex = Math.floor(Math.random() * customers.length);
showElement(customers[randomIndex]);
}
// Show dialogue box
showElement("#dialogueBox img");
@@ -30,4 +43,8 @@ document.addEventListener("DOMContentLoaded", function() {
// Show normal Qin Shi Huang
showElement('#qinshihuang img');
// Show random question
var randomQuestion = questions[Math.floor(Math.random() * questions.length)];
document.getElementById("dialogueText").innerHTML = randomQuestion;
});