|
| 1 | +/* |
| 2 | + Class: KiwiClient |
| 3 | +
|
| 4 | + Topic: |
| 5 | + Interface entre les jeux et la frusion (extension de GameClient) |
| 6 | +
|
| 7 | + Version: |
| 8 | + $Id: KiwiClient.as,v 1.15 2005/01/25 16:49:31 sbenard Exp $ |
| 9 | +*/ |
| 10 | + |
| 11 | +class bkiwi.KiwiClient extends frusion.gameclient.GameClient { |
| 12 | + |
| 13 | + private var root : MovieClip ; |
| 14 | + |
| 15 | + public var fl_fake : Boolean ; |
| 16 | + public var fl_success : Boolean ; |
| 17 | + public var fl_localScore : Boolean ; |
| 18 | + |
| 19 | + |
| 20 | +/*------------------------------------------------------------------------ |
| 21 | + CONSTRUCTEUR |
| 22 | + ------------------------------------------------------------------------*/ |
| 23 | + function KiwiClient(mc) { |
| 24 | + super() ; |
| 25 | + setRoot(mc) ; |
| 26 | + fl_success = false ; |
| 27 | + fl_localScore = false ; |
| 28 | + this.fl_fake = this.root.USEFAKESERVER ; |
| 29 | + } |
| 30 | + |
| 31 | +/*------------------------------------------------------------------------ |
| 32 | + DÉFINI LE ROOT |
| 33 | + ------------------------------------------------------------------------*/ |
| 34 | + function setRoot(mc) { |
| 35 | + root = mc ; |
| 36 | + } |
| 37 | + |
| 38 | + |
| 39 | +/*------------------------------------------------------------------------ |
| 40 | + TEST LE FD BLANC |
| 41 | + ------------------------------------------------------------------------*/ |
| 42 | + function isWhite() { |
| 43 | + if ( fl_fake ) |
| 44 | + return true ; |
| 45 | + else |
| 46 | + return super.isWhite() ; |
| 47 | + } |
| 48 | + |
| 49 | + |
| 50 | +/*------------------------------------------------------------------------ |
| 51 | + TEST LE FD BLANC |
| 52 | + ------------------------------------------------------------------------*/ |
| 53 | + function isBlack() { |
| 54 | + if ( fl_fake ) |
| 55 | + return false ; |
| 56 | + else |
| 57 | + return super.isBlack() ; |
| 58 | + } |
| 59 | + |
| 60 | + |
| 61 | +/*------------------------------------------------------------------------ |
| 62 | + TEST LE FD BLANC |
| 63 | + ------------------------------------------------------------------------*/ |
| 64 | + function isRed() { |
| 65 | + if ( fl_fake ) |
| 66 | + return false ; |
| 67 | + else |
| 68 | + return super.isRed() ; |
| 69 | + } |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +/*------------------------------------------------------------------------ |
| 74 | + MODIFIE LE CONTEXTE DE L'OBJET |
| 75 | + ------------------------------------------------------------------------*/ |
| 76 | + function changeRoot( newRoot : MovieClip ) : Void { |
| 77 | + this.root = newRoot ; |
| 78 | + } |
| 79 | + |
| 80 | + |
| 81 | +// *** COMMANDES |
| 82 | + |
| 83 | + |
| 84 | +/*------------------------------------------------------------------------ |
| 85 | + INITIALISATION ET CONNEXION AU SERVICE |
| 86 | + ------------------------------------------------------------------------*/ |
| 87 | + function serviceConnect() : Void { |
| 88 | + fl_success = false ; |
| 89 | + super.serviceConnect() ; |
| 90 | + |
| 91 | + if ( this.fl_fake ) { |
| 92 | + root.getFakeInit() ; |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + |
| 97 | +/*------------------------------------------------------------------------ |
| 98 | + DÉMARRE UNE PARTIE |
| 99 | + ------------------------------------------------------------------------*/ |
| 100 | + function startGame() : Void { |
| 101 | + fl_success = false ; |
| 102 | + super.startGame() ; |
| 103 | + |
| 104 | + if ( this.fl_fake ) { |
| 105 | + root.sendFakeServerCommand("startGame") ; |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +/*------------------------------------------------------------------------ |
| 112 | + TERMINE UNE PARTIE |
| 113 | + ------------------------------------------------------------------------*/ |
| 114 | + function endGame() { |
| 115 | + root.gdebug("endGame: fl_localScore="+fl_localScore) ; |
| 116 | + fl_success = false ; |
| 117 | + super.endGame() ; |
| 118 | + if ( this.fl_fake ) |
| 119 | + root.sendFakeServerCommand("endGame") ; |
| 120 | + } |
| 121 | + |
| 122 | + |
| 123 | +/*------------------------------------------------------------------------ |
| 124 | + SAUVE LE SCORE |
| 125 | + ------------------------------------------------------------------------*/ |
| 126 | + function saveScore(score,misc) { |
| 127 | + root.gdebug("saveScore: score="+score+" misc="+misc) ; |
| 128 | + fl_success = false ; |
| 129 | + fl_localScore = false; |
| 130 | + super.saveScore(score,misc) ; |
| 131 | + } |
| 132 | + |
| 133 | + |
| 134 | + |
| 135 | +// *** EVENTS |
| 136 | + |
| 137 | +/*------------------------------------------------------------------------ |
| 138 | + EVENT: SERVICE CONNECT |
| 139 | + ------------------------------------------------------------------------*/ |
| 140 | + function onServiceConnect() : Void { |
| 141 | + fl_success = true ; |
| 142 | + root.frutiSlots = this.slots ; |
| 143 | + } |
| 144 | + |
| 145 | + |
| 146 | +/*------------------------------------------------------------------------ |
| 147 | + EVENT: ABANDON DE PARTIE |
| 148 | + ------------------------------------------------------------------------*/ |
| 149 | + function onEndGame() { |
| 150 | + fl_success = true ; |
| 151 | + root.gdebug("onEndGame") ; |
| 152 | + } |
| 153 | + |
| 154 | + |
| 155 | + |
| 156 | +/*------------------------------------------------------------------------ |
| 157 | + EVENT: GAME CLOSE |
| 158 | + ------------------------------------------------------------------------*/ |
| 159 | + function onGameClose() : Void { |
| 160 | + if ( this.gameRunning ) |
| 161 | + this.endGame() ; |
| 162 | + else |
| 163 | + this.closeService() ; |
| 164 | + } |
| 165 | + |
| 166 | + |
| 167 | +/*------------------------------------------------------------------------ |
| 168 | + EVENT: STARTGAME |
| 169 | + ------------------------------------------------------------------------*/ |
| 170 | + function onStartGame() { |
| 171 | + fl_success = true ; |
| 172 | + } |
| 173 | + |
| 174 | + |
| 175 | +/*------------------------------------------------------------------------ |
| 176 | + EVENT: SCORE SAUVÉ |
| 177 | + ------------------------------------------------------------------------*/ |
| 178 | + function onSaveScore() { |
| 179 | + root.gdebug("onSaveScore") ; |
| 180 | + fl_success = true ; |
| 181 | + if ( this.forceClose ) |
| 182 | + this.closeService() ; |
| 183 | + } |
| 184 | + |
| 185 | + |
| 186 | +/*------------------------------------------------------------------------ |
| 187 | + EVENT: SCORE FRUTICARD SAUVÉ |
| 188 | + ------------------------------------------------------------------------*/ |
| 189 | + function onSaveScoreFruticard() { |
| 190 | + fl_success = true ; |
| 191 | + fl_localScore = true ; |
| 192 | + root.gdebug("onSaveScoreFruticard") ; |
| 193 | + } |
| 194 | + |
| 195 | + |
| 196 | +/*------------------------------------------------------------------------ |
| 197 | + EVENT: ERREUR |
| 198 | + ------------------------------------------------------------------------*/ |
| 199 | + function onError() { |
| 200 | + root.error("onError") ; |
| 201 | + super.onError() ; |
| 202 | + } |
| 203 | + |
| 204 | +} |
| 205 | + |
| 206 | + |
0 commit comments