-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAnswerQuestionAction.java
More file actions
43 lines (31 loc) · 1.07 KB
/
AnswerQuestionAction.java
File metadata and controls
43 lines (31 loc) · 1.07 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
import java.time.Instant;
public class AnswerQuestionAction implements Action {
private Player player;
private Question question;
private String answer;
public AnswerQuestionAction(Player player, Question question, String answer) {
this.player = player;
this.question = question;
this.answer = answer;
}
@Override
public void execute() {
if(question == null) {
System.out.println("No question selected.");
return;
}
question.addAnswer(answer);
// Create log
GameEventLog log = new GameEventLog(Game.getInstance().getCaseId(),Instant.now().toString(),"answerQuestion");
log.addPlayerInfo(player.getPlayerId());
log.selectCategory(question.getCategory());
log.selectValue(question.getValue());
log.setContent(question.getContent());
log.addAnswer(answer);
player.getPublisher().setEventLog(log);
}
@Override
public String toString() {
return "answerQuestion";
}
}