Frame 1
function Events() {
var listeners = new Array();
var stopCount = 0;
Object.prototype.eventOrphan = false;
this.runIt = function (object) {
if (typeof(object.run) == "function") {
if (object.eventOrphan) {
stopCount--;
}
object.eventOrphan = false;
var _local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1] == object) {
return(undefined);
}
_local1++;
}
listeners.push(object);
} else {
wr("tried to run bad object!");
wrObj(object);
}
};
this.stopIt = function (object) {
var _local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1] == object) {
stopCount++;
listeners[_local1].eventOrphan = true;
return(undefined);
}
_local1++;
}
};
onEnterFrame = function () {
if ((Key.isDown(16) && (Key.isDown(17))) && (dev_mode)) {
return(undefined);
}
var _local2 = listeners;
var _local1 = 0;
while (_local1 < _local2.length) {
if (!_local2[_local1].eventOrphan) {
_local2[_local1].run();
}
_local1++;
}
if (stopCount > 0) {
_local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1].eventOrphan) {
listeners[_local1].eventOrphan = false;
listeners.splice(_local1, 1);
_local1--;
stopCount--;
}
_local1++;
}
}
};
}
function Sprites() {
var sprite_root = createEmptyMovieClip("sprite_root", 0);
var zRange = 500;
var zArray = new Array(zRange);
var _local2 = 0;
while (_local2 < zRange) {
zArray[_local2] = zRange - _local2;
_local2++;
}
this.getNumFree = function () {
return(zArray.length);
};
this.create = function (props) {
var _local4 = zArray.pop() + (zRange * 4);
var _local5 = "sp" + _local4;
var _local7 = (props.parent_sprite ? (props.parent_sprite) : (sprite_root));
var _local3;
if (typeof(props.member) == "string") {
_local3 = _local7.attachMovie(props.member, _local5, _local4);
} else {
_local3 = _local7.createEmptyMovieClip(_local5, _local4);
}
_local3._x = ((typeof(props.x) == "number") ? (props.x) : 0);
_local3._y = ((typeof(props.y) == "number") ? (props.y) : 0);
if (typeof(props.width) == "number") {
_local3._width = props.width;
}
if (typeof(props.height) == "number") {
_local3._height = props.height;
}
if (typeof(props.xscale) == "number") {
_local3._xscale = props.xscale;
}
if (typeof(props.yscale) == "number") {
_local3._yscale = props.yscale;
}
_local3._visible = ((typeof(props.visible) == "boolean") ? (props.visible) : true);
_local3._alpha = ((typeof(props.alpha) == "number") ? (props.alpha) : 100);
_local3.zIndex = _local4;
_local3.toLevel = function (_l) {
var _local3 = this.zIndex;
var _local2 = ((_l - 1) * zRange) + (this.zIndex % zRange);
this.swapDepths(_local2);
this.zIndex = _local2;
};
if (typeof(props.level) == "number") {
_local3.toLevel(props.level);
}
return(_local3);
};
this.remove = function (sprite) {
if (!sprite.zIndex) {
return(undefined);
}
var _local1 = sprite.zIndex % zRange;
sprite.removeMovieClip();
zArray.push(_local1);
return(_local1);
};
this.sort = function (sprite_array, descending) {
var _local2 = [];
var _local4 = sprite_array.length;
var _local1 = 0;
while (_local1 < _local4) {
_local2.push(sprite_array[_local1].getDepth());
_local1++;
}
if (descending) {
_local2.sort(Array.NUMERIC | Array.DESCENDING);
} else {
_local2.sort(Array.NUMERIC);
}
_local1 = 0;
while (_local1 < _local4) {
sprite_array[_local1].swapDepths(_local2[_local1]);
sprite_array[_local1].zIndex = _local2[_local1];
_local1++;
}
};
}
function SoundFx() {
var _local3 = ["card_sound_2.aif", "card_sound_6.aif", "click_sound_2.aif", "click.wav", "game_over.aif", "game_win.aif", "next_round.aif", "stick.aif", "tone_a.aif", "tone_b.aif", "beep.wav", "introSound", "outroSound", "attentionSound"];
var _local5 = createEmptyMovieClip("sound_fx_base", -1);
var _local6 = 0;
var sounds = new Object();
var _local2 = 0;
while (_local2 < _local3.length) {
var _local4 = new Sound(_local5.createEmptyMovieClip("sound_" + (_local2 + 1), (-_local2) - 2));
_local4.attachSound(_local3[_local2]);
_local4.onSoundComplete = function () {
this.playing = false;
};
sounds[_local3[_local2]] = _local4;
sounds[_local3[_local2]].playing = false;
sounds[_local3[_local2]].soundName = _local3[_local2];
_local2++;
}
this.play = function (sound, nostop, vol) {
if (no_sound == 1) {
return(undefined);
}
if (sounds[sound].playing) {
if (nostop) {
return(undefined);
}
this.stop(sound);
}
sounds[sound].playing = true;
if (vol) {
sounds[sound].setVolume(vol);
} else {
sounds[sound].setVolume(100);
}
sounds[sound].start();
};
this.playLooped = function (sound, vol) {
if (no_sound == 1) {
return(undefined);
}
if (sounds[sound].playing) {
return(undefined);
}
sounds[sound].playing = true;
if (vol) {
sounds[sound].setVolume(vol);
} else {
sounds[sound].setVolume(100);
}
sounds[sound].start(0, 99);
};
this.stop = function (sound) {
sounds[sound].stop();
sounds[sound].playing = false;
};
}
function Random() {
var seed = 0;
var seed2 = 0;
this.range = function (start, stop) {
var _local2 = stop - start;
var _local1 = Math.random() * (_local2 + 1);
_local1 = Math.floor(start + _local1);
return(Math.min(_local1, stop));
};
this.setSeed = function (s) {
seed = s & 65535;
seed2 = seed;
};
this.rangeFromSeed = function (start, stop) {
var _local3 = stop - start;
var _local2 = this.floatFromSeed() * (_local3 + 1);
_local2 = Math.floor(start + _local2);
return(Math.min(_local2, stop));
};
this.rangeFromSeed2 = function (start, stop) {
var _local3 = stop - start;
var _local2 = this.floatFromSeed2() * (_local3 + 1);
_local2 = Math.floor(start + _local2);
return(Math.min(_local2, stop));
};
this.floatFromSeed = function () {
seed = ((seed * 732573) + 3545443) & 65535;
var _local1 = seed / 65536;
return(_local1);
};
this.floatFromSeed2 = function () {
seed2 = ((seed2 * 732573) + 3545443) & 65535;
var _local1 = seed2 / 65536;
return(_local1);
};
}
function wr() {
var _local3 = "> ";
var _local2 = 0;
while (_local2 < arguments.length) {
_local3 = _local3 + arguments[_local2];
_local2++;
if (arguments.length != _local2) {
_local3 = _local3 + " ";
}
}
trace(_local3);
if (netlog_wr) {
game.network.send_string(("LOG " + game.table.local_player.playernum) + _local3);
}
}
function wrObj(obj, rec) {
function wrObjDump(obj, rec, currprop) {
currprop = ((typeof(currprop) == "string") ? (currprop + ".") : "");
for (var _local4 in obj) {
trace(((currprop + _local4) + ": ") + obj[_local4]);
if (rec) {
if (typeof(obj[_local4]) == "object") {
wrObjDump(obj[_local4], rec, currprop + _local4);
}
}
}
}
trace("--- Obj dump: ---------");
wrObjDump(obj, rec);
trace("-----------------------");
}
function fill(width, p) {
var _local2 = "";
var _local3 = ((typeof(p) != "string") ? " " : (p));
var _local1 = 0;
while (_local1 < width) {
_local2 = _local2 + _local3;
_local1++;
}
return(_local2);
}
function parseArgString(argstr) {
var _local5 = [];
var _local2 = false;
var _local1 = "";
var _local3;
var _local4 = 0;
while (_local4 < argstr.length) {
_local3 = argstr.substr(_local4, 1);
if ((_local3 == "\"") && (!_local2)) {
_local2 = true;
} else if ((_local3 == " ") && (!_local2)) {
if (_local1 != "") {
_local5.push(_local1);
_local1 = "";
}
} else if ((_local3 == "\"") && (_local2)) {
_local2 = false;
_local5.push(_local1);
_local1 = "";
} else {
_local1 = _local1 + _local3;
}
_local4++;
}
if (_local1 != "") {
_local5.push(_local1);
}
return(_local5);
}
function GamedataObj(props) {
this.ready = false;
this.init = function (props) {
this.parent = props.parent;
events.runIt(this);
if (dev_mode) {
this.load_dev_xml();
}
};
this.run = function () {
if (gameData != undefined) {
this.parse_and_set(gameData);
events.stopIt(this);
}
};
this.parse_and_set = function (xmlstr) {
this.parse_gamedata(xmlstr);
this.ready = true;
this.parent.gamedata_loaded();
};
this.parse_gamedata = function (xmlstr) {
this.settings = {};
this.text = {};
this.mp = {};
var _local6 = new XML();
_local6.ignoreWhite = true;
_local6.parseXML(xmlstr);
var _local4 = _local6.firstChild.attributes;
for (var _local5 in _local4) {
this[_local5] = _local4[_local5];
}
var _local3 = _local6.firstChild.childNodes;
var _local2 = 0;
while (_local2 < _local3.length) {
if (_local3[_local2].nodeName == "text") {
this.text[_local3[_local2].attributes.id] = _local3[_local2].firstChild.nodeValue;
} else if (_local3[_local2].nodeName == "multiplayer") {
for (var _local5 in _local3[_local2].attributes) {
this.mp[_local5] = _local3[_local2].attributes[_local5];
}
} else if (_local3[_local2].nodeName == "settings") {
for (var _local5 in _local3[_local2].attributes) {
this.settings[_local5] = _local3[_local2].attributes[_local5];
}
}
_local2++;
}
};
this.load_dev_xml = function () {
var _local1 = new XML();
_local1.ignoreWhite = true;
_local1.onData = function (src) {
gameData = src;
};
_local1.load("xml/gamedata.xml");
};
this.init(props);
}
function Rules(props) {
var players;
var local_player;
var current_playernum;
var next_round = 0;
var current_round = 0;
var playernum_sequence;
var current_playernum_sequence;
var no_players = 4;
var no_teams = 2;
var bagback = 10;
var bagback_score = 100;
var win_score = 500;
var game_over = false;
var cir_sent = false;
var start_player = random.rangeFromSeed(0, no_players - 1);
var spades_played = false;
var deal_count = 0;
var deal_rq_count = 0;
var trump_color = null;
var card_values = {};
card_values["2"] = 2;
card_values["3"] = 3;
card_values["4"] = 4;
card_values["5"] = 5;
card_values["6"] = 6;
card_values["7"] = 7;
card_values["8"] = 8;
card_values["9"] = 9;
card_values.T = 10;
card_values.J = 11;
card_values.Q = 12;
card_values.K = 13;
card_values.A = 14;
this.init = function (props) {
this.team_score = [0, 0];
this.team_bags = [0, 0];
this.team_round_score = [0, 0];
this.team_round_bags = [0, 0];
players = props.players_ref;
this.requested_team = -1;
this.dealing = false;
playernum_sequence = [3, 0, 2, 1];
current_playernum_sequence = start_player;
current_playernum = playernum_sequence[current_playernum_sequence];
events.runIt(this);
};
this.set_gamedata = function (gd) {
win_score = this.get_gamedata_int(gd.win_score, win_score);
bagback = this.get_gamedata_int(gd.bagback, bagback);
bagback_score = this.get_gamedata_int(gd.bagback_score, bagback_score);
};
this.get_gamedata_int = function (prop, defaultval) {
var _local1 = parseInt(prop);
return((isNaN(_local1) ? (defaultval) : (_local1)));
};
this.deal_cards = function (num, carddata) {
deal_count = deal_count + (carddata.length / 2);
players[num].deal_cards(carddata);
game.network.pause_incoming();
new Delay({callback:game.network.resume_incoming, callback_scope:game.network, frames:3});
if (deal_count == 52) {
this.set_trump("3S");
}
};
this.set_trump = function (carddata) {
trump_color = carddata.substr(1, 1);
game.deal_done();
};
this.check_card_legal = function (hand, card) {
var _local1 = true;
if (game.table.pile.get_size() == 0) {
if ((card.color == "S") && (!spades_played)) {
if (((hand.color_counts.C + hand.color_counts.H) + hand.color_counts.D) > 0) {
_local1 = false;
}
}
} else if (game.table.pile.get_color() != card.color) {
if (hand.color_counts[game.table.pile.get_color()] != 0) {
_local1 = false;
}
}
return(_local1);
};
this.card_clicked = function (hand, card) {
if (local_player.playernum != current_playernum) {
return(false);
}
if (!this.check_card_legal(hand, card)) {
return(false);
}
var _local4 = hand.get_card_index(card);
hand.release_card(card);
card.playernum_sequence = current_playernum_sequence;
game.table.pile.add_card(card, hand.parent);
if (card.color == "S") {
spades_played = true;
}
game.network.send_string(((((("GPC " + local_player.playernum) + ",") + _local4) + ",") + card.value) + card.color);
this.check_trick();
return(true);
};
this.play_opponent_card = function (pnum, card_index, cardstr) {
var _local3 = players[pnum].hand;
var _local2 = _local3.get_card_by_index(card_index);
if (players[pnum].teamnum == local_player.teamnum) {
var _local7 = _local2.color;
var _local5 = _local2.value;
var _local6 = _local3.get_card_by_col_val(cardstr.charAt(1), cardstr.charAt(0));
_local6.setCard({color:_local7, value:_local5});
}
_local2.setCard({color:cardstr.charAt(1), value:cardstr.charAt(0)});
_local3.release_card(_local2);
_local2.switchSide();
_local2.playernum_sequence = current_playernum_sequence;
game.table.pile.add_card(_local2, _local3.parent);
if (_local2.color == "S") {
spades_played = true;
}
this.check_trick();
game.network.pause_incoming();
new Delay({callback:game.network.resume_incoming, callback_scope:game.network, seconds:0.2});
};
this.check_trick = function () {
var _local2 = game.table.pile;
if (_local2.get_size() == players.length) {
this.build_trick();
if (local_player.hand.get_no_cards() == 0) {
this.end_round();
}
return(undefined);
}
this.next_player();
};
this.build_trick = function () {
var _local13 = [];
var _local15 = game.table.pile;
var _local2 = _local15.get_cards();
_local15.purge();
var _local6 = -1;
var _local11 = -1;
var _local14 = _local2[0].color;
var _local4 = 0;
while (_local4 < _local2.length) {
var _local3 = 0;
if ((_local2[_local4].color == _local14) || (_local2[_local4].color == trump_color)) {
_local3 = _local3 + card_values[_local2[_local4].value];
_local3 = _local3 + ((_local2[_local4].color == trump_color) ? 100 : 0);
}
var _local9 = players[playernum_sequence[_local2[_local4].playernum_sequence]].seatnum;
_local13.push({seat:_local9, value:_local2[_local4].value, color:_local2[_local4].color});
if (_local3 > _local6) {
_local6 = _local3;
_local11 = _local2[_local4].playernum_sequence;
}
_local4++;
}
var _local10 = playernum_sequence[_local11];
var _local5 = players[_local10];
var _local12;
_local4 = 0;
while (_local4 < players.length) {
if ((_local4 != _local10) && (_local5.teamnum == players[_local4].teamnum)) {
_local12 = players[_local4];
break;
}
_local4++;
}
_local5.add_trick(_local2);
if (_local5.bet > _local5.num_visual_tricks) {
_local5.num_visual_tricks++;
} else if ((_local5.bet == 0) || (_local5.bet == "blind_nil")) {
_local5.num_visual_tricks++;
} else if (_local12.bet > _local12.num_visual_tricks) {
_local12.num_visual_tricks++;
} else {
_local5.num_visual_tricks++;
}
players[_local10].round_score[current_round] = players[_local10].round_score[current_round] + 1;
var _local16 = function () {
var _local2 = 0;
while (_local2 < players.length) {
game.gui.set_player_tricks(players[_local2]);
_local2++;
}
game.gui.set_lasttrick(this.t);
if (game.table.local_player.teamnum == p.teamnum) {
soundFx.play("stick.aif");
}
};
new Delay({seconds:1.4, callback:_local16, callback_scope:{p:players[_local10], t:_local13}});
this.next_player(_local11, 0.6);
};
this.start_game = function () {
wr("rules.start_game()");
current_round = (next_round = 0);
this.prepare_round();
};
this.prepare_round = function () {
var _local2 = 0;
while (_local2 < players.length) {
players[_local2].bet = -1;
_local2++;
}
this.team_round_score = [0, 0];
this.team_round_bags = [0, 0];
};
this.start_round = function () {
wr("rules.start_round");
current_round = next_round;
current_playernum_sequence = start_player;
current_playernum = playernum_sequence[current_playernum_sequence];
players[current_playernum].enable();
game.start_round(current_round);
};
this.end_round = function () {
var _local6 = 0;
while (_local6 < players.length) {
var _local2 = players[_local6];
var _local7 = players[_local2.teammatenum];
var _local9 = (_local2.bet != 0) && (_local2.bet != "blind_nil");
var _local5 = _local2.num_visual_tricks;
var _local3 = 0;
var _local4 = 0;
if (_local2.bet == 0) {
if (_local5 == 0) {
_local3 = _local3 + 100;
} else {
_local3 = _local3 - 100;
_local4 = _local5;
}
} else if (_local2.bet == "blind_nil") {
if (_local5 == 0) {
_local3 = _local3 + 200;
} else {
_local3 = _local3 - 200;
_local4 = _local5;
}
} else if ((_local5 < _local2.bet) || (_local9 && (_local7.num_visual_tricks < _local7.bet))) {
_local3 = (-_local2.bet) * 10;
wr("single normal, score:", _local3);
} else {
var _local8 = parseInt(_local2.bet);
_local3 = _local8 * 10;
_local4 = _local5 - _local8;
}
_local3 = _local3 + _local4;
this.team_round_bags[_local2.teamnum] = this.team_round_bags[_local2.teamnum] + _local4;
this.team_bags[_local2.teamnum] = this.team_bags[_local2.teamnum] + _local4;
if (this.team_bags[_local2.teamnum] >= bagback) {
this.team_bags[_local2.teamnum] = this.team_bags[_local2.teamnum] - bagback;
_local3 = _local3 - bagback_score;
}
this.team_round_score[_local2.teamnum] = this.team_round_score[_local2.teamnum] + _local3;
this.team_score[_local2.teamnum] = this.team_score[_local2.teamnum] + _local3;
_local6++;
}
deal_count = 0;
deal_rq_count = 0;
spades_played = false;
_local6 = 0;
while (_local6 < players.length) {
players[_local6].ready_for_round = false;
_local6++;
}
start_player = (start_player + 1) % no_players;
var _local10 = false;
_local6 = 0;
while (_local6 < this.team_score.length) {
_local10 = _local10 | (this.team_score[_local6] > win_score);
_local6++;
}
if (_local10) {
this.set_game_over();
}
next_round++;
game.end_round();
};
this.get_round_localwinner = function () {
var _local4 = game.rules.get_teamscore();
var _local2 = _local4[current_round];
var _local1 = local_player.teamnum;
var _local3 = _local2[_local1] >= _local2[(_local1 + 1) % 2];
return(_local3);
};
this.get_game_localwinner = function () {
var _local3 = this.get_teamscore();
var _local2 = local_player.teamnum;
var _local4 = _local3[_local2];
var _local5 = _local3[(_local2 + 1) % 2];
return(_local4 >= _local5);
};
this.set_game_over = function () {
game_over = true;
var _local4 = this.get_teamscore();
var _local3 = 0;
var _local2 = 0;
while (_local2 < no_teams) {
_local3 = Math.max(_local3, _local4[_local2]);
_local2++;
}
if (_local3 == _local4[local_player.teamnum]) {
local_player.winner = true;
}
_local2 = 0;
while (_local2 < players.length) {
players[_local2].ready_for_round = false;
_local2++;
}
game.set_game_over();
};
this.get_game_over = function () {
return(game_over);
};
this.localplayer_next_round = function () {
game.network.send_string("GNR " + local_player.playernum);
this.player_next_round(local_player.playernum);
if (players[local_player.teammatenum].ai_player) {
if (!players[local_player.teammatenum].ready_for_round) {
players[local_player.teammatenum].ai_player.send_next_round();
}
}
};
this.player_next_round = function (playernum) {
players[playernum].ready_for_round = true;
game.table.players[playernum].avatar.avatar_sprite._visible = true;
var _local3 = true;
var _local2 = 0;
while (_local2 < players.length) {
_local3 = _local3 & players[_local2].ready_for_round;
_local2++;
}
if (_local3) {
game.table.next_round();
this.request_deal();
}
};
this.all_next_round = function () {
var _local1 = 0;
while (_local1 < players.length) {
players[_local1].ready_for_round = true;
_local1++;
}
};
this.next_player = function (requested_suequence_number, next_player_delay) {
players[current_playernum].disable();
if (typeof(requested_suequence_number) == "number") {
current_playernum_sequence = requested_suequence_number;
} else {
current_playernum_sequence = (current_playernum_sequence + 1) % playernum_sequence.length;
}
current_playernum = playernum_sequence[current_playernum_sequence];
if (typeof(next_player_delay) == "number") {
new Delay({seconds:next_player_delay, callback:this.enable_current_player, callback_scope:this});
} else {
new Delay({seconds:0.5, callback:this.enable_current_player, callback_scope:this});
}
};
this.enable_current_player = function () {
players[current_playernum].enable();
};
this.add_local_player = function (pobj) {
var _local1 = game.table.add_local_player(pobj);
_local1.round_score = [];
_local1.bagcount = 0;
_local1.num_active_team_requests = 0;
local_player = _local1;
};
this.add_remote_player = function (pobj) {
var _local1 = game.table.add_remote_player(pobj);
_local1.player_sequence_number = _local1.playernum;
_local1.round_score = [];
_local1.bagcount = 0;
};
this.run = function () {
if (this.dealing) {
this.deal_a_card();
}
};
this.request_deal = function () {
if (this.dealing) {
return(undefined);
}
players[0].set_dealer(true);
var _local2 = local_player.dealer;
_local2 = _local2 | ((players[0].ai_player != null) && (local_player.teammatenum == 0));
if (_local2) {
game.network.send_string("JRD");
deal_rq_count = 0;
this.dealing = true;
}
};
this.deal_a_card = function () {
if (deal_rq_count == 52) {
this.dealing = false;
return(undefined);
}
var _local2 = (start_player + deal_rq_count) % playernum_sequence.length;
var _local3 = playernum_sequence[_local2];
game.network.send_string((("JRC " + _local3) + ",") + 1);
deal_rq_count = deal_rq_count + 1;
};
this.check_continue_deal = function () {
if (this.dealing) {
return(undefined);
}
var _local2 = 1;
while (_local2 < players.length) {
if (!players[_local2].ready_for_round) {
return(undefined);
}
_local2++;
}
if (deal_count == 52) {
return(undefined);
}
var _local3 = 52 - deal_count;
if (_local3 == 52) {
game.network.send_string("JRD");
}
deal_rq_count = deal_count;
this.dealing = true;
};
this.get_teamscore = function () {
return(this.team_score);
};
this.get_current_round = function () {
return(current_round);
};
this.get_start_player = function () {
return(start_player);
};
this.get_start_player_num = function () {
return(playernum_sequence[start_player]);
};
this.get_deal_seatnum = function () {
return(players[playernum_sequence[(start_player + 3) % playernum_sequence.length]].seatnum);
};
this.get_no_players = function () {
return(no_players);
};
this.get_current_playernum = function () {
return(current_playernum);
};
this.get_deal_count = function () {
return(deal_count);
};
this.send_cir = function () {
if (!cir_sent) {
game.network.send_string("CIR");
cir_sent = true;
}
};
this.select_random_team = function () {
this.select_team(99);
};
this.select_team = function (requested_team) {
if (requested_team == local_player.teamnum) {
return(false);
}
if (local_player.num_active_team_requests < 1) {
local_player.num_active_team_requests++;
this.requested_team = requested_team;
game.network.send_string("JST " + requested_team);
return(true);
}
return(false);
};
this.team_selection_rejected = function () {
local_player.num_active_team_requests--;
this.requested_team = -1;
game.team_selector.player_join_team(local_player.playernum, local_player.teamnum);
};
this.player_join_team = function (p_num, team_num) {
local_player.num_active_team_requests--;
players[p_num].set_team(team_num);
game.team_selector.player_join_team(p_num, team_num);
};
this.get_card_value = function (_value) {
return(card_values[_value]);
};
this.get_local_playernum = function () {
return(local_player.playernum);
};
this.team_select_done = function () {
var _local4 = [0, 1];
var _local6 = [0, 0];
var _local3 = 0;
while (_local3 < players.length) {
var _local2 = players[_local3].teamnum;
var _local1 = 0;
while (_local1 < players.length) {
if ((_local3 != _local1) && (players[_local3].teamnum == players[_local1].teamnum)) {
players[_local3].teammatenum = _local1;
}
_local1++;
}
playernum_sequence[_local4[_local2]] = _local3;
players[_local3].set_sequencenum(_local4[_local2]);
_local4[_local2] = _local4[_local2] + 2;
_local6[_local2]++;
_local3++;
}
if ((_local6[0] != 2) || (_local6[1] != 2)) {
game.team_selector.hide();
game.remove_player(-1);
return(undefined);
}
_local3 = 0;
while (_local3 < players.length) {
var _local5 = ((players[_local3].sequencenum - local_player.sequencenum) + players.length) % players.length;
players[_local3].set_seatnum(_local5);
_local3++;
}
current_playernum = playernum_sequence[current_playernum_sequence];
game.team_select_done();
};
this.start_betting = function () {
current_playernum_sequence = start_player;
current_playernum = playernum_sequence[current_playernum_sequence];
this.prepare_round();
var _local2 = playernum_sequence[start_player];
if (players[_local2].ai_player) {
players[_local2].ai_player.place_bet();
}
};
this.localplayer_place_bet = function (bet) {
game.network.send_string((("GPB " + local_player.playernum) + ",") + bet);
this.player_place_bet(local_player.playernum, bet);
};
this.player_place_bet = function (pnum, bet) {
players[pnum].bet = bet;
game.gui.show_placed_bet(pnum, bet);
current_playernum_sequence = (current_playernum_sequence + 1) % playernum_sequence.length;
current_playernum = playernum_sequence[current_playernum_sequence];
var _local2 = this.check_bets();
if (_local2) {
return(undefined);
}
if (local_player.playernum == current_playernum) {
game.gui.start_bettingbox();
return(undefined);
}
if (players[current_playernum].ai_player) {
players[current_playernum].ai_player.place_bet();
return(undefined);
}
};
this.check_bets = function () {
var _local3 = true;
var _local2 = 0;
while (_local2 < players.length) {
_local3 = _local3 & (players[_local2].bet != -1);
_local2++;
}
if (_local3) {
this.start_round();
return(1);
}
return(0);
};
this.get_trump_color = function () {
return(trump_color);
};
this.init(props);
}
function Gui(props) {
this.state = "startup";
this.player_count = 0;
this.player_boxes = [];
this.halos = [];
this.player_positions = [];
this.avatar_positions = [];
this.halo_positions = [];
this.score_avatar_pos = [];
this.instr_avatar_pos = [];
this.chatbubble_positions = [];
this.other_positions = {};
this.scoreboard_timer = null;
this.bettingbox_timer = null;
this.lasttrick_viewed = false;
this.init = function (props) {
this.parent = props.parent;
this.ph = sprites.create({member:"placeholders_gui", visible:false});
var _local2;
var _local3 = 0;
while (_local3 < 4) {
_local2 = this.ph["player" + _local3];
this.player_positions.push([_local2._x, _local2._y, _local2._xscale, _local2._yscale]);
_local2 = this.ph["avatar" + _local3];
this.avatar_positions.push([_local2._x, _local2._y, _local2._xscale, _local2._yscale]);
_local2 = this.ph["chat" + _local3];
this.chatbubble_positions.push([_local2._x, _local2._y, _local2._xscale, _local2._yscale]);
_local2 = this.ph["halo" + _local3];
this.halo_positions.push([_local2._x, _local2._y, _local2._xscale, _local2._yscale]);
_local3++;
}
_local2 = this.ph.emoticons;
this.other_positions.emoticons = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local2 = this.ph.hourglass;
this.other_positions.hourglass = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local2 = this.ph.score_board;
this.other_positions.score_board = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local2 = this.ph.chat_icon;
this.other_positions.chat_icon = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local2 = this.ph.chat_box;
this.other_positions.chat_box = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local2 = this.ph.lasttrick_panel;
this.other_positions.lasttrick_panel = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local2 = this.ph.time_box;
this.other_positions.time_box = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local2 = this.ph.score_box;
this.other_positions.score_box = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local2 = this.ph.betting_box;
this.other_positions.betting_box = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local2 = this.ph.logo;
this.other_positions.logo = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local3 = 0;
while (_local3 < 4) {
_local2 = this.ph["score_avatar" + _local3];
this.score_avatar_pos.push([_local2._x, _local2._y, _local2._xscale, _local2._yscale]);
_local3++;
}
sprites.remove(this.ph);
this.ph = sprites.create({member:"placeholders_instructions", visible:false});
_local2 = this.ph.instructions;
this.other_positions.instructions = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local2 = this.ph.statusbox;
this.other_positions.statusbox = [_local2._x, _local2._y, _local2._xscale, _local2._yscale];
_local3 = 0;
while (_local3 < 4) {
_local2 = this.ph["avatar" + _local3];
this.instr_avatar_pos.push([_local2._x, _local2._y, _local2._xscale, _local2._yscale]);
_local3++;
}
sprites.remove(this.ph);
this.bg = sprites.create({member:"bg_main", x:0, y:0, level:1});
this.bg_dark_plate = sprites.create({member:"bg_dark_plate", x:0, y:0, visible:false, level:15});
this.lasttrick_panel = sprites.create({member:"lasttrick_panel", x:this.other_positions.lasttrick_panel[0], y:this.other_positions.lasttrick_panel[1], visible:false, level:10});
this.score_box = sprites.create({member:"score_box", x:this.other_positions.score_box[0], y:this.other_positions.score_box[1], visible:false, level:10});
this.time_box = sprites.create({member:"time_box", x:this.other_positions.time_box[0], y:this.other_positions.time_box[1], visible:false, level:10});
this.logo = sprites.create({member:"logo", x:this.other_positions.logo[0], y:this.other_positions.logo[1], visible:false, level:4});
this.scoreboard = sprites.create({member:"score_board", x:this.other_positions.score_board[0], y:this.other_positions.score_board[1], visible:false, level:17});
this.scoreboard.active = false;
var _local4 = function () {
game.gui.click_scoreboard();
};
this.scoreboard_timer = new Timer({duration:10, textref:this.scoreboard.next_round_counter, cb:_local4, format:"sec"});
this.bettingbox = sprites.create({member:"betting_box", x:this.other_positions.betting_box[0], y:this.other_positions.betting_box[1], level:11});
this.bettingbox.active = false;
this.bettingbox._visible = false;
var _local5 = function () {
game.gui.autoselect_bettingbox();
};
this.bettingbox_timer = new Timer({duration:15, textref:this.bettingbox.counter, cb:_local5, format:"sec"});
this.hourglass = new HourGlass({x:this.other_positions.hourglass[0], y:this.other_positions.hourglass[1], scale:this.other_positions.hourglass[2]});
this.chat = new ChatClient({positions:this.other_positions});
this.alertbox = sprites.create({member:"alertbox", x:0, y:0, visible:false, level:22});
this.alertbox.active = false;
this.alertbox._x = (props.parent.width * 0.5) - (this.alertbox._width / 2);
this.alertbox._y = (props.parent.height * 0.43) - (this.alertbox._height / 2);
this.alertbox.tween_obj = new Tween();
_local3 = 0;
while (_local3 < 2) {
this.set_teamscore(_local3, 0);
this.set_teambagcnt(_local3, 0);
_local3++;
}
};
this.set_gamedata = function (gamedata) {
this.chat.set_chat_to_fast_msg(gamedata.text.chat_to_fast);
};
this.show_instructions = function () {
this.instructions = sprites.create({member:"instructions", x:this.other_positions.instructions[0], y:this.other_positions.instructions[1]});
this.instructions.active = true;
this.instructions.header.text = game.gamedata.text.instruction_header.toUpperCase();
this.instructions.start_btn_text.text = game.gamedata.text.start_btn_text.toUpperCase();
this.instructions.h1.text = game.gamedata.text.instruction_h1.toUpperCase();
this.instructions.t1.text = game.gamedata.text.instruction_t1;
this.instructions.h2.text = game.gamedata.text.instruction_h2.toUpperCase();
this.instructions.t2.text = game.gamedata.text.instruction_t2;
this.instructions.h3.text = game.gamedata.text.instruction_h3.toUpperCase();
this.instructions.h4.text = game.gamedata.text.instruction_h4.toUpperCase();
this.instructions.t4.text = game.gamedata.text.instruction_t4;
var _local2 = "";
_local2 = _local2 + (game.gamedata.text.ace + ":\n");
_local2 = _local2 + (game.gamedata.text.three + ":\n");
_local2 = _local2 + (game.gamedata.text.king + ":\n");
_local2 = _local2 + (game.gamedata.text.queen + ":\n");
_local2 = _local2 + (game.gamedata.text.jack + ":\n");
_local2 = _local2 + game.gamedata.text.instruction_t3;
this.instructions.t3.text = _local2;
this.instructions.t3b.text = "11\n10\n4\n3\n2";
this.instructions.t3c.text = fill(5, game.gamedata.text.points + newline);
this.instructions.tween_obj = new Tween();
var _local3 = [{sprite:this.instructions, from:{_alpha:0, _xscale:70, _yscale:70, _x:this.other_positions.instructions[0] + (this.instructions._width * 0.15), _y:this.other_positions.instructions[1] + (this.instructions._height * 0.15)}, to:{_alpha:100, _xscale:100, _yscale:100, _x:this.other_positions.instructions[0], _y:this.other_positions.instructions[1]}}];
this.instructions.tween_obj.go(_local3, {duration:300});
soundFx.play("introSound");
this.instructions.onRelease = function () {
game.gui.click_instructions();
};
};
this.click_instructions = function () {
if (!this.instructions.active) {
return(undefined);
}
this.instructions.active = false;
delete this.instructions.onRelease;
this.hide_instructions();
this.slide_up_statusbox();
game.network.pause_incoming();
new Delay({seconds:0.6, callback:game.network.resume_incoming, callback_scope:game.network});
game.rules.send_cir();
soundFx.play("click.wav", false, 80);
};
this.hide_instructions = function () {
soundFx.stop("introSound");
var _local2 = [{sprite:this.instructions, from:{_alpha:100, _xscale:100, _yscale:100, _x:this.other_positions.instructions[0], _y:this.other_positions.instructions[1]}, to:{_alpha:0, _xscale:70, _yscale:70, _x:this.other_positions.instructions[0] + (this.instructions._width * 0.15), _y:this.other_positions.instructions[1] + (this.instructions._height * 0.15)}}];
this.instructions.tween_obj.go(_local2, {duration:200});
};
this.show_bettingbox = function () {
wr("show_bettingbox");
this.bettingbox.current_selection = null;
this.bettingbox.placed_bid = null;
this.bettingbox.counter._visible = false;
this.bettingbox.header.text = game.gamedata.text.betting_box_header;
var _local2 = 0;
while (_local2 < 14) {
var _local4 = this.bettingbox["bet_" + _local2];
_local4.msg.text = ((_local2 == 0) ? (game.gamedata.text.nil) : (_local2));
var _local3 = new ClickButton({sp:_local4, id:_local2, callback:this.click_bettingbox, callback_scope:this});
_local3.disable();
_local4.btn_obj = _local3;
_local2++;
}
var _local4 = this.bettingbox.btn_1;
_local4.msg.text = game.gamedata.text.blind_nil;
var _local3 = new ClickButton({sp:_local4, id:"blind_nil", callback:this.click_bettingbox, callback_scope:this});
_local4.btn_obj = _local3;
_local4 = this.bettingbox.btn_2;
_local4.msg.text = game.gamedata.text.show_cards;
_local3 = new ClickButton({sp:_local4, id:"show_cards", callback:this.click_bettingbox, callback_scope:this});
_local4.btn_obj = _local3;
_local4 = this.bettingbox.btn_3;
_local4.msg.text = game.gamedata.text.place_bid;
_local3 = new ClickButton({sp:_local4, id:"place_bid", callback:this.click_bettingbox, callback_scope:this});
_local4.btn_obj = _local3;
_local3.disable();
_local4._alpha = 50;
this.bettingbox.tween_obj = new Tween();
var _local5 = [{sprite:this.bettingbox, from:{_alpha:0, _xscale:70, _yscale:70}, to:{_alpha:100, _xscale:100, _yscale:100}}];
this.bettingbox._visible = true;
this.bettingbox.active = true;
this.bettingbox.running = false;
this.bettingbox.betting_fade._visible = true;
_local4 = this.bettingbox.btn_1;
_local4._alpha = 100;
_local4 = this.bettingbox.btn_2;
_local4._alpha = 100;
_local2 = 0;
while (_local2 < 14) {
acolor = new Color(this.bettingbox["bet_" + _local2].msg);
acolor2 = new Color(this.bettingbox["bet_" + _local2].bet_button_bg);
acolor.setRGB(6853020);
acolor2.setRGB(14410723);
_local2++;
}
this.bettingbox.tween_obj.go(_local5, {duration:300});
};
this.click_bettingbox = function (id) {
wr("click_bettingbox() id:", id);
soundFx.play("click.wav", false, 80);
if (id == "blind_nil") {
var _local5 = this.bettingbox.btn_1;
_local5.btn_obj.disable();
game.table.local_player.emoticons.setMood("mad", 3);
if (this.bettingbox.running) {
this.stop_bettingbox();
game.rules.localplayer_place_bet(id);
game.table.players[game.rules.get_local_playernum()].show_cards();
this.chat.msg_receive((("" + game.rules.get_local_playernum()) + ",") + game.gamedata.text.blind_nil);
this.hide_bettingbox();
} else {
wr("bet before start - saving");
game.table.players[game.rules.get_local_playernum()].show_cards();
this.bettingbox.placed_bid = id;
this.hide_bettingbox();
}
}
if (id == "place_bid") {
var _local5 = this.bettingbox.btn_3;
_local5.btn_obj.disable();
if (this.bettingbox.running) {
this.stop_bettingbox();
wr("betting place bid clicked with sel = ", this.bettingbox.current_selection);
game.rules.localplayer_place_bet(this.bettingbox.current_selection);
var _local6;
if (this.bettingbox.current_selection == 0) {
game.table.local_player.emoticons.setMood("superior", 3);
_local6 = game.gamedata.text.nil;
} else {
_local6 = this.bettingbox.current_selection;
}
this.chat.msg_receive((("" + game.rules.get_local_playernum()) + ",") + _local6);
this.hide_bettingbox();
} else {
wr("bet before start - saving");
game.table.players[game.rules.get_local_playernum()].show_cards();
this.bettingbox.placed_bid = this.bettingbox.current_selection;
this.hide_bettingbox();
}
}
if (typeof(id) == "number") {
this.bettingbox.current_selection = id;
var _local2 = 0;
while (_local2 < 14) {
acolor = new Color(this.bettingbox["bet_" + _local2].msg);
acolor2 = new Color(this.bettingbox["bet_" + _local2].bet_button_bg);
acolor.setRGB(6853020);
acolor2.setRGB(14410723);
_local2++;
}
acolor = new Color(this.bettingbox["bet_" + id].msg);
acolor2 = new Color(this.bettingbox["bet_" + id].bet_button_bg);
acolor.setRGB(16777215);
acolor2.setRGB(9329967);
var _local5 = this.bettingbox.btn_3;
_local5.btn_obj.enable();
_local5._alpha = 100;
}
if (id == "show_cards") {
game.table.players[game.rules.get_local_playernum()].show_cards();
var _local5 = this.bettingbox.btn_1;
_local5.btn_obj.disable();
_local5._alpha = 30;
_local5 = this.bettingbox.btn_2;
_local5.btn_obj.disable();
_local5._alpha = 30;
var _local2 = 0;
while (_local2 < 14) {
var _local3 = this.bettingbox["bet_" + _local2];
_local3._alpha = 100;
_local3.btn_obj.enable();
_local2++;
}
this.bettingbox.betting_fade._visible = false;
}
};
this.hide_bettingbox = function () {
wr("hide_bettingbox");
this.bettingbox.active = false;
var _local2 = [{sprite:this.bettingbox, to:{_alpha:0, _xscale:70, _yscale:70}, from:{_alpha:100, _xscale:100, _yscale:100}}];
this.bettingbox.tween_obj.go(_local2, {duration:200});
};
this.start_bettingbox = function () {
wr("start_bettingbox");
if (this.bettingbox.running) {
return(undefined);
}
if (this.bettingbox.placed_bid != null) {
this.execute_bettingbox_bet();
return(undefined);
}
wr("bet not set earlier - starting timer");
this.bettingbox.running = true;
this.bettingbox_timer.init();
this.bettingbox_timer.startTimer();
this.bettingbox.counter._visible = true;
soundFx.play("next_round.aif");
};
this.stop_bettingbox = function () {
wr("stop_bettingbox");
if (!this.bettingbox.running) {
return(undefined);
}
this.bettingbox.running = false;
this.bettingbox_timer.stopTimer();
this.bettingbox.counter._visible = false;
};
this.execute_bettingbox_bet = function () {
wr("this.execute_bettingbox_bet");
wr("this.bettingbox.placed_bid", this.bettingbox.placed_bid);
var _local2 = this.bettingbox.placed_bid;
if (_local2 == "blind_nil") {
game.rules.localplayer_place_bet(_local2);
this.chat.msg_receive((("" + game.rules.get_local_playernum()) + ",") + game.gamedata.text.blind_nil);
} else {
game.rules.localplayer_place_bet(_local2);
var _local3;
if (_local2 == 0) {
_local3 = game.gamedata.text.nil;
} else {
_local3 = _local2;
}
this.chat.msg_receive((("" + game.rules.get_local_playernum()) + ",") + _local3);
}
};
this.autoselect_bettingbox = function () {
wr("this.autoselect_bettingbox");
soundFx.play("click.wav", false, 80);
if (this.bettingbox.current_selection == null) {
wr("current_selection = undefined or null");
this.bettingbox.current_selection = 3;
game.rules.localplayer_place_bet(this.bettingbox.current_selection);
var _local2;
if (this.bettingbox.current_selection == 0) {
_local2 = game.gamedata.text.nil;
} else {
_local2 = this.bettingbox.current_selection;
}
this.chat.msg_receive((("" + game.rules.get_local_playernum()) + ",") + _local2);
game.table.players[game.rules.get_local_playernum()].show_cards();
this.hide_bettingbox();
} else {
wr("this.bettingbox.current_selection", this.bettingbox.current_selection);
game.rules.localplayer_place_bet(this.bettingbox.current_selection);
if (this.bettingbox.current_selection == 0) {
var _local2 = game.gamedata.text.nil;
} else {
var _local2 = this.bettingbox.current_selection;
}
this.chat.msg_receive((("" + game.rules.get_local_playernum()) + ",") + _local2);
game.table.players[game.rules.get_local_playernum()].show_cards();
this.hide_bettingbox();
}
};
this.is_bettingbox_visible = function () {
return(this.bettingbox._visible);
};
this.hide_lasttrick = function () {
var _local2 = [{sprite:this.lasttrick_panel.fade, to:{_y:-100}, from:{_y:this.lasttrick_panel.fade._y}}, {sprite:this.lasttrick_panel.minicards, to:{_y:-100}, from:{_y:this.lasttrick_panel.minicards._y}}];
this.lasttrick_panel.tween_obj.go(_local2, {duration:200});
this.lasttrick_panel.bg.gotoAndPlay(1);
this.lasttrick_panel.is_showing = false;
};
this.show_lasttrick = function () {
var _local2 = [{sprite:this.lasttrick_panel.fade, from:{_y:this.lasttrick_panel.fade._y}, to:{_y:9}}, {sprite:this.lasttrick_panel.minicards, from:{_y:this.lasttrick_panel.minicards._y}, to:{_y:44}}];
this.lasttrick_panel.tween_obj.go(_local2, {duration:200});
this.lasttrick_panel.bg.gotoAndPlay(2);
this.lasttrick_panel.is_showing = true;
};
this.show_table = function () {
var _local2 = game.gamedata.text.totaltime;
this.stopwatch = new Stopwatch({textref:this.time_box.totaltime, text:_local2});
this.stopwatch.start();
this.time_box.round.text = (game.gamedata.text.round + " ") + 1;
this.score_box.score.text = game.gamedata.text.score;
this.score_box.bags.text = game.gamedata.text.bags;
this.lasttrick_panel.lasttrick.text = game.gamedata.text.lasttrick;
this.lasttrick_panel.minicards._visible = false;
this.lasttrick_panel.tween_obj = new Tween();
this.lasttrick_panel.is_showing = false;
this.lasttrick_panel.onRelease = function () {
wr("lasttrick pushed");
soundFx.play("click.wav", false, 80);
if (game.gui.lasttrick_panel.is_showing) {
game.gui.hide_lasttrick();
} else {
game.gui.show_lasttrick();
}
};
var _local4 = new Tween();
var _local3 = [{to:{_alpha:100}, from:{_alpha:0}, sprite:this.lasttrick_panel}, {to:{_alpha:100}, from:{_alpha:0}, sprite:this.score_box}, {to:{_alpha:100}, from:{_alpha:0}, sprite:this.time_box}, {to:{_alpha:100}, from:{_alpha:0}, sprite:this.logo}];
_local4.go(_local3, {duration:300, callback:this.show_playerboxes, callback_scope:this});
};
this.set_lasttrick = function (sortedTricks) {
this.lasttrick_panel.minicards._visible = true;
var _local2 = 0;
while (_local2 < sortedTricks.length) {
var _local3 = sortedTricks[_local2].value;
_local3 = ((_local3 == "T") ? 10 : (_local3));
this.lasttrick_panel.minicards["minicard" + sortedTricks[_local2].seat].value.text = _local3;
this.lasttrick_panel.minicards["minicard" + sortedTricks[_local2].seat].color_symbols.gotoAndStop(sortedTricks[_local2].color);
_local2++;
}
if (!this.lasttrick_viewed) {
this.show_lasttrick();
this.lasttrick_viewed = true;
}
};
this.show_scoreboard = function () {
wr("gui.show_scoreboard()");
var _local2 = 0;
while (_local2 < 2) {
this.set_teamscore(_local2, game.rules.team_score[_local2]);
this.set_teambagcnt(_local2, game.rules.team_bags[_local2]);
_local2++;
}
this.scoreboard.active = true;
this.scoreboard.header.text = game.gamedata.text.scoreboard_header;
this.scoreboard.next_round.text = game.gamedata.text.next_round;
_local2 = 0;
while (_local2 < 2) {
this.scoreboard["total_desc_" + _local2].text = game.gamedata.text.total_desc;
this.scoreboard["score_desc_" + _local2].text = game.gamedata.text.score_desc;
this.scoreboard["bags_desc_" + _local2].text = game.gamedata.text.bags_desc;
this.scoreboard["total_value_" + _local2].text = game.rules.team_score[_local2];
this.scoreboard["score_value_" + _local2].text = game.rules.team_round_score[_local2];
this.scoreboard["bags_value_" + _local2].text = game.rules.team_round_bags[_local2];
_local2++;
}
if (!game.get_game_over()) {
this.scoreboard.onRelease = function () {
game.gui.click_scoreboard();
};
this.scoreboard_timer.init();
this.scoreboard_timer.startTimer();
soundFx.play("next_round.aif");
} else {
this.scoreboard.next_round.text = "";
this.scoreboard.next_round_counter.text = "";
this.scoreboard.next_round_frame._visible = false;
this.scoreboard.header.text = game.gamedata.text.scoreboard_game_over;
var _local3 = game.table.local_player.teamnum;
if (game.table.local_player.winner) {
this.scoreboard["win_lose_" + _local3].text = game.gamedata.text.winners;
_local3 = (_local3 + 1) % 2;
this.scoreboard["win_lose_" + _local3].text = game.gamedata.text.losers;
soundFx.play("game_win.aif");
} else {
this.scoreboard["win_lose_" + _local3].text = game.gamedata.text.losers;
_local3 = (_local3 + 1) % 2;
this.scoreboard["win_lose_" + _local3].text = game.gamedata.text.winners;
soundFx.play("game_over.aif");
}
}
this.scoreboard._visible = true;
this.scoreboard._alpha = 0;
if (!this.scoreboard.tween_obj) {
this.scoreboard.tween_obj = new Tween();
}
var _local4 = [{sprite:this.scoreboard, from:{_alpha:0, _xscale:70, _yscale:70, _x:this.other_positions.score_board[0] + (this.scoreboard._width * 0.15), _y:this.other_positions.score_board[1] + (this.scoreboard._height * 0.15)}, to:{_alpha:100, _xscale:100, _yscale:100, _x:this.other_positions.score_board[0], _y:this.other_positions.score_board[1]}}];
this.scoreboard.tween_obj.go(_local4, {duration:300, callback:this.avatars_to_scoreboard, callback_scope:this});
this.bg_dark_plate._visible = true;
};
this.click_scoreboard = function () {
soundFx.play("click.wav", false, 80);
delete this.scoreboard.onRelease;
this.scoreboard_timer.stopTimer();
game.rules.click_scoreboard();
this.hide_scoreboard();
game.table.local_player.avatar.setMood("neutral");
game.rules.localplayer_next_round();
};
this.hide_scoreboard = function () {
if (!this.scoreboard.active) {
return(undefined);
}
this.scoreboard.active = false;
var _local3 = [{sprite:this.scoreboard, from:{_alpha:100, _xscale:100, _yscale:100, _x:this.other_positions.score_board[0], _y:this.other_positions.score_board[1]}, to:{_alpha:0, _xscale:70, _yscale:70, _x:this.other_positions.score_board[0] + (this.scoreboard._width * 0.15), _y:this.other_positions.score_board[1] + (this.scoreboard._height * 0.15)}}];
this.scoreboard.tween_obj.go(_local3, {duration:200});
this.bg_dark_plate._visible = false;
var _local2 = 0;
while (_local2 < game.table.players.length) {
this.positionate_avatar(game.table.players[_local2].seatnum, game.table.players[_local2].avatar);
game.table.players[_local2].avatar.avatar_sprite._visible = game.table.players[_local2].ready_for_round;
this.reset_player_tricks();
this.lasttrick_panel.minicards._visible = false;
_local2++;
}
};
this.hilite_playerbox = function (boxnum, activate) {
if (!this.player_boxes[boxnum].pulsate) {
this.player_boxes[boxnum].pulsate = new Pulsate({sprite:this.player_boxes[boxnum].hilite, alpha:60});
}
if (activate) {
this.player_boxes[boxnum].pulsate.start();
this.player_boxes[boxnum].hilite._visible = true;
} else {
this.player_boxes[boxnum].pulsate.stop();
this.player_boxes[boxnum].hilite._visible = false;
}
};
this.set_playerbox = function (boxnum, teamnum, name) {
wr("game.table.local_player.teamnum", game.table.local_player.teamnum);
var _local5 = ((teamnum == 0) ? "player_box_blue" : "player_box_red");
var _local3 = sprites.create({member:_local5, x:this.player_positions[boxnum][0], y:this.player_positions[boxnum][1], visible:false, level:10});
var _local4 = sprites.create({member:"halo", x:this.halo_positions[boxnum][0], y:this.halo_positions[boxnum][1], visible:false, level:2});
this.halos[boxnum] = _local4;
_local3.hilite._visible = false;
_local3.name.text = name;
_local3.name._alpha = 100;
this.player_boxes[boxnum] = _local3;
};
this.set_teamscore = function (teamnum, score) {
var _local2 = ((teamnum == 0) ? (this.score_box.score_blue) : (this.score_box.score_red));
_local2.text = score;
};
this.set_teambagcnt = function (teamnum, bag_cnt) {
var _local2 = ((teamnum == 0) ? (this.score_box.bags_blue) : (this.score_box.bags_red));
_local2.text = bag_cnt;
};
this.show_placed_bet = function (pnum, bet) {
var _local2 = 0;
while (_local2 < bet) {
var _local3 = _local2 + 1;
var _local4 = game.table.players[pnum].seatnum;
this.player_boxes[_local4]["marker" + _local3].gotoAndStop(3);
_local2++;
}
};
this.set_player_tricks = function (player) {
var _local6 = player.num_visual_tricks;
var _local5 = player.bet;
var _local2 = 0;
while (_local2 < 14) {
var _local4 = _local2 + 1;
if (_local2 < _local6) {
if (_local2 < _local5) {
if (player.local && (this.player_boxes[player.seatnum]["marker" + _local4]._currentframe != 2)) {
game.table.local_player.emoticons.setMood("happy", 3);
wr("game.table.local_player.emoticons.setMood(happy)");
}
this.player_boxes[player.seatnum]["marker" + _local4].gotoAndStop(2);
} else {
if (player.local && (this.player_boxes[player.seatnum]["marker" + _local4]._currentframe != 4)) {
game.table.local_player.emoticons.setMood("sad", 3);
}
this.player_boxes[player.seatnum]["marker" + _local4].gotoAndStop(4);
}
} else if (_local2 < _local5) {
this.player_boxes[player.seatnum]["marker" + _local4].gotoAndStop(3);
}
_local2++;
}
};
this.reset_player_tricks = function () {
wr("reset_player_tricks");
var _local4 = 0;
while (_local4 < this.player_boxes.length) {
var _local2 = 0;
while (_local2 < 14) {
var _local3 = _local2 + 1;
this.player_boxes[_local4]["marker" + _local3].gotoAndStop(1);
_local2++;
}
_local4++;
}
};
this.show_playerboxes = function () {
var _local13 = new Tween();
var _local7 = [];
var _local6;
var _local2;
var _local3 = 0;
while (_local3 < this.player_boxes.length) {
_local6 = this.player_positions[_local3][0] < (game.width / 2);
this.player_boxes[_local3]._x = (_local6 ? (-this.player_boxes[_local3]._width) : (game.width));
this.player_boxes[_local3]._visible = true;
_local2 = {sprite:this.player_boxes[_local3], from:{_x:this.player_positions[_local3][0], _alpha:0}, to:{_x:this.player_positions[_local3][0], _alpha:100}};
_local7.push(_local2);
_local3++;
}
var _local4;
var _local5;
_local3 = 0;
while (_local3 < game.table.players.length) {
_local4 = game.table.players[_local3].avatar.avatar_sprite;
_local5 = game.table.players[_local3].avatar.avatar_sprite._x;
_local6 = _local4._x < (game.width / 2);
_local4._x = (_local6 ? (-_local5) : (game.width + (game.width - _local5)));
_local4._visible = true;
_local2 = {sprite:_local4, from:{_x:_local5, _alpha:0}, to:{_x:_local5, _alpha:100}};
_local7.push(_local2);
_local3++;
}
_local3 = 0;
while (_local3 < this.halos.length) {
this.halos[_local3]._visible = true;
_local2 = {sprite:this.halos[_local3], from:{_alpha:0}, to:{_alpha:100}};
_local7.push(_local2);
_local3++;
}
_local13.go(_local7, {duration:500});
};
this.avatar_ready = function (avatar) {
avatar.avatar_sprite._xscale = -this.instr_avatar_pos[this.player_count][2];
avatar.avatar_sprite._yscale = this.instr_avatar_pos[this.player_count][3];
avatar.avatar_sprite._x = this.instr_avatar_pos[this.player_count][0] + (avatar.avatar_width * (this.instr_avatar_pos[this.player_count][2] / 100));
avatar.avatar_sprite._y = this.instr_avatar_pos[this.player_count][1] + this.statusbox.offset_y;
wr("gui.avatar_ready");
wr("avatar_sprite._x", avatar.avatar_sprite._x, "avatar_sprite._y", avatar.avatar_sprite._y);
avatar.avatar_sprite._visible = true;
this.player_count++;
this.set_statusbox_msg(((game.gamedata.text.waiting_for_players + " (") + this.player_count) + "/4)");
soundFx.play("tone_a.aif", false, 80);
};
this.positionate_avatar = function (num, avatar) {
var _local3 = 70;
wr("gui.positionate_avatar", num);
avatar.avatar_sprite._x = this.avatar_positions[num][0];
avatar.avatar_sprite._y = this.avatar_positions[num][1];
avatar.avatar_sprite._visible = false;
avatar.avatar_sprite._xscale = -_local3;
avatar.avatar_sprite._x = avatar.avatar_sprite._x + ((avatar.avatar_width * _local3) / 100);
avatar.avatar_sprite._yscale = _local3;
};
this.avatars_to_scoreboard = function () {
var _local4;
var _local2;
var _local3 = [0, 2];
var _local5 = 0;
while (_local5 < game.table.players.length) {
_local4 = game.table.players[_local5].avatar.avatar_sprite;
_local2 = game.table.players[_local5].teamnum;
_local4._x = this.score_avatar_pos[_local3[_local2]][0];
_local4._y = this.score_avatar_pos[_local3[_local2]][1];
_local4._yscale = this.score_avatar_pos[_local3[_local2]][3];
if ((_local3[_local2] % 2) == 1) {
_local4._xscale = this.score_avatar_pos[_local3[_local2]][2];
} else {
_local4._xscale = -this.score_avatar_pos[_local3[_local2]][2];
_local4._x = _local4._x + (game.table.players[_local5].avatar.avatar_width * (this.score_avatar_pos[_local3[_local2]][2] / 100));
}
_local4._visible = true;
_local3[_local2]++;
_local5++;
}
var _local6 = game.rules.get_round_localwinner();
if (game.get_game_over()) {
_local6 = game.rules.get_game_localwinner();
}
var _local7 = (_local6 ? "happy" : "angry");
game.table.local_player.avatar.setMood(_local7);
};
this.show_statusbox = function () {
this.statusbox = sprites.create({member:"statusbox", x:this.other_positions.statusbox[0], y:this.other_positions.statusbox[1]});
this.statusbox.status.text = game.gamedata.text.status_tag.toUpperCase();
this.statusbox.status_msg.text = game.gamedata.text.waiting_for_players + " (0/4)";
this.statusbox.time_to_game.text = game.gamedata.text.time_to_start.toUpperCase();
this.statusbox.time.text = "";
this.statusbox.offset_y = 0;
var _local2 = function () {
game.gui.instructions_timer_ended();
};
this.instructions_timer = new Timer({duration:20, textref:this.statusbox.time, cb:_local2, format:"time"});
this.instructions_timer.startTimer();
this.statusbox.tween_obj = new Tween();
var _local3 = [{to:{_alpha:100}, from:{_alpha:0}, sprite:this.statusbox}];
this.statusbox.tween_obj.go(_local3, {duration:200});
this.statusbox.active = true;
};
this.slide_up_statusbox = function () {
var _local11 = (game.height / 2) - (this.statusbox._height / 2);
var _local9 = this.other_positions.statusbox[1] - _local11;
this.statusbox.offset_y = -_local9;
var _local10 = [{from:{_y:this.other_positions.statusbox[1]}, to:{_y:_local11}, sprite:this.statusbox}];
var _local4;
var _local3;
var _local13;
var _local2 = 0;
while (_local2 < game.table.players.length) {
_local3 = game.table.players[_local2].avatar.avatar_sprite;
avatar_y = game.table.players[_local2].avatar.avatar_sprite._y;
_local4 = {sprite:_local3, from:{_y:this.instr_avatar_pos[_local2][1]}, to:{_y:this.instr_avatar_pos[_local2][1] - _local9}};
_local10.push(_local4);
_local2++;
}
this.statusbox.tween_obj.go(_local10, {duration:500});
};
this.hide_statusbox = function () {
if (!this.statusbox.active) {
return(undefined);
}
this.statusbox.active = false;
this.instructions_timer.stopTimer();
if (this.status_dotanimator) {
this.status_dotanimator.stop();
}
var _local4 = [{to:{_alpha:0}, from:{_alpha:100}, sprite:this.statusbox}];
this.statusbox.tween_obj.go(_local4, {duration:200});
var _local3;
var _local2 = 0;
while (_local2 < game.table.players.length) {
_local3 = game.table.players[_local2].avatar.avatar_sprite;
_local3._visible = false;
_local2++;
}
};
this.set_statusbox_msg = function (msg) {
if (!this.statusbox) {
return(undefined);
}
this.statusbox.status_msg.text = msg;
};
this.instructions_timer_ended = function () {
game.rules.send_cir();
this.click_instructions();
this.status_dotanimator = {txt:"", dots:0, cnt:0, running:false, run:function () {
this.cnt++;
var _local2 = "..............";
if ((this.cnt % 25) == 0) {
this.dots++;
this.dots = this.dots % 11;
game.gui.statusbox.time.text = this.txt + _local2.substr(0, this.dots);
}
}, start:function () {
if (this.running) {
return(undefined);
}
this.running = true;
events.runIt(this);
}, stop:function () {
if (!this.running) {
return(undefined);
}
this.running = false;
events.stopIt(this);
}};
this.status_dotanimator.start();
};
this.show_alert = function (msg) {
soundFx.play("game_over.aif");
this.bg_dark_plate.toLevel(21);
this.bg_dark_plate.onRelease = function () {
trace("bg_dark_plate cover click");
};
this.bg_dark_plate.useHandCursor = false;
this.bg_dark_plate._visible = true;
this.alertbox.header.text = game.gamedata.text.alert;
this.alertbox.msg.text = msg;
this.alertbox._visible = true;
if (!this.alertbox.active) {
this.alertbox._alpha = 0;
var _local2 = [{sprite:this.alertbox, from:{_alpha:0, _xscale:70, _yscale:70, _x:this.alertbox._x + (this.alertbox._width * 0.15), _y:this.alertbox._y + (this.alertbox._height * 0.15)}, to:{_alpha:100, _xscale:100, _yscale:100, _x:this.alertbox._x, _y:this.alertbox._y}}];
this.alertbox.tween_obj.go(_local2, {duration:300});
}
this.alertbox.active = true;
};
this.halt = function () {
if (this.instructions.active) {
delete this.instructions.onRelease;
this.hide_instructions();
}
if (this.statusbox.active) {
this.hide_statusbox();
}
if (this.bettingbox.active) {
this.stop_bettingbox();
this.hide_bettingbox();
}
if (this.scoreboard.active) {
delete this.scoreboard.onRelease;
this.scoreboard_timer.stopTimer();
this.hide_scoreboard();
}
};
this.init(props);
}
function Table(props) {
this.players = [];
this.positions = [];
this.trick_positions = [];
this.hand_positions = [];
this.deck_positions = [];
this.local_player = null;
this.deck = null;
this.pile = null;
this.pile_positions = [];
this.trump_position = [];
this.card_group = sprites.create({x:0, y:0});
this.card_group.setMask(this.card_mask);
this.init = function (props) {
this.ph = sprites.create({member:"placeholders_table", visible:false});
var _local4;
var _local3;
var _local12;
var _local11;
var _local5 = 0;
while (_local5 < 4) {
_local4 = this.ph["hand" + _local5];
_local3 = _local4.getBounds(_root);
_local12 = _local3.xMin + ((_local3.xMax - _local3.xMin) / 2);
_local11 = _local3.yMin + ((_local3.yMax - _local3.yMin) / 2);
this.hand_positions.push([_local12, _local11, _local4._rotation, _local4._xscale]);
this.positions.push([_local12, _local11, _local4._width, _local4._height]);
_local4 = this.ph["pile" + _local5];
_local3 = _local4.getBounds(_root);
_local12 = _local3.xMin + ((_local3.xMax - _local3.xMin) / 2);
_local11 = _local3.yMin + ((_local3.yMax - _local3.yMin) / 2);
this.pile_positions.push([_local12, _local11, _local4._rotation, _local4._xscale]);
_local4 = this.ph["trick" + _local5];
_local3 = _local4.getBounds(_root);
_local12 = _local3.xMin + ((_local3.xMax - _local3.xMin) / 2);
_local11 = _local3.yMin + ((_local3.yMax - _local3.yMin) / 2);
var _local6 = 20;
if (_local12 > (props.width / 2)) {
_local6 = -_local6;
}
this.trick_positions.push([_local12, _local11, _local6, 0, _local4._rotation * 2]);
_local4 = this.ph["deck" + _local5];
_local3 = _local4.getBounds(_root);
_local12 = _local3.xMin + ((_local3.xMax - _local3.xMin) / 2);
_local11 = _local3.yMin + ((_local3.yMax - _local3.yMin) / 2);
this.deck_positions.push([_local12, _local11, _local4._rotation, _local4._xscale]);
_local5++;
}
var _local8 = this.ph.trump;
_local3 = _local8.getBounds(_root);
_local12 = _local3.xMin + ((_local3.xMax - _local3.xMin) / 2);
_local11 = _local3.yMin + ((_local3.yMax - _local3.yMin) / 2);
this.trump_position = [_local12, _local11, _local8._rotation, _local8._xscale];
this.pile = new Pile({x:200, y:200, parent:this});
};
this.get_centerpos = function (mc) {
var _local1 = (mc._rotation * Math.PI) / 180;
var _local2 = 0;
};
this.add_local_player = function (pobj) {
pobj.parent = this;
pobj.local = true;
this.players[pobj.playernum] = new Player(pobj);
this.local_player = this.players[pobj.playernum];
this.players[pobj.playernum].add_avatar();
return(this.players[pobj.playernum]);
};
this.add_remote_player = function (pobj) {
pobj.parent = this;
pobj.local = false;
this.players[pobj.playernum] = new Player(pobj);
this.players[pobj.playernum].add_avatar();
return(this.players[pobj.playernum]);
};
this.next_round = function () {
var _local2 = 0;
while (_local2 < this.players.length) {
this.players[_local2].next_round();
_local2++;
}
var _local3 = game.rules.get_deal_seatnum();
this.deck = new Deck({x:this.deck_positions[_local3][0], y:this.deck_positions[_local3][1], v:this.deck_positions[_local3][2], scale:this.deck_positions[_local3][3], parent:this, parent_sp:this.card_group});
this.deck.show();
};
this.halt = function () {
var _local2 = 0;
while (_local2 < this.players.length) {
this.players[_local2].halt();
_local2++;
}
};
this.init(props);
}
function Network(props) {
this.cmd_listeners = {};
this.out_listeners = [];
this.pause_in_active = 0;
this.pause_in_stack = [];
this.init = function (props) {
this.parent = props.parent;
};
this.connect = function (props) {
this.mp_props = props;
var _local3 = {listener:this, host:props.hostname, port:props.port, pingtime:parseInt(props.pingtime)};
this.sock = new CommSocket(_local3);
this.sock.connect();
};
this.disconnect = function () {
this.sock.disconnect();
};
this.add_listener = function (cmd, obj) {
this.cmd_listeners[cmd] = obj;
};
this.socketEvent = function (props, force_through) {
if (typeof(props.status) == "string") {
if (props.status == "connection established") {
var _local6 = this.mp_props.slotid;
var _local7 = this.mp_props.magic;
this.send_string((("CCC " + _local6) + " ") + _local7);
} else if ((props.status == "no connection") || (props.status == "connection failed")) {
this.handleCommError("unable_to_connect");
} else if (props.status == "connection closed") {
this.handleCommError("local_disconnect");
}
}
if (typeof(props.data) == "string") {
if (((this.pause_in_active > 0) || (this.pause_in_stack.length > 0)) && (force_through != true)) {
this.pause_in_stack.push(props);
} else {
var _local5 = props.data.charAt(0);
var _local3 = props.data.substr(0, 3);
var _local4 = props.data.substr(4);
if (_local5 == "S") {
this.handleServerEvent(_local3, _local4);
} else if (_local5 == "G") {
this.handleGameEvent(_local3, _local4);
} else if (this.cmd_listeners[_local3]) {
this.cmd_listeners[_local3].networkEvent(_local3, _local4);
}
}
}
};
this.handleServerEvent = function (cmd, dat) {
switch (cmd) {
case "SCA" :
this.parent.add_local_player(this.parse_player_info(dat));
break;
case "SAC" :
this.parent.add_remote_player(this.parse_player_info(dat));
break;
case "SCD" :
this.parent.remove_player(parseInt(dat));
break;
case "SSG" :
this.parent.start_game();
break;
case "SAG" :
this.handleCommError("server_abort_game");
break;
case "STM" :
break;
default :
this.parent.networkServerEvent(cmd, dat);
}
};
this.handleGameEvent = function (cmd, dat) {
var _local2 = dat.split(",");
var _local4 = parseInt(_local2[0]);
_local2.splice(0, 1);
var _local3 = _local2.join(",");
this.parent.networkGameEvent(cmd, _local4, _local3);
};
this.handleCommError = function (msg) {
this.parent.handleCommError(msg);
};
this.send_string = function (str, sender) {
if (this.sock.online) {
this.sock.send_string(str);
}
};
this.send_ai_string = function (str) {
if (this.sock.online) {
this.socketEvent({data:str});
this.sock.send_string(str);
}
};
this.pause_incoming = function () {
this.pause_in_active++;
};
this.resume_incoming = function () {
this.pause_in_active--;
if (this.pause_in_active > 0) {
return(undefined);
}
var _local2 = 0;
while (_local2 < this.pause_in_stack.length) {
this.socketEvent(this.pause_in_stack[_local2], true);
if (this.pause_in_active > 0) {
this.pause_in_stack.splice(0, _local2 + 1);
return(undefined);
}
_local2++;
}
this.pause_in_stack = [];
};
this.parse_player_info = function (dat) {
var _local2 = parseArgString(dat);
var _local1 = {};
_local1.playernum = parseInt(_local2[0]);
_local1.playername = _local2[1];
_local1.avatar = _local2[2];
return(_local1);
};
this.init(props);
}
function Playdata(props) {
this.init = function (props) {
};
this.init(props);
}
function Robohand(props) {
this.init = function (props) {
this.cards = [];
this.color_counts = {};
this.color_counts.S = 0;
this.color_counts.D = 0;
this.color_counts.H = 0;
this.color_counts.C = 0;
};
this.add_card = function (_carddata) {
this.color_counts[_carddata.charAt(1)]++;
this.cards.push(_carddata);
};
this.remove_card = function (_index) {
this.color_counts[this.cards[_index].charAt(1)]--;
this.cards.length();
this.cards.splice(_index, 1);
this.cards.length();
};
this.init(props);
}
function Roboplayer(props) {
var card_values = {};
card_values["2"] = 2;
card_values["3"] = 3;
card_values["4"] = 4;
card_values["5"] = 5;
card_values["6"] = 6;
card_values["7"] = 7;
card_values["8"] = 8;
card_values["9"] = 9;
card_values.T = 10;
card_values.J = 11;
card_values.Q = 12;
card_values.K = 13;
card_values.A = 14;
this.init = function (props) {
this.net_verbose = false;
this.verbose = false;
this.players = [];
this.current_playernumindex = 0;
this.playernum_sequence = [];
this.current_playernum_sequence = -1;
this.deck_length = 52;
this.playfast = false;
this.disconnect_ai_test = true;
this.hand = new Robohand();
this.cards_deal_count = 0;
this.pile = [];
var _local3 = function () {
this.my_robot.connect();
};
var _local2 = new RoboDelay(_local3, (this.playfast ? 0 : (Math.round(Math.random() * 40) + 40)));
_local2.my_robot = this;
};
this.connect = function () {
this.network = new Network({parent:this});
this.network.connect(props);
};
this.add_local_player = function (pobj) {
this.network.send_string("CIR");
this.playername = pobj.playername;
this.playernum = pobj.playernum;
this.players[this.playernum] = {playernum:this.playernum};
};
this.add_remote_player = function (pobj) {
if (this.verbose) {
wr(("robot " + this.playernum) + ": added player:", pobj.playernum);
}
this.players[pobj.playernum] = {playernum:pobj.playernum};
};
this.start_game = function () {
if (this.verbose) {
wr("roboplayer.start_game()");
}
var _local2 = (this.playfast ? 0 : (Math.random() * 1));
new Delay({seconds:_local2, callback:this.select_random_team, callback_scope:this});
};
this.start_betting = function () {
this.bet_count = 0;
this.current_playernum_sequence = ((game.rules.get_start_player() + this.playernum_sequence.length) - 1) % this.playernum_sequence.length;
this.next_bet();
};
this.next_bet = function () {
if (this.bet_count == 4) {
this.start_round();
return(undefined);
}
this.bet_count++;
this.current_playernum_sequence = (this.current_playernum_sequence + 1) % this.playernum_sequence.length;
wr("robot", this.playernum, "got bet, next to bid is:", this.current_playernum_sequence);
if (this.playernum_sequence[this.current_playernum_sequence] == this.playernum) {
var _local3 = function () {
this.my_robot.place_bet();
};
var _local2 = new RoboDelay(_local3, (this.playfast ? 0 : 25));
_local2.my_robot = this;
}
};
this.start_round = function () {
if (this.disconnect_ai_test) {
if (this.players[this.playernum].teamnum == game.table.local_player.teamnum) {
this.network.disconnect();
return(undefined);
}
}
this.current_playernum_sequence = ((game.rules.get_start_player() + this.playernum_sequence.length) - 1) % this.playernum_sequence.length;
this.next_player();
};
this.next_player = function () {
if (this.pile.length == this.players.length) {
var _local5 = game.rules.get_trump_color();
var _local4 = -1;
var _local6 = -1;
var _local7 = this.pile[0].color;
var _local2 = 0;
while (_local2 < this.pile.length) {
var _local3 = 0;
if ((this.pile[_local2].color == _local7) || (this.pile[_local2].color == _local5)) {
_local3 = _local3 + card_values[this.pile[_local2].value];
_local3 = _local3 + ((this.pile[_local2].color == _local5) ? 100 : 0);
}
if (_local3 > _local4) {
_local4 = _local3;
win_playernumindex = this.pile[_local2].playernumindex;
_local6 = this.pile[_local2].playernum_sequence;
win_count = 1;
} else if (_local3 > win_playernumindex) {
win_count++;
}
_local2++;
}
if (this.verbose) {
wr("in robot, winning player is:", this.players[win_playernumindex].playernum);
}
this.current_playernum_sequence = _local6;
this.pile = [];
if (this.hand.cards.length == 0) {
this.network.send_string("GNR " + this.playernum);
this.deck_length = 52;
}
} else {
this.current_playernum_sequence = (this.current_playernum_sequence + 1) % this.playernum_sequence.length;
}
this.current_playernumindex = this.playernum_sequence[this.current_playernum_sequence];
if (this.verbose) {
wr(("robot " + this.playernum) + " next player sequence:", ((this.current_playernum_sequence + " (player ") + this.players[this.current_playernumindex].playernum) + ")");
}
if (this.players[this.current_playernumindex].playernum == this.playernum) {
var _local9 = function () {
this.my_robot.play_card();
};
var _local8 = new RoboDelay(_local9, (this.playfast ? 0 : (Math.round(Math.random() * 30) + 20)));
_local8.my_robot = this;
}
};
this.play_card = function () {
if (this.hand.cards.length == 0) {
return(undefined);
}
var _local2 = 0;
_local2 = 0;
while (_local2 < this.hand.cards.length) {
wr("robot", this.playernum, "check card:", this.hand.cards[_local2]);
if (game.rules.check_card_legal(this.hand, {color:this.hand.cards[_local2].charAt(1)})) {
break;
}
_local2++;
}
if (_local2 == this.hand.cards.length) {
wr("alert!!! robot could not find a legal card!!");
_local2 = random.range(0, this.hand.cards.length - 1);
}
var _local3 = this.hand.cards[_local2];
this.hand.remove_card(_local2);
this.pile.push({color:_local3.charAt(1), value:_local3.charAt(0), playernumindex:this.current_playernumindex, playernum_sequence:this.current_playernum_sequence});
this.network.send_string((((("GPC " + this.playernum) + ",") + _local2) + ",") + _local3);
this.next_player();
};
this.networkServerEvent = function (cmd, dat) {
if (this.net_verbose) {
wr(("robot " + this.playernum) + " networkServerEvent()", cmd, dat);
}
switch (cmd) {
case "STR" :
break;
case "STJ" :
var _local4 = dat.split(",");
var _local7 = parseInt(_local4[0]);
var _local8 = parseInt(_local4[1]);
this.player_join_team(_local7, _local8);
break;
case "STD" :
this.team_select_done();
break;
case "SDC" :
_local4 = dat.split(",", 2);
var _local5 = parseInt(_local4[0]);
var _local3 = _local4[1];
this.deck_length = this.deck_length - (_local3.length / 2);
this.cards_deal_count = this.cards_deal_count + (_local3.length / 2);
if (_local5 == this.playernum) {
var _local2 = 0;
while (_local2 < _local3.length) {
this.hand.add_card(_local3.charAt(_local2) + _local3.charAt(_local2 + 1));
_local2 = _local2 + 2;
}
}
if (this.deck_length != 0) {
break;
}
wr("robot start betting");
this.start_betting();
}
};
this.networkGameEvent = function (cmd, playernum, playdata) {
if (this.net_verbose) {
wr(("robot " + this.playernum) + " networkGameEvent()", cmd, playernum, playdata);
}
switch (cmd) {
case "GPB" :
wr("robot got bet! ", playdata);
this.next_bet();
break;
case "GPC" :
var _local2 = playdata.split(",")[1];
this.pile.push({color:_local2.charAt(1), value:_local2.charAt(0), playernumindex:this.current_playernumindex, playernum_sequence:this.current_playernum_sequence});
this.next_player();
}
};
this.place_bet = function () {
wr("robot", this.playernum, "placing a bet!!");
var _local3 = random.range(1, 4);
var _local2 = (("GPB " + this.playernum) + ",") + _local3;
this.network.send_string(_local2);
this.next_bet();
};
this.handleCommError = function (msg) {
wr("BOT Network error: " + msg);
game.gui.show_alert("BOT Network error: " + msg);
game.gui.hide_statusbox();
};
this.select_random_team = function () {
this.network.send_string("JST 99");
};
this.player_join_team = function (p_num, teamnum) {
this.players[p_num].teamnum = teamnum;
};
this.team_select_done = function () {
var _local4 = [0, 1];
var _local2 = 0;
while (_local2 < this.players.length) {
var _local3 = this.players[_local2].teamnum;
this.playernum_sequence[_local4[_local3]] = _local2;
this.players[_local2].player_sequence_number = _local2;
_local4[_local3] = _local4[_local3] + 2;
_local2++;
}
if (this.verbose) {
wr(("robot " + this.playernum) + ": teamsequence is:", this.playernum_sequence);
}
};
this.deal_cards = function (carddata) {
};
this.enable = function () {
};
this.disable = function () {
};
this.kill = function () {
};
this.halt = function () {
};
this.init(props);
}
function RoboDelay(what, frames) {
this.what = what;
this.counter = 0;
this.nFrames = frames;
this.run = function () {
this.counter++;
if (this.counter > this.nFrames) {
events.stopIt(this);
this.what();
}
};
events.runIt(this);
}
function Avatar(props) {
this.ready = false;
this.avatar_width = 110;
this.avatar_height = 110;
this.init = function (props) {
this.parent = props.parent;
this.props = props;
this.swf_path = game.gamedata.mp.chatcontrol;
};
this.load = function () {
if (__midas_chatcontrol) {
this.chatcontrol = __midas_chatcontrol;
if (__midas_chatcontrol.initiated) {
this.getAvatar();
} else {
var _local3 = {parent:this};
_local3.run = function () {
if (this.parent.chatcontrol.initiated) {
events.stopIt(this);
this.parent.getAvatar();
}
};
events.runIt(_local3);
}
} else {
this.sp = sprites.create({x:0, y:0, level:18});
this.chatcontrol = sprites.create({x:0, y:0, parent_sprite:this.sp});
this.chatcontrol.loadMovie(this.swf_path);
this.chatcontrol.initiated = false;
__midas_chatcontrol = this.chatcontrol;
var _local3 = {cc_load_ready:false, cc:this.chatcontrol, parent:this};
_local3.run = function () {
if (this.cc_load_ready) {
events.stopIt(this);
this.parent.setupChatControl();
this.parent.getAvatar();
return(undefined);
}
var _local2 = this.cc.getBytesTotal();
if (isNaN(_local2) || (_local2 < 1)) {
_local2 = -1;
} else if (this.cc.getBytesLoaded() == _local2) {
this.cc_load_ready = true;
}
};
events.runIt(_local3);
}
};
this.setupChatControl = function () {
if (__midas_chatcontrol) {
if (__midas_chatcontrol.initiated) {
return(false);
}
}
System.security.allowDomain(_root.gameDomain);
this.chatcontrol.setAllowDomain(_root.gameDomain);
if (dev_mode) {
this.chatcontrol.init(this, "../chatcontrol/");
} else {
this.chatcontrol.init(this);
}
this.chatcontrol.initiated = true;
this.chatcontrol.enable();
};
this.getAvatar = function () {
if (!this.chatcontrol.initiated) {
return(undefined);
}
this.avatar_display = this.chatcontrol.getAvatar(this.props.playernum, this.props.avatar, 0, 0, this.parent.local, this);
this.avatar_display.show();
this.avatar_sprite = this.avatar_display.clipRef;
};
this.onAvatarLoaded = function () {
this.ready = true;
if (this.parent.avatar_ready) {
this.parent.avatar_ready();
}
};
this.setMood = function (mood) {
if (!this.avatar_display) {
return(undefined);
}
this.chatcontrol.setMood(this.avatar_display, mood);
};
this.ccom = function (a) {
game.network.send_string(a);
};
this.hide = function () {
this.avatar_sprite._visible = false;
};
this.init(props);
}
function ClickButton(props) {
this.init = function (props) {
this.sp = props.sp;
this.id = props.id;
this.callback = props.callback;
this.callback_scope = props.callback_scope;
this.padding = ((typeof(props.padding) == "number") ? (props.padding) : 0);
this.on_down = props.on_down || false;
this.color_obj = new Color(this.sp);
this.std_color = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0};
this.over_color = ((typeof(props.over_color) == "object") ? (props.over_color) : null);
this.over_alpha = ((typeof(props.over_alpha) == "number") ? (props.over_alpha) : null);
if (this.padding > 0) {
this.click_sp = this.sp.createEmptyMovieClip("cl_a", 99);
this.click_sp._x = -this.padding;
this.click_sp._y = -this.padding;
this.drawRect(this.click_sp, this.sp._width + (this.padding * 2), this.sp._height + (this.padding * 2), 65280, 0);
} else {
this.click_sp = this.sp;
}
this.click_sp.parent = this;
this.enable();
};
this.enable = function () {
this.click_sp.onPress = function () {
if (this.parent.on_down) {
this.parent.exec_cb();
}
};
this.click_sp.onRelease = function () {
if (!this.parent.on_down) {
this.parent.exec_cb();
}
};
this.click_sp.onRollOver = function () {
if (this.parent.over_color) {
this.parent.color_obj.setTransform(this.parent.over_color);
}
if (this.parent.over_alpha) {
this.parent.sp._alpha = this.parent.over_alpha;
}
};
this.click_sp.onRollOut = function () {
if (this.parent.over_color) {
this.parent.color_obj.setTransform(this.parent.std_color);
}
if (this.parent.over_alpha) {
this.parent.sp._alpha = 100;
}
};
this.click_sp.onDragOut = function () {
if (this.parent.over_color) {
this.parent.color_obj.setTransform(this.parent.std_color);
}
if (this.parent.over_alpha) {
this.parent.sp._alpha = 100;
}
};
};
this.disable = function () {
delete this.click_sp.onPress;
delete this.click_sp.onRelease;
delete this.click_sp.onDragOut;
delete this.click_sp.onRollOver;
delete this.click_sp.onRollOut;
};
this.exec_cb = function () {
if (this.callback) {
this.callback.call(this.callback_scope, this.id);
}
};
this.kill = function () {
this.disable();
delete this.click_sp.parent;
sprites.remove(this.click_sp);
};
this.drawRect = function (mc, w, h, c, a) {
mc.moveTo(0, 0);
mc.beginFill(c, a);
mc.lineTo(w, 0);
mc.lineTo(w, h);
mc.lineTo(0, h);
mc.lineTo(0, 0);
mc.endFill();
};
this.init(props);
}
function CommSocket(props) {
function handle_onConnect(success) {
if (success) {
self.online = true;
if (net_debug) {
trace("CommSocket: connection established");
}
_add_to_queue({status:"connection established"});
} else {
if (net_debug) {
trace("CommSocket: connection failed");
}
_add_to_queue({status:"connection failed"});
}
}
function handle_onClose() {
self.online = false;
if (net_debug) {
trace("CommSocket: connection closed");
}
_add_to_queue({status:"connection closed"});
}
function handle_onError(err) {
if (net_debug) {
trace("CommSocket error: " + err);
}
}
function handle_onData(src) {
_add_to_queue({data:src});
last_activity = getTimer();
}
function _add_to_queue(obj) {
msg_queue.push(obj);
}
function _dispatch_event(obj) {
listener.socketEvent(obj);
}
var zock = null;
var host = props.host;
var port = props.port;
var pingtime = ((props.pingtime > 0) ? (props.pingtime * 1000) : 10000);
var lastping = 0;
var last_activity = 0;
var listener = props.listener;
var msg_queue = [];
var _local8 = 0;
var _local6 = 0;
var self = this;
this.online = false;
this.connect = function () {
if (zock) {
return(undefined);
}
events.runIt(this);
zock = new XMLSocket();
zock.onConnect = handle_onConnect;
zock.onClose = handle_onClose;
zock.onData = handle_onData;
zock.onError = handle_onError;
if (zock.connect(host, port)) {
if (net_debug) {
trace((("CommSocket: connecting to " + host) + " ") + port);
}
_add_to_queue({status:"connecting"});
} else {
if (net_debug) {
trace("CommSocket: no connection");
}
_add_to_queue({status:"no connection"});
}
};
this.disconnect = function () {
if (!zock) {
return(undefined);
}
zock.close();
this.online = false;
zock = null;
events.stopIt(this);
};
this.send_string = function (str) {
zock.send(str);
};
this.send_data = function (data) {
var _local1 = stringify(data);
zock.send(_local1);
};
this.run = function () {
if (msg_queue.length > 0) {
_dispatch_event(msg_queue.shift());
}
var _local2 = getTimer();
if ((_local2 - lastping) > pingtime) {
lastping = _local2;
if (this.online) {
this.send_string("CTM");
}
} else if ((_local2 - last_activity) > (pingtime + 4000)) {
this.disconnect();
listener.handleCommError("local_disconnect");
}
};
}
function Timer(props) {
function time_format_str(t) {
var _local2 = "";
if (timeformat == "sec") {
_local2 = "" + Math.floor(t);
} else {
_local2 = Math.floor(t / 60) + ":";
t = t % 60;
_local2 = _local2 + ((t < 10) ? ("0" + t) : (t));
}
return(_local2);
}
var running = false;
var timeLeft = {};
var textref;
var textfunc;
var timeformat = "time";
var callback;
var tick_sound;
this.init = function (props) {
timeLeft.startTime = getTimer();
timeLeft.stopTime = timeLeft.startTime;
timeLeft.secondsLeft = 0;
timeLeft.current = -1;
timeLeft.stopped = false;
if (props.duration) {
timeLeft.duration = parseInt(props.duration);
}
if (props.textref) {
textref = props.textref;
textfunc = null;
} else if (props.textfunc) {
textfunc = props.textfunc;
textref = null;
}
if (props.cb) {
callback = props.cb;
}
if (typeof(props.format) == "string") {
timeformat = props.format;
}
if (typeof(props.tick_sound) == "string") {
tick_sound = props.tick_sound;
}
running = false;
if (timeLeft.duration > 0) {
this.time_countdown();
}
};
this.time_countdown = function () {
if (timeLeft.stopped) {
return(undefined);
}
var _local4 = Math.max(0, (timeLeft.duration * 1000) - (getTimer() - timeLeft.startTime));
var _local2 = Math.round(_local4 / 1000);
timeLeft.secondsLeft = _local2;
var _local3 = time_format_str(_local2);
if (timeLeft.current != _local3) {
timeLeft.current = _local3;
if (textref) {
textref.text = _local3;
} else if (textfunc) {
textfunc(_local3);
}
if (_local2 <= 5) {
if (typeof(tick_sound) == "string") {
soundFx.play(tick_sound);
}
}
}
if (_local4 == 0) {
this.stopTimer();
if (callback) {
callback();
}
}
return(_local2);
};
this.startTimer = function () {
if (running) {
return(undefined);
}
running = true;
timeLeft.startTime = timeLeft.startTime + (getTimer() - timeLeft.stopTime);
timeLeft.stopped = false;
events.runIt(this);
};
this.stopTimer = function () {
if (!running) {
return(undefined);
}
running = false;
timeLeft.stopTime = getTimer();
timeLeft.stopped = true;
events.stopIt(this);
};
this.stopResetTimer = function () {
this.stopTimer();
this.init();
};
this.run = function () {
this.time_countdown();
};
this.setStopTime = function (t) {
timeLeft.stopTime = parseInt(t);
};
this.setSecondsPassed = function (t) {
timeLeft.startTime = timeLeft.stopTime + ((t - timeLeft.duration) * 1000);
timeLeft.secondsLeft = t;
var _local1 = time_format_str(t);
if (timeLeft.current != _local1) {
timeLeft.current = _local1;
if (textref) {
textref.text = _local1;
} else if (textfunc) {
textfunc(_local1);
}
}
};
this.getSecondsLeft = function () {
return(timeLeft.secondsLeft);
};
this.init(props);
}
function Stopwatch(props) {
function time_format_str(t) {
var _local2 = "";
if (timeformat == "sec") {
_local2 = "" + Math.floor(t);
} else {
_local2 = Math.floor(t / 60) + ":";
t = t % 60;
_local2 = _local2 + ((t < 10) ? ("0" + t) : (t));
}
return(_local2);
}
var running = false;
var textref;
var textfunc;
var timeformat = "time";
var callback;
this.init = function (props) {
wr("stopwatch init");
this.startTime = getTimer();
this.stopTime = 0;
this.current = -1;
this.stopped = false;
this.leadingtext = "";
if (props.duration) {
this.duration = parseInt(props.duration);
}
if (typeof(props.text) == "string") {
wr("props.text", props.text);
this.leadingtext = props.text;
}
if (props.textref) {
textref = props.textref;
textfunc = null;
} else if (props.textfunc) {
textfunc = props.textfunc;
textref = null;
}
if (props.cb) {
callback = props.cb;
}
if (typeof(props.format) == "string") {
timeformat = props.format;
}
running = false;
};
this.time_countup = function () {
if (this.stopped) {
return(undefined);
}
var _local4 = getTimer() - this.startTime;
var _local3 = Math.round(_local4 / 1000);
this.secondsLeft = _local3;
var _local2 = time_format_str(_local3);
if (this.current != _local2) {
this.current = _local2;
if (textref) {
textref.text = (this.leadingtext + " ") + _local2;
} else if (textfunc) {
textfunc(_local2);
}
}
if (this.duration) {
if (_local4 >= (this.duration * 1000)) {
this.stop();
wr("timer.t == 0 exec.callback()");
if (callback) {
callback();
}
}
}
return(_local3);
};
this.start = function () {
wr("timer.start()");
if (running) {
return(undefined);
}
running = true;
this.startTime = getTimer();
this.stopped = false;
events.runIt(this);
};
this.stop = function () {
wr("timer.stopTimer()");
if (!running) {
return(undefined);
}
running = false;
this.stopTime = getTimer();
this.stopped = true;
events.stopIt(this);
};
this.stopResetTimer = function () {
this.stop();
this.init();
};
this.run = function () {
this.time_countup();
};
this.init(props);
}
function ScoreAutomat(props) {
function updateScore() {
var _local1 = dest_p - curr_p;
var _local2 = _local1 * speed;
if (Math.abs(_local1) <= 2) {
curr_p = dest_p;
} else {
curr_p = curr_p + _local2;
}
txt_field.text = txt_prefix + Math.round(curr_p);
if (dest_p == curr_p) {
calcReady();
}
}
function calcReady() {
running = false;
}
var running = false;
var speed = 0.4;
var curr_p = 0;
var dest_p = 0;
var txt_field;
var txt_prefix;
this.init = function (props) {
txt_field = props._field;
txt_prefix = props._prefix;
};
this.addScore = function (howMuch) {
running = true;
dest_p = dest_p + howMuch;
};
this.setScore = function (howMuch) {
dest_p = Math.round(howMuch);
curr_p = dest_p;
txt_field.text = txt_prefix + dest_p;
};
this.run = function () {
if (running) {
updateScore();
}
};
this.init(props);
}
function Tween(props) {
function limit_3(a, b, c) {
return(((a < b) ? (b) : (((a > c) ? (c) : (a)))));
}
function computeNextFloat(from, to, ease) {
return(from + ((to - from) * ease));
}
this.running = false;
this.animation = [];
this.callback = null;
this.callback_scope = null;
this.init = function (props) {
};
this.go = function (anim, props) {
this.duration = props.duration || 500;
this.starttime = props.starttime || (new Date().getTime());
this.callback = props.callback;
this.callback_scope = props.callback_scope;
this.animation = anim;
if (Key.isDown(16) && (dev_mode)) {
this.duration = this.duration * 5;
}
this.animate();
var _local2 = 0;
while (_local2 < this.animation.length) {
if (typeof(this.animation[_local2].from._alpha) == "number") {
this.animation[_local2].sprite._visible = true;
}
_local2++;
}
if (!this.running) {
this.running = true;
events.runIt(this);
}
};
this.run = function () {
this.animate();
};
this.animate = function () {
var _local7;
var _local5;
var _local8 = new Date().getTime();
var _local4 = this.animation.length;
var _local2;
var _local3;
_local7 = limit_3(_local8 - this.starttime, 0, this.duration);
_local5 = 0.5 - (0.5 * Math.cos((Math.PI * _local7) / this.duration));
if (_local7 >= this.duration) {
if (this.running) {
this.running = false;
events.stopIt(this);
}
_local2 = 0;
while (_local2 < _local4) {
_local3 = this.animation[_local2].sprite;
for (var _local6 in this.animation[_local2].to) {
_local3[_local6] = this.animation[_local2].to[_local6];
if (_local6 == "_alpha") {
if (this.animation[_local2].to[_local6] < 1) {
_local3._visible = false;
}
}
}
_local2++;
}
if (this.callback) {
this.callback.call(this.callback_scope);
}
} else {
_local2 = 0;
while (_local2 < _local4) {
_local3 = this.animation[_local2].sprite;
for (var _local6 in this.animation[_local2].to) {
_local3[_local6] = computeNextFloat(this.animation[_local2].from[_local6], this.animation[_local2].to[_local6], _local5);
}
_local2++;
}
}
};
this.stop = function () {
if (this.running) {
this.running = false;
events.stopIt(this);
}
};
this.init(props);
}
function Delay(props) {
this.init = function (props) {
this.callback = props.callback;
this.callback_scope = props.callback_scope;
if (typeof(props.frames) == "number") {
this.frame_current = 0;
this.frame_frames = props.frames;
this.run = this.run_frame_delay;
} else if (typeof(props.seconds) == "number") {
this.time_startTime = getTimer();
this.time_duration = props.seconds;
this.run = this.run_time_delay;
} else {
wr("invalid delay...");
wrObj(props);
return(false);
}
events.runIt(this);
};
this.run_frame_delay = function () {
this.frame_current++;
if (this.frame_current >= this.frame_frames) {
this.done();
}
};
this.run_time_delay = function () {
var _local2 = Math.max(0, this.time_duration - ((getTimer() - this.time_startTime) / 1000));
if (_local2 == 0) {
this.done();
}
return(_local2);
};
this.done = function () {
events.stopIt(this);
if (this.callback) {
this.callback.call(this.callback_scope);
}
};
this.init(props);
}
function Pulsate(props) {
this.running = false;
this.sinv = [1, 2, 4, 7, 10, 14, 18, 22, 28, 33, 39, 44, 50, 56, 62, 67, 73, 78, 82, 87, 90, 94, 96, 98, 99, 100, 100, 99, 98, 96, 93, 90, 86, 82, 77, 72, 66, 61, 55, 49, 43, 37, 32, 27, 22, 17, 13, 9, 6, 4, 2, 0];
this.sinlen = this.sinv.length;
this.sinpos = 0;
this.alpha_div = 1;
if (typeof(props.alpha) == "number") {
this.alpha_div = props.alpha / 100;
}
this.mysprite = props.sprite;
this.start = function () {
if (this.running) {
return(undefined);
}
this.running = true;
this.sinpos = 0;
events.runIt(this);
};
this.stop = function () {
if (!this.running) {
return(undefined);
}
this.running = false;
this.mysprite._alpha = 0;
events.stopIt(this);
};
this.run = function () {
this.mysprite._alpha = this.sinv[this.sinpos++] * this.alpha_div;
if (this.sinpos == this.sinlen) {
this.sinpos = 0;
}
};
}
function Draggable(props) {
this.init = function (props) {
this.parent = props.parent;
this.sp = props.sprite;
this.sp_target = props.sp_target || (props.sprite);
this.sp_follow = props.sp_follow;
this.sp.drag_self = this;
this.enable();
};
this.enable = function () {
this.sp.onPress = this.sp_onPress;
this.sp.onRelease = this.sp_onRelease;
this.sp.onReleaseOutside = this.sp_onReleaseOutside;
};
this.disable = function () {
delete this.sp.onPress;
delete this.sp.onRelease;
delete this.sp.onReleaseOutside;
delete this.sp.onMouseMove;
};
this.sp_onPress = function () {
this.ox = this.drag_self.sp_target._x - _root._xmouse;
this.oy = this.drag_self.sp_target._y - _root._ymouse;
if (this.drag_self.sp_follow) {
this.follow_ox = this.drag_self.sp_target._x - _root._xmouse;
this.follow_oy = this.drag_self.sp_target._y - _root._ymouse;
}
this.onMouseMove = function () {
this.drag_self.sp_target._x = _root._xmouse + this.ox;
this.drag_self.sp_target._y = _root._ymouse + this.oy;
if (this.drag_self.sp_follow) {
this.drag_self.sp_follow._x = _root._xmouse + this.follow_ox;
this.drag_self.sp_follow._y = _root._ymouse + this.follow_oy;
}
};
this.drag_self.start_drag();
};
this.sp_onRelease = function () {
this.drag_self.stop_drag();
};
this.sp_onReleaseOutside = function () {
this.drag_self.stop_drag();
};
this.start_drag = function () {
if (this.parent.draggable_start) {
this.parent.draggable_start(this.sp_target);
}
};
this.stop_drag = function () {
delete this.sp.onMouseMove;
if (this.parent.draggable_dropped) {
this.parent.draggable_dropped(this.sp_target);
}
};
this.init(props);
}
function Emoticons(props) {
this.moods = ["mad", "tired", "superior", "happy", "surprised"];
this.mood_active = false;
this.mood_duration = 5;
this.init = function (props) {
this.parent = props.parent;
events.runIt(this);
};
this.setMood = function (m, t) {
wr("setMood", m, t);
game.table.local_player.avatar.setMood(m);
this.click_time = getTimer();
this.mood_duration = t;
this.mood_active = true;
};
this.reset_mood = function () {
game.table.local_player.avatar.setMood("neutral");
this.mood_active = false;
};
this.run = function () {
if (this.mood_active) {
var _local2 = Math.max(0, this.mood_duration - ((getTimer() - this.click_time) / 1000));
if (_local2 == 0) {
this.reset_mood();
}
}
};
this.init(props);
}
function HourGlass(props) {
function limit_3(a, b, c) {
return(((a < b) ? (b) : (((a > c) ? (c) : (a)))));
}
function computeNextFloat(from, to, perc) {
return(from + ((to - from) * perc));
}
this.running = false;
this.top_start_y = -41;
this.top_end_y = 0;
this.btm_start_y = 59;
this.btm_end_y = 11;
this.callback = null;
this.callback_scope = null;
this.blink_speed = 4;
this.blink_count = 0;
this.init = function (props) {
this.sp = sprites.create({member:"hourglass", x:props.x, y:props.y, alpha:0, level:11});
this.sp._xscale = props.scale;
this.sp._yscale = props.scale;
this.mask_top = this.sp.mask_top;
this.mask_btm = this.sp.mask_bottom;
this.sand = this.sp.sand;
this.red = this.sp.red;
my_color = new Color(this.sp);
my_color.setRGB(6853020);
this.tween_obj = new Tween();
this.mask_top.stop();
this.mask_btm.stop();
this.sand.stop();
this.sand._visible = false;
};
this.start = function (props) {
this.start_percent = (props.percent / 100) || 1;
this.duration = props.duration || 5000;
this.starttime = new Date().getTime();
this.callback = props.callback;
this.callback_scope = props.callback_scope;
this.t_y = computeNextFloat(this.top_start_y, this.top_end_y, 1 - this.start_percent);
this.b_y = computeNextFloat(this.btm_start_y, this.btm_end_y, 1 - this.start_percent);
this.mask_top.gotoAndPlay(1);
this.mask_btm.gotoAndPlay(1);
this.sand.gotoAndPlay(1);
this.sand._visible = true;
if (!this.running) {
this.running = true;
events.runIt(this);
var _local3 = [{from:{_rotation:180, _alpha:10}, to:{_rotation:0, _alpha:100}, sprite:this.sp}];
this.tween_obj.go(_local3, {duration:250});
}
this.run();
};
this.stop = function () {
this.mask_top.stop();
this.mask_btm.stop();
this.sand.stop();
this.sand._visible = false;
if (this.running) {
this.running = false;
events.stopIt(this);
var _local2 = [{from:{_rotation:0, _alpha:100}, to:{_rotation:-180, _alpha:0}, sprite:this.sp}];
this.tween_obj.go(_local2, {duration:250});
}
};
this.run = function () {
var _local6 = new Date().getTime();
var _local3 = limit_3(_local6 - this.starttime, 0, this.duration);
var _local2 = _local3 / this.duration;
if (_local3 >= this.duration) {
this.stop();
this.mask_top._y = this.top_end_y;
this.mask_btm._y = this.btm_end_y;
if (this.callback) {
this.callback.call(this.callback_scope);
}
} else {
var _local4 = computeNextFloat(this.t_y, this.top_end_y, _local2);
var _local5 = computeNextFloat(this.b_y, this.btm_end_y, _local2);
this.mask_top._y = _local4;
this.mask_btm._y = _local5;
if (_local2 > 0.85) {
this.blink_count++;
if (this.blink_speed == this.blink_count) {
this.blink_count = 0;
this.sp._visible = !this.sp._visible;
}
}
}
};
this.show = function () {
};
this.hide = function () {
};
this.kill = function () {
this.tween_obj.stop();
sprites.remove(this.sp);
if (this.running) {
events.stopIt(this);
}
};
this.init(props);
}
function ChatClient(props) {
this.bubbles = [];
this.chat_enabled = false;
this.init = function (props) {
this.positions = props.positions;
this.chat_box = sprites.create({member:"chat_box", x:this.positions.chat_box[0], y:this.positions.chat_box[1], visible:false, alpha:0, level:19});
this.chat_box.orig_w = this.chat_box._width;
this.chat_box.orig_h = this.chat_box._height;
this.chat_box.bg.onRelease = function () {
};
this.chat_box.bg.useHandCursor = false;
this.chat_icon = sprites.create({member:"chat_icon", x:this.positions.chat_icon[0], y:this.positions.chat_icon[1], visible:false, level:19});
this.open_btn = new ClickButton({sp:this.chat_icon, id:"open", callback_scope:this, callback:this.show_panel, padding:4, over_alpha:60});
this.chat_icon.orig_w = this.chat_icon._width;
this.chat_icon.orig_h = this.chat_icon._height;
this.str_to_fast = "Oooops!";
this.field_in = this.chat_box.chat_in;
this.button_send = this.chat_box.send_button;
this.speedlimit = {active:false, last:0, sum:0, cnt:0, limit:1000};
this.tween_obj = new Tween();
if (typeof(props.username) == "string") {
this.username = props.username;
}
this.field_in.maxChars = 40;
this.field_in.active = false;
this.field_in.onSetFocus = function () {
this.active = true;
};
this.field_in.onKillFocus = function () {
this.active = false;
};
this.onKeyUp = function () {
if (!this.chat_enabled) {
return(undefined);
}
if (!this.field_in.active) {
if (Key.getCode() == 32) {
this.show_panel();
}
}
};
this.onKeyDown = function () {
if (!this.chat_enabled) {
return(undefined);
}
if (this.field_in.active) {
if (this.field_in.text == "") {
if ((Key.getCode() == 13) || (Key.getCode() == 32)) {
this.hide_panel();
}
} else if (Key.getCode() == 13) {
this.msg_send();
}
}
};
Key.addListener(this);
this.send_btn = new ClickButton({sp:this.button_send, callback_scope:this, callback:this.msg_send, over_alpha:72});
this.field_in.text = "";
};
this.set_chat_to_fast_msg = function (str) {
wr("chat.set_chat_to_fast_msg");
this.str_to_fast = str;
};
this.msg_send = function () {
var _local2 = getTimer();
if (this.speedlimit.active) {
if (_local2 > (this.speedlimit.last + (this.speedlimit.limit * 5))) {
this.speedlimit.active = false;
} else {
return(undefined);
}
}
this.speedlimit.cnt++;
this.speedlimit.sum = this.speedlimit.sum + (_local2 - this.speedlimit.last);
this.speedlimit.last = _local2;
if (this.speedlimit.cnt >= 3) {
if (this.speedlimit.sum < (this.speedlimit.limit * 3)) {
this.draw_msg(game.table.local_player.playernum, (newline + this.str_to_fast) + newline);
this.speedlimit.active = true;
}
this.speedlimit.cnt = 0;
this.speedlimit.sum = 0;
if (this.speedlimit.active) {
return(undefined);
}
}
var _local3 = this.field_in.text;
if (_local3 != "") {
game.network.send_string((("MSG " + game.table.local_player.playernum) + ",") + _local3);
this.draw_msg(game.table.local_player.playernum, _local3);
soundFx.play("tone_a.aif", false, 60);
}
this.hide_panel();
};
this.msg_receive = function (dat) {
var _local2 = dat.split(",", 2);
var _local3 = parseInt(_local2[0]);
var _local4 = _local2[1];
this.draw_msg(_local3, _local4);
soundFx.play("tone_b.aif", false, 60);
};
this.focus_chat = function () {
Selection.setFocus(this.field_in);
};
this.show = function () {
this.chat_enabled = true;
this.chat_icon._visible = true;
};
this.hide = function () {
this.chat_enabled = false;
this.chat_icon._visible = false;
this.chat_box._visible = false;
};
this.show_panel = function () {
this.field_in.text = "";
var _local2 = [{to:{_alpha:0, _x:this.positions.chat_box[0], _y:this.positions.chat_box[1], _width:this.chat_box.orig_w, _height:this.chat_box.orig_h}, from:{_alpha:100, _x:this.positions.chat_icon[0], _y:this.positions.chat_icon[1], _width:this.chat_icon.orig_w, _height:this.chat_icon.orig_h}, sprite:this.chat_icon}, {to:{_alpha:100, _x:this.positions.chat_box[0], _y:this.positions.chat_box[1], _width:this.chat_box.orig_w, _height:this.chat_box.orig_h}, from:{_alpha:0, _x:this.positions.chat_icon[0], _y:this.positions.chat_icon[1], _width:this.chat_icon.orig_w, _height:this.chat_icon.orig_h}, sprite:this.chat_box}];
this.tween_obj.go(_local2, {duration:300});
this.focus_chat();
};
this.hide_panel = function () {
var _local2 = [{to:{_alpha:0, _x:this.positions.chat_icon[0], _y:this.positions.chat_icon[1], _width:this.chat_icon.orig_w, _height:this.chat_icon.orig_h}, from:{_alpha:100, _x:this.positions.chat_box[0], _y:this.positions.chat_box[1], _width:this.chat_box.orig_w, _height:this.chat_box.orig_h}, sprite:this.chat_box}, {to:{_alpha:100, _x:this.positions.chat_icon[0], _y:this.positions.chat_icon[1], _width:this.chat_icon.orig_w, _height:this.chat_icon.orig_h}, from:{_alpha:0, _x:this.positions.chat_box[0], _y:this.positions.chat_box[1], _width:this.chat_box.orig_w, _height:this.chat_box.orig_h}, sprite:this.chat_icon}];
this.tween_obj.go(_local2, {duration:300});
};
this.draw_msg = function (pno, str) {
if (this.bubbles[pno] != undefined) {
if (this.bubbles[pno].step < 3) {
this.bubbles[pno].step = 2;
this.bubbles[pno].is_orphan = true;
this.bubbles[pno].next_step();
}
}
var _local3 = game.gui.chatbubble_positions[game.table.players[pno].seatnum];
var _local4 = _local3[1] < ((2 * game.height) / 3);
var movement = (_local4 ? -1 : 1);
var _local5 = _local3[0];
var tmp_y = (_local3[1] + (_local4 ? -10 : 10));
var _local6 = (_local4 ? "chat_bubble_flipped" : "chat_bubble");
var _local2 = sprites.create({member:_local6, x:_local5, y:tmp_y, alpha:0, level:19});
_local2.txt.text = str;
var _local8 = (_local2.txt._height - _local2.txt.textHeight) / 2;
if (_local8 > 3) {
_local2.txt._y = _local2.txt._y + (((_local2.txt._height - _local2.txt.textHeight) / 2) - 2);
}
_local2.tween_obj = new Tween();
this.bubbles[pno] = _local2;
_local2.pno = pno;
_local2.parent = this;
_local2.step = 0;
_local2.next_step = function () {
if (this.step == 0) {
var _local2 = [{from:{_alpha:0, _y:tmp_y}, to:{_alpha:100, _y:tmp_y - (15 * movement)}, sprite:this}];
this.tween_obj.go(_local2, {duration:400, callback_scope:this, callback:this.next_step});
} else if (this.step == 1) {
var _local2 = [{from:{_y:this._y}, to:{_y:this._y - (5 * movement)}, sprite:this}];
this.tween_obj.go(_local2, {duration:2000, callback_scope:this, callback:this.next_step});
} else if (this.step == 2) {
var _local2 = [{from:{_y:this._y, _alpha:100}, to:{_y:this._y - (10 * movement), _alpha:0}, sprite:this}];
this.tween_obj.go(_local2, {duration:300, callback_scope:this, callback:this.next_step});
} else if (this.step == 3) {
this.tween_obj.stop();
if (!this.is_orphan) {
this.parent.bubbles[this.pno] = null;
}
sprites.remove(this);
}
this.step++;
};
_local2.next_step();
};
this.init(props);
}
function SoundFx() {
var _local3 = ["card_sound_2.aif", "card_sound_6.aif", "click_sound_2.aif", "click.wav", "game_over.aif", "game_win.aif", "next_round.aif", "stick.aif", "tone_a.aif", "tone_b.aif", "beep.wav", "introSound", "outroSound", "attentionSound"];
var _local5 = createEmptyMovieClip("sound_fx_base", -1);
var _local6 = 0;
var sounds = new Object();
var _local2 = 0;
while (_local2 < _local3.length) {
var _local4 = new Sound(_local5.createEmptyMovieClip("sound_" + (_local2 + 1), (-_local2) - 2));
_local4.attachSound(_local3[_local2]);
_local4.onSoundComplete = function () {
this.playing = false;
};
sounds[_local3[_local2]] = _local4;
sounds[_local3[_local2]].playing = false;
sounds[_local3[_local2]].soundName = _local3[_local2];
_local2++;
}
this.play = function (sound, nostop, vol) {
if (no_sound == 1) {
return(undefined);
}
if (sounds[sound].playing) {
if (nostop) {
return(undefined);
}
this.stop(sound);
}
sounds[sound].playing = true;
if (vol) {
sounds[sound].setVolume(vol);
} else {
sounds[sound].setVolume(100);
}
sounds[sound].start();
};
this.playLooped = function (sound, vol) {
if (no_sound == 1) {
return(undefined);
}
if (sounds[sound].playing) {
return(undefined);
}
sounds[sound].playing = true;
if (vol) {
sounds[sound].setVolume(vol);
} else {
sounds[sound].setVolume(100);
}
sounds[sound].start(0, 99);
};
this.stop = function (sound) {
sounds[sound].stop();
sounds[sound].playing = false;
};
}
function Pile(props) {
this.init = function (props) {
this.parent = props.parent;
this.x = props.x;
this.y = props.y;
this.cards = [];
this.level_start = 3;
};
this.add_card = function (_card, _player) {
var _local6 = (this.parent.pile_positions[_player.seatnum][0] + random(6)) - 3;
var _local4 = (this.parent.pile_positions[_player.seatnum][1] + random(6)) - 3;
if (_player.seatnum == 1) {
var _local7 = (this.parent.pile_positions[_player.seatnum][2] + 30) + (random(20) - 10);
} else if (_player.seatnum == 3) {
var _local7 = (this.parent.pile_positions[_player.seatnum][2] - 30) - (random(20) - 10);
} else {
var _local7 = this.parent.pile_positions[_player.seatnum][2] + (random(14) - 7);
}
var _local8 = this.parent.pile_positions[_player.seatnum][3];
this.cards.push(_card);
_card.set_parent(this);
_card.last_hand = _player.hand;
var _local5 = function () {
this.show_fade_shadow();
this.last_hand.resort_hand_after_release();
this.toLevel(4);
this.parent.z_sort_cards();
};
_card.show_simple_shadow();
_card.animate_to({x:_local6, y:_local4, v:_local7, scale:_local8, cb:_local5, cb_scope:_card});
};
this.z_sort_cards = function () {
var _local3 = [];
var _local2 = 0;
while (_local2 < this.cards.length) {
_local3.push(this.cards[_local2].get_sprite());
_local2++;
}
sprites.sort(_local3);
};
this.get_size = function () {
return(this.cards.length);
};
this.get_cards = function () {
return(this.cards);
};
this.get_color = function () {
return(this.cards[0].color);
};
this.purge = function () {
this.cards = [];
};
this.enable = function () {
};
this.disable = function () {
};
this.show = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].show();
_local2++;
}
};
this.hide = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].hide();
_local2++;
}
};
this.kill = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].kill();
_local2++;
}
};
this.init(props);
}
function Deck(props) {
this.init = function (props) {
this.parent = props.parent;
this.x = props.x;
this.y = props.y;
this.v = props.v + (random(14) - 7);
this.scale = props.scale;
this.trump_x = props.trump_x;
this.trump_y = props.trump_y;
this.trump_v = props.trump_v;
this.trump_scale = props.trump_scale;
this.trump_card = null;
this.cards = [];
props.num_cards = 52;
var _local8 = [];
var _local6 = this.x;
var _local5 = this.y;
var _local9 = true;
if (props.num_cards > 0) {
var _local3 = 0;
while (_local3 < props.num_cards) {
var _local2 = new Card({x:_local6, y:_local5, v:this.v, scale:this.scale, parent_sp:props.parent_sp, parent:this});
_local2.hide();
this.cards.push(_local2);
_local8.push(_local2.get_sprite());
if ((_local3 % 8) == 7) {
_local5 = _local5 - 1;
_local6 = _local6 - 1;
}
_local3++;
}
}
sprites.sort(_local8);
this.cards[this.cards.length - 1].show();
};
this.set_trump = function (carddata) {
if (this.cards.length > 0) {
var _local2 = this.cards[0];
this.cards.splice(0, 1);
_local2.setCard({color:carddata.charAt(1), value:carddata.charAt(0)});
_local2.setTurnedUp(true);
_local2.animate_to({x:this.trump_x, y:this.trump_y, v:this.trump_v, scale:this.trup_scale});
this.trump_card = _local2;
}
};
this.get_trump_card = function () {
var _local2 = this.trump_card;
this.trump_card = null;
return(_local2);
};
this.get_card = function () {
var _local2 = null;
if (this.cards.length > 0) {
_local2 = this.cards[this.cards.length - 1];
this.cards.splice(this.cards.length - 1, 1);
_local2.show();
if (this.cards.length > 0) {
this.cards[this.cards.length - 1].show();
}
} else if (this.trump_card) {
_local2 = this.trump_card;
this.trump_card = null;
}
return(_local2);
};
this.get_length = function () {
return(this.cards.length + ((this.trump_card != null) ? 1 : 0));
};
this.enable = function () {
};
this.disable = function () {
};
this.show = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
if ((_local2 % 8) == 7) {
this.cards[_local2].show();
}
this.cards[_local2].show_simple_shadow();
_local2++;
}
if (this.cards.length > 0) {
this.cards[this.cards.length - 1].show();
}
};
this.hide = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].hide();
_local2++;
}
if (this.trump_card != null) {
this.trump_card.hide();
}
};
this.kill = function () {
};
this.init(props);
}
function Card(props) {
this.value = null;
this.color = null;
this.turned_up = true;
this.card_back = null;
this.card_front = null;
this.init = function (props) {
global_card_count++;
this.parent = props.parent;
this.x = props.x;
this.y = props.y;
this.v = ((props.v != undefined) ? (props.v) : 0);
this.scale = props.scale;
this.scale = ((typeof(props.scale) == "number") ? (props.scale) : 100);
this.tween = new Tween();
this.group = sprites.create({x:this.x, y:this.y, level:8, parent_sprite:props.parent_sp});
this.card_back = sprites.create({member:"card_bg", parent_sprite:this.group, x:0, y:0});
this.card_front = sprites.create({member:"card_fg", parent_sprite:this.group, x:0, y:0, visible:false});
this.card_front.shadow._visible = true;
this.card_front.sharpshadow._visible = false;
this.card_back.shadow._visible = true;
this.card_back.sharpshadow._visible = false;
this.card_back._x = this.card_back._x - (this.card_back._width / 2);
this.card_back._y = this.card_back._y - (this.card_back._height / 2);
this.card_front._x = this.card_front._x - (this.card_front._width / 2);
this.card_front._y = this.card_front._y - (this.card_front._height / 2);
this.card_front.gotoAndStop(1);
this.setTurnedUp(false);
this.group.parent = this;
this.group._rotation = this.v;
this.group.set_scale = function (n) {
this._xscale = n;
this._yscale = n;
};
this.group.addProperty("scale", function () {
return(this._xscale);
}, this.group.set_scale);
this.group.set_scale(this.scale);
this.group.onRollOver = function () {
this.parent.mouse_over(this);
};
this.group.onDragOver = function () {
this.parent.mouse_over(this);
};
this.group.onRollOut = function () {
this.parent.mouse_out(this);
};
this.group.onDragOut = function () {
this.parent.mouse_out(this);
};
this.group.useHandCursor = false;
this.width = this.card_back._width;
this.height = this.card_back._height;
};
this.mouse_over = function (sp) {
this.parent.mouse_over(this);
};
this.mouse_out = function () {
this.parent.mouse_out(this);
};
this.set_position = function (x, y) {
this.group._x = (this.x = x);
this.group._y = (this.y = y);
};
this.set_parent = function (p) {
this.parent = p;
};
this.animate_to = function (props) {
var _local8 = ((typeof(props.duration) == "number") ? (props.duration) : 350);
var _local6 = ((typeof(props.x) == "number") ? (props.x) : (this.group._x));
var _local5 = ((typeof(props.y) == "number") ? (props.y) : (this.group._y));
var _local3 = ((typeof(props.v) == "number") ? (props.v) : (this.group._rotation));
var _local4 = ((typeof(props.scale) == "number") ? (props.scale) : (this.group._xscale));
var _local7 = [{to:{_x:_local6, _y:_local5, _rotation:_local3, scale:_local4}, from:{_x:this.group._x, _y:this.group._y, _rotation:this.v, scale:this.group._xscale}, sprite:this.group}];
this.tween.go(_local7, {duration:_local8, callback:props.cb, callback_scope:props.cb_scope});
this.x = _local6;
this.y = _local5;
this.v = _local3;
this.scale = _local4;
};
this.activate_click = function () {
this.group.onRelease = function () {
this.parent.card_click();
};
this.group.useHandCursor = true;
};
this.deactivate_click = function () {
delete this.group.onRelease;
this.group.useHandCursor = false;
};
this.getlevel = function () {
return(this.group.getlevel());
};
this.toLevel = function (l) {
this.group.toLevel(l);
};
this.setCard = function (cardprops) {
if ((cardprops.color == "x") || (cardprops.value == "x")) {
return(undefined);
}
this.color = cardprops.color;
this.value = cardprops.value;
this.card_front.gotoAndStop(this.getCardFgOffset(this.color, this.value));
this.group._visible = true;
};
this.setTurnedUp = function (_turned_up) {
if (this.turned_up != _turned_up) {
this.switchSide();
}
};
this.switchSide = function () {
if (this.turned_up) {
this.turned_up = false;
this.card_front._visible = false;
this.card_back._visible = true;
} else {
this.turned_up = true;
this.card_front._visible = true;
this.card_back._visible = false;
}
};
this.card_click = function () {
this.parent.doAction(this, "args...");
};
this.enable = function () {
};
this.disable = function () {
};
this.show = function () {
this.group._visible = true;
};
this.show_simple_shadow = function () {
if (this.card_front._visible) {
this.card_front.shadow._visible = false;
this.card_front.sharpshadow._visible = true;
} else if (this.card_back._visible) {
this.card_back.shadow._visible = false;
this.card_back.sharpshadow._visible = true;
}
};
this.show_fade_shadow = function () {
if (this.card_front._visible) {
this.card_front.shadow._visible = true;
this.card_front.sharpshadow._visible = false;
} else if (this.card_back._visible) {
this.card_back.shadow._visible = true;
this.card_back.sharpshadow._visible = false;
}
};
this.hide = function () {
this.group._visible = false;
};
this.get_sprite = function () {
return(this.group);
};
this.kill = function () {
sprites.remove(this.card_front);
sprites.remove(this.card_back);
sprites.remove(this.group);
global_card_count--;
};
this.getCardFgOffset = function (_color, _value) {
var _local2 = 0;
switch (_color) {
case "S" :
break;
case "C" :
_local2 = 13;
break;
case "H" :
_local2 = 26;
break;
case "D" :
_local2 = 39;
}
return(this.valueToInt(_value) + _local2);
};
this.getValue = function () {
return(this.valueToInt(this.value));
};
this.valueToInt = function (_value) {
var _local2 = parseInt(_value);
if ((_local2 > 0) && (_local2 < 10)) {
return(_local2);
}
var _local1 = {};
_local1.T = 10;
_local1.J = 11;
_local1.Q = 12;
_local1.K = 13;
_local1.A = 14;
return(_local1[_value]);
};
this.init(props);
}
function Trick(props) {
this.init = function (props) {
this.parent = props.parent;
this.cards = props.cards;
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].set_parent(this);
_local2++;
}
var _local3 = this.parent.get_trick_pos();
this.x = _local3.x;
this.y = _local3.y;
this.v = _local3.v;
};
this.animate_to_targetpos = function () {
var _local5 = function () {
this.hide();
};
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].setTurnedUp(false);
this.cards[_local2].toLevel(3);
this.cards[_local2].show_simple_shadow();
this.cards[_local2].animate_to({x:this.x, y:this.y, v:this.v, cb:_local5, cb_scope:this.cards[_local2]});
_local2++;
}
soundFx.play("card_sound_6.aif", false, 80);
};
this.z_sort_cards = function () {
var _local3 = [];
var _local2 = 0;
while (_local2 < this.cards.length) {
_local3.push(this.cards[_local2].get_sprite());
_local2++;
}
sprites.sort(_local3);
};
this.get_size = function () {
return(this.cards.length);
};
this.get_sprite = function () {
return(this.cards[0].get_sprite());
};
this.get_cards = function () {
return(this.cards);
};
this.purge = function () {
this.cards = [];
};
this.enable = function () {
};
this.disable = function () {
};
this.show = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].show();
_local2++;
}
};
this.hide = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].hide();
_local2++;
}
};
this.kill = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].kill();
_local2++;
}
};
this.init(props);
}
function Hand(props) {
this.enabled = false;
this.cards = [];
this.is_over = false;
this.mouse_over_cardindex = -1;
this.size_min = 140;
this.size_max = 155;
this.size_span = 40;
this.amplitude = 4;
this.ratio = (Math.PI/2) / this.size_span;
this.amplitude_y = 12;
this.color_counts = {};
var center_x_displacement = 16;
this.init = function (props) {
this.parent = props.parent;
this.set_pos(props.x, props.y);
this.color_counts.S = 0;
this.color_counts.D = 0;
this.color_counts.H = 0;
this.color_counts.C = 0;
events.runIt(this);
};
this.set_pos = function (x, y, v, scale) {
this.x = x;
this.y = y;
this.v = v;
this.scale = scale;
};
this.deal_cards = function (carddata) {
var _local2 = 0;
while (_local2 < carddata.length) {
this.get_card(this.x + (this.cards.length * 32), this.y, {color:carddata.charAt(_local2 + 1), value:carddata.charAt(_local2)});
_local2 = _local2 + 2;
}
};
this.resort = function () {
var _local10 = (this.parent.local ? 3 : 5);
var _local6 = (this.parent.local ? 600 : 150);
var _local5 = 0;
_local5 = _local5 - ((_local10 * (this.cards.length - 1)) / 2);
var _local4 = 0;
while (_local4 < this.cards.length) {
var _local3 = _local6 * Math.sin((_local5 * Math.PI) / 180);
var _local2 = _local6 - (_local6 * Math.cos((_local5 * Math.PI) / 180));
switch (this.parent.seatnum) {
case 0 :
_local3 = this.x + _local3;
_local2 = this.y + _local2;
break;
case 1 :
var _local7 = this.x - _local2;
_local2 = this.y + _local3;
_local3 = _local7;
break;
case 2 :
_local3 = this.x - _local3;
_local2 = this.y - _local2;
break;
case 3 :
_local7 = this.x + _local2;
_local2 = this.y - _local3;
_local3 = _local7;
}
this.cards[_local4].hand_angle = _local5;
this.cards[_local4].animate_to({x:_local3, y:_local2, v:_local5 + this.v, scale:this.scale});
_local5 = _local5 + _local10;
_local4++;
}
};
this.deal = function (_card) {
this.z_sort_cards();
var _local6 = (this.parent.local ? 3 : 5);
var _local5 = (this.parent.local ? 600 : 150);
var _local4 = ((-_local6) * 12) / 2;
_local4 = _local4 + ((this.cards.length - 1) * _local6);
var _local3 = _local5 * Math.sin((_local4 * Math.PI) / 180);
var _local2 = _local5 - (_local5 * Math.cos((_local4 * Math.PI) / 180));
switch (this.parent.seatnum) {
case 0 :
_local3 = this.x + _local3;
_local2 = this.y + _local2;
break;
case 1 :
var _local8 = this.x - _local2;
_local2 = this.y + _local3;
_local3 = _local8;
break;
case 2 :
_local3 = this.x - _local3;
_local2 = this.y - _local2;
break;
case 3 :
_local8 = this.x + _local2;
_local2 = this.y - _local3;
_local3 = _local8;
}
_card.animate_to({x:_local3, y:_local2, v:_local4 + this.v, scale:this.scale, duration:250, cb:_card.show_fade_shadow, cb_scope:_card});
soundFx.play("card_sound_2.aif", false, 70);
};
this.get_no_cards = function () {
return(this.cards.length);
};
this.get_random_card = function () {
return(this.cards[random.rangeFromSeed(0, this.cards.length - 1)]);
};
this.get_card = function (x, y, cardprops) {
var _local2 = this.parent.parent.deck.get_card();
_local2.set_parent(this);
_local2.setCard(cardprops);
this.add_card(_local2);
};
this.create_card = function (x, y, cardprops) {
var _local2 = new Card({x:x, y:y, parent:this});
_local2.setCard(cardprops);
this.add_card(_local2);
};
this.add_card = function (_card) {
if (this.parent.local && (this.enabled)) {
_card.activate_click();
}
this.color_counts[_card.color]++;
_card.set_parent(this);
this.cards.push(_card);
this.deal(_card);
};
this.show_cards = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].setTurnedUp(true);
_local2++;
}
this.suite_sort_cards();
this.z_sort_cards();
this.resort();
};
this.doAction = function (obj, args) {
var _local11 = 600;
var _local3;
var _local4 = 1000;
var _local6 = null;
var _local7 = -1;
var _local5;
var _local9 = this.xmouse - this.x;
var _local8 = this.ymouse - (this.y + _local11);
var _local10 = Math.sqrt((_local9 * _local9) + (_local8 * _local8));
if (_local10 != 0) {
_local9 = _local9 / _local10;
_local8 = _local8 / _local10;
_local5 = (Math.asin(_local9) * 180) / Math.PI;
_local5 = _local5 + 1.9;
if (_local8 > 0) {
_local5 = -_local5;
}
}
var _local2 = 0;
while (_local2 < this.cards.length) {
_local3 = Math.abs(_local5 - this.cards[_local2].hand_angle);
if (_local3 < _local4) {
_local4 = _local3;
_local7 = _local2;
_local6 = this.cards[_local2];
}
_local2++;
}
this.parent.card_clicked(this, _local6);
};
this.mouse_over = function (card) {
this.is_over = true;
};
this.mouse_out = function (card) {
this.is_over = false;
};
this.mouse_over_index = function (n) {
if (this.mouse_over_cardindex != n) {
if (this.mouse_over_cardindex >= 0) {
var _local4 = new Tween();
var _local2 = this.cards[this.mouse_over_cardindex];
var _local7 = [{to:{_x:_local2.x, _y:_local2.y}, from:{_x:_local2.group._x, _y:_local2.group._y}, sprite:_local2.group}];
_local4.go(_local7, {duration:350});
}
this.mouse_over_cardindex = n;
var _local2 = this.cards[this.mouse_over_cardindex];
var _local3 = ((Math.PI*2) * _local2.group._rotation) / 360;
var _local5 = _local2.x + (6 * Math.sin(_local3));
var _local6 = _local2.y - (6 * Math.cos(_local3));
var _local4 = new Tween();
var _local7 = [{to:{_x:_local5, _y:_local6}, from:{_x:_local2.group._x, _y:_local2.group._y}, sprite:_local2.group}];
_local4.go(_local7, {duration:350});
}
};
this.mouse_out_index = function (n) {
};
this.get_card_by_col_val = function (col, val) {
var _local3 = 0;
while (_local3 < this.cards.length) {
var _local2 = this.cards[_local3];
if ((_local2.color == col) && (_local2.value == val)) {
return(_local2);
}
_local3++;
}
wr("card fetch", col, val, "failed!");
return(null);
};
this.get_card_by_index = function (i) {
if ((i < 0) || (i >= this.cards.length)) {
return(null);
}
return(this.cards[i]);
};
this.get_card_index = function (obj) {
var _local2 = 0;
while (_local2 < this.cards.length) {
if (obj == this.cards[_local2]) {
return(_local2);
}
_local2++;
}
};
this.release_card = function (obj) {
this.mouse_over_cardindex = -1;
var _local2 = 0;
while (_local2 < this.cards.length) {
if (obj == this.cards[_local2]) {
this.color_counts[obj.color]--;
this.cards.splice(_local2, 1);
obj.deactivate_click();
soundFx.play("click_sound_2.aif", false, 65);
return(obj);
}
_local2++;
}
};
this.resort_hand_after_release = function () {
if (game.table.deck.get_length() == 0) {
this.resort();
}
};
this.check_inside_rect = function () {
var _local2 = this.cards[this.cards.length - 1];
var _local3 = this.cards[0];
var _local4 = (((this.xmouse > (_local3.x - (_local3.group._width / 2))) && (this.xmouse < (_local2.x + (_local2.group._width / 2)))) && (this.ymouse > (_local2.y - (_local2.group._height / 2)))) && (this.ymouse < (_local2.y + (_local2.group._height / 2)));
return(_local4);
};
this.run = function () {
if (this.parent.local) {
this.xmouse = _root._xmouse;
this.ymouse = _root._ymouse;
if (this.enabled) {
if (this.check_inside_rect()) {
var _local20 = 600;
var _local5;
var _local10 = 1000;
var _local13 = null;
var _local9 = -1;
var _local11;
var _local4 = this.xmouse - this.x;
var _local15 = this.ymouse - (this.y + _local20);
var _local16 = Math.sqrt((_local4 * _local4) + (_local15 * _local15));
if (_local16 != 0) {
_local4 = _local4 / _local16;
_local15 = _local15 / _local16;
_local11 = (Math.asin(_local4) * 180) / Math.PI;
_local11 = _local11 + 1.9;
if (_local15 > 0) {
_local11 = -_local11;
}
}
var _local3 = 0;
while (_local3 < this.cards.length) {
_local5 = Math.abs(_local11 - this.cards[_local3].hand_angle);
if (_local5 < _local10) {
_local10 = _local5;
_local9 = _local3;
_local13 = this.cards[_local3];
}
_local3++;
}
var _local14 = this.cards[_local9];
var _local18 = ((Math.PI*2) * _local14.group._rotation) / 360;
var _local12 = _local14.x + (this.amplitude_y * Math.sin(_local18));
var _local21 = _local14.y - (this.amplitude_y * Math.cos(_local18));
if (_local9 != this.mouse_over_cardindex) {
if (this.mouse_over_cardindex >= 0) {
var _local17 = this.cards[this.mouse_over_cardindex];
var _local19 = new Tween();
var _local22 = [{to:{_y:_local17.y}, from:{_y:_local17.group._y}, sprite:_local17.group}];
_local19.go(_local22, {duration:100});
}
this.mouse_over_cardindex = _local9;
var _local19 = new Tween();
var _local22 = [{to:{_y:_local21}, from:{_y:_local14.group._y}, sprite:_local14.group}];
_local19.go(_local22, {duration:100});
game.network.send_string((("GMO " + this.parent.playernum) + ",") + this.mouse_over_cardindex);
}
_local3 = 0;
while (_local3 < this.cards.length) {
var _local6 = this.cards[_local3].card_back._width * ((_local3 / (this.cards.length - 1)) - 0.5);
_local4 = ((this.cards[_local3].x - center_x_displacement) - this.xmouse) + _local6;
_local4 = Math.min(Math.max(_local4, -this.size_span), this.size_span);
var _local7 = ((_local3 == _local9) ? (_local12) : (this.cards[_local3].x));
var _local8 = _local7 + (this.amplitude * Math.sin(_local4 * this.ratio));
this.cards[_local3].group._x = this.cards[_local3].group._x + ((_local8 - this.cards[_local3].group._x) * 0.3);
_local3++;
}
} else {
if (this.mouse_over_cardindex >= 0) {
this.mouse_over_cardindex = -1;
game.network.send_string((("GMO " + this.parent.playernum) + ",") + this.mouse_over_cardindex);
}
var _local3 = 0;
while (_local3 < this.cards.length) {
this.cards[_local3].group._x = this.cards[_local3].group._x + ((this.cards[_local3].x - this.cards[_local3].group._x) * 0.6);
this.cards[_local3].group._y = this.cards[_local3].group._y + ((this.cards[_local3].y - this.cards[_local3].group._y) * 0.6);
_local3++;
}
}
} else if (this.mouse_over_cardindex >= 0) {
this.mouse_over_cardindex = -1;
game.network.send_string((("GMO " + this.parent.playernum) + ",") + this.mouse_over_cardindex);
}
}
return(true);
};
this.enable = function () {
this.enabled = true;
if (this.parent.local) {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].activate_click();
_local2++;
}
}
};
this.suite_sort_cards = function () {
var suite_vals = {};
suite_vals.H = 0;
suite_vals.C = 25;
suite_vals.D = 50;
suite_vals.S = 75;
var _local4 = function (a, b) {
var _local2 = suite_vals[a.color] + game.rules.get_card_value(a.value);
var _local1 = suite_vals[b.color] + game.rules.get_card_value(b.value);
if (_local2 < _local1) {
return(-1);
}
if (_local2 > _local1) {
return(1);
}
return(-1);
};
this.cards.sort(_local4);
};
this.z_sort_cards = function () {
var _local3 = [];
var _local2 = 0;
while (_local2 < this.cards.length) {
_local3.push(this.cards[_local2].get_sprite());
_local2++;
}
sprites.sort(_local3);
};
this.disable = function () {
this.enabled = false;
if (this.parent.local) {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].deactivate_click();
_local2++;
}
}
};
this.halt = function () {
events.stopIt(this);
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].halt();
_local2++;
}
};
this.show = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].show();
_local2++;
}
};
this.hide = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].hide();
_local2++;
}
};
this.kill = function () {
var _local2 = 0;
while (_local2 < this.cards.length) {
this.cards[_local2].kill();
_local2++;
}
this.cards = [];
};
this.init(props);
}
function SoundFx() {
var _local3 = ["card_sound_2.aif", "card_sound_6.aif", "click_sound_2.aif", "click.wav", "game_over.aif", "game_win.aif", "next_round.aif", "stick.aif", "tone_a.aif", "tone_b.aif", "beep.wav", "introSound", "outroSound", "attentionSound"];
var _local5 = createEmptyMovieClip("sound_fx_base", -1);
var _local6 = 0;
var sounds = new Object();
var _local2 = 0;
while (_local2 < _local3.length) {
var _local4 = new Sound(_local5.createEmptyMovieClip("sound_" + (_local2 + 1), (-_local2) - 2));
_local4.attachSound(_local3[_local2]);
_local4.onSoundComplete = function () {
this.playing = false;
};
sounds[_local3[_local2]] = _local4;
sounds[_local3[_local2]].playing = false;
sounds[_local3[_local2]].soundName = _local3[_local2];
_local2++;
}
this.play = function (sound, nostop, vol) {
if (no_sound == 1) {
return(undefined);
}
if (sounds[sound].playing) {
if (nostop) {
return(undefined);
}
this.stop(sound);
}
sounds[sound].playing = true;
if (vol) {
sounds[sound].setVolume(vol);
} else {
sounds[sound].setVolume(100);
}
sounds[sound].start();
};
this.playLooped = function (sound, vol) {
if (no_sound == 1) {
return(undefined);
}
if (sounds[sound].playing) {
return(undefined);
}
sounds[sound].playing = true;
if (vol) {
sounds[sound].setVolume(vol);
} else {
sounds[sound].setVolume(100);
}
sounds[sound].start(0, 99);
};
this.stop = function (sound) {
sounds[sound].stop();
sounds[sound].playing = false;
};
}
function Player(props) {
this.init = function (props) {
this.parent = props.parent;
this.playername = props.playername;
this.playernum = props.playernum;
this.avatardata = props.avatar;
this.local = props.local;
this.sequencenum = -1;
this.teamnum = -1;
this.teammatenum = -1;
this.seatnum = -1;
this.avatar = null;
this.dealer = false;
this.winner = false;
this.ready_for_round = false;
this.enabled = false;
this.ai_player = null;
this.bet = -1;
this.score = 0;
this.cards_revealed = false;
this.disconnected = false;
this.auto_select_count = 0;
this.auto_select_max = 3;
this.pos_x = this.parent.positions[this.playernum][0] + (this.parent.positions[this.playernum][2] / 2);
this.pos_y = this.parent.positions[this.playernum][1] + (this.parent.positions[this.playernum][3] / 2);
this.hand_pos = this.parent.hand_positions[this.playernum];
this.hand = new Hand({parent:this, x:this.hand_pos[0], y:this.hand_pos[1]});
this.tricks = [];
this.num_visual_tricks = 0;
if (this.local) {
this.emoticons = new Emoticons({parent:this});
}
};
this.set_ai_player = function (ai_p) {
this.ai_player = ai_p;
};
this.set_sequencenum = function (num) {
this.sequencenum = num;
};
this.set_seatnum = function (num) {
this.seatnum = num;
this.pos_x = this.parent.positions[this.seatnum][0] + (this.parent.positions[this.seatnum][2] / 2);
this.pos_y = this.parent.positions[this.seatnum][1] + (this.parent.positions[this.seatnum][3] / 2);
this.hand_pos = this.parent.hand_positions[this.seatnum];
this.hand.set_pos(this.hand_pos[0], this.hand_pos[1], this.hand_pos[2], this.hand_pos[3]);
game.gui.positionate_avatar(num, this.avatar);
game.gui.set_playerbox(num, this.teamnum, this.playername);
};
this.add_avatar = function () {
this.avatar = new Avatar({parent:this, playernum:this.playernum, avatar:this.avatardata, x:0, y:0});
this.avatar.load();
};
this.avatar_ready = function () {
if (game.gameover) {
return(undefined);
}
if (this.local) {
game.gui.show_instructions();
}
game.gui.avatar_ready(this.avatar);
};
this.deal_cards = function (carddata) {
this.hand.deal_cards(carddata);
};
this.show_cards = function () {
this.hand.show_cards();
};
this.set_dealer = function (d) {
this.dealer = d;
};
this.add_trick = function (cards) {
var _local4 = new Trick({cards:cards, parent:this});
this.tricks.push(_local4);
var _local3 = [];
var _local2 = 0;
while (_local2 < this.tricks.length) {
_local3.push(this.tricks[_local2].get_sprite());
_local2++;
}
new Delay({seconds:1.2, callback:_local4.animate_to_targetpos, callback_scope:_local4});
};
this.get_trick_pos = function () {
var _local3 = this.parent.trick_positions[this.seatnum][0];
var _local2 = this.parent.trick_positions[this.seatnum][1];
var _local4 = this.parent.trick_positions[this.seatnum][4];
_local3 = _local3 + this.parent.trick_positions[this.seatnum][2];
_local2 = _local2 + this.parent.trick_positions[this.seatnum][3];
return({x:_local3, y:_local2, v:_local4});
};
this.next_round = function () {
var _local2 = 0;
while (_local2 < this.tricks.length) {
this.tricks[_local2].kill();
_local2++;
}
this.tricks = [];
this.num_visual_tricks = 0;
};
this.set_team = function (team_num) {
this.teamnum = team_num;
};
this.auto_select_card = function () {
var _local2 = 0;
while (_local2 < this.hand.cards.length) {
var _local3 = this.hand.cards[_local2];
if (game.rules.card_clicked(this.hand, _local3)) {
game.gui.hourglass.stop();
break;
}
_local2++;
}
this.auto_select_count++;
if (this.auto_select_count == this.auto_select_max) {
game.handleCommError("inactive_too_long");
}
};
this.enable = function () {
this.enabled = true;
if (this.hand.get_no_cards() > 0) {
game.gui.hilite_playerbox(this.seatnum, true);
if (this.local) {
soundFx.play("attentionSound", false, 70);
this.hand.enable();
var _local2 = parseInt(game.gamedata.autoplay);
if (isNaN(_local2) || (_local2 == 0)) {
_local2 = 10;
}
game.gui.hourglass.start({duration:_local2 * 1000, callback:this.auto_select_card, callback_scope:this});
} else if (this.ai_player) {
this.ai_player.play_card();
}
}
};
this.card_clicked = function (hand, card) {
if (game.rules.card_clicked(hand, card)) {
this.auto_select_count = 0;
game.gui.hourglass.stop();
} else {
soundFx.play("beep.wav");
}
};
this.disable = function () {
this.enabled = false;
if (this.local) {
this.hand.disable();
}
game.gui.hilite_playerbox(this.seatnum, false);
};
this.halt = function () {
this.hand.halt();
if (this.local) {
game.gui.hourglass.stop();
}
};
this.show = function () {
this.hand.show();
};
this.hide = function () {
this.hand.hide();
};
this.kill = function () {
this.hand.kill();
};
this.init(props);
}
function Ai_player(props) {
this.init = function (props) {
this.parent = props.parent;
this.network_queue = [];
if (this.parent.playernum == 0) {
game.rules.check_continue_deal();
}
if (game.table.local_player.ready_for_round && (!this.parent.ready_for_round)) {
this.send_next_round();
return(undefined);
}
if ((this.parent.bet == -1) && (game.rules.get_deal_count() == 52)) {
if (game.rules.get_current_playernum() == this.parent.playernum) {
this.place_bet();
return(undefined);
}
}
if (this.parent.enabled) {
this.play_card();
}
};
this.play_card = function () {
wr("ai_player.play_card()");
var _local3 = this.parent.hand;
var _local2 = 0;
var _local4;
_local2 = 0;
while (_local2 < _local3.cards.length) {
if (game.rules.check_card_legal(_local3, _local3.cards[_local2])) {
break;
}
_local2++;
}
if (_local2 == _local3.cards.length) {
wr("ai_player could not find a legal card!!");
_local2 = random.range(0, _local3.cards.length - 1);
}
_local4 = _local3.cards[_local2];
this.network_queue.push(((((("GPC " + this.parent.playernum) + ",") + _local2) + ",") + _local4.value) + _local4.color);
new Delay({callback:this.send_next_queued, callback_scope:this, seconds:0.8});
};
this.place_bet = function () {
var _local2 = random.range(1, 4);
this.network_queue.push((("GPB " + this.parent.playernum) + ",") + _local2);
new Delay({callback:this.send_next_queued, callback_scope:this, seconds:1.5});
};
this.send_next_round = function () {
game.network.send_ai_string("GNR " + this.parent.playernum);
};
this.send_next_queued = function () {
var _local2 = this.network_queue.shift();
game.network.send_ai_string(_local2);
};
this.init(props);
}
function Game(props) {
this.width = 752;
this.height = 620;
this.gamestarted = false;
this.gameover = false;
this.no_disc_opponents = 0;
this.init = function (props) {
_quality = "BEST";
this.gamedata = new GamedataObj({parent:this});
this.gui = new Gui({parent:this});
this.table = new Table({width:this.width, height:this.height});
this.network = new Network({parent:this});
this.playdata = new Playdata();
this.rules = new Rules({players_ref:this.table.players});
this.network.add_listener("MCC", this);
};
this.gamedata_loaded = function () {
this.rules.set_gamedata(this.gamedata);
this.gui.set_gamedata(this.gamedata);
this.gui.show_statusbox();
this.network.connect(this.gamedata.mp);
if (dev_mode) {
this.robo = [];
var _local4 = parseInt(_level0.robocount) || 0;
if (isNaN(_local4)) {
_local4 = -1;
}
var _local2 = 0;
while (_local2 < _local4) {
var _local3 = new Roboplayer(this.gamedata.mp);
this.robo.push(_local3);
_local2++;
}
}
};
this.add_local_player = function (pobj) {
this.rules.add_local_player(pobj);
};
this.add_remote_player = function (pobj) {
this.rules.add_remote_player(pobj);
};
this.remove_player = function (pno) {
wr("game.remove_player()", pno);
if (this.gameover) {
return(undefined);
}
if (!this.gamestarted) {
this.gui.show_alert(this.gamedata.text.opponent_disconnect);
this.set_game_over("opponent_disconnect");
} else if (this.table.local_player.teamnum == this.table.players[pno].teamnum) {
wr("teammate_disconnect");
var _local5 = this.table.players[pno];
var _local6 = new Ai_player({parent:_local5});
_local5.set_ai_player(_local6);
} else {
this.no_disc_opponents++;
wr("opponent_disconnect");
wr("no_disc_opponents", this.no_disc_opponents);
if (this.no_disc_opponents == 2) {
wr("Both opponents have disconnected - set game over");
this.gui.show_alert(this.gamedata.text.opponent_disconnect);
this.set_game_over("opponent_disconnect");
}
}
if (!this.gameover) {
var _local4 = this.table.players[pno].avatar.avatar_sprite;
_local4._visible = false;
var _local3 = sprites.create({member:"robot_avatar", x:_local4._x, y:_local4._y, visible:true, level:18});
_local3._xscale = -70;
_local3._yscale = 70;
this.table.players[pno].avatar.avatar_sprite = _local3;
this.gui.player_boxes[this.table.players[pno].seatnum].name.text = this.gamedata.text.robot;
this.gui.chat.msg_receive((("" + pno) + ",") + game.gamedata.text.robot_activated);
}
};
this.start_game = function () {
var _local3 = 0;
var _local2 = 0;
while (_local2 < this.table.players.length) {
if (this.table.players[_local2]) {
_local3++;
}
_local2++;
}
if (_local3 < this.rules.get_no_players()) {
this.remove_player(-1);
return(undefined);
}
this.lowerbar = sprites.create({member:"lowerbar", x:0, y:600, visible:true, level:10});
this.lowerbar.btn_end_sp = this.lowerbar.btn_end;
this.lowerbar.btn_end_sp.txt.text = this.gamedata.text.end_game;
var _local8 = new ClickButton({sp:this.lowerbar.btn_end_sp, id:"end_game", callback:this.end_game_pressed, callback_scope:this});
this.rules.select_random_team();
this.network.pause_incoming();
new Delay({seconds:0.4, callback:this.gui.hide_statusbox, callback_scope:this.gui});
new Delay({seconds:2, callback:this.network.resume_incoming, callback_scope:this.network});
};
this.end_game_pressed = function () {
this.set_game_over("disconnected");
};
this.start_round = function (current_round) {
var _local2 = current_round + 1;
this.gui.time_box.round.text = (game.gamedata.text.round + " ") + _local2;
};
this.team_select_done = function () {
if (this.gameover) {
return(undefined);
}
fscommand ("gameStart");
this.gamestarted = true;
this.gui.show_table();
new Delay({seconds:1.5, callback:this.gui.chat.show, callback_scope:this.gui.chat});
this.table.next_round();
this.rules.all_next_round();
new Delay({seconds:1.5, callback:this.rules.request_deal, callback_scope:this.rules});
};
this.deal_done = function () {
wr("game.deal_done");
this.rules.start_betting();
this.gui.show_bettingbox();
if (this.table.local_player.playernum == this.rules.get_start_player_num()) {
this.gui.start_bettingbox();
}
};
this.end_round = function () {
new Delay({seconds:3, callback:game.gui.show_scoreboard, callback_scope:game.gui});
};
this.set_game_over = function (reason) {
if (this.gameover) {
return(undefined);
}
this.gameover = true;
var _local8 = function (obj) {
soundFx.play("outroSound");
clearInterval(obj.clearIntervalId);
};
var _local4 = new Object();
_local4.clearIntervalId = setInterval(_local8, 1000, _local4);
var _local3 = (this.table.local_player.winner ? 1000 : 500);
if (reason == "disconnected") {
_local3 = 0;
this.network.pause_incoming();
} else if (reason == "teammate_disconnect") {
_local3 = 500;
} else if (reason == "opponent_disconnect") {
_local3 = 1000;
}
this.table.halt();
this.gui.halt();
if (this.team_selector.active) {
this.team_selector.halt();
}
fscommand ("gameEnd", _local3);
var _local6 = function () {
this.network.disconnect();
wr("quit");
fscommand ("gameQuit");
};
var _local2 = parseInt(game.gamedata.postdelay);
if (isNaN(_local2)) {
_local2 = 0;
}
_local2 = _local2 + 2;
new Delay({seconds:_local2, callback:_local6, callback_scope:this});
};
this.get_game_over = function () {
return(this.rules.get_game_over());
};
this.networkServerEvent = function (cmd, dat) {
if (net_debug) {
wr("game.networkServerEvent()", cmd, dat);
}
switch (cmd) {
case "STR" :
this.rules.team_selection_rejected();
break;
case "STJ" :
var _local2 = dat.split(",");
var _local6 = parseInt(_local2[0]);
var _local5 = parseInt(_local2[1]);
this.rules.player_join_team(_local6, _local5);
break;
case "STD" :
this.rules.team_select_done();
break;
case "SDC" :
_local2 = dat.split(",", 2);
var _local3 = parseInt(_local2[0]);
var _local7 = _local2[1];
this.rules.deal_cards(_local3, _local7);
}
};
this.networkGameEvent = function (cmd, playernum, playdata) {
if (net_debug) {
wr("game.networkGameEvent()", cmd, playernum, playdata);
}
switch (cmd) {
case "GPC" :
var _local5 = playdata.split(",");
var _local6 = parseInt(_local5[0]);
var _local7 = _local5[1];
this.rules.play_opponent_card(playernum, _local6, _local7);
break;
case "GPB" :
wr("localplayer got bet from player", playernum, ":", playdata);
this.rules.player_place_bet(playernum, playdata);
var _local4;
if (playdata == "blind_nil") {
_local4 = this.gamedata.text.blind_nil;
} else if (playdata == 0) {
_local4 = this.gamedata.text.nil;
} else {
_local4 = playdata;
}
this.gui.chat.msg_receive((("" + playernum) + ",") + _local4);
break;
case "GNR" :
this.rules.player_next_round(playernum);
break;
case "GMO" :
this.table.players[playernum].hand.mouse_over_index(parseInt(playdata));
}
};
this.networkEvent = function (cmd, dat) {
if (net_debug) {
wr("game.networkEvent()", cmd, dat);
}
switch (cmd) {
case "MCC" :
if (__midas_chatcontrol) {
__midas_chatcontrol.hm("MCC " + dat);
}
break;
case "MSG" :
if (!this.gui.chat) {
break;
}
this.gui.chat.msg_receive(dat);
}
};
this.handleCommError = function (msg) {
if (this.gameover) {
return(undefined);
}
this.set_game_over("disconnected");
this.gui.show_alert(this.gamedata.text[msg]);
this.gui.hide_statusbox();
};
this.init(props);
}
function startup() {
if (_game_started) {
return(undefined);
}
_game_started = true;
events = new Events();
sprites = new Sprites();
soundFx = new SoundFx();
random = new Random();
game = new Game();
}
var global_card_count = 0;
var game_version = "1.2";
var dev_mode = false;
var net_debug = false;
var netlog_wr = false;
var game;
var events;
var sprites;
var soundFx;
var random;
var _game_started = false;
Stage.showMenu = false;
Stage.scaleMode = "noScale";
_focusrect = false;
stop();
startup();
Symbol 103 MovieClip [card_fg] Frame 1
stop();
Symbol 129 MovieClip Frame 1
stop();
Symbol 129 MovieClip Frame 2
stop();
Symbol 129 MovieClip Frame 3
stop();
Symbol 129 MovieClip Frame 4
stop();
Symbol 136 MovieClip Frame 1
stop();
Symbol 136 MovieClip Frame 2
stop();
Symbol 167 MovieClip Frame 1
stop();
Symbol 185 MovieClip Frame 1
stop();
Symbol 185 MovieClip Frame 2