1
2 package hoplugins.teamAnalyzer.ht;
3
4 import hoplugins.Commons;
5
6 import hoplugins.teamAnalyzer.SystemManager;
7 import hoplugins.teamAnalyzer.vo.Match;
8
9
10 /***
11 * Class that check for CHPP approval in operations
12 *
13 * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
14 */
15 public class CHPPManager {
16
17
18 /***
19 * Check if CHPP rules approve download for a match
20 *
21 * @param match Match to be downloaded
22 *
23 * @return true if allowed
24 */
25 public static boolean isDownloadAllowed(Match match) {
26 boolean isNextOpponent = ((match.getHomeId() == SystemManager.getLeagueOpponentId())
27 || (match.getAwayId() == SystemManager.getLeagueOpponentId()));
28 boolean last2Weeks = false;
29 int actualWeek = getWeekNumber(Commons.getModel().getBasics().getSeason(),
30 Commons.getModel().getBasics().getSpieltag());
31 int gameWeek = getWeekNumber(match.getSeason(), match.getWeek());
32
33 if ((actualWeek - gameWeek) < 3) {
34 last2Weeks = true;
35 }
36
37 return (isNextOpponent && last2Weeks);
38 }
39
40 /***
41 * Return the week number from week and season, used for CHPP compatibility
42 *
43 * @param season
44 * @param week
45 *
46 * @return
47 */
48 private static int getWeekNumber(int season, int week) {
49 return ((season - 1) * 16) + week;
50 }
51 }