Kontakt

Fakturační údaje

IČ: 87189224, BÚ: 1958653063/0800

Contact info in QR code

Siege (Obkličovačka)

Informace

Stáhni a hraj!

  • Spustitelný soubor hry si stáhnou oba hráči
  • Zakladatel hry
    • V nabídce "Game > Create" vytvoří novou hru
    • Pošle protihráči svou IP adresu (zjistí ji v levém dolním rohu okna)
  • Protihráč
    • Jakmile obdrží IP adresu zakladatele hry, v nabídce "Game > Join" se připojí ke hře
  • Cílem je zabrat co nejvíce soupeřových polí.
  • Pozn.: Síťové spojení funguje na LAN (lokální) síťi a na počítačích s veřejnou IP adresou.

Zdrojové kódy (zip)

Zdrojové kódy (prohlížení)

  1: package siege.core;
  2: 
  3: import java.util.Observable;
  4: 
  5: /**
  6:  * Holds all player related informations, such as IP address, name,
  7:  * score, and tells if is local player and/or challenger.
  8:  *
  9:  * Observe:
 10:  * - Score
 11:  *
 12:  * Observers:
 13:  * - reports changes of name, ip address, score
 14:  * - StatusView
 15:  *
 16:  * @author Ondrej Macoszek, ondra@macoszek.cz
 17:  */
 18: public class Player extends Observable implements Comparable
 19: {
 20:     /**
 21:      * Players name
 22:      */
 23:     private String name;
 24: 
 25:     /**
 26:      * IP address of player in string
 27:      */
 28:     private String address; 
 29: 
 30:     /**
 31:      * Current score
 32:      */
 33:     private Score score;
 34: 
 35:     /**
 36:      * Location of player
 37:      * - true - local player
 38:      * - false - remote player
 39:      */
 40:     private boolean isLocalPlayer = false;
 41: 
 42:     /**
 43:      * Role of player
 44:      * - true - challenger
 45:      * - false - participant
 46:      */
 47:     private boolean isChallenger = false;
 48: 
 49: 
 50:     /**
 51:      * Constructor
 52:      */
 53:     public Player () 
 54:     {
 55:         super();
 56:         score = new Score(this);
 57:     }
 58: 
 59:     /**
 60:      * Constructor initilizing players name
 61:      * @param name
 62:      */
 63:     public Player (String name)
 64:     {
 65:         this();
 66:         this.name = name;
 67:     }
 68: 
 69:     /**
 70:      * Get players name
 71:      */
 72:     public String getName ()
 73:     {
 74:         return name;
 75:     }
 76: 
 77:     /**
 78:      * Set new name to player
 79:      * @param name
 80:      */
 81:     public void setName (String name)
 82:     {
 83:         this.name = name;
 84:         setChanged();
 85:         notifyObservers();
 86:     }
 87: 
 88:     /**
 89:      * Get IP address of player
 90:      */
 91:     public String getAddress ()
 92:     {
 93:         return address;
 94:     }
 95: 
 96:     /**
 97:      * Set new IP address
 98:      * @param address
 99:      */
100:     public void setAddress (String address)
101:     {
102:         this.address = address;
103:     }
104: 
105:     /**
106:      * Get score information
107:      */
108:     public Score getScore ()
109:     {
110:         return score;
111:     }
112: 
113:     /**
114:      * Test if player is challenger
115:      */
116:     public boolean isChallenger ()
117:     {
118:         return isChallenger;
119:     }
120: 
121:     /**
122:      * Test if player is partaker
123:      */
124:     public boolean isPartaker ()
125:     {
126:         return !isChallenger;
127:     }
128: 
129:     /**
130:      * Set challenger status
131:      * - true - challanger
132:      * - false - participant
133:      */
134:     public void setChallenger (boolean status)
135:     {
136:         this.isChallenger = status;
137:     }
138: 
139:     /**
140:      * Test if player is local
141:      */
142:     public boolean isLocalPlayer ()
143:     {
144:         return isLocalPlayer;
145:     }
146: 
147:     /**
148:      * Test if player is remote
149:      */
150:     public boolean isRemotePlayer ()
151:     {
152:         return !isLocalPlayer;
153:     }
154: 
155:     /**
156:      * Set local player status
157:      * - true - local player
158:      * - false - remote player
159:      */
160:     public void setLocalPlayer (boolean status)
161:     {
162:         if(status) {
163:             isLocalPlayer = true;
164:         } else {
165:             isLocalPlayer = false;
166:         }
167:         setChanged();
168:         notifyObservers();
169:     }
170: 
171:     /**
172:      * Compare by player score
173:      */
174:     public int compareTo(Object o) 
175:     {
176:         return score.compareTo(((Player)o).score);
177:     }
178: }