Source code: org/dma/ihm/game/calendar/events/GameCalendarYearEndEvent.java
1 package org.dma.ihm.game.calendar.events;
2
3 import java.util.*;
4
5 import org.dma.ihm.controller.*;
6 import org.dma.ihm.controller.data.*;
7 import org.dma.ihm.game.*;
8 import org.dma.ihm.game.calendar.*;
9 import org.dma.ihm.game.league.*;
10
11 /**
12 * GameCalendarYearEndEvent Special event that "marks" the end of a year and
13 * calls controller functions for a calendar "endSeason", and so should be
14 * really the last event of a season !
15 *
16 * @author Bernhard von Gunten / Arik Dasen
17 * @created December 29, 2001
18 */
19 public class GameCalendarYearEndEvent extends GameCalendarEvent {
20
21 /**
22 * Creates event
23 *
24 * @param source The source of this event
25 * @param day The day of this event
26 */
27 public GameCalendarYearEndEvent(Object source, Calendar day) {
28 super(source, day, "GameCalendarYearEndEvent");
29 }
30
31 /** Resets the calendar and adds a (happy) newYear event */
32 public void play() {
33 super.play();
34 // Backup season data for history etc.
35 Controller.getScenario().endSeason();
36 // Set a NEW YEAR in the Calendar
37 Controller.getScenario().getGameCalendar().endSeason();
38 // Add the first event to the year
39 Controller.getScenario().getGameCalendar().addEvent(new GameCalendarYearStartEvent(this, Controller.getScenario().getGameCalendar().getFirstDay()));
40 // Add a displayGui for each user that the season is started
41 User[] users = Controller.getScenario().getUsers();
42 for (int i = 0; i < users.length; i++) {
43 GameCalendarDisplayGuiEvent tmp = new GameCalendarDisplayGuiEvent(this, Controller.getScenario().getGameCalendar().getFirstDay(), users[i], Controller.getTranslation("event.beginOfSeason"));
44 Controller.getScenario().getGameCalendar().addEvent(tmp);
45 }
46 }
47
48 }