-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathChooseQuestionAction.java
More file actions
60 lines (43 loc) · 1.77 KB
/
ChooseQuestionAction.java
File metadata and controls
60 lines (43 loc) · 1.77 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
import java.time.Instant;
public class ChooseQuestionAction implements Action {
private Player player;
private String category;
private int value;
private Question question;
private QuestionList questions;
public ChooseQuestionAction(Player player, String category, int value, QuestionList questions) {
this.player = player;
this.category = category;
this.value = value;
this.questions = questions;
//this.question = questions.searchQuestion(category, value);
}
@Override
public void execute() {
question = questions.searchQuestion(category, value);
if(question == null) {
System.out.println("Question not found for category: " + category + " and value: " + value);
return;
}
if(question.isAnswered() || question.getValue() == 0) {
System.out.println("Question already answered or invalid value.");
return;
}
// Create log
GameEventLog eventLog = new GameEventLog(Game.getInstance().getCaseId(),Instant.now().toString(),"chooseQuestion");
eventLog.addPlayerInfo(player.getPlayerId());
eventLog.selectCategory(question.getCategory());
eventLog.selectValue(question.getValue());
eventLog.setContent(question.getContent());
player.getPublisher().setEventLog(eventLog);
//System.out.println(player.getPlayerId() + " has chosen the question: " + question.toString());
}
public Question getQuestion() {
return question;
}
@Override
public String toString() {
return "chooseQuestion";
//return "ChooseQuestionAction by " + player.getPlayerId() + " for question: " + question.toString();
}
}