GameView.java
2.55 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
package fi.insomnia.bortal.view;
import java.util.Collections;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.model.ListDataModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.CardTemplateBeanLocal;
import fi.insomnia.bortal.beans.GameBeanLocal;
import fi.insomnia.bortal.beans.UserBeanLocal;
import fi.insomnia.bortal.enums.Permission;
import fi.insomnia.bortal.enums.RolePermission;
import fi.insomnia.bortal.model.News;
import fi.insomnia.bortal.model.PrintedCard;
import fi.insomnia.bortal.view.helpers.RfidEvent;
@ManagedBean(name = "gameView")
@SessionScoped
public class GameView extends GenericView {
private static final Logger logger = LoggerFactory.getLogger(GameView.class);
@EJB
private GameBeanLocal gamebean;
@EJB
private CardTemplateBeanLocal cdbean;
private ListDataModel<PrintedCard> inforow;
@EJB
private UserBeanLocal userbean;
@ManagedProperty(value = "#{readerView}")
private ReaderView readerView;
public String editReaderEvent() {
readerView.setRfidevent(new RfidEvent("unknown", "unknown", inforow.getRowData().getGameCards().getRowData()));
return "/shop/editGame";
}
public Integer getMyPoints() {
userbean.fatalNotLoggedIn();
PrintedCard currcard = null;
for (PrintedCard pc : userbean.getCurrentUser().getPrintedCards()) {
if (!pc.getEnabled()) {
continue;
}
if (currcard == null || currcard.getTemplate().getPower() < pc.getTemplate().getPower()) {
currcard = pc;
}
}
return currcard.getGamepoints();
}
public void initGamepoints() {
userbean.fatalPermission(Permission.GAME, RolePermission.EXECUTE, " need Game:X to init userlist at gameview");
List<PrintedCard> list = cdbean.findActiveCards();
Collections.sort(list, PrintedCard.GAMEPOINT_COMPARATOR);
setInforow(new ListDataModel<PrintedCard>(list));
}
public void setInforow(ListDataModel<PrintedCard> inforow) {
this.inforow = inforow;
}
public ListDataModel<PrintedCard> getInforow() {
return inforow;
}
public List<News> getGameNews() {
return gamebean.getNews();
}
public void setReaderView(ReaderView readerView) {
this.readerView = readerView;
}
public ReaderView getReaderView() {
return readerView;
}
}