~ubuntu-branches/ubuntu/precise/triplea/precise

« back to all changes in this revision

Viewing changes to src/games/strategy/triplea/ui/display/TripleaDisplay.java

  • Committer: Package Import Robot
  • Author(s): Scott Howard
  • Date: 2011-11-11 21:40:11 UTC
  • Revision ID: package-import@ubuntu.com-20111111214011-sehf2rwat36o2xqf
Tags: upstream-1.3.2.2
ImportĀ upstreamĀ versionĀ 1.3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This program is free software; you can redistribute it and/or modify
 
3
 * it under the terms of the GNU General Public License as published by
 
4
 * the Free Software Foundation; either version 2 of the License, or
 
5
 * (at your option) any later version.
 
6
 * This program is distributed in the hope that it will be useful,
 
7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
8
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
9
 * GNU General Public License for more details.
 
10
 * You should have received a copy of the GNU General Public License
 
11
 * along with this program; if not, write to the Free Software
 
12
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
13
 */
 
14
package games.strategy.triplea.ui.display;
 
15
 
 
16
import java.util.*;
 
17
 
 
18
import games.strategy.engine.data.*;
 
19
import games.strategy.engine.display.IDisplayBridge;
 
20
import games.strategy.net.GUID;
 
21
import games.strategy.triplea.delegate.DiceRoll;
 
22
import games.strategy.triplea.ui.TripleAFrame;
 
23
 
 
24
/**
 
25
 * 
 
26
 *
 
27
 *
 
28
 * @author Sean Bridges
 
29
 */
 
30
public class TripleaDisplay implements ITripleaDisplay
 
31
{
 
32
    private IDisplayBridge m_displayBridge;
 
33
    private final TripleAFrame m_ui;
 
34
    
 
35
    /**
 
36
     * @param ui
 
37
     */
 
38
    public TripleaDisplay(final TripleAFrame ui)
 
39
    {
 
40
        m_ui = ui;
 
41
    }
 
42
    /* 
 
43
     * @see games.strategy.engine.display.IDisplay#initialize(games.strategy.engine.display.IDisplayBridge)
 
44
     */
 
45
    public void initialize(IDisplayBridge bridge)
 
46
    {
 
47
       m_displayBridge = bridge;
 
48
       m_displayBridge.toString();
 
49
        
 
50
    }
 
51
    /* (non-Javadoc)
 
52
     * @see games.strategy.triplea.ui.display.ITripleaDisplay#showBattle(games.strategy.net.GUID, java.util.List, games.strategy.engine.data.Territory, java.lang.String, java.util.Collection, java.util.Collection)
 
53
     */
 
54
    public void showBattle(GUID battleID, Territory location, String battleTitle, Collection<Unit> attackingUnits, Collection<Unit> defendingUnits, Map<Unit, Collection<Unit>> unit_dependents,PlayerID attacker, PlayerID defender)
 
55
    {
 
56
        m_ui.getBattlePanel().showBattle(battleID,  location, battleTitle,  attackingUnits, defendingUnits, unit_dependents, attacker, defender);
 
57
        
 
58
    }
 
59
    /* (non-Javadoc)
 
60
     * @see games.strategy.triplea.ui.display.ITripleaDisplay#listBattleSteps(games.strategy.net.GUID, java.lang.String, java.util.List)
 
61
     */
 
62
    public void listBattleSteps(GUID battleID, List steps)
 
63
    {
 
64
       m_ui.getBattlePanel().listBattle(battleID, steps);
 
65
        
 
66
    }
 
67
    /* 
 
68
     * @see games.strategy.triplea.ui.display.ITripleaDisplay#casualtyNotification(java.lang.String, games.strategy.triplea.delegate.DiceRoll, games.strategy.engine.data.PlayerID, java.util.Collection, java.util.Collection, java.util.Map, boolean)
 
69
     */
 
70
    public void casualtyNotification(GUID battleID,
 
71
            String step,
 
72
            DiceRoll dice,
 
73
            PlayerID player,
 
74
            Collection<Unit> killed,
 
75
            Collection<Unit> damaged,
 
76
            Map<Unit,Collection<Unit>> dependents)
 
77
    {
 
78
        m_ui.getBattlePanel().casualtyNotification(step,dice, player, killed, damaged, dependents);
 
79
        
 
80
    }
 
81
    
 
82
    /* 
 
83
     * @see games.strategy.triplea.ui.display.ITripleaDisplay#casualtyNotification(java.lang.String, games.strategy.triplea.delegate.DiceRoll, games.strategy.engine.data.PlayerID, java.util.Collection, java.util.Collection, java.util.Map, boolean)
 
84
     */
 
85
    public void deadUnitNotification(GUID battleID,
 
86
            PlayerID player,
 
87
            Collection<Unit> killed,
 
88
            Map<Unit,Collection<Unit>> dependents)
 
89
    {
 
90
        m_ui.getBattlePanel().deadUnitNotification(player, killed, dependents);
 
91
        
 
92
    }
 
93
    
 
94
    /* 
 
95
     * @see games.strategy.triplea.ui.display.ITripleaDisplay#casualtyNotification(java.lang.String, games.strategy.triplea.delegate.DiceRoll, games.strategy.engine.data.PlayerID, java.util.Collection, java.util.Collection, java.util.Map, boolean)
 
96
     */
 
97
    public void scrambleNotification(GUID battleID,
 
98
            String step,
 
99
            PlayerID player,
 
100
            Collection<Unit> scrambled,
 
101
            Map<Unit,Collection<Unit>> dependents)
 
102
    {
 
103
        m_ui.getBattlePanel().scrambleNotification(step, player, scrambled, dependents);        
 
104
    }
 
105
    
 
106
    /* (non-Javadoc)
 
107
     * @see games.strategy.triplea.ui.display.ITripleaDisplay#battleEnd(games.strategy.net.GUID, java.lang.String)
 
108
     */
 
109
    public void battleEnd(GUID battleID, String message)
 
110
    {
 
111
        m_ui.getBattlePanel().battleEndMessage(battleID, message);
 
112
    }
 
113
    /* )
 
114
     * @see games.strategy.triplea.ui.display.ITripleaDisplay#bombingResults(games.strategy.net.GUID, int[], int)
 
115
     */
 
116
    public void bombingResults(GUID battleID, int[] dice, int cost)
 
117
    {
 
118
        m_ui.getBattlePanel().bombingResults(battleID, dice, cost);
 
119
    }
 
120
    
 
121
    public void notifyRetreat(String shortMessage, String message, String step, PlayerID retreatingPlayer)
 
122
    {
 
123
        //we just told the game to retreat, so we already know
 
124
        if(m_ui.playing(retreatingPlayer))
 
125
            return;
 
126
        
 
127
        m_ui.getBattlePanel().notifyRetreat(shortMessage, message, step, retreatingPlayer);
 
128
    }
 
129
 
 
130
    public void notifyScramble(String shortMessage, String message, String step, PlayerID scramblingPlayer)
 
131
    {
 
132
        //we just told the game to scramble, so we already know
 
133
        if(m_ui.playing(scramblingPlayer))
 
134
            return;
 
135
        
 
136
        m_ui.getBattlePanel().notifyScramble(shortMessage, message, step, scramblingPlayer);
 
137
    }
 
138
    /**
 
139
     * Show dice for the given battle and step
 
140
     * 
 
141
     * @param battleId
 
142
     * @param dice
 
143
     * @param the player who must act on the roll, ignore
 
144
     */
 
145
    public void notifyDice(GUID battleId, DiceRoll dice, String stepName)
 
146
    {
 
147
        m_ui.getBattlePanel().showDice(null, dice, stepName);
 
148
    }
 
149
    
 
150
    public void notifyRetreat(GUID battleId, Collection retreating)
 
151
    {
 
152
        m_ui.getBattlePanel().notifyRetreat(retreating);
 
153
    }
 
154
    
 
155
    public void gotoBattleStep(GUID battleId, String step)
 
156
    {
 
157
        m_ui.getBattlePanel().gotoStep(battleId, step);
 
158
    }
 
159
 
 
160
   public void shutDown()
 
161
   {
 
162
       m_ui.stopGame();
 
163
   }
 
164
    
 
165
}