-
-
Save bonniss/bf9d54eb06c21bf1456300f28011f400 to your computer and use it in GitHub Desktop.
DragonBot Js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ("undefined" == typeof ZotataPlayUserID) var ZotataPlayUserID = ""; | |
if ("undefined" == typeof ZotataPlayAuthKey) var ZotataPlayAuthKey = ""; | |
if ("undefined" == typeof debug) var debug = -1 != location.hostname.indexOf("t.dragonbound.net"); | |
var VERSION = 101, | |
SERVER_ADDRESS = -1 != location.hostname.indexOf("t.dragonbound.net") ? "http://t.dragonbound.net:9000" : "http://game.dragonbound.net:80", | |
LOCATION_TYPE_UNKNOWN = "unknown", | |
LOCATION_TYPE_CHANNEL = "channel", | |
LOCATION_TYPE_ROOM = "room", | |
ROOM_STATUS_WAITING = "W", | |
ROOM_STATUS_FULL = "F", | |
ROOM_STATUS_PLAYING = "P", | |
GUI_LOCATION_CHANNEL = 1, | |
GUI_LOCATION_ROOM = 2, | |
GUI_LOCATION_GAME = 3, | |
GUI_LOCATION_SHOP = 4, | |
ITEM_NONE = -1, | |
ITEM_DUAL = 0, | |
ITEM_TELEPORT = 1, | |
ITEM_CLASS = ["itemDual", "itemTeleport"], | |
ITEM_SIZE = [2, 2], | |
CHAT_TYPE_NORMAL = 0, | |
CHAT_TYPE_DEAD = 2, | |
CHAT_TYPE_GOLD = 3, | |
CHAT_TYPE_GM = 5, | |
CHAT_TYPE_SYSTEM = 6, | |
CHAT_TYPE_GM_BUGLE = 9, | |
MOBILE_ARMOR = 0, | |
MOBILE_ICE = 1, | |
MOBILE_ADUKA = 2, | |
MOBILE_LIGHTNING = 3, | |
MOBILE_BIGFOOT = 4, | |
MOBILE_JD = 5, | |
NUMBER_OF_MOBILES = 6, | |
EXPLODE_ARMOR1 = 0, | |
EXPLODE_ARMOR2 = 1, | |
EXPLODE_ARMORSS = 2, | |
EXPLODE_ICE1 = 3, | |
EXPLODE_ICE2 = 4, | |
EXPLODE_ICESS = 5, | |
EXPLODE_ADUKA1_THOR = 6, | |
EXPLODE_TELEPORT = 7, | |
EXPLODE_LIGHTINING12_JD1 = 8, | |
EXPLODE_LIGHTNINGSS = 9, | |
EXPLODE_BIGFOOT1SS = 10, | |
EXPLODE_BIGFOOT2 = 11, | |
EXPLODE_JD2 = 12, | |
EXPLODE_JDSS = 13, | |
BULLET_ARMOR1 = 0, | |
BULLET_ARMOR2 = 1, | |
BULLET_ARMORSS = 2, | |
BULLET_ARMOESS2 = 3, | |
BULLET_ICE1 = 4, | |
BULLET_ICE2 = 5, | |
BULLET_ICESS = 6, | |
BULLET_ADUKA1_THOR = 7, | |
BULLET_ADUKA2 = 8, | |
BULLET_ADUKASS = 9, | |
BULLET_TELEPORT = 10, | |
BULLET_LIGHTNING12 = 11, | |
BULLET_LIGHTNINGSS = 12, | |
BULLET_BIGFOOT1 = 13, | |
BULLET_BIGFOOT2 = 14, | |
BULLET_BIGFOOTSS = 15, | |
BULLET_JD1 = 16, | |
BULLET_JD2 = 17, | |
BULLET_JDSS = 18, | |
MOBILE = [], | |
EXPLODE = [], | |
BULLET = [], | |
AVATAR_TYPE_HEAD = "h", | |
AVATAR_TYPE_BODY = "b", | |
AVATAR_TYPE_EYES = "g", | |
AVATAR_TYPE_FLAG = "f", | |
AVATAR_NAKED_HEAD_MALE = 1, | |
AVATAR_NAKED_BODY_MALE = 2, | |
AVATAR_NAKED_HEAD_FEMALE = 3, | |
AVATAR_NAKED_BODY_FEMALE = 4, | |
AVATAR_INDEX_N = 0, | |
AVATAR_INDEX_TYPE = 1, | |
AVATAR_INDEX_GENDER = 2, | |
AVATAR_INDEX_NAME = 3, | |
AVATAR_INDEX_DESC = 4, | |
AVATAR_INDEX_SHOP = 5, | |
AVATAR_INDEX_GOLD_WEEK = 6, | |
AVATAR_INDEX_GOLD_MONTH = 7, | |
AVATAR_INDEX_GOLD_PERM = 8, | |
AVATAR_INDEX_CASH_WEEK = 9, | |
AVATAR_INDEX_CASH_MONTH = 10, | |
AVATAR_INDEX_CASH_PERM = 11, | |
AVATAR_INDEX_STAT_POP = 12, | |
AVATAR_INDEX_STAT_TIME = 13, | |
AVATAR_INDEX_STAT_ATK = 14, | |
AVATAR_INDEX_STAT_DEF = 15, | |
AVATAR_INDEX_STAT_LIFE = 16, | |
AVATAR_INDEX_STAT_ITEM = 17, | |
AVATAR_INDEX_STAT_DIG = 18, | |
AVATAR_INDEX_STAT_SHLD = 19, | |
AVATAR_INDEX_GRAPHICS = 20, | |
GAME_MODE_NORMAL = 0, | |
GAME_MODE_BOSS = 1, | |
MOBILE_GRAPHICS = []; | |
MOBILE_GRAPHICS[MOBILE_ARMOR] = { | |
w: 36, | |
h: 39, | |
center_x: 18, | |
center_y: 37, | |
player_x: 17, | |
player_y: -28, | |
frames: 18 | |
}; | |
MOBILE_GRAPHICS[MOBILE_ICE] = { | |
w: 55, | |
h: 58, | |
center_x: 27, | |
center_y: 55, | |
player_x: -5, | |
player_y: -40, | |
frames: 19 | |
}; | |
MOBILE_GRAPHICS[MOBILE_ADUKA] = { | |
w: 67, | |
h: 65, | |
center_x: 33, | |
center_y: 60, | |
player_x: -20, | |
player_y: -27, | |
frames: 20 | |
}; | |
MOBILE_GRAPHICS[MOBILE_LIGHTNING] = { | |
w: 42, | |
h: 58, | |
center_x: 21, | |
center_y: 57, | |
player_x: 10, | |
player_y: -34, | |
frames: 20 | |
}; | |
MOBILE_GRAPHICS[MOBILE_BIGFOOT] = { | |
w: 50, | |
h: 61, | |
center_x: 25, | |
center_y: 55, | |
player_x: -2, | |
player_y: -34, | |
frames: 40 | |
}; | |
MOBILE_GRAPHICS[MOBILE_JD] = { | |
w: 36, | |
h: 58, | |
center_x: 18, | |
center_y: 57, | |
player_x: 11, | |
player_y: -34, | |
frames: 20 | |
}; | |
var GENDER_MALE = "m", | |
GENDER_FEMALE = "f", | |
MS_IN_1_HOUR = 36E5, | |
MS_IN_1_DAY = 24 * MS_IN_1_HOUR, | |
g_myPlayerInfo, g_channel_skip_rooms = 0, | |
g_roomsList, g_game = void 0, | |
g_gui_location = GUI_LOCATION_CHANNEL, | |
g_room_players, g_graphics_high = !0, | |
g_items = [ITEM_DUAL, ITEM_NONE, ITEM_DUAL, ITEM_NONE, ITEM_TELEPORT, ITEM_NONE], | |
g_auto_ready_timer, g_ranking_offset = 1, | |
g_is_ranking_loading = !1, | |
g_is_show_ranking = !1, | |
g_shop_player, g_channel_player, g_current_buy_avatar_index, g_current_shop_type, g_current_shop_page, g_bot_select_for_slot, g_is_game_background = 0 != getCookie("background"), | |
g_is_game_slice = 0 != getCookie("slice"), | |
g_is_ranking_loaded = !1; | |
function InitGlobals() { | |
MOBILE[MOBILE_ARMOR] = { | |
explodes: [EXPLODE_ARMOR1, EXPLODE_ARMOR2, EXPLODE_ARMORSS], | |
bullets: [0, 1, 2, 3] | |
}; | |
MOBILE[MOBILE_ICE] = { | |
explodes: [EXPLODE_ICE1, EXPLODE_ICE2, EXPLODE_ICESS], | |
bullets: [4, 5, 6] | |
}; | |
MOBILE[MOBILE_ADUKA] = { | |
explodes: [EXPLODE_ADUKA1_THOR], | |
bullets: [7, 8, 9] | |
}; | |
MOBILE[MOBILE_LIGHTNING] = { | |
explodes: [EXPLODE_LIGHTINING12_JD1, EXPLODE_LIGHTNINGSS], | |
bullets: [11, 12, 13] | |
}; | |
MOBILE[MOBILE_BIGFOOT] = { | |
explodes: [EXPLODE_BIGFOOT1SS, EXPLODE_BIGFOOT2], | |
bullets: [14, 15, 16] | |
}; | |
MOBILE[MOBILE_JD] = { | |
explodes: [EXPLODE_LIGHTINING12_JD1, EXPLODE_JD2, EXPLODE_JDSS], | |
bullets: [17, 18, 19] | |
}; | |
EXPLODE[EXPLODE_ARMOR1] = { | |
file: "armor1.png", | |
sound: AUDIO_ARMOR_BLAST, | |
graphics: [ | |
[31, 29, 17, 9], | |
[68, 78, 37, 34], | |
[98, 111, 52, 54], | |
[111, 124, 57, 64], | |
[128, 125, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64] | |
] | |
}; | |
EXPLODE[EXPLODE_ARMOR2] = { | |
file: "armor2.png", | |
sound: AUDIO_ARMOR_BLAST, | |
graphics: [ | |
[20, 20, 10, 10], | |
[46, 52, 23, 26], | |
[66, 74, 33, 37], | |
[74, 84, 34, 42], | |
[89, 90, 43, 45], | |
[90, 95, 43, 49], | |
[93, 98, 45, 51], | |
[99, 103, 48, 52], | |
[101, 106, 50, 53], | |
[103, 109, 51, 54], | |
[105, 112, 52, 56], | |
[107, 114, 53, 57], | |
[110, 117, 54, 58], | |
[113, 119, 56, 58], | |
[113, 121, 56, 59], | |
[115, 122, 57, 59], | |
[117, 124, 58, 59], | |
[117, 124, 58, 59], | |
[117, 115, 58, 59], | |
[106, 100, 47, 46] | |
] | |
}; | |
EXPLODE[EXPLODE_ARMORSS] = { | |
file: "armorSS.png", | |
sound: AUDIO_ARMOR_BLAST, | |
graphics: [ | |
[128, 124, 64, 60], | |
[128, 128, 64, 64], | |
[128, 126, 64, 62], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 128, 64, 64], | |
[128, 91, 64, 27] | |
] | |
}; | |
EXPLODE[EXPLODE_ICE1] = { | |
file: "ice1.png", | |
sound: AUDIO_ICE_BLAST, | |
graphics: [ | |
[31, 35, 15, 22], | |
[53, 51, 25, 30], | |
[81, 77, 39, 41], | |
[99, 108, 47, 52], | |
[103, 110, 49, 53], | |
[104, 97, 49, 49], | |
[94, 93, 48, 48], | |
[103, 109, 51, 51], | |
[111, 107, 57, 50], | |
[103, 106, 53, 51], | |
[101, 107, 52, 53], | |
[93, 104, 44, 56], | |
[101, 108, 48, 58], | |
[110, 100, 52, 60], | |
[122, 107, 58, 62], | |
[121, 110, 57, 61] | |
] | |
}; | |
EXPLODE[EXPLODE_ICE2] = { | |
file: "ice2.png", | |
sound: AUDIO_ICE_BLAST2, | |
graphics: [ | |
[25, 28, 14, 16], | |
[48, 53, 26, 28], | |
[73, 78, 39, 38], | |
[96, 103, 50, 47], | |
[106, 106, 55, 48], | |
[116, 107, 58, 49], | |
[116, 111, 58, 53], | |
[116, 116, 58, 58], | |
[116, 116, 58, 58], | |
[113, 116, 58, 58], | |
[81, 80, 38, 53], | |
[78, 82, 32, 44], | |
[66, 70, 31, 33], | |
[61, 67, 31, 33], | |
[54, 58, 31, 35], | |
[53, 61, 30, 37], | |
[55, 53, 32, 30], | |
[49, 49, 26, 26], | |
[49, 49, 26, 26], | |
[49, 49, 26, 26], | |
[49, 49, 26, 26], | |
[48, 47, 25, 23], | |
[48, 44, 24, 18], | |
[51, 46, 26, 17], | |
[54, 47, 29, 16], | |
[57, 46, 32, 14] | |
] | |
}; | |
EXPLODE[EXPLODE_ICESS] = { | |
file: "iceSS.png", | |
sound: AUDIO_ICE_BLAST2, | |
graphics: [ | |
[80, 80, 35, 40], | |
[222, 222, 101, 111], | |
[223, 223, 101, 112], | |
[247, 247, 119, 119], | |
[247, 251, 119, 123], | |
[247, 248, 119, 120], | |
[247, 249, 119, 121], | |
[223, 223, 102, 115], | |
[224, 224, 103, 115], | |
[223, 222, 102, 115], | |
[221, 222, 101, 115], | |
[223, 222, 102, 115], | |
[222, 222, 102, 115], | |
[222, 222, 102, 115], | |
[222, 221, 102, 115], | |
[222, 221, 102, 115], | |
[222, 221, 102, 115], | |
[221, 222, 102, 116], | |
[221, 221, 102, 115], | |
[222, 220, 103, 115], | |
[222, 220, 103, 115], | |
[222, 219, 104, 115], | |
[222, 217, 105, 114], | |
[203, 175, 104, 88], | |
[206, 175, 106, 88], | |
[216, 180, 111, 86], | |
[224, 183, 115, 82], | |
[236, 184, 120, 70], | |
[244, 181, 123, 53], | |
[246, 157, 123, 29] | |
] | |
}; | |
EXPLODE[EXPLODE_ADUKA1_THOR] = { | |
file: "aduka1-thor.png", | |
sound: AUDIO_ARMOR_BLAST, | |
graphics: [ | |
[18, 18, 9, 9], | |
[60, 60, 30, 30], | |
[48, 47, 24, 23], | |
[63, 67, 31, 31], | |
[78, 80, 38, 39], | |
[93, 96, 46, 47], | |
[104, 96, 52, 47], | |
[114, 96, 57, 47], | |
[124, 96, 62, 47], | |
[128, 96, 61, 47], | |
[128, 92, 57, 48], | |
[76, 84, 34, 40], | |
[79, 76, 35, 40], | |
[82, 78, 37, 44], | |
[81, 79, 36, 45], | |
[76, 79, 38, 46] | |
] | |
}; | |
EXPLODE[EXPLODE_TELEPORT] = { | |
file: "teleport.png", | |
sound: AUDIO_LIGHTNING_BLAST, | |
graphics: [ | |
[43, 44, 22, 20], | |
[100, 101, 51, 49], | |
[113, 112, 57, 56], | |
[103, 102, 52, 49], | |
[114, 116, 57, 55], | |
[123, 126, 61, 62], | |
[126, 128, 62, 64], | |
[125, 128, 64, 64], | |
[125, 128, 64, 64], | |
[122, 128, 64, 64], | |
[126, 128, 64, 64], | |
[123, 126, 59, 62], | |
[119, 123, 59, 64], | |
[123, 121, 62, 61], | |
[121, 126, 61, 64], | |
[118, 128, 58, 64], | |
[121, 120, 59, 64], | |
[123, 121, 61, 64], | |
[122, 120, 62, 62] | |
] | |
}; | |
EXPLODE[EXPLODE_LIGHTINING12_JD1] = { | |
file: "lightning12-jd1.png", | |
sound: AUDIO_LIGHTNING_BLAST, | |
graphics: [ | |
[27, 17, 13, 8], | |
[55, 56, 29, 30], | |
[92, 92, 51, 49], | |
[114, 108, 59, 54], | |
[125, 122, 62, 61], | |
[119, 121, 57, 64], | |
[116, 113, 58, 59], | |
[102, 108, 51, 56], | |
[94, 92, 48, 44], | |
[65, 66, 32, 33], | |
[50, 51, 25, 25], | |
[74, 74, 37, 37], | |
[94, 94, 47, 47], | |
[112, 112, 56, 56] | |
] | |
}; | |
EXPLODE[EXPLODE_LIGHTNINGSS] = { | |
file: "lightningSS.png", | |
sound: AUDIO_LIGHTNING_BLAST, | |
graphics: [ | |
[21, 23, 12, 14], | |
[52, 49, 29, 26], | |
[38, 46, 22, 27], | |
[69, 78, 41, 40], | |
[142, 130, 77, 66], | |
[213, 216, 105, 106], | |
[250, 240, 126, 124], | |
[253, 246, 128, 124], | |
[256, 252, 128, 124], | |
[256, 240, 128, 124], | |
[256, 240, 128, 124], | |
[256, 240, 128, 124], | |
[256, 241, 128, 124], | |
[253, 241, 128, 123], | |
[240, 241, 115, 124], | |
[242, 243, 114, 124], | |
[252, 252, 128, 124], | |
[237, 237, 114, 122], | |
[234, 234, 113, 120] | |
] | |
}; | |
EXPLODE[EXPLODE_BIGFOOT1SS] = { | |
file: "bigfoot1SS.png", | |
sound: AUDIO_BIGFOOT_BLAST1, | |
graphics: [ | |
[56, 52, 28, 30], | |
[79, 72, 38, 41], | |
[92, 83, 41, 44], | |
[99, 101, 46, 51], | |
[101, 107, 48, 51], | |
[109, 102, 56, 51], | |
[109, 106, 57, 50], | |
[109, 101, 57, 50], | |
[108, 100, 57, 50], | |
[105, 100, 57, 50], | |
[102, 97, 57, 49], | |
[98, 97, 56, 49], | |
[92, 85, 53, 49], | |
[84, 80, 49, 45], | |
[81, 80, 47, 45], | |
[83, 79, 47, 43], | |
[79, 80, 44, 44], | |
[81, 80, 45, 44], | |
[80, 72, 45, 39] | |
] | |
}; | |
EXPLODE[EXPLODE_BIGFOOT2] = { | |
file: "bigfoot2.png", | |
sound: AUDIO_BIGFOOT_BLAST2, | |
graphics: [ | |
[26, 24, 14, 11], | |
[37, 34, 17, 15], | |
[43, 40, 23, 20], | |
[46, 47, 24, 23], | |
[47, 48, 24, 24], | |
[52, 48, 26, 25], | |
[51, 48, 25, 25], | |
[51, 47, 25, 25], | |
[50, 46, 24, 24], | |
[49, 46, 23, 24], | |
[48, 46, 22, 24], | |
[46, 44, 20, 23], | |
[42, 40, 19, 19], | |
[39, 38, 17, 19], | |
[38, 37, 17, 19], | |
[38, 37, 17, 19], | |
[37, 37, 17, 19], | |
[38, 37, 18, 19], | |
[37, 34, 17, 18] | |
] | |
}; | |
EXPLODE[EXPLODE_JD2] = { | |
file: "jd2.png", | |
sound: AUDIO_JD_BLAST2, | |
graphics: [ | |
[120, 102, 64, 64], | |
[121, 124, 60, 64], | |
[121, 128, 61, 64], | |
[124, 128, 64, 64], | |
[128, 126, 64, 64], | |
[117, 119, 59, 60], | |
[115, 113, 57, 55], | |
[120, 112, 61, 54], | |
[120, 110, 61, 53], | |
[118, 110, 60, 54], | |
[114, 114, 58, 54], | |
[109, 110, 55, 52], | |
[103, 107, 52, 53], | |
[97, 99, 49, 49], | |
[92, 88, 49, 44], | |
[79, 77, 41, 39], | |
[66, 63, 35, 32], | |
[36, 35, 18, 18], | |
[8, 8, 4, 4], | |
[67, 67, 34, 44] | |
] | |
}; | |
EXPLODE[EXPLODE_JDSS] = { | |
file: "jdSS.png", | |
sound: AUDIO_JD_BLAST1, | |
graphics: [ | |
[185, 182, 97, 98], | |
[233, 232, 119, 123], | |
[244, 237, 125, 124], | |
[244, 238, 125, 124], | |
[253, 241, 128, 124], | |
[256, 240, 128, 124], | |
[256, 241, 128, 124], | |
[256, 243, 128, 124], | |
[256, 243, 128, 124], | |
[256, 243, 128, 124], | |
[256, 243, 128, 124], | |
[254, 243, 128, 124], | |
[254, 243, 128, 124], | |
[256, 243, 128, 124], | |
[256, 243, 128, 124], | |
[256, 243, 128, 124], | |
[256, 243, 128, 124], | |
[256, 243, 128, 124], | |
[256, 243, 128, 124], | |
[256, 243, 128, 124], | |
[256, 243, 128, 124], | |
[256, 243, 128, 124], | |
[256, 242, 128, 124], | |
[256, 243, 128, 124], | |
[256, 245, 128, 124], | |
[256, 247, 128, 124], | |
[256, 248, 128, 124], | |
[256, 242, 128, 124], | |
[256, 242, 128, 124], | |
[250, 239, 126, 124] | |
] | |
}; | |
BULLET[BULLET_ARMOR1] = { | |
sound: AUDIO_ARMOR_FIRE | |
}; | |
BULLET[BULLET_ARMOR2] = { | |
sound: AUDIO_ARMOR_FIRE2 | |
}; | |
BULLET[BULLET_ARMORSS] = { | |
sound: AUDIO_ARMOR_FIRE2 | |
}; | |
BULLET[BULLET_ARMOESS2] = { | |
sound: AUDIO_ARMOR_FIRE2 | |
}; | |
BULLET[BULLET_ICE1] = { | |
file: "ice1.png", | |
sound: AUDIO_ICE_FIRE, | |
graphics: [ | |
[24, 14, 6, 7], | |
[24, 16, 6, 8], | |
[24, 16, 6, 8], | |
[24, 14, 6, 7], | |
[24, 14, 6, 6], | |
[24, 15, 6, 7], | |
[24, 15, 6, 7], | |
[24, 15, 6, 7], | |
[24, 13, 6, 6], | |
[24, 14, 6, 6], | |
[24, 15, 6, 7], | |
[24, 15, 6, 7], | |
[24, 16, 6, 7], | |
[24, 15, 6, 7], | |
[24, 14, 6, 7], | |
[24, 14, 6, 7], | |
[24, 15, 6, 7], | |
[24, 15, 6, 7], | |
[24, 14, 6, 7], | |
[24, 14, 6, 7] | |
] | |
}; | |
BULLET[BULLET_ICE2] = { | |
file: "ice2.png", | |
sound: AUDIO_ICE_FIRE, | |
graphics: [ | |
[24, 24, 13, 10], | |
[24, 22, 13, 9], | |
[24, 19, 13, 8], | |
[24, 20, 13, 8], | |
[24, 22, 13, 9], | |
[24, 24, 13, 10], | |
[23, 24, 13, 10], | |
[22, 24, 12, 10], | |
[22, 24, 12, 10], | |
[23, 24, 13, 10], | |
[23, 24, 13, 10], | |
[24, 24, 13, 10] | |
] | |
}; | |
BULLET[BULLET_ICESS] = { | |
file: "iceSS.png", | |
sound: AUDIO_ICE_FIRE, | |
graphics: [ | |
[33, 29, 22, 14], | |
[33, 28, 22, 14], | |
[33, 25, 23, 13], | |
[31, 19, 22, 10], | |
[28, 16, 20, 8], | |
[28, 21, 19, 10], | |
[30, 26, 19, 12], | |
[32, 29, 20, 14], | |
[33, 29, 21, 14], | |
[33, 26, 21, 12], | |
[32, 23, 21, 11], | |
[30, 17, 20, 8], | |
[28, 18, 19, 9], | |
[28, 23, 19, 11], | |
[31, 27, 21, 13] | |
] | |
}; | |
BULLET[BULLET_ADUKA1_THOR] = { | |
file: "aduka1-thor.png", | |
sound: AUDIO_ADUKA_FIRE, | |
graphics: [ | |
[24, 24, 13, 12], | |
[30, 27, 15, 14], | |
[34, 31, 16, 19], | |
[36, 31, 17, 18], | |
[32, 30, 16, 19], | |
[34, 31, 16, 19], | |
[35, 30, 15, 15], | |
[33, 30, 15, 14], | |
[35, 30, 15, 12], | |
[32, 32, 13, 13] | |
] | |
}; | |
BULLET[BULLET_ADUKA2] = { | |
file: "aduka2.png", | |
sound: AUDIO_ADUKA_FIRE2, | |
graphics: [ | |
[33, 26, 16, 15], | |
[33, 24, 16, 13], | |
[34, 25, 17, 14], | |
[34, 26, 17, 15], | |
[33, 25, 16, 14], | |
[33, 24, 16, 13], | |
[33, 26, 16, 15], | |
[34, 27, 17, 16] | |
] | |
}; | |
BULLET[BULLET_ADUKASS] = { | |
file: "adukaSS.png", | |
sound: AUDIO_ADUKA_FIRE2, | |
graphics: [ | |
[44, 34, 25, 32], | |
[43, 31, 24, 30], | |
[44, 32, 25, 31], | |
[45, 34, 26, 33], | |
[44, 33, 25, 32], | |
[43, 32, 24, 30], | |
[44, 34, 25, 32], | |
[44, 37, 25, 35] | |
] | |
}; | |
BULLET[BULLET_TELEPORT] = { | |
file: "teleport.png", | |
sound: AUDIO_ARMOR_FIRE, | |
graphics: [ | |
[31, 24, 18, 12], | |
[34, 22, 21, 12], | |
[34, 22, 21, 12], | |
[35, 24, 22, 13], | |
[38, 24, 25, 13], | |
[37, 23, 24, 12], | |
[38, 23, 25, 12], | |
[34, 24, 21, 13], | |
[38, 24, 25, 12], | |
[33, 26, 20, 13], | |
[36, 25, 23, 13], | |
[31, 24, 18, 12] | |
] | |
}; | |
BULLET[BULLET_LIGHTNING12] = { | |
file: "lightning12.png", | |
sound: AUDIO_LIGHTNING_FIRE, | |
graphics: [ | |
[35, 32, 15, 15], | |
[33, 31, 16, 15], | |
[36, 39, 16, 19], | |
[39, 42, 19, 21], | |
[37, 39, 18, 18], | |
[37, 36, 18, 17], | |
[34, 33, 14, 15], | |
[27, 27, 12, 12], | |
[38, 44, 17, 19], | |
[32, 32, 14, 13] | |
] | |
}; | |
BULLET[BULLET_LIGHTNINGSS] = { | |
file: "lightningSS.png", | |
sound: AUDIO_LIGHTNING_FIRE, | |
graphics: [ | |
[55, 36, 42, 17], | |
[58, 36, 44, 17], | |
[58, 37, 44, 18], | |
[59, 37, 44, 18], | |
[60, 37, 44, 18], | |
[60, 37, 44, 18], | |
[58, 37, 42, 18], | |
[59, 37, 44, 18], | |
[58, 37, 44, 18], | |
[57, 36, 44, 17], | |
[57, 36, 44, 17], | |
[57, 37, 44, 17] | |
] | |
}; | |
BULLET[BULLET_BIGFOOT1] = { | |
file: "bigfoot1.png", | |
sound: AUDIO_BIGFOOT_FIRE1, | |
graphics: [ | |
[18, 12, 9, 6], | |
[18, 12, 9, 6], | |
[18, 12, 9, 6], | |
[18, 12, 9, 6], | |
[18, 12, 9, 6] | |
] | |
}; | |
BULLET[BULLET_BIGFOOT2] = { | |
file: "bigfoot2.png", | |
sound: AUDIO_BIGFOOT_FIRE2, | |
graphics: [ | |
[12, 10, 6, 5], | |
[12, 9, 6, 4], | |
[12, 9, 6, 4], | |
[12, 9, 6, 4], | |
[12, 10, 6, 5], | |
[12, 10, 6, 5], | |
[12, 9, 6, 4], | |
[12, 10, 6, 5], | |
[12, 10, 6, 5], | |
[12, 10, 6, 5] | |
] | |
}; | |
BULLET[BULLET_BIGFOOTSS] = { | |
file: "bigfootSS.png", | |
sound: AUDIO_BIGFOOT_FIRE1, | |
graphics: [ | |
[20, 14, 15, 7], | |
[20, 14, 15, 7], | |
[20, 14, 15, 7], | |
[20, 14, 15, 7], | |
[20, 14, 15, 7] | |
] | |
}; | |
BULLET[BULLET_JD1] = { | |
file: "jd1.png", | |
sound: AUDIO_JD_FIRE, | |
graphics: [ | |
[20, 20, 10, 10], | |
[20, 20, 10, 10], | |
[20, 20, 10, 10], | |
[20, 20, 10, 10], | |
[20, 20, 10, 10], | |
[20, 20, 10, 10], | |
[20, 20, 10, 10], | |
[20, 20, 10, 10] | |
] | |
}; | |
BULLET[BULLET_JD2] = { | |
file: "jd2.png", | |
sound: AUDIO_JD_FIRE, | |
graphics: [ | |
[29, 30, 15, 15], | |
[31, 31, 16, 15], | |
[29, 30, 15, 15], | |
[29, 31, 15, 16], | |
[30, 31, 15, 16], | |
[29, 31, 14, 14], | |
[30, 31, 15, 15], | |
[30, 31, 16, 14] | |
] | |
}; | |
BULLET[BULLET_JDSS] = { | |
file: "jdSS.png", | |
sound: AUDIO_JD_FIRE, | |
graphics: [ | |
[34, 35, 17, 18], | |
[36, 35, 18, 17], | |
[34, 36, 18, 18], | |
[35, 37, 18, 19], | |
[36, 35, 18, 18], | |
[35, 37, 17, 17], | |
[35, 37, 18, 18], | |
[35, 36, 19, 16] | |
] | |
} | |
} | |
var COMPUTER_PLAYER = [{ | |
rank: 0, | |
name: "Clown Stripe", | |
gp: 2, | |
atk: 5, | |
def: 0, | |
life: 10, | |
dig: 0 | |
}, { | |
rank: 1, | |
name: "Haris Pilton", | |
gp: 3, | |
atk: 7, | |
def: 4, | |
life: 15, | |
dig: 0 | |
}, { | |
rank: 3, | |
name: "Harly Potler", | |
gp: 4, | |
atk: 10, | |
def: 8, | |
life: 20, | |
dig: 5 | |
}, { | |
rank: 5, | |
name: "Angie Jelly", | |
gp: 5, | |
atk: 12, | |
def: 12, | |
life: 25, | |
dig: 9 | |
}, { | |
rank: 7, | |
name: "Floyd Pinkus", | |
gp: 6, | |
atk: 17, | |
def: 18, | |
life: 30, | |
dig: 14 | |
}, { | |
rank: 9, | |
name: "Yuffie Kisaragi", | |
gp: 7, | |
atk: 25, | |
def: 24, | |
life: 35, | |
dig: 18 | |
}, { | |
rank: 13, | |
name: "Bill Board", | |
gp: 8, | |
atk: 33, | |
def: 32, | |
life: 40, | |
dig: 22 | |
}, { | |
rank: 15, | |
name: "Gilly Gamesh", | |
gp: 10, | |
atk: 40, | |
def: 40, | |
life: 45, | |
dig: 25 | |
}, { | |
rank: 17, | |
name: "Lance Alot", | |
gp: 12, | |
atk: 50, | |
def: "??", | |
life: 50, | |
dig: 10 | |
}, { | |
rank: 18, | |
name: "Voldy Moore", | |
gp: 14, | |
atk: 50, | |
def: 50, | |
life: "??", | |
dig: 20 | |
}, { | |
rank: 19, | |
name: "Jack the Ripper", | |
gp: 16, | |
atk: 50, | |
def: 50, | |
life: 50, | |
dig: "??" | |
}, { | |
rank: 20, | |
name: "Seffy Roth", | |
gp: 20, | |
atk: "??", | |
def: 50, | |
life: 50, | |
dig: 30 | |
}]; | |
$(document).ajaxSend(function (a, b, c) { | |
function d(a) { | |
var b = null; | |
if (document.cookie && "" != document.cookie) for (var c = document.cookie.split(";"), d = 0; d < c.length; d++) { | |
var e = jQuery.trim(c[d]); | |
if (e.substring(0, a.length + 1) == a + "=") { | |
b = decodeURIComponent(e.substring(a.length + 1)); | |
break | |
} | |
} | |
return b | |
} | |
if (a = !/^(GET|HEAD|OPTIONS|TRACE)$/.test(c.type)) var c = c.url, | |
a = "//" + document.location.host, | |
e = document.location.protocol + a, | |
a = c == e || c.slice(0, e.length + 1) == e + "/" || c == a || c.slice(0, a.length + 1) == a + "/" || !/^(\/\/|http:|https:).*/.test(c); | |
a && b.setRequestHeader("X-CSRFToken", d("csrftoken")) | |
}); | |
function preloadImages(a) { | |
$(a).each(function () { | |
(new Image).src = this | |
}) | |
} | |
var g_draggable_z_index = 1001; | |
$.prototype.draggable2 = function () { | |
var a = this, | |
b = !1, | |
c = !1, | |
d, e, f, h; | |
a.css("z-index", g_draggable_z_index += 1); | |
this.mousedown(function (c) { | |
b = !0; | |
d = c.pageX; | |
e = c.pageY; | |
c = a.offset(); | |
f = c.left; | |
h = c.top; | |
a.css("z-index", g_draggable_z_index += 1) | |
}); | |
$(document).mousemove(function (g) { | |
if (b && !c && (5 < Math.abs(g.pageX - d) || 5 < Math.abs(g.pageY - e))) c = !0; | |
c && a.css({ | |
left: (f + (g.pageX - d)) / g_aspect_ratio - g_no_aspect_left + "px", | |
top: (h + (g.pageY - e)) / g_aspect_ratio - g_no_aspect_top + "px" | |
}) | |
}); | |
$(document).mouseup(function () { | |
c = b = !1 | |
}); | |
return this | |
}; | |
$(document).ready(function () { | |
InitGlobals(); | |
$(document).bind("contextmenu", function () { | |
return !1 | |
}); | |
$(document).bind("dragstart", function (a) { | |
return !(a.srcElement && "img" == a.srcElement.localName) | |
}); | |
var a = navigator.userAgent; | |
a.match(/(iPhone|iPod|blackberry|android|htc|lg|midp|mmp|mobile|nokia|opera mini|palm|pocket|psp|sgh|smartphone|symbian|treo mini|Playstation Portable|SonyEricsson|Samsung|MobileExplorer|PalmSource|Benq|Windows Phone|Windows Mobile|IEMobile|Windows CE|Nintendo Wii)/i) && (g_graphics_high = !1, window.scrollTo(0, 1)); | |
a.match(/(Windows|MacOS|Mac OS|UNIX|Linux)/i) ? g_is_show_ranking = !0 : $("#touch_ui").show(); | |
$("#buttonRanking").html(g_is_show_ranking ? "Ranking >>" : "<< Ranking"); | |
a.match(/(Chrome|Safari)/i) && $("#game_back,#game_front").css({ | |
position: "fixed", | |
overflow: "hidden" | |
}); | |
AudioInit(); | |
ChannelGUI(); | |
RankingGUI(); | |
RoomGUI(); | |
GameGUI(); | |
ShopGUI(); | |
$("#dialogCreateRoom").draggable2(); | |
$(".AlertBox").draggable2(); | |
$("#shop_buy_dialog").draggable2(); | |
$("#playerInfoDialog").draggable2(); | |
$("#playerInfoDialog").draggable2(); | |
$("#OptionsDialog").draggable2(); | |
$("body").bind("keyup", function (a) { | |
a.which == 13 && (g_myPlayerInfo.location_type == LOCATION_TYPE_CHANNEL ? $("#dialogCreateRoom").is(":visible") ? CreateRoomDialogPressedOK() : $("#channelInput").focus() : g_game ? $("#gameInput").focus() : $("#roomInput").focus()) | |
}); | |
document.onhelp = function () { | |
return false | |
}; | |
window.onhelp = function () { | |
return false | |
}; | |
$("#container, .NoSelect").bind("selectstart", function (a) { | |
a.stopPropagation(); | |
return false | |
}); | |
$(".CanSelect").bind("selectstart", function (a) { | |
a.stopPropagation(); | |
return true | |
}); | |
setTimeout(ButtonGlow, 700); | |
g_is_game_background && $("#map_bg").show(); | |
ResizeInit(); | |
"" != ZotataPlayUserID && NetworkStuff() | |
}); | |
function UpdateSliceDragGUI() { | |
g_is_game_slice ? $("#slice_drag_button").removeClass("drag") : $("#slice_drag_button").addClass("drag") | |
} | |
function ButtonGlow() { | |
var a = $("#buttonQuickJoin"); | |
a.hasClass("buttonGlow") ? a.removeClass("buttonGlow") : a.addClass("buttonGlow"); | |
setTimeout(ButtonGlow, 700) | |
} | |
$(window).load(function () { | |
top.location != self.location ? top.location.replace("http://dragonbound.net") : preloadImages("/static/images/room_bg.png /static/images/room_stuff.png /static/images/maps/metamine.png /static/images/maps/miramo.png /static/images/game_stuff.png /static/images/turn_timer.png /static/images/shots.png /static/images/scores_stuff.png /static/images/explodes/aduka1-thor.png /static/images/explodes/teleport.png /static/images/bullets/teleport.png".split(" ")) | |
}); | |
function ExplodeDialog(a) { | |
if (g_graphics_high) { | |
var b = $("#" + a + " .AlertBox"); | |
0 < b.length ? (b.effect("explode"), $("#" + a).fadeOut()) : $("#" + a).effect("explode") | |
} else $("#" + a).hide() | |
} | |
function FadeInDialog(a) { | |
g_graphics_high ? ($("#" + a + " .AlertBox").fadeIn(), $("#" + a).fadeIn()) : $("#" + a).show() | |
} | |
function ToggleOptionsDialog() { | |
$("#OptionsDialog").is(":visible") ? ExplodeDialog("OptionsDialog") : (PrepareOptionsDialog(), FadeInDialog("OptionsDialog")) | |
} | |
var ROOM_NAMES = ["Hello World", "The Love Room", "DragonBound", "Welcome", "Let's Rock!"]; | |
function ChannelGUI() { | |
$("#channel").tinyscrollbar({ | |
size: 101 | |
}); | |
$("#playersList").tinyscrollbar({ | |
size: 207 | |
}); | |
$("#friendsList").tinyscrollbar({ | |
size: 208 | |
}); | |
$("#buttonCreateRoom").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT); | |
6 > g_myPlayerInfo.unlock ? CreateRoomChangeMode(GAME_MODE_BOSS) : CreateRoomChangeMode(GAME_MODE_NORMAL); | |
$("#createRoomTitle").val(ROOM_NAMES[random(0, ROOM_NAMES.length - 1)]); | |
FadeInDialog("dialogCreateRoom"); | |
$("#createRoomTitle").focus() | |
}); | |
$("#buttonOptions").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ToggleOptionsDialog() | |
}); | |
$("#buttonRoomsListDown").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
g_channel_skip_rooms < g_roomsList.length - 6 && (g_channel_skip_rooms += 6); | |
ChannelRoomsUpdate(g_roomsList) | |
}); | |
$("#buttonRoomsListUp").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
0 < g_channel_skip_rooms && (g_channel_skip_rooms -= 6); | |
ChannelRoomsUpdate(g_roomsList) | |
}); | |
$(".room").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
var a = $(this).children(".roomNumber").html(); | |
$(this).children(".roomLock").hasClass("roomLocked") ? ($("#join_room_input").val(a), FadeInDialog("dialog_join_room_div"), $("#join_password_input").val("").focus()) : SendRoomJoin(a) | |
}); | |
$("#buttonMyInfo").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
FadeInDialog("dialog_change_name_div") | |
}); | |
$("#buttonShop").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
SwitchToShopScreen() | |
}); | |
$("#buttonQuickJoin").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
SendQuickJoin() | |
}); | |
$("#dialog_change_name_cancel").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ExplodeDialog("dialog_change_name_div") | |
}); | |
$("#dialog_change_name_ok").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
SendChangeName($("#display_name").val(), $("#can_show_photo").is(":checked")); | |
ExplodeDialog("dialog_change_name_div") | |
}); | |
$("#dialog_join_room_cancel").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ExplodeDialog("dialog_join_room_div") | |
}); | |
$("#dialog_join_room_ok").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
SendRoomJoin($("#join_room_input").val(), $("#join_password_input").val()); | |
ExplodeDialog("dialog_join_room_div") | |
}); | |
$("#channelInput").bind("keyup", function (a) { | |
13 == a.which && "" != this.value && (a = this.value, this.value = "", ZotataPlayChat(a)) | |
}); | |
$("#buttonRanking").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
g_is_show_ranking = !g_is_show_ranking; | |
Resize(); | |
$("#buttonRanking").html(g_is_show_ranking ? "Ranking >>" : "<< Ranking") | |
}); | |
$("#event_button").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
SendEvent(0) | |
}); | |
$("#facebook_post").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
Facebook_PostToFeed() | |
}); | |
$("#buttonAllBuddyList").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
var a = $("#buttonAllBuddyList"); | |
a.hasClass("BuddyList") ? (a.removeClass("BuddyList"), $("#friendsList").hide()) : (a.addClass("BuddyList"), $("#friendsList").show().tinyscrollbar_update("top")) | |
}); | |
CreateRoomDialogGUI(); | |
OptionsDialogGUI() | |
} | |
function PrepareOptionsDialog() { | |
g_game ? ($("#OptionsLeave").show(), $("#OptionsOK").css("left", "175px"), $("#OptionsDialog").css({ | |
left: 2, | |
top: 267 | |
})) : g_game || ($("#OptionsLeave").hide(), $("#OptionsOK").css("left", "106px"), $("#OptionsDialog").css({ | |
left: 241, | |
top: 221 | |
})); | |
g_audio_is_music_on ? $("#OptionsMusic").removeClass("CheckboxOff").addClass("CheckboxOn") : $("#OptionsMusic").removeClass("CheckboxOn").addClass("CheckboxOff"); | |
g_audio_is_effects_on ? $("#OptionsEffects").removeClass("CheckboxOff").addClass("CheckboxOn") : $("#OptionsEffects").removeClass("CheckboxOn").addClass("CheckboxOff"); | |
g_graphics_high ? ($("#OptionsGraphicsHigh").removeClass("RadioOff").addClass("RadioOn"), $("#OptionsGraphicsLow").removeClass("RadioOn").addClass("RadioOff")) : ($("#OptionsGraphicsHigh").removeClass("RadioOn").addClass("RadioOff"), $("#OptionsGraphicsLow").removeClass("RadioOff").addClass("RadioOn")); | |
g_is_game_background ? ($("#OptionsBackgroundOn").removeClass("RadioOff").addClass("RadioOn"), $("#OptionsBackgroundOff").removeClass("RadioOn").addClass("RadioOff")) : ($("#OptionsBackgroundOn").removeClass("RadioOn").addClass("RadioOff"), $("#OptionsBackgroundOff").removeClass("RadioOff").addClass("RadioOn")); | |
g_is_game_slice ? ($("#OptionsShootingModeSlice").removeClass("RadioOff").addClass("RadioOn"), $("#OptionsShootingModeDrag").removeClass("RadioOn").addClass("RadioOff")) : ($("#OptionsShootingModeSlice").removeClass("RadioOn").addClass("RadioOff"), $("#OptionsShootingModeDrag").removeClass("RadioOff").addClass("RadioOn")) | |
} | |
function OptionsDialogGUI() { | |
$("#OptionsOK").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ExplodeDialog("OptionsDialog") | |
}); | |
$("#OptionsMusic").click(function () { | |
$("#OptionsMusic").hasClass("CheckboxOn") ? (AudioTurnMusicOff(), setCookie("music", 0)) : (AudioTurnMusicOn(), setCookie("music", 1)); | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
PrepareOptionsDialog() | |
}); | |
$("#OptionsEffects").click(function () { | |
$("#OptionsEffects").hasClass("CheckboxOn") ? (AudioTurnEffectsOff(), setCookie("effects", 0)) : (AudioTurnEffectsOn(), setCookie("effects", 1)); | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
PrepareOptionsDialog() | |
}); | |
$("#OptionsGraphicsHigh").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
g_graphics_high = !0; | |
PrepareOptionsDialog() | |
}); | |
$("#OptionsGraphicsLow").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
g_graphics_high = !1; | |
PrepareOptionsDialog() | |
}); | |
$("#OptionsBackgroundOn").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
g_is_game_background = !0; | |
PrepareOptionsDialog(); | |
$("#map_bg").show(); | |
setCookie("background", 1) | |
}); | |
$("#OptionsBackgroundOff").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
g_is_game_background = !1; | |
PrepareOptionsDialog(); | |
$("#map_bg").hide(); | |
setCookie("background", 0) | |
}); | |
$("#OptionsShootingModeSlice").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
g_is_game_slice = !0; | |
PrepareOptionsDialog(); | |
UpdateSliceDragGUI(); | |
setCookie("slice", 1) | |
}); | |
$("#OptionsShootingModeDrag").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
g_is_game_slice = !1; | |
PrepareOptionsDialog(); | |
UpdateSliceDragGUI(); | |
setCookie("slice", 0) | |
}); | |
$("#OptionsLeave").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ExplodeDialog("OptionsDialog"); | |
SendRoomLeave() | |
}); | |
$("#OptionsDialog").bind("touchstart click touchend", function (a) { | |
a.stopPropagation(); | |
return !1 | |
}) | |
} | |
function CreateRoomDialogPressedOK() { | |
var a, b = "", | |
c, d; | |
a = $("#createRoomTitle").val(); | |
$("#CreateRoomPrivateCheckbox").hasClass("checkboxOn") && (b = $("#createRoomPasswordInput").val()); | |
c = $("#CreateRoomPlayers"); | |
c = c.hasClass("players1v1") ? 2 : c.hasClass("players2v2") ? 4 : c.hasClass("players3v3") ? 6 : c.hasClass("players1vB") ? 1 : c.hasClass("players2vB") ? 2 : c.hasClass("players3vB") ? 3 : c.hasClass("players4vB") ? 4 : 8; | |
d = $("#CreateRoomMode").hasClass("gameModeNormal") ? GAME_MODE_NORMAL : GAME_MODE_BOSS; | |
SendRoomCreate(a, b, c, d) | |
} | |
function CreateRoomDialogGUI() { | |
$("#dialogCreateRoomButtonCancel").click(function () { | |
g_graphics_high ? $("#dialogCreateRoom").effect("explode") : $("#dialogCreateRoom").hide(); | |
AudioPlay(AUDIO_BUTTON_SELECT2) | |
}); | |
$("#dialogCreateRoomButtonOK").click(function () { | |
CreateRoomDialogPressedOK(); | |
AudioPlay(AUDIO_BUTTON_SELECT2) | |
}); | |
$("#CreateRoomPrivateCheckbox").click(function () { | |
var a = $("#CreateRoomPrivateCheckbox"); | |
a.hasClass("checkboxOff") ? (a.removeClass("checkboxOff").addClass("checkboxOn"), $("#CreateRoomPassword").show(), $("#createRoomPasswordInput").focus()) : (a.removeClass("checkboxOn").addClass("checkboxOff"), $("#CreateRoomPassword").hide()); | |
AudioPlay(AUDIO_BUTTON_SELECT2) | |
}); | |
$("#CreateRoomNumPlayersPrev").click(function () { | |
var a = $("#CreateRoomPlayers"), | |
b; | |
b = $("#CreateRoomMode").hasClass("gameModeNormal") ? a.hasClass("players1v1") ? "players4v4" : a.hasClass("players2v2") ? "players1v1" : a.hasClass("players3v3") ? "players2v2" : "players3v3" : a.hasClass("players1vB") ? "players4vB" : a.hasClass("players2vB") ? "players1vB" : a.hasClass("players3vB") ? "players2vB" : "players3vB"; | |
a.removeClass().addClass(b); | |
AudioPlay(AUDIO_BUTTON_SELECT2) | |
}); | |
$("#CreateRoomNumPlayersNext").click(function () { | |
var a = $("#CreateRoomPlayers"), | |
b; | |
b = $("#CreateRoomMode").hasClass("gameModeNormal") ? a.hasClass("players1v1") ? "players2v2" : a.hasClass("players2v2") ? "players3v3" : a.hasClass("players3v3") ? "players4v4" : "players1v1" : a.hasClass("players1vB") ? "players2vB" : a.hasClass("players2vB") ? "players3vB" : a.hasClass("players3vB") ? "players4vB" : "players1vB"; | |
a.removeClass().addClass(b); | |
AudioPlay(AUDIO_BUTTON_SELECT2) | |
}); | |
$("#CreateRoomModePrev, #CreateRoomModeNext").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
$("#CreateRoomMode").hasClass("gameModeNormal") ? CreateRoomChangeMode(GAME_MODE_BOSS) : CreateRoomChangeMode(GAME_MODE_NORMAL) | |
}) | |
} | |
function CreateRoomChangeMode(a) { | |
var b = $("#CreateRoomMode"), | |
c = $("#CreateRoomPlayers"), | |
d; | |
a == GAME_MODE_BOSS ? (a = "gameModeBoss", d = c.hasClass("players1v1") ? "players1vB" : c.hasClass("players2v2") ? "players2vB" : c.hasClass("players3v3") ? "players3vB" : "players4vB") : (a = "gameModeNormal", d = c.hasClass("players1vB") ? "players1v1" : c.hasClass("players2vB") ? "players2v2" : c.hasClass("players3vB") ? "players3v3" : "players4v4"); | |
b.removeClass().addClass(a); | |
c.removeClass().addClass(d); | |
$("#CreateRoomModeIcon").removeClass().addClass("iconMode" + a.slice(8)); | |
"gameModeNormal" == a && 1 > g_myPlayerInfo.unlock ? ($("#dialogCreateLocked").show(), $("#dialogCreateMessage").html("This mode is locked until you win at BOSS mode as room master."), $("#dialogCreateRoomButtonOK").hide()) : ($("#dialogCreateLocked").hide(), $("#dialogCreateMessage").html(""), $("#dialogCreateRoomButtonOK").show()) | |
} | |
function ShopGUI() { | |
$("#shop_my_items_container").tinyscrollbar({ | |
size: 237 | |
}); | |
$("#buttonShopExit").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopClose() | |
}); | |
$("#shop_item0").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSelectItem(0) | |
}); | |
$("#shop_item1").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSelectItem(1) | |
}); | |
$("#shop_item2").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSelectItem(2) | |
}); | |
$("#shop_item3").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSelectItem(3) | |
}); | |
$("#shop_item4").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSelectItem(4) | |
}); | |
$("#shop_item5").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSelectItem(5) | |
}); | |
$("#shop_item6").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSelectItem(6) | |
}); | |
$("#shop_item7").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSelectItem(7) | |
}); | |
$("#shop_item8").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSelectItem(8) | |
}); | |
$("#buttonShopTry").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopTry() | |
}); | |
$("#buttonShopBuy").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopBuy() | |
}); | |
$("#buy_cancel_btn").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopBuyCloseDialog() | |
}); | |
$("#buy_period_next_btn").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSetPeriod((ShopGetPeriod() + 1) % 3) | |
}); | |
$("#buy_period_prev_btn").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSetPeriod((ShopGetPeriod() + 2) % 3) | |
}); | |
$("#buy_gold_btn").click(function () { | |
$(this).hasClass("active") && (AudioPlay(AUDIO_BUTTON_SELECT2), ShopDoPurchase(!1)) | |
}); | |
$("#buy_cash_btn").click(function () { | |
$(this).hasClass("active") && (AudioPlay(AUDIO_BUTTON_SELECT2), ShopDoPurchase(!0)) | |
}); | |
$("#buttonShopHead").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSetPage(AVATAR_TYPE_HEAD, 0) | |
}); | |
$("#buttonShopBody").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSetPage(AVATAR_TYPE_BODY, 0) | |
}); | |
$("#buttonShopEyes").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSetPage(AVATAR_TYPE_EYES, 0) | |
}); | |
$("#buttonShopFlag").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSetPage(AVATAR_TYPE_FLAG, 0) | |
}); | |
$("#buttonShopNext").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSetPage(g_current_shop_type, g_current_shop_page + 1) | |
}); | |
$("#buttonShopPrev").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ShopSetPage(g_current_shop_type, g_current_shop_page - 1) | |
}) | |
} | |
function GameGUI() { | |
$("#gameChat").tinyscrollbar({ | |
size: 99 | |
}); | |
$("#btnShot1").click(function () { | |
SelectShotType(0); | |
AudioPlay(AUDIO_BUTTON_SELECT2) | |
}); | |
$("#btnShot2").click(function () { | |
SelectShotType(1); | |
AudioPlay(AUDIO_BUTTON_SELECT2) | |
}); | |
$("#btnShotSS").click(function () { | |
SelectShotType(2); | |
AudioPlay(AUDIO_BUTTON_SELECT2) | |
}); | |
$("#btnPass").click(function () { | |
g_game && g_game.PassTurnClicked(); | |
AudioPlay(AUDIO_BUTTON_SELECT2) | |
}); | |
$("#btnEsc").click(function () { | |
ToggleOptionsDialog(); | |
AudioPlay(AUDIO_BUTTON_SELECT2) | |
}); | |
$("#gameItemSlot0").click(function () { | |
g_game && g_game.UseItem(0) | |
}); | |
$("#gameItemSlot1").click(function () { | |
g_game && g_game.UseItem(1) | |
}); | |
$("#gameItemSlot2").click(function () { | |
g_game && g_game.UseItem(2) | |
}); | |
$("#gameItemSlot3").click(function () { | |
g_game && g_game.UseItem(3) | |
}); | |
$("#gameItemSlot4").click(function () { | |
g_game && g_game.UseItem(4) | |
}); | |
$("#gameItemSlot5").click(function () { | |
g_game && g_game.UseItem(5) | |
}); | |
$("#slice_drag_button").click(function () { | |
g_is_game_slice = !g_is_game_slice; | |
UpdateSliceDragGUI() | |
}); | |
UpdateSliceDragGUI(); | |
$("#gameInput").bind("keyup", function (a) { | |
if (13 == a.which) { | |
if ("" != this.value) { | |
var c = this.value; | |
this.value = ""; | |
ZotataPlayChat(c) | |
} | |
$("#gameInput").blur(); | |
a.stopPropagation() | |
} | |
}); | |
var a; | |
$("#powerMarkArea").bind("mousedown", function (b) { | |
a = !0; | |
b = b.offsetX; | |
$("#powerMark").css("left", b + 1) | |
}).bind("mouseup", function () { | |
a = !1 | |
}).bind("mousemove", function (b) { | |
a && 3 != b.eventPhase && (b = b.offsetX, 0 > b ? b = 0 : 400 < b && (b = 400), $("#powerMark").css("left", b + 1)) | |
}) | |
} | |
function SelectShotType(a) { | |
2 == a && !$("#btnShotSS").is(":visible") && (a = 0); | |
switch (a) { | |
case 0: | |
$("#btnShot2, #btnShotSS").removeClass("Pressed"); | |
$("#btnShot1").addClass("Pressed"); | |
break; | |
case 1: | |
$("#btnShot1, #btnShotSS").removeClass("Pressed"); | |
$("#btnShot2").addClass("Pressed"); | |
break; | |
case 2: | |
$("#btnShot1, #btnShot2").removeClass("Pressed"), $("#btnShotSS").addClass("Pressed") | |
} | |
g_game && g_game.ChangedShot(a) | |
} | |
function GetSelectedShotType() { | |
var a = 0; | |
$("#btnShot2").hasClass("Pressed") ? a = 1 : $("#btnShotSS").hasClass("Pressed") && (a = 2); | |
return a | |
} | |
function SetReplyTo(a) { | |
var b = g_myPlayerInfo.location_type == LOCATION_TYPE_CHANNEL ? "#channelInput" : g_game ? "#gameInput" : "#roomInput", | |
c = $(b).val(); | |
$(b).focus(); | |
$(b).val("@" + a + ": " + c) | |
} | |
function AddToChatInput(a) { | |
if ("" != a) { | |
var b = g_myPlayerInfo.location_type == LOCATION_TYPE_CHANNEL ? "#channelInput" : g_game ? "#gameInput" : "#roomInput", | |
c = $(b).val(); | |
$(b).focus(); | |
$(b).val(c + a) | |
} | |
} | |
function ChatReceived(a, b, c) { | |
var d = "", | |
e = "", | |
f = "", | |
h = "", | |
g = ""; | |
void 0 == g_myPlayerInfo || void 0 == g_myPlayerInfo.location_type || g_myPlayerInfo.location_type == LOCATION_TYPE_CHANNEL ? (e = "#channelTextHtml", d = "#channel") : g_game ? (e = "#gameChatHtml", d = "#gameChat", f = ".GamePlayerBalloon", h = ".GamePlayerBalloonTip", g = ".PlayerName") : (e = "#roomChatHtml", d = "#roomChat", f = ".roomPlayerBalloon", h = ".roomPlayerBalloonTip", g = ".roomPlayerName"); | |
d && ($(e).append('<div class="zotata-chat-line zotata-chat-type' + c + '" >' + (0 != c ? '<div class="zotata-chat-icon zotata-chat-icon' + c + '"></div> ' : " ") + ("" != a ? a + "] " : "") + b + "</div>"), $(d).tinyscrollbar_update("bottom")); | |
"" != f && "" != a && $(g).each(function () { | |
if ($(this).text() == a) { | |
var c = $(this).parents().children(f), | |
d = $(this).parents().children(h); | |
d.stop(true, true).fadeOut("slow"); | |
c.stop(true, true).hide("slow").promise().done(function () { | |
c.html(b).show("slow").animate({ | |
opacity: 0.9 | |
}, 5E3).fadeOut(2E3); | |
d.fadeIn("slow").animate({ | |
opacity: 0.9 | |
}, 5E3).fadeOut(2E3) | |
}) | |
} | |
}) | |
} | |
function ChannelChatClear() { | |
$("#channelTextHtml").html(""); | |
$("#channel").tinyscrollbar_update("bottom") | |
} | |
var PLAYER_INDEX_USER_ID = 0, | |
PLAYER_INDEX_GAME_ID = 1, | |
PLAYER_INDEX_RANK = 2, | |
PLAYER_INDEX_TEAM = 3, | |
PLAYER_INDEX_IS_MASTER = 4, | |
PLAYER_INDEX_IS_READY = 5, | |
PLAYER_INDEX_GENDER = 6, | |
PLAYER_INDEX_MOBILE = 7, | |
PLAYER_INDEX_AVATARS = 8, | |
PLAYER_INDEX_IS_BOT = 9; | |
function ChannelUpdatePlayersList(a) { | |
for (var b = "", c = 0; c < a.length; c++) b += '<div class="playerListItem" id="player_user_id_' + a[c][PLAYER_INDEX_USER_ID] + '" user_id=' + a[c][PLAYER_INDEX_USER_ID] + '><div class="playerListRank rank rank' + a[c][PLAYER_INDEX_RANK] + '"></div><div class="playerListName blackShadow">' + a[c][PLAYER_INDEX_GAME_ID] + "</div></div>"; | |
$("#channelPlayersListHtml").html(b); | |
$("#playersList").tinyscrollbar_update("top") | |
} | |
function ChannelPlayerJoined(a, b, c) { | |
ChannelPlayerLeft(a); | |
$("#channelPlayersListHtml").append('<div class="playerListItem" id="player_user_id_' + a + '" user_id=' + a + '><div class="playerListRank rank rank' + c + '"></div><div class="playerListName blackShadow">' + b + "</div></div>"); | |
$("#playersList").tinyscrollbar_update("relative") | |
} | |
function ChannelPlayerLeft(a) { | |
$("#player_user_id_" + a).remove(); | |
$("#playersList").tinyscrollbar_update("relative") | |
} | |
var FRIEND_INDEX_ID = 0, | |
FRIEND_INDEX_NAME = 1, | |
FRIEND_INDEX_GENDER = 2, | |
FRIEND_INDEX_RANK = 3, | |
FRIEND_INDEX_GP = 4, | |
FRIEND_INDEX_IMAGE = 5, | |
FRIEND_INDEX_SERVER = 6, | |
FRIEND_INDEX_ROOM = 7; | |
function UpdateFriendsList(a) { | |
for (var b = "", c = 0; c < a.length; c++) { | |
var d = a[c], | |
e = d[FRIEND_INDEX_IMAGE], | |
e = "" == e ? d[FRIEND_INDEX_GENDER] == GENDER_FEMALE ? "/static/images/fb_girl.gif" : "/static/images/fb_boy.gif" : "http://graph.facebook.com/" + e + "/picture?type=large", | |
f = "Offline"; | |
0 != d[FRIEND_INDEX_SERVER] && (f = 0 == d[FRIEND_INDEX_ROOM] ? "In Channel" : "In Room: " + d[FRIEND_INDEX_ROOM]); | |
b += '<div id="friend_' + d[FRIEND_INDEX_ID] + '" friend="' + d[FRIEND_INDEX_ID] + '" class="friendListItem' + (1 == c % 2 ? " odd" : "") + '"> <div class="friendListPhoto"><img class="friendListPhotoImg" src="' + e + '"></div> <div class="friendListRank rank rank' + d[FRIEND_INDEX_RANK] + '"></div> <div class="friendListName blackShadow">' + d[FRIEND_INDEX_NAME] + '</div> <div class="friendListGP blackShadow">GP ' + d[FRIEND_INDEX_GP] + '</div> <div class="friendListLocation blackShadow">' + f + "</div> </div>" | |
} | |
$("#friendsListHtml").html(b); | |
$(".friendListItem").bind("click", function () { | |
$(".friendListItem").removeClass("selected"); | |
$(this).addClass("selected"); | |
ChatDialogCreate($(this).attr("friend"), $(this).children(".friendListName").html()) | |
}); | |
$("#friendsList").tinyscrollbar_update("top"); | |
UpdateFriendsInRooms() | |
} | |
function UpdateFriendsInRooms() { | |
var a = []; | |
$(".friendListLocation").each(function () { | |
var b = $(this).html(); - 1 != b.indexOf("In Room: ") && (b = Number(b.substr(9)), a.push(b)) | |
}); | |
$("#roomsList > .room").each(function () { | |
var b = $(this), | |
c = Number(b.children(".roomNumber").html()); | |
0 < c && (-1 != a.indexOf(c) ? b.children(".roomBuddy").show() : b.children(".roomBuddy").hide()) | |
}) | |
} | |
function FriendUpdate(a) { | |
var b = "Offline"; | |
0 != a[3] && (b = 0 == a[4] ? "In Channel" : "In Room: " + a[4]); | |
var c = $("#friend_" + a[0]); | |
c.children(".friendListRank").removeClass().addClass("friendListRank rank rank" + a[1]); | |
c.children(".friendListGP").html("GP " + a[2]); | |
c.children(".friendListLocation").html(b); | |
UpdateFriendsInRooms() | |
} | |
function ChatDialogCreate(a, b) { | |
if (0 == $("#chat_" + a).length) { | |
$("#chat_divs").append('<div class="ChatDialog" id="chat_' + a + '" friend=' + a + '><div class="chatDialogName blackShadow">' + b + '</div><div class="chatDialogDelete opacity_button"></div><div class="chatDialogClose opacity_button"></div><input type="text" class="chatDialogInput" value="" maxlength="150"><div class="chatDialogText"><div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div></div></div></div><div class="viewport"><div class="CanSelect overview chatDialogTextHtml"></div></div></div></div>'); | |
var c = $("#chat_" + a); | |
c.draggable2(); | |
c.bind("mousedown", function (a) { | |
a.stopPropagation() | |
}); | |
c.children(".chatDialogText").tinyscrollbar({ | |
size: 183 | |
}); | |
c.children(".chatDialogInput").bind("keyup", function (a) { | |
13 == a.which && (a.stopPropagation(), a = $(this).val(), "" != a && (SendPrivateChat($(this).parent().attr("friend"), a), $(this).val(""))) | |
}); | |
c.children(".chatDialogClose").click(function (a) { | |
$(this).parent().remove(); | |
a.stopPropagation() | |
}); | |
c.children(".chatDialogDelete").click(function (a) { | |
a.stopPropagation(); | |
var b = $(this).parent().attr("friend"); | |
OpenDialog("Delete Friend?", "Are you sure to delete this friend?", DIALOG_BUTTONS_OK_CANCEL, function (a) { | |
a && SendDeleteFriend(b) | |
}) | |
}) | |
} | |
} | |
function FriendPrivateChat(a, b, c) { | |
var d = $("#chat_" + a); | |
0 == d.length && (ChatDialogCreate(a, b), d = $("#chat_" + a)); | |
d.find(".chatDialogTextHtml").append("[" + b + "] " + c + "<br>"); | |
d.children(".chatDialogText").tinyscrollbar_update("bottom") | |
} | |
function pad(a, b) { | |
for (var c = "" + a; c.length < b;) c = "0" + c; | |
return c | |
} | |
function ChannelPlayerInfoUpdate() { | |
$("#myName").html(g_myPlayerInfo.game_id); | |
$("#myRank").removeClass().addClass("rank rank" + g_myPlayerInfo.rank); | |
$("#myGP").html(Commatize(g_myPlayerInfo.gp)); | |
$("#myCash").html(Commatize(g_myPlayerInfo.cash)); | |
$("#myGold").html(Commatize(g_myPlayerInfo.gold)); | |
var a = g_myPlayerInfo.fb, | |
a = "" == a ? g_myPlayerInfo.gender == GENDER_FEMALE ? "/static/images/fb_girl.gif" : "/static/images/fb_boy.gif" : "http://graph.facebook.com/" + a + "/picture?type=large"; | |
$("#myPhotoImage").attr("src", a); | |
g_channel_player ? (g_channel_player.change(g_myPlayerInfo.head, AVATAR_TYPE_HEAD), g_channel_player.change(g_myPlayerInfo.body, AVATAR_TYPE_BODY), g_channel_player.change(g_myPlayerInfo.eyes, AVATAR_TYPE_EYES), g_channel_player.change(g_myPlayerInfo.flag, AVATAR_TYPE_FLAG)) : g_channel_player = new CPlayerGraphic("#channel_player", - 1, g_myPlayerInfo.head, g_myPlayerInfo.body, g_myPlayerInfo.eyes, g_myPlayerInfo.flag, !1); | |
0 < g_myPlayerInfo.event1 ? $("#event_button").html("Free Cash Event<br><br>" + pad(Math.floor(g_myPlayerInfo.event1 / 60), 2) + ":" + pad(g_myPlayerInfo.event1 % 60, 2)) : $("#event_button").html('Free Cash Event<span style="font-size:8px;"><br><br>+?? Cash<br>+?? Gold</span>'); | |
0 < g_myPlayerInfo.event2 ? $("#facebook_post").html("Post to Facebook<br><br>" + pad(Math.floor(g_myPlayerInfo.event2 / 60), 2) + ":" + pad(g_myPlayerInfo.event2 % 60, 2)) : $("#facebook_post").html('Post to Facebook<span style="font-size:7px;"><br><br>+1000 Cash<br>+5000 Gold</span>') | |
} | |
function ChannelRoomsUpdate(a) { | |
6 <= g_channel_skip_rooms && a.length <= g_channel_skip_rooms && (g_channel_skip_rooms -= 6); | |
$("#roomsList > .room").each(function (b) { | |
var c = $(this), | |
d = a[b + g_channel_skip_rooms]; | |
if (d) { | |
var b = d[0], | |
e = d[1], | |
f = d[2], | |
h = d[3], | |
g = d[4], | |
j = d[5], | |
i = d[6], | |
d = d[7]; | |
c.children(".roomNumber").html(b); | |
ChannelRoomChangeDetails(c, e, f, h, g, j, i, d); | |
c.show() | |
} else c.hide() | |
}); | |
g_roomsList = a; | |
UpdateFriendsInRooms() | |
} | |
function ChannelRoomUpdate(a) { | |
var b = a[0], | |
c = a[1], | |
d = a[2], | |
e = a[3], | |
f = a[4], | |
h = a[5], | |
g = a[6], | |
j = a[7]; | |
$("#roomsList > .room").each(function () { | |
var a = $(this); | |
a.children(".roomNumber").html() == b && ChannelRoomChangeDetails(a, c, d, e, f, h, g, j) | |
}) | |
} | |
function ChannelRoomChangeDetails(a, b, c, d, e, f, h, g) { | |
a.children(".roomTitle").html(b); | |
a.children(".numPlayers").html(c); | |
a.children(".maxPlayers").html(d); | |
b = ""; | |
e == ROOM_STATUS_WAITING ? b = "status-waiting" : e == ROOM_STATUS_FULL ? b = "status-full" : e == ROOM_STATUS_PLAYING && (b = "status-playing"); | |
a.children(".status").removeClass().addClass("status " + b); | |
e = ""; | |
f == GAME_MODE_NORMAL ? e = "iconModeNormal" : f == GAME_MODE_BOSS && (e = "iconModeBoss"); | |
a.children(".gameMode").removeClass().addClass("gameMode " + e); | |
h ? a.children(".roomLock").addClass("roomLocked") : a.children(".roomLock").removeClass("roomLocked"); | |
a.children(".roomMap").removeClass().addClass("roomMap roomMap" + g) | |
} | |
function GuiCloseChannelScreen() { | |
$("#dialogCreateRoom").fadeOut(g_graphics_high ? "slow" : 0); | |
$("#OptionsDialog").hide(); | |
$("#channelScreen").fadeOut(g_graphics_high ? "slow" : 0, function () { | |
g_channel_player && (g_channel_player.remove(), g_channel_player = void 0) | |
}); | |
$("#buttonAllBuddyList").removeClass("BuddyList") | |
} | |
function GuiCloseRoomScreen() { | |
$("#roomScreen").fadeOut(g_graphics_high ? "slow" : 0, function () { | |
$("#roomButtonReady").hide(); | |
$("#roomButtonStart").hide(); | |
$("#roomChatHtml").html(""); | |
$("#roomChat .scrollbar").hide(); | |
$(".roomPlayerBalloon").hide(); | |
$(".roomPlayerBalloonTip").hide(); | |
$("#playerInfoDialog").hide(); | |
$("#friendsListExtra").hide(); | |
$("#dialog_room_options").hide(); | |
RoomRemoveAnimations() | |
}); | |
$("#room_item_buddy_tab").removeClass("buddy") | |
} | |
function GuiCloseGameScreen() { | |
$("#OptionsDialog").hide(); | |
$("#gameScreen").fadeOut(g_graphics_high ? "slow" : 0, function () { | |
g_game && (g_game.Destructor(), g_game = void 0) | |
}) | |
} | |
function GuiCloseShopScreen() { | |
$("#shopScreen").fadeOut(g_graphics_high ? "slow" : 0, function () { | |
g_shop_player.remove(); | |
g_shop_player = void 0 | |
}) | |
} | |
function GuiCloseCurrentScreen() { | |
g_gui_location == GUI_LOCATION_CHANNEL ? GuiCloseChannelScreen() : g_gui_location == GUI_LOCATION_ROOM ? GuiCloseRoomScreen() : g_gui_location == GUI_LOCATION_GAME ? GuiCloseGameScreen() : g_gui_location == GUI_LOCATION_SHOP && GuiCloseShopScreen(); | |
$("#friendsList").hide() | |
} | |
function SwitchToChannelScreen() { | |
g_gui_location != GUI_LOCATION_CHANNEL && $("#channelScreen, #roomScreen, #gameScreen, #shopScreen").promise().done(function () { | |
GuiCloseCurrentScreen(); | |
$("#channelScreen, #roomScreen, #gameScreen, #shopScreen").promise().done(function () { | |
g_gui_location = GUI_LOCATION_CHANNEL; | |
$("#channelInput").val(""); | |
$("#channelScreen").fadeIn(g_graphics_high ? 400 : 0); | |
$("#channel").tinyscrollbar_update("bottom"); | |
ChannelPlayerInfoUpdate(); | |
AudioPlayInLoop(AUDIO_MUSIC_CHANNEL, !0); | |
$("#playersList").tinyscrollbar_update("top") | |
}) | |
}) | |
} | |
function SwitchToRoomScreen() { | |
g_gui_location != GUI_LOCATION_ROOM && $("#channelScreen, #roomScreen, #gameScreen, #shopScreen").promise().done(function () { | |
GuiCloseCurrentScreen(); | |
$("#channelScreen, #roomScreen, #gameScreen, #shopScreen").promise().done(function () { | |
g_gui_location = GUI_LOCATION_ROOM; | |
$("#roomInput").val(""); | |
$("#room_timer").hide(); | |
$("#select_bot_div").hide(); | |
g_room_players && RoomUpdatePlayers(g_room_players); | |
AutoReadyStartTimer(); | |
$("#roomsList > .room").each(function () { | |
$(this).hide() | |
}); | |
$("#playerInfoDialog").hide(); | |
$("#roomScreen").fadeIn(g_graphics_high ? 400 : 0); | |
AudioPlayInLoop(AUDIO_MUSIC_ROOM, !0) | |
}) | |
}) | |
} | |
function SwitchToGameScreen() { | |
g_gui_location != GUI_LOCATION_GAME && $("#channelScreen, #roomScreen, #gameScreen, #shopScreen").promise().done(function () { | |
GuiCloseCurrentScreen(); | |
$("#channelScreen, #roomScreen, #gameScreen, #shopScreen").promise().done(function () { | |
g_gui_location = GUI_LOCATION_GAME; | |
$("#gameScreen").fadeIn(g_graphics_high ? 400 : 0); | |
AudioPlayInLoop(AUDIO_MUSIC_STAGE1, !0) | |
}) | |
}) | |
} | |
function SwitchToShopScreen() { | |
g_gui_location != GUI_LOCATION_SHOP && $("#channelScreen, #roomScreen, #gameScreen, #shopScreen").promise().done(function () { | |
GuiCloseCurrentScreen(); | |
g_gui_location = GUI_LOCATION_SHOP; | |
$("#channelScreen, #roomScreen, #gameScreen, #shopScreen").promise().done(function () { | |
$("#shopScreen").fadeIn(g_graphics_high ? 400 : 0); | |
ShopSetPage(AVATAR_TYPE_HEAD, 0); | |
ShopSetMyItems(); | |
g_shop_player || (g_shop_player = new CPlayerGraphic("#shop_player", - 1, g_myPlayerInfo.head, g_myPlayerInfo.body, g_myPlayerInfo.eyes, g_myPlayerInfo.flag, !0)); | |
ShopUpdateMyStats() | |
}) | |
}) | |
} | |
function Commatize(a) { | |
return a.toString().replace(/(\d)(?=(\d{3})+$)/g, "$1,") | |
} | |
function ShopSetMyItems() { | |
SendGetMyAvatars() | |
} | |
function ShopSetMyItems2(a) { | |
var b = "", | |
c = "pop time atk def life item dig shld".split(" "), | |
d = [AVATAR_INDEX_STAT_POP, AVATAR_INDEX_STAT_TIME, AVATAR_INDEX_STAT_ATK, AVATAR_INDEX_STAT_DEF, AVATAR_INDEX_STAT_LIFE, AVATAR_INDEX_STAT_ITEM, AVATAR_INDEX_STAT_DIG, AVATAR_INDEX_STAT_SHLD]; | |
ShopWearEquippedItems(); | |
for (var e = 0; e < a.length; e++) { | |
var f = a[e], | |
h = f[0], | |
g = f[1], | |
j = f[2], | |
i = f[3], | |
k = AVATARS[g]; | |
if (void 0 == k) deubg && console.log("*** ERROR: Unknown avatar:", f); | |
else { | |
var f = k[AVATAR_INDEX_TYPE], | |
l = k[AVATAR_INDEX_GENDER], | |
m = k[AVATAR_INDEX_NAME], | |
n = void 0; | |
if (i) if (i = new Date(i) - new Date, i >= MS_IN_1_DAY) n = Math.floor(i / MS_IN_1_DAY) + 1 + " Days"; | |
else if (0 < i) n = Math.floor(i / MS_IN_1_HOUR) + 1 + " Hours"; | |
else continue; | |
b += '<div id="shop_my_item' + e + '" class="shop_my_item" onmousedown="ShopSelectMyItem(' + e + ')" avatar_id="' + h + '" avatar_number="' + g + '" avatar_type="' + f + '"><div class="shop_my_item_icon shop_item_icon_' + f + l + '"></div><div class="shop_my_item_name">' + m + (n ? " (" + n + ")" : "") + '</div><div class="shop_my_item_equip' + (j ? " equipped" : "") + ' "></div>'; | |
for (i = h = 0; i < c.length; i++) f = d[i], l = c[i], k[f] && (b += '<div class="shop_my_item_stat shop_my_item_stat' + h + '"> <div class="stat_icon stat_icon_' + (0 < k[f] ? l : l + "-") + '"></div> <div class="stat_digit1 stat_font stat_font' + Math.floor(Math.abs(k[f] / 10)) + '"></div> <div class="stat_digit2 stat_font stat_font' + Math.abs(k[f] % 10) + '"></div> </div>', h++); | |
b += "</div>"; | |
j && g_shop_player.change(g) | |
} | |
} | |
$("#shop_my_items").html(b); | |
$("#shop_my_items_container").tinyscrollbar_update(); | |
a = a.length.toString().split(""); | |
for (b = 0; 4 > b; b++) $("#shop_my_items_number .digit" + b).removeClass().addClass("digit" + b + (b < a.length ? " stat_font stat_font" + a[b] : "")); | |
ShopUpdateMyStats() | |
} | |
function ShopSetMyGoldCash(a, b) { | |
$("#shop_my_cash").html(Commatize(b) + " Cash"); | |
$("#shop_my_gold").html(Commatize(a) + " Gold") | |
} | |
function ShopSelectMyItem(a) { | |
if ($("#shop_my_item" + a).hasClass("selected")) { | |
$("#shop_my_item" + a).attr("avatar_id"); | |
$("#shop_my_item" + a).attr("avatar_number"); | |
var b = $("#shop_my_item" + a).attr("avatar_type"); | |
$("#shop_my_item" + a + " .shop_my_item_equip").hasClass("equipped") ? $("#shop_my_item" + a + " .shop_my_item_equip").removeClass("equipped") : ($(".shop_my_item_equip.equipped").each(function () { | |
$(this).parent().attr("avatar_type") == b && $(this).removeClass("equipped") | |
}), $("#shop_my_item" + a + " .shop_my_item_equip").addClass("equipped")); | |
ShopWearEquippedItems() | |
} else $(".shop_my_item").removeClass("selected"), $(".shop_my_item .shop_my_item_name").removeClass("blackShadow"), $("#shop_my_item" + a).addClass("selected"), $("#shop_my_item" + a + " .shop_my_item_name").addClass("blackShadow") | |
} | |
function ShopSetPage(a, b) { | |
var c = [], | |
d; | |
for (d = 0; d < AVATARS.length; d++) AVATARS[d] && (AVATARS[d][AVATAR_INDEX_SHOP] && AVATARS[d][AVATAR_INDEX_TYPE] == a && (AVATARS[d][AVATAR_INDEX_GENDER] == g_myPlayerInfo.gender || a == AVATAR_TYPE_FLAG)) && c.push(d); | |
d = Math.floor((c.length + 9 - 1) / 9); | |
0 == d ? b = 0 : (0 > b && (b += d), b %= d); | |
c = c.slice(9 * b, 9 * (b + 1)); | |
g_current_shop_type = a; | |
g_current_shop_page = b; | |
var e = "pop time atk def life item dig shld".split(" "), | |
f = [AVATAR_INDEX_STAT_POP, AVATAR_INDEX_STAT_TIME, AVATAR_INDEX_STAT_ATK, AVATAR_INDEX_STAT_DEF, AVATAR_INDEX_STAT_LIFE, AVATAR_INDEX_STAT_ITEM, AVATAR_INDEX_STAT_DIG, AVATAR_INDEX_STAT_SHLD]; | |
for (d = 0; d < c.length; d++) { | |
var h = c[d], | |
g = AVATARS[h], | |
j = g[AVATAR_INDEX_TYPE], | |
i = g[AVATAR_INDEX_GENDER], | |
k = "/static/images/avatars/large/s" + i + j + (g[AVATAR_INDEX_N] + 1E5).toString().substring(1) + ".png"; | |
$("#shop_item" + d + " .shop_item_icon").removeClass().addClass("shop_item_icon shop_item_icon_" + j + i); | |
$("#shop_item" + d + " .shop_item_name").html(g[AVATAR_INDEX_NAME]); | |
$("#shop_item" + d + " .shop_item_image img").attr("src", k); | |
j = g[AVATAR_INDEX_GOLD_WEEK] ? g[AVATAR_INDEX_GOLD_WEEK] : g[AVATAR_INDEX_GOLD_MONTH] ? g[AVATAR_INDEX_GOLD_MONTH] : g[AVATAR_INDEX_GOLD_PERM] ? g[AVATAR_INDEX_GOLD_PERM] : 0; | |
i = g[AVATAR_INDEX_CASH_WEEK] ? g[AVATAR_INDEX_CASH_WEEK] : g[AVATAR_INDEX_CASH_MONTH] ? g[AVATAR_INDEX_CASH_MONTH] : g[AVATAR_INDEX_CASH_PERM] ? g[AVATAR_INDEX_CASH_PERM] : 0; | |
$("#shop_item" + d + " .shop_item_cash").html(i ? Commatize(i) + " Cash" : "Gold Only"); | |
$("#shop_item" + d + " .shop_item_gold").html(j ? Commatize(j) + " Gold" : "Cash Only"); | |
$("#shop_item" + d).show(); | |
$("#shop_item" + d).attr("avatar_index", h); | |
for (j = h = 0; j < e.length; j++) i = f[j], k = e[j], g[i] && ($("#shop_item" + d + " .shop_item_stat" + h + " .stat_icon").removeClass().addClass("stat_icon stat_icon_" + (0 < g[i] ? k : k + "-")).show(), $("#shop_item" + d + " .shop_item_stat" + h + " .stat_digit1").removeClass().addClass("stat_digit1 stat_font stat_font" + Math.floor(Math.abs(g[i] / 10))).show(), $("#shop_item" + d + " .shop_item_stat" + h + " .stat_digit2").removeClass().addClass("stat_digit2 stat_font stat_font" + Math.abs(g[i] % 10)).show(), h++); | |
for (; 8 > h; h++) $("#shop_item" + d + " .shop_item_stat" + h + " .stat_icon").hide(), $("#shop_item" + d + " .shop_item_stat" + h + " .stat_digit1").hide(), $("#shop_item" + d + " .shop_item_stat" + h + " .stat_digit2").hide() | |
} | |
for (; 9 > d; d++) $("#shop_item" + d).hide(); | |
c = ShopGetSelected(); | |
$("#shop_item" + c).removeClass("selected") | |
} | |
function ShopWearEquippedItems() { | |
var a = !0, | |
b = !0; | |
$(".shop_my_item_equip.equipped").parent().each(function () { | |
g_shop_player.change($(this).attr("avatar_number")); | |
$(this).attr("avatar_type") == AVATAR_TYPE_HEAD ? a = !1 : $(this).attr("avatar_type") == AVATAR_TYPE_BODY && (b = !1) | |
}); | |
a && g_shop_player.change(g_myPlayerInfo.gender == GENDER_MALE ? AVATAR_NAKED_HEAD_MALE : AVATAR_NAKED_HEAD_FEMALE); | |
b && g_shop_player.change(g_myPlayerInfo.gender == GENDER_MALE ? AVATAR_NAKED_BODY_MALE : AVATAR_NAKED_BODY_FEMALE); | |
ShopUpdateMyStats() | |
} | |
function ShopSelectItem(a) { | |
var b = ShopGetSelected(); | |
b == a ? ($("#shop_item" + b).removeClass("selected"), ShopWearEquippedItems()) : ($("#shop_item" + b).removeClass("selected"), $("#shop_item" + a).addClass("selected"), ShopTry()) | |
} | |
function ShopGetSelected() { | |
for (var a = 0; 9 > a; a++) if ($("#shop_item" + a).hasClass("selected")) return a | |
} | |
function ShopTry() { | |
var a = ShopGetSelected(); | |
void 0 != a && (a = $("#shop_item" + a).attr("avatar_index"), g_shop_player.change(a), ShopUpdateMyStats()) | |
} | |
function ShopBuy() { | |
var a = ShopGetSelected(); | |
if (void 0 != a) { | |
var a = $("#shop_item" + a).attr("avatar_index"), | |
b = AVATARS[a], | |
c = b[AVATAR_INDEX_TYPE], | |
d = b[AVATAR_INDEX_GENDER], | |
e = b[AVATAR_INDEX_NAME], | |
f = "/static/images/avatars/large/s" + d + c + (b[AVATAR_INDEX_N] + 1E5).toString().substring(1) + ".png"; | |
$("#shop_buy_dialog .shop_item_icon").removeClass().addClass("shop_item_icon shop_item_icon_" + c + d); | |
$("#shop_buy_dialog .shop_item_name").html(e); | |
$("#shop_buy_dialog .shop_item_image img").attr("src", f); | |
$("#buy_cash_week").html(0 < b[AVATAR_INDEX_CASH_WEEK] ? Commatize(b[AVATAR_INDEX_CASH_WEEK]) : "Can't buy"); | |
$("#buy_cash_month").html(0 < b[AVATAR_INDEX_CASH_MONTH] ? Commatize(b[AVATAR_INDEX_CASH_MONTH]) : "Can't buy"); | |
$("#buy_cash_perm").html(0 < b[AVATAR_INDEX_CASH_PERM] ? Commatize(b[AVATAR_INDEX_CASH_PERM]) : "Can't buy"); | |
$("#buy_gold_week").html(0 < b[AVATAR_INDEX_GOLD_WEEK] ? Commatize(b[AVATAR_INDEX_GOLD_WEEK]) : "Can't buy"); | |
$("#buy_gold_month").html(0 < b[AVATAR_INDEX_GOLD_MONTH] ? Commatize(b[AVATAR_INDEX_GOLD_MONTH]) : "Can't buy"); | |
$("#buy_gold_perm").html(0 < b[AVATAR_INDEX_GOLD_PERM] ? Commatize(b[AVATAR_INDEX_GOLD_PERM]) : "Can't buy"); | |
g_current_buy_avatar_index = a; | |
ShopSetPeriod(0); | |
g_graphics_high ? $("#shop_buy_dialog").fadeIn() : $("#shop_buy_dialog").show() | |
} | |
} | |
function ShopBuyCloseDialog() { | |
g_graphics_high ? $("#shop_buy_dialog").effect("explode") : $("#shop_buy_dialog").hide() | |
} | |
var BUY_PERIOD = ["1 Week", "1 Month", "Limitless"], | |
PERIOD_WEEK = 0, | |
PERIOD_MONTH = 1, | |
PERIOD_PERM = 2; | |
function ShopGetPeriod() { | |
var a = BUY_PERIOD.indexOf($("#buy_period").html()); - 1 == a && ShopSetPeriod(0); | |
return a | |
} | |
function ShopSetPeriod(a) { | |
$("#buy_period").html(BUY_PERIOD[a]); | |
var b = AVATARS[g_current_buy_avatar_index]; | |
a == PERIOD_WEEK ? (0 < b[AVATAR_INDEX_CASH_WEEK] ? $("#buy_cash_btn").addClass("active") : $("#buy_cash_btn").removeClass("active"), 0 < b[AVATAR_INDEX_GOLD_WEEK] ? $("#buy_gold_btn").addClass("active") : $("#buy_gold_btn").removeClass("active")) : a == PERIOD_MONTH ? (0 < b[AVATAR_INDEX_CASH_MONTH] ? $("#buy_cash_btn").addClass("active") : $("#buy_cash_btn").removeClass("active"), 0 < b[AVATAR_INDEX_GOLD_MONTH] ? $("#buy_gold_btn").addClass("active") : $("#buy_gold_btn").removeClass("active")) : a == PERIOD_PERM && (0 < b[AVATAR_INDEX_CASH_PERM] ? $("#buy_cash_btn").addClass("active") : $("#buy_cash_btn").removeClass("active"), 0 < b[AVATAR_INDEX_GOLD_PERM] ? $("#buy_gold_btn").addClass("active") : $("#buy_gold_btn").removeClass("active")) | |
} | |
function ShopDoPurchase(a) { | |
var b = AVATARS[g_current_buy_avatar_index], | |
c, d = ShopGetPeriod(); | |
d == PERIOD_WEEK ? c = a ? b[AVATAR_INDEX_CASH_WEEK] : b[AVATAR_INDEX_GOLD_WEEK] : d == PERIOD_MONTH ? c = a ? b[AVATAR_INDEX_CASH_MONTH] : b[AVATAR_INDEX_GOLD_MONTH] : d == PERIOD_PERM && (c = a ? b[AVATAR_INDEX_CASH_PERM] : b[AVATAR_INDEX_GOLD_PERM]); | |
OpenDialog("Are you sure?", 'Are you sure you want to purchase <span class="AlertBold">' + b[AVATAR_INDEX_NAME] + '</span> for <span class="AlertBold">' + $("#buy_period").html() + '</span> time at <span class="AlertBold">' + Commatize(c) + " " + (a ? "Cash" : "Gold") + "</span> ?", 2, function (b) { | |
b && SendPurchase(g_current_buy_avatar_index, a, d, c) | |
}) | |
} | |
function ShopUpdateMyStats() { | |
for (var a = "pop shld item def life atk dig time".split(" "), b = [AVATAR_INDEX_STAT_POP, AVATAR_INDEX_STAT_SHLD, AVATAR_INDEX_STAT_ITEM, AVATAR_INDEX_STAT_DEF, AVATAR_INDEX_STAT_LIFE, AVATAR_INDEX_STAT_ATK, AVATAR_INDEX_STAT_DIG, AVATAR_INDEX_STAT_TIME], c = g_shop_player.GetAvatars(), d = 0; d < a.length; d++) { | |
for (var e = 0, f = 0; f < c.length; f++) { | |
var h = AVATARS[c[f]]; | |
void 0 != h && (h = h[b[d]], void 0 != h && (e += h)) | |
} | |
50 < e && (e = 50); | |
f = a[d]; | |
$("#shop_my_stats .shop_item_stat" + d + " .stat_icon").removeClass().addClass("stat_icon stat_icon_" + (0 <= e ? f : f + "-")).show(); | |
$("#shop_my_stats .shop_item_stat" + d + " .stat_digit1").removeClass().addClass("stat_digit1 stat_font stat_font" + Math.floor(Math.abs(e / 10))).show(); | |
$("#shop_my_stats .shop_item_stat" + d + " .stat_digit2").removeClass().addClass("stat_digit2 stat_font stat_font" + Math.abs(e % 10)).show() | |
} | |
} | |
function ShopClose() { | |
var a = []; | |
$(".shop_my_item_equip.equipped").parent().each(function () { | |
a.push(Number($(this).attr("avatar_id"))) | |
}); | |
SendEquip(a); | |
SwitchToChannelScreen() | |
} | |
var DIALOG_BUTTONS_NONE = 0, | |
DIALOG_BUTTONS_OK = 1, | |
DIALOG_BUTTONS_OK_CANCEL = 2, | |
g_dialog_graphic; | |
function OpenDialog(a, b, c, d, e) { | |
CloseDialog(); | |
$("#myDialog .AlertBoxTitle").html(a); | |
$("#myDialog .AlertBoxContent").html(b.replace(/\n/g, "<br>")); | |
c == DIALOG_BUTTONS_NONE || void 0 == c ? ($("#myDialog .AlertBoxOK").hide(), $("#myDialog .AlertBoxCancel").hide()) : c == DIALOG_BUTTONS_OK ? ($("#myDialog .AlertBoxCancel").hide(), $("#myDialog .AlertBoxOK").show().unbind("click").bind("click", function () { | |
CloseDialog(); | |
d && d(!0) | |
})) : c == DIALOG_BUTTONS_OK_CANCEL && ($("#myDialog .AlertBoxOK").show().unbind("click").bind("click", function () { | |
CloseDialog(); | |
d && d(!0) | |
}), $("#myDialog .AlertBoxCancel").show().unbind("click").bind("click", function () { | |
CloseDialog(); | |
d && d(!1) | |
})); | |
e && (g_dialog_graphic && g_dialog_graphic.remove(), g_dialog_graphic = new CPlayerGraphic("#dialog_graphic", - 1, e[0], e[1], e[2], e[3], !1)); | |
g_graphics_high ? ($(".DialogLayer .AlertBox").fadeIn(), $(".DialogLayer").fadeIn()) : ($(".DialogLayer .AlertBox").show(), $(".DialogLayer").show()); | |
$(".DialogLayer").css("z-index", g_draggable_z_index += 1) | |
} | |
function CloseDialog() { | |
g_graphics_high && $(".DialogLayer").is(":visible") ? ($(".DialogLayer .AlertBox").effect("explode"), $(".DialogLayer").fadeOut()) : ($(".DialogLayer .AlertBox").hide(), $(".DialogLayer").hide()); | |
g_dialog_graphic && g_dialog_graphic.remove() | |
} | |
function ShowDisconnectedDialog() { | |
$("#dialog_change_name_div").fadeOut(); | |
OpenDialog("Disconnected", 'Trying to reconnect to server...<br><br><br>If it takes too long:<br> Refresh (F5) [or F12 on IE9]<br> Change to <a href="https://www.google.com/chrome/">Chrome</a> / <a href="http://www.mozilla.org/en-US/firefox/new/">Firefox</a><br> Or check our <a href="http://www.facebook.com/pages/DragonBound-Community/266025740173562">Community</a>', 0) | |
} | |
function Facebook_PostToFeed() { | |
FB.ui({ | |
method: "feed", | |
link: "http://DragonBound.net", | |
picture: "http://DragonBound.net//static/images/icon2_180x180.png", | |
name: "DragonBound - The new generation of HTML5 online multi-player games in your browser!", | |
caption: "DragonBound.net", | |
description: "Play with or against your friends from your browser anywhere for free. Shop for avatars to make you stronger. Unlock hidden characters, game modes, and challenges. Meet new friends. Single player option too." | |
}, function (a) { | |
SendEvent(1, a.post_id) | |
}) | |
}; | |
var PLAYER_LOOK_LEFT = 0, | |
PLAYER_LOOK_RIGHT = 1, | |
DIV_TO_CREATE_GAME_OBJECTS = "#game_objects", | |
WALK_WALL_LIMIT = 10, | |
TURN_TIME = 20, | |
KEY = { | |
Backspace: 8, | |
Tab: 9, | |
Enter: 13, | |
Esc: 27, | |
Space: 32, | |
Left: 37, | |
Up: 38, | |
Right: 39, | |
Down: 40, | |
F1: 112, | |
F2: 113, | |
F3: 114, | |
F4: 115, | |
F5: 116, | |
F6: 117, | |
F7: 118, | |
F8: 119, | |
F9: 120, | |
F10: 121 | |
}; | |
function ZotataPhysics2(a, b, c, d, e, f) { | |
this.x0 = a; | |
this.y0 = b; | |
this.v = new Vector(c, d); | |
this.ax = e; | |
this.ay = f | |
} | |
ZotataPhysics2.prototype.GetPosAtTime = function (a) { | |
a /= 1E3; | |
return { | |
x: this.x0 + this.v.x * a + this.ax * a * a / 2, | |
y: this.y0 + this.v.y * a + this.ay * a * a / 2 | |
} | |
}; | |
ZotataPhysics2.prototype.GetAngleAtTime = function (a) { | |
var b = this.GetPosAtTime(a - 10), | |
a = this.GetPosAtTime(a + 10); | |
return RadToAngle(Math.atan2(a.y - b.y, a.x - b.x)) | |
}; | |
var g_last_shot_sound_time; | |
function CShot(a, b, c, d) { | |
if (!(this instanceof arguments.callee)) throw Error("Constructor called as a function"); | |
this.shot = b; | |
this.unique_id = a; | |
this.div_id = "#Shot" + a; | |
this.div_id2 = "#ShotB" + a; | |
this.pic_div_id = this.div_id + " " + this.div_id2; | |
this.start_time = get_time(); | |
this.zp = new ZotataPhysics2(b.start.x, b.start.y, b.start.ang, b.start.power, b.start.ax, b.start.ay); | |
this.callback_finish = d; | |
this.created_div = !1; | |
this.is_camera_focus = c; | |
this.thor = b.thor; | |
b.ss && $("#ss_shot_background").fadeIn(); | |
this.shot.start.t || this.CreateDiv(); | |
var e = this; | |
this.interval = setInterval(function () { | |
e.update() | |
}, 30) | |
} | |
CShot.prototype.CreateDiv = function () { | |
if (this.thor) { | |
var a = 3E3; | |
this.shot.hole && (a = Math.round(Dist2Points(this.shot.start.x, this.shot.start.y, this.shot.hole.x, this.shot.hole.y))); | |
g_game.ThorShoot(this.shot.start.x, this.shot.start.y, this.shot.start.ang, a); | |
this.Remove(); | |
this.callback_finish(this.unique_id) | |
} else { | |
(a = BULLET[this.shot.img]) && a.file ? ($(DIV_TO_CREATE_GAME_OBJECTS).append('<div class="Shot" id="' + this.div_id.slice(1) + '"><div id="' + this.div_id2.slice(1) + '"></div></div>'), this.anim_obj = new CAnimatedObject2("bullets/" + a.file, a.graphics, 0, 0, this.div_id2, 1, 20, !1, LOOP_NORMAL, 0, 19, !0)) : $(DIV_TO_CREATE_GAME_OBJECTS).append('<div class="Shot" id="' + this.div_id.slice(1) + '"><div class="shot_img shot_img_' + this.shot.img + '" id="' + this.div_id2.slice(1) + '"></div></div>'); | |
this.created_div = !0; | |
var b = get_time(); | |
if ((void 0 == g_last_shot_sound_time || b >= g_last_shot_sound_time + 20) && a) g_last_shot_sound_time = b, this.shot.is_lightning || AudioPlay(a.sound) | |
} | |
}; | |
CShot.prototype.update = function () { | |
var a = get_time() - this.start_time; | |
if (void 0 != this.shot.start.t) if (a >= this.shot.start.t) a -= this.shot.start.t, this.created_div || this.CreateDiv(); | |
else return; | |
if (!this.thor) if (a >= this.shot.time) this.Remove(), this.callback_finish(this.unique_id); | |
else { | |
var b = this.zp.GetPosAtTime(a), | |
c = this.zp.GetAngleAtTime(a); | |
$(this.div_id).css({ | |
left: b.x, | |
top: b.y | |
}); | |
$(this.pic_div_id).css({ | |
rotate: +c + "deg" | |
}); | |
this.shot.change && a >= this.shot.change.at && $(this.pic_div_id).removeClass().addClass("shot_img shot_img_" + this.shot.change.img); | |
this.is_camera_focus && (500 < a && !g_game.isInMapDraggin) && g_game.camera.FocusAt(b.x, b.y, !0, !0) | |
} | |
}; | |
CShot.prototype.Remove = function () { | |
this.interval = clearInterval(this.interval); | |
$(this.div_id).remove(); | |
this.anim_obj && this.anim_obj.remove(); | |
this.shot.ss && setTimeout(function () { | |
$("#ss_shot_background").fadeOut() | |
}, 1E3) | |
}; | |
function CDamageEffect(a, b, c, d, e) { | |
if (!(this instanceof arguments.callee)) throw Error("Constructor called as a function"); | |
var f = "#DamageEffect_" + d + "_" + e, | |
h = $(f); | |
0 < h.length && (c += Number(h.attr("damage")), a = Number(h.attr("x")), b = Number(h.attr("y")), $(f).remove()); | |
for (var h = String(c), g = '<div class="DamageEffect" damage=' + c + " x=" + a + " y=" + b + ' id="' + f.slice(1) + '" style="left: ' + a + "px; top: " + b + 'px;">', j = 0; j < h.length; j++) { | |
var i = h.charCodeAt(j); | |
45 == i && (g += '<div class="DamageDigit DamageDigit-" style="left:' + 14 * j + 'px;"></div>'); | |
48 <= i && 57 >= i && (g += '<div class="DamageDigit DamageDigit' + (i - 48) + '" style="left:' + 14 * j + 'px;"></div>') | |
} | |
$(DIV_TO_CREATE_GAME_OBJECTS).append(g + "</div>"); | |
setTimeout(function () { | |
$(f).animate({ | |
top: "-=30" | |
}) | |
}, 10); | |
setTimeout(function () { | |
$(f).fadeOut(3E3, function () { | |
$(f).remove() | |
}) | |
}, 2E3) | |
} | |
function ZotataGB(a, b) { | |
if (!(this instanceof arguments.callee)) throw Error("[ZotataGB] Constructor called as a function"); | |
if (!a) throw Error("[ZotataGB] missing my_username"); | |
debug && console.log("[ZotataGB] game init - you are playing as", a); | |
this.my_user_id = a; | |
this.my_player_index = this.my_player_number = -1; | |
this.queue = []; | |
this.is_queue_executing = !1; | |
this.players = []; | |
this.shots = []; | |
this.camera = new CCamera(b.map); | |
this.isInMapDraggin = !1; | |
this.turn = -1; | |
this.after_shot_chat = []; | |
this.after_shot_gold = void 0; | |
this.steps = this.no_ss_turns = 0; | |
$(DIV_TO_CREATE_GAME_OBJECTS).children().remove(); | |
this.UnselectAllItems(); | |
this.UpdateGuiGold(0); | |
$("#last_power_mark").css("left", 240); | |
$("#game_over").hide(); | |
$("#game_replay").hide(); | |
this.SetBinds(); | |
$(".Player .GamePlayerBalloon").hide(); | |
$(".Player .GamePlayerBalloonTip").hide(); | |
$(".Player .Turn").hide(); | |
$("#powerBar").css("width", 1); | |
$("#walkBar").css("width", 400); | |
$("#LastAngleDigit-").hide(); | |
$("#LastAngleDigit1").removeClass().addClass("LastAngleDigit LastAngleDigit0"); | |
$("#LastAngleDigit2").removeClass().addClass("LastAngleDigit LastAngleDigit0"); | |
SelectShotType(0); | |
$("#btnShotSS").fadeIn(); | |
$("#gameInput").val(""); | |
$("#gameChatHtml").html(""); | |
$("#gameChat .scrollbar").hide(); | |
$("#thor").css({ | |
left: 680, | |
top: 0 | |
}); | |
$("#thor_rotate").children().not("#thor_laser").remove(); | |
this.thor_obj = new CAnimatedObject("thor", "thor.png", 0, 0, 159, 99, 97, 58, "#thor_rotate", 1, 20, 50, !1, g_graphics_high ? 1 : 3); | |
this.UpdateWeather(b.w); | |
this.UpdateWind(b.d); | |
this.UpdateThor(b.thor); | |
this.next_turn = b.turn; | |
this.camera.FocusAt(200, - 200, !0); | |
$("#loading_map").show(); | |
var c = this; | |
this.ground = new CGround(b.map, function () { | |
$("#loading_map").hide(); | |
c.CreatePlayers(b.players); | |
c.UpdateTurnList(); | |
c.StartNextTurn(); | |
c.QueueUnblock() | |
}) | |
} | |
ZotataGB.prototype.UIShootStart = function () { | |
if (this.turn == this.my_player_number && !this.intervalDoSpace) { | |
this.UIWalkLeftEnd(); | |
this.UIWalkRightEnd(); | |
$("#powerBar").css("width", 0); | |
var a = this, | |
b = get_time(); | |
this.intervalDoSpace = setInterval(function () { | |
var c = (get_time() - b) / 10; | |
$("#powerBar").css("width", c); | |
400 <= c && a.Shoot(400) | |
}, 10) | |
} | |
}; | |
ZotataGB.prototype.UIShootEnd = function () { | |
this.intervalDoSpace && this.Shoot(Number($("#powerBar").css("width").slice(0, - 2))) | |
}; | |
ZotataGB.prototype.UIWalkLeftStart = function () { | |
if (this.turn == this.my_player_number) { | |
if (!this.intervalDoLeft) { | |
var a = this, | |
b = get_time(), | |
c = 0; | |
this.intervalDoLeft = setInterval(function () { | |
var d = Math.floor((get_time() - b) / 20), | |
e = d - c; | |
200 < a.steps + e && (e = 200 - a.steps); | |
if (200 == a.steps) a.players[a.my_player_index].Look(PLAYER_LOOK_LEFT); | |
else { | |
for (var f = 0; f < e && !1 != a.players[a.my_player_index].Walk(PLAYER_LOOK_LEFT); f++); | |
e = f | |
} | |
a.steps += e; | |
c = d; | |
$("#walkBar").css("width", 400 - 2 * a.steps) | |
}, 20) | |
} | |
} else this.players[this.my_player_index].Look(PLAYER_LOOK_LEFT) | |
}; | |
ZotataGB.prototype.UIWalkLeftEnd = function () { | |
this.intervalDoLeft = clearInterval(this.intervalDoLeft) | |
}; | |
ZotataGB.prototype.UIWalkRightStart = function () { | |
if (this.turn == this.my_player_number) { | |
if (!this.intervalDoRight) { | |
var a = this, | |
b = get_time(), | |
c = 0; | |
this.intervalDoRight = setInterval(function () { | |
var d = Math.floor((get_time() - b) / 20), | |
e = d - c; | |
200 < a.steps + e && (e = 200 - a.steps); | |
if (200 == a.steps) a.players[a.my_player_index].Look(PLAYER_LOOK_RIGHT); | |
else { | |
for (var f = 0; f < e && !1 != a.players[a.my_player_index].Walk(PLAYER_LOOK_RIGHT); f++); | |
e = f | |
} | |
a.steps += e; | |
c = d; | |
$("#walkBar").css("width", 400 - 2 * a.steps) | |
}, 20) | |
} | |
} else this.players[this.my_player_index].Look(PLAYER_LOOK_RIGHT) | |
}; | |
ZotataGB.prototype.UIWalkRightEnd = function () { | |
this.intervalDoRight = clearInterval(this.intervalDoRight) | |
}; | |
ZotataGB.prototype.UIAngleUpStart = function () { | |
if (!this.intervalDoUp && !this.intervalDoDown) { | |
var a = this, | |
b = get_time(), | |
c = this.players[this.my_player_index].ang; | |
this.intervalDoUp = setInterval(function () { | |
var d = c + Math.floor((get_time() - b) / 50) * (90 < a.players[a.my_player_index].minang ? -1 : 1); | |
a.players[a.my_player_index].ChangeAngleTo(d) | |
}, 50) | |
} | |
}; | |
ZotataGB.prototype.UIAngleUpEnd = function () { | |
this.intervalDoUp = clearInterval(this.intervalDoUp) | |
}; | |
ZotataGB.prototype.UIAngleDownStart = function () { | |
if (!this.intervalDoDown && !this.intervalDoUp) { | |
var a = this, | |
b = get_time(), | |
c = this.players[this.my_player_index].ang; | |
this.intervalDoDown = setInterval(function () { | |
var d = c - Math.floor((get_time() - b) / 50) * (90 < a.players[a.my_player_index].minang ? -1 : 1); | |
a.players[a.my_player_index].ChangeAngleTo(d) | |
}, 50) | |
} | |
}; | |
ZotataGB.prototype.UIAngleDownEnd = function () { | |
this.intervalDoDown = clearInterval(this.intervalDoDown) | |
}; | |
ZotataGB.prototype.UINextShot = function () { | |
SelectShotType((GetSelectedShotType() + 1) % 3) | |
}; | |
ZotataGB.prototype.ChangedShot = function (a) { | |
this.players[this.my_player_index].ChangedShot(a) | |
}; | |
ZotataGB.prototype.UIDragStart = function (a) { | |
this.drag_start_x = a | |
}; | |
ZotataGB.prototype.UIDragMove = function (a) { | |
a = (a - this.drag_start_x) / 1.5; | |
1 > a && (a = 1); | |
400 < a && (a = 400); | |
$("#powerBar").css("width", a); | |
400 <= a && this.UIDragEnd() | |
}; | |
ZotataGB.prototype.UIDragEnd = function () { | |
this.Shoot(Number($("#powerBar").css("width").slice(0, - 2))) | |
}; | |
ZotataGB.prototype.UseItem = function (a) { | |
var b = $("#gameItemSlot" + a); | |
b.hasClass("item") ? b.hasClass("Pressed") ? b.removeClass("Pressed") : ($(".item").removeClass("Pressed"), b.addClass("Pressed"), this.turn == this.my_player_number && this.UsePressedItem(a)) : 0 < a && (a--, $("#gameItemSlot" + a).hasClass("big") && this.UseItem(a)) | |
}; | |
ZotataGB.prototype.UsePressedItem = function (a) { | |
for (a = void 0 != a ? a : 0; 6 > a; a++) if ($("#gameItemSlot" + a).hasClass("Pressed")) { | |
this.players[this.my_player_index].UseItem(a); | |
break | |
} | |
}; | |
ZotataGB.prototype.UnselectAllItems = function () { | |
for (var a = 0; 6 > a; a++) $("#gameItemSlot" + a).removeClass("Pressed") | |
}; | |
ZotataGB.prototype.SetBinds = function () { | |
function a(a) { | |
a = a || window.event; | |
a.preventDefault && a.preventDefault(); | |
a.stopPropagation && a.stopPropagation(); | |
a.cancelBubble = !0; | |
return a.returnValue = !1 | |
} | |
var b = this; | |
$("#btnShoot").bind("mousedown touchstart", function () { | |
b.UIShootStart() | |
}); | |
$("#btnShoot").bind("mouseup touchend", function () { | |
b.UIShootEnd() | |
}); | |
$("#btnLeft").bind("mousedown touchstart", function () { | |
b.UIWalkLeftStart() | |
}); | |
$("#btnLeft").bind("mouseup touchend", function () { | |
b.UIWalkLeftEnd() | |
}); | |
$("#btnRight").bind("mousedown touchstart", function () { | |
b.UIWalkRightStart() | |
}); | |
$("#btnRight").bind("mouseup touchend", function () { | |
b.UIWalkRightEnd() | |
}); | |
$("#btnUp").bind("mousedown touchstart", function () { | |
b.UIAngleUpStart() | |
}); | |
$("#btnUp").bind("mouseup touchend", function () { | |
b.UIAngleUpEnd() | |
}); | |
$("#btnDown").bind("mousedown touchstart", function () { | |
b.UIAngleDownStart() | |
}); | |
$("#btnDown").bind("mouseup touchend", function () { | |
b.UIAngleDownEnd() | |
}); | |
$(document).bind("keydown", function (a) { | |
$("#touch_ui").is(":visible") && $("#touch_ui").fadeOut("slow"); | |
switch (a.which) { | |
case KEY.Left: | |
$("#gameInput").is(":focus") || (b.UIWalkLeftStart(), a.preventDefault()); | |
break; | |
case KEY.Right: | |
$("#gameInput").is(":focus") || (b.UIWalkRightStart(), a.preventDefault()); | |
break; | |
case KEY.Up: | |
b.UIAngleUpStart(); | |
a.preventDefault(); | |
break; | |
case KEY.Down: | |
b.UIAngleDownStart(); | |
a.preventDefault(); | |
break; | |
case KEY.Space: | |
!$("#gameInput").is(":focus") && (!$(".chatDialogInput").is(":focus") && g_is_game_slice) && (b.UIShootStart(), a.preventDefault()); | |
break; | |
case KEY.F8: | |
b.PassTurnClicked(); | |
a.preventDefault(); | |
break; | |
case KEY.Tab: | |
b.UINextShot(); | |
a.preventDefault(); | |
break; | |
case KEY.F1: | |
b.UseItem(0); | |
a.preventDefault(); | |
break; | |
case KEY.F2: | |
b.UseItem(1); | |
a.preventDefault(); | |
break; | |
case KEY.F3: | |
b.UseItem(2); | |
a.preventDefault(); | |
break; | |
case KEY.F4: | |
b.UseItem(3); | |
a.preventDefault(); | |
break; | |
case KEY.F5: | |
b.UseItem(4); | |
a.preventDefault(); | |
break; | |
case KEY.F6: | |
b.UseItem(5); | |
a.preventDefault(); | |
break; | |
case KEY.Backspace: | |
$(document.activeElement).is("input") || a.preventDefault(); | |
break; | |
case KEY.Esc: | |
ToggleOptionsDialog(); | |
a.preventDefault(); | |
break; | |
case KEY.F10: | |
$("#friendsList").is(":visible") ? $("#friendsList").hide() : $("#friendsList").show().tinyscrollbar_update("top"), a.preventDefault() | |
} | |
}); | |
$(document).bind("keyup", function (a) { | |
switch (a.which) { | |
case KEY.Left: | |
b.UIWalkLeftEnd(); | |
a.preventDefault(); | |
break; | |
case KEY.Right: | |
b.UIWalkRightEnd(); | |
a.preventDefault(); | |
break; | |
case KEY.Up: | |
b.UIAngleUpEnd(); | |
a.preventDefault(); | |
break; | |
case KEY.Down: | |
b.UIAngleDownEnd(); | |
a.preventDefault(); | |
break; | |
case KEY.Space: | |
b.UIShootEnd(); | |
a.preventDefault(); | |
break; | |
case KEY.F1: | |
a.preventDefault(); | |
break; | |
case KEY.F2: | |
a.preventDefault(); | |
break; | |
case KEY.F3: | |
a.preventDefault(); | |
break; | |
case KEY.F4: | |
a.preventDefault(); | |
break; | |
case KEY.F5: | |
a.preventDefault(); | |
break; | |
case KEY.F6: | |
a.preventDefault() | |
} | |
}); | |
$("#gameui").bind("mousedown", function (a) { | |
a.stopPropagation(); | |
return !1 | |
}); | |
$(document).bind("mousedown", function (a) { | |
if (2 == a.button) b.lastDragX = a.pageX, b.lastDragY = a.pageY, b.isInMapDraggin = !0, $("#container").addClass("HandCursor"); | |
else if (0 == a.button && (b.score_screen_timeout && (b.score_screen_timeout = clearTimeout(b.score_screen_timeout), SwitchToRoomScreen()), !g_is_game_slice && b.turn == b.my_player_number)) b.isInDrag = !0, b.UIDragStart(a.pageX) | |
}); | |
$(document).bind("mouseup", function (a) { | |
2 == a.button ? (b.isInMapDraggin = !1, $("#container").removeClass("HandCursor")) : 0 == a.button && b.isInDrag && (b.isInDrag = !1, b.UIDragMove(a.pageX), b.UIDragEnd()) | |
}); | |
$(document).bind("mousemove", function (a) { | |
b.isInDrag && b.UIDragMove(a.pageX); | |
b.isInMapDraggin && (b.camera.MoveBy(b.lastDragX - a.pageX, b.lastDragY - a.pageY, !1), b.lastDragX = a.pageX, b.lastDragY = a.pageY) | |
}); | |
var c = document.getElementById("touch_ui"); | |
c.ontouchstart = a; | |
c.ontouchmove = a; | |
c.ontouchend = a; | |
c.ontouchcancel = a; | |
$(document).bind("touchstart", function (a) { | |
$("#touch_ui").show(); | |
if (b.score_screen_timeout) b.score_screen_timeout = clearTimeout(b.score_screen_timeout), SwitchToRoomScreen(); | |
else if (!b.intervalDoSpace && !b.intervalDoLeft && !b.intervalDoRight && !b.intervalDoUp && !b.intervalDoDown) { | |
if (a.originalEvent.touches && a.originalEvent.touches.length) a = a.originalEvent.touches[0]; | |
else if (a.originalEvent.changedTouches && a.originalEvent.changedTouches.length) a = a.originalEvent.changedTouches[0]; | |
else return; | |
b.lastDragX = a.pageX; | |
b.lastDragY = a.pageY; | |
b.isInMapDraggin = !0; | |
a.preventDefault() | |
} | |
}); | |
$(document).bind("touchend", function () { | |
b.isInMapDraggin = !1 | |
}); | |
$(document).bind("touchmove", function (a) { | |
a.preventDefault(); | |
if (b.intervalDoSpace || b.intervalDoLeft || b.intervalDoRight || b.intervalDoUp || b.intervalDoDown) b.isInMapDraggin = !1; | |
else { | |
if (a.originalEvent.touches && a.originalEvent.touches.length) a = a.originalEvent.touches[0]; | |
else if (a.originalEvent.changedTouches && a.originalEvent.changedTouches.length) a = a.originalEvent.changedTouches[0]; | |
else return; | |
b.isInMapDraggin && (b.camera.MoveBy(b.lastDragX - a.pageX, b.lastDragY - a.pageY, !1), b.lastDragX = a.pageX, b.lastDragY = a.pageY) | |
} | |
}) | |
}; | |
ZotataGB.prototype.Destructor = function () { | |
$(document).unbind("keydown"); | |
$(document).unbind("keyup"); | |
$(document).unbind("mousedown"); | |
$(document).unbind("mouseup"); | |
$(document).unbind("mousemove"); | |
$(document).unbind("touchstart"); | |
$(document).unbind("touchend"); | |
$(document).unbind("touchmove"); | |
$("#btnShoot").unbind("mousedown touchstart"); | |
$("#btnShoot").unbind("mouseup touchend"); | |
$("#btnLeft").unbind("mousedown touchstart"); | |
$("#btnLeft").unbind("mouseup touchend"); | |
$("#btnRight").unbind("mousedown touchstart"); | |
$("#btnRight").unbind("mouseup touchend"); | |
$("#btnUp").unbind("mousedown touchstart"); | |
$("#btnUp").unbind("mouseup touchend"); | |
$("#btnDown").unbind("mousedown touchstart"); | |
$("#btnDown").unbind("mouseup touchend"); | |
this.turnTimeout = clearTimeout(this.turnTimeout); | |
var a; | |
for (a = 0; a < this.shots.length; a++) this.shots[a].shot.Remove(); | |
this.shots = []; | |
this.EndTurn(); | |
this.score_screen_timeout = clearTimeout(this.score_screen_timeout); | |
for (a = 0; a < this.players.length; a++) this.players[a].Remove(); | |
$(".Player").hide(); | |
$("#powerBar").css("width", 0); | |
$("#turn_timer").hide(); | |
$("#game_over").hide(); | |
$(DIV_TO_CREATE_GAME_OBJECTS).children().remove() | |
}; | |
ZotataGB.prototype.CreatePlayers = function (a) { | |
for (var b = 0; b < a.length; b++) { | |
var c = !1; | |
a[b].user_id == this.my_user_id && (this.my_player_number = a[b].n, this.my_player_index = b, c = !0); | |
this.players.push(new CPlayer(a[b], c, this.ground)) | |
} | |
if (-1 == this.my_player_index) throw Error("[ZotataGB.CreatePlayers] I don't know who am I playing"); | |
}; | |
ZotataGB.prototype.UpdatePlayers = function (a) { | |
for (var b = 0; b < a.length; b++) { | |
var c = a[b], | |
d = c[1], | |
e = c[2], | |
f = c[3], | |
h = c[4], | |
g = c[5], | |
j = 1 == c[6], | |
c = this.GetPlayerByPlayerNumber(c[0]); | |
c.MoveTo(d, e, f); | |
c.ChangeDelay(h, g); | |
c.ChangeAliveTo(j) | |
} | |
}; | |
ZotataGB.prototype.UpdateTurnList = function () { | |
for (var a = [], b = this.players[this.my_player_index].delay, c = this.players[this.my_player_index].delay_before, d = 0; d < this.players.length; d++) { | |
var e = this.players[d]; | |
e.is_alive && a.push({ | |
rank: e.rank, | |
name: e.name, | |
user_id: e.user_id, | |
team: e.team, | |
delay: e.delay, | |
lastturn: e.lastturn | |
}) | |
} | |
a.sort(function (a, b) { | |
return a.delay == b.delay ? a.lastturn - b.lastturn : a.delay - b.delay | |
}); | |
for (d = 0; d < a.length; d++) e = a[d].delay - b, e = 0 < e ? "+" + e : e, $("#turn_line" + d + " .turn_line_name").html(a[d].name), $("#turn_line" + d + " .turn_line_rank").removeClass().addClass("turn_line_rank rank rank" + a[d].rank), "A" == a[d].team ? ($("#turn_line" + d + " .turn_line_number").removeClass("turn_line_number_b").addClass("turn_line_number_a turn_line_number" + d), $("#turn_line" + d + " .turn_line_name").removeClass("turn_line_name_b").addClass("turn_line_name_a turn_line_number" + d)) : ($("#turn_line" + d + " .turn_line_number").removeClass("turn_line_number_a").addClass("turn_line_number_b turn_line_number" + d), $("#turn_line" + d + " .turn_line_name").removeClass("turn_line_name_a").addClass("turn_line_name_b turn_line_number" + d)), a[d].user_id == this.my_user_id ? ($("#turn_line" + d).addClass("turn_line_me"), e = b - c) : $("#turn_line" + d).removeClass("turn_line_me"), $("#turn_line" + d + " .turn_line_delay").html(e), $("#turn_line" + d).show(); | |
for (; 8 > d; d++) $("#turn_line" + d).hide() | |
}; | |
ZotataGB.prototype.UpdatePlayer = function (a) { | |
var b = a[0]; | |
if (b != this.my_player_number) { | |
var c = a[1], | |
d = a[2], | |
a = a[3]; | |
this.GetPlayerByPlayerNumber(b).MoveTo(c, d, a) | |
} | |
}; | |
ZotataGB.prototype.CreateShot = function (a, b) { | |
var c = this, | |
d = function (b) { | |
var d; | |
for (d = 0; d < c.shots.length; d++) if (c.shots[d].id == b) { | |
c.shots.splice(d, 1); | |
break | |
} | |
if (a.hole) { | |
0 < a.hole.rx && 0 < a.hole.ry && c.ground.ExplodeAt(a.hole.x, a.hole.y, a.hole.rx, a.hole.ry); | |
a.is_lightning && c.CreateLightning(a.hole.x, a.hole.y, a.start.ang); | |
CreateExplode(a.exp, a.hole.x, a.hole.y); | |
if (a.damages) for (d = 0; d < a.damages.length; d++) b = c.GetPlayerByPlayerNumber(a.damages[d].n), a.damages[d].hp && b.ChangeHPShield(a.damages[d].hp, a.damages[d].shield), void 0 != a.damages[d].movex && b.MoveTo(a.damages[d].movex, void 0 != a.damages[d].movey ? a.damages[d].movey : b.y, void 0, !1); | |
for (d = 0; d < c.players.length; d++) c.players[d].Fall() | |
} | |
if (a.tele) for (d = 0; d < a.tele.length; d += 5) { | |
var b = a.tele[d + 1], | |
e = a.tele[d + 2], | |
j = a.tele[d + 3], | |
i = a.tele[d + 4], | |
k = c.GetPlayerByPlayerNumber(a.tele[d]); | |
k && (k.MoveTo(b, e, void 0, !0), k.MoveTo(j, i, void 0, !1), CreateExplode(a.exp, b, e)) | |
} | |
0 == c.shots.length && ((c.ReceivedChatArray(c.after_shot_chat), c.after_shot_gold && (AudioPlay(AUDIO_GOLD), c.UpdateGuiGold(c.after_shot_gold)), c.UpdateThor(c.after_shot_thor), c.UpdateWeather(c.after_shot_weather), c.UpdateWind(c.next_wind), 2 < c.queue.length) ? (c.StartNextTurn(), c.QueueUnblock()) : setTimeout(function () { | |
c.StartNextTurn(); | |
c.QueueUnblock() | |
}, 1E3)) | |
}, e = random(0, 999999); | |
2 < this.queue.length ? d(e) : this.shots.push({ | |
id: e, | |
shot: new CShot(e, a, b, d) | |
}) | |
}; | |
ZotataGB.prototype.ReceivedChatArray = function (a) { | |
if (a) for (var b = 0; b < a.length; b++) ChatReceived("", a[b][0], a[b][1]) | |
}; | |
ZotataGB.prototype.QueueAddCommand = function (a, b) { | |
this.queue.push({ | |
opcode: a, | |
params: b | |
}); | |
this.QueueExecuteNext() | |
}; | |
ZotataGB.prototype.QueueUnblock = function () { | |
this.is_queue_executing = !0; | |
this.QueueExecuteNext() | |
}; | |
ZotataGB.prototype.QueueExecuteNext = function () { | |
for (; this.is_queue_executing && 0 < this.queue.length;) { | |
var a = this.queue.shift(); | |
switch (a.opcode) { | |
case "play": | |
this.UpdatePlayers(a.params.p); | |
this.UpdateTurnList(); | |
this.turn_number = a.params.t; | |
this.after_shot_chat = a.params.chat; | |
this.after_shot_gold = a.params.n == this.my_player_number ? a.params.gold : void 0; | |
this.EndTurn(); | |
this.after_shot_thor = a.params.thor; | |
this.after_shot_weather = a.params.w; | |
this.next_turn = a.params.turn; | |
this.next_wind = a.params.d; | |
if (a.params.shots && 0 < a.params.shots.length) { | |
for (var b = 0; b < a.params.shots.length; b++) this.CreateShot(a.params.shots[b], 0 == b), a.params.shots[b].ss && a.params.n == this.my_player_number && (this.no_ss_turns = 4, $("#btnShotSS").fadeOut(), 2 == GetSelectedShotType() && SelectShotType(0)); | |
this.is_queue_executing = !1; | |
return | |
} | |
this.ReceivedChatArray(a.params.chat); | |
this.UpdateThor(this.after_shot_thor); | |
this.UpdateWeather(this.after_shot_weather); | |
this.UpdateWind(this.next_wind); | |
this.StartNextTurn(); | |
break; | |
case "update": | |
this.UpdatePlayer(a.params); | |
break; | |
case "game-over": | |
this.ReceivedChatArray(a.params.chat); | |
this.GameOver(a.params); | |
break; | |
case "dead": | |
(a = this.GetPlayerByPlayerNumber(a.params)) && a.ChangeAliveTo(!1) | |
} | |
} | |
}; | |
ZotataGB.prototype.EndTurn = function () { | |
var a = this.GetPlayerByPlayerNumber(this.turn); | |
a && a.ChangeMyTurn(!1); | |
this.turn = -1; | |
this.intervalDoLeft = clearInterval(this.intervalDoLeft); | |
this.intervalDoRight = clearInterval(this.intervalDoRight); | |
this.intervalDoSpace = clearInterval(this.intervalDoSpace); | |
this.turnTimeout = clearTimeout(this.turnTimeout); | |
this.isInDrag = !1; | |
$("#turn_timer").hide() | |
}; | |
ZotataGB.prototype.PassTurn = function () { | |
this.EndTurn(); | |
var a = Math.floor((get_time() - this.start_turn_time) / 1E3); | |
a > TURN_TIME && (a = TURN_TIME); | |
this.players[this.my_player_index].PassTurn(a) | |
}; | |
ZotataGB.prototype.Shoot = function (a) { | |
this.EndTurn(); | |
var b = Math.floor((get_time() - this.start_turn_time) / 1E3); | |
b > TURN_TIME && (b = TURN_TIME); | |
this.players[this.my_player_index].Shoot(a, b, GetSelectedShotType()); | |
$("#last_power_mark").animate({ | |
left: 240 + a | |
}) | |
}; | |
ZotataGB.prototype.PassTurnClicked = function () { | |
this.turn == this.my_player_number && this.PassTurn() | |
}; | |
ZotataGB.prototype.StartNextTurn = function () { | |
this.StartNextTurn2() | |
}; | |
ZotataGB.prototype.StartNextTurn2 = function () { | |
this.turn = this.next_turn; | |
if (-1 != this.turn) { | |
var a = this.GetPlayerByPlayerNumber(this.turn); | |
if (a) if (a.ChangeMyTurn(!0), 2 < this.queue.length ? $("#game_replay").show() : $("#game_replay").hide(), 0 == this.no_ss_turns && $("#btnShotSS").fadeIn(), this.camera.FocusAt(a.x, a.y, !0), this.start_turn_time = get_time(), this.turn == this.my_player_number) { | |
0 < this.no_ss_turns && this.no_ss_turns--; | |
this.steps = 0; | |
$("#walkBar").css("width", 400); | |
this.UsePressedItem(); | |
$("#turn_timer").stop(!0, !0).hide().css("background-position", "0 -1900px").show("slow"); | |
var b = this, | |
c = function () { | |
AudioPlay(AUDIO_TURN_TICK); | |
if (b.turn == b.my_player_number) { | |
var d = TURN_TIME - Math.floor((get_time() - b.start_turn_time) / 1E3); | |
0 < d ? (g_graphics_high ? $("#turn_timer").animate({ | |
backgroundPositionY: "-" + (d - 1) + "00px" | |
}, 200, "linear") : $("#turn_timer").css({ | |
backgroundPositionY: "-" + (d - 1) + "00px" | |
}), 0 == b.queue.length && a.SendPosUpdate(), b.turnTimeout = setTimeout(function () { | |
c() | |
}, 1E3)) : b.PassTurn() | |
} | |
}; | |
this.turnTimeout = setTimeout(c, 1E3); | |
AudioPlay(AUDIO_MY_TURN) | |
} else $("#turn_timer").hide(); | |
else debug && console.log("[ZotataGB.StartNextTurn2] ERROR: turn of unknown player number", this.turn) | |
} | |
}; | |
ZotataGB.prototype.GetPlayerByPlayerNumber = function (a) { | |
if (-1 != a) for (var b = 0; b < this.players.length; b++) if (this.players[b].player_number_in_game == a) return this.players[b] | |
}; | |
ZotataGB.prototype.GameOver = function (a) { | |
$("#scores_lose_a").hide(); | |
$("#scores_lose_b").hide(); | |
"B" != a.won && $("#scores_lose_b").show(); | |
"A" != a.won && $("#scores_lose_a").show(); | |
$(".score").hide(); | |
for (var b = 0; b < a.scores.length; b++) { | |
var c = a.scores[b], | |
d = c[0], | |
e = c[1], | |
f = c[2], | |
h = c[3], | |
g = c[4], | |
c = c[5]; | |
$("#score" + d + " .score_name").html(f); | |
$("#score" + d + " .score_rank").removeClass().addClass("score_rank rank rank" + h); | |
$("#score" + d + " .score_gp").html(g + " GP"); | |
$("#score" + d + " .score_gold").html(c + " GOLD"); | |
e == this.my_user_id ? $("#score" + d + " .score_me").show() : $("#score" + d + " .score_me").hide(); | |
$("#score" + d).show() | |
} | |
LoadRanking(5); | |
var j = this; | |
$(".Player").promise().done(function () { | |
$("#game_over").delay(1500).fadeIn(1500); | |
j.score_screen_timeout = setTimeout(function () { | |
SwitchToRoomScreen() | |
}, 1E4) | |
}) | |
}; | |
ZotataGB.prototype.ChangePlayersInRoom = function (a) { | |
var b, c; | |
for (b = 0; b < this.players.length; b++) this.players[b].mark = !1; | |
for (c = 0; c < a.length; c++) for (b = 0; b < this.players.length; b++) a[c][PLAYER_INDEX_USER_ID] == this.players[b].user_id && (this.players[b].mark = !0); | |
for (b = 0; b < this.players.length; b++) this.players[b].mark || this.players[b].ChangeAliveTo(!1) | |
}; | |
ZotataGB.prototype.UpdateGuiGold = function (a) { | |
for (var b = a.toString().split("").reverse(), a = 0; a < b.length && 5 > a; a++) "-" == b[a] ? $("#UIGoldDigit" + a).animate({ | |
backgroundPositionY: "-154px" | |
}, 1E3) : $("#UIGoldDigit" + a).animate({ | |
backgroundPositionY: -14 - 14 * Number(b[a]) + "px" | |
}, 1E3); | |
for (; 5 > a; a++) $("#UIGoldDigit" + a).animate({ | |
backgroundPositionY: "0" | |
}, 1E3) | |
}; | |
var THOR_LEVEL = [0, 300, 900, 1800, 3200, 6E3]; | |
ZotataGB.prototype.UpdateThor = function (a) { | |
if (a) { | |
for (var b = a[0], c = a[1], d = a[2], a = a[3], e = 0; e + 1 < THOR_LEVEL.length && a >= THOR_LEVEL[e + 1];) e++; | |
e++; | |
$("#thor").stop(!0, !0).animate({ | |
left: b, | |
top: c | |
}, 2E3); | |
$("#thor_rotate").stop(!0, !0).animate({ | |
rotate: "-" + d + "deg" | |
}, 1E3); | |
$("#thor_lvl").html("Lv." + e); | |
$("#thor_damage").html(a); | |
$("#thor_laser").fadeOut() | |
} | |
}; | |
ZotataGB.prototype.ThorShoot = function (a, b, c, d) { | |
$("#thor").stop(!0, !0).css({ | |
left: a, | |
top: b | |
}); | |
$("#thor_rotate").stop(!0, !0).css({ | |
rotate: "-" + c + "deg" | |
}); | |
$("#thor_laser").stop(!0, !0).css({ | |
width: d | |
}).show().fadeOut() | |
}; | |
ZotataGB.prototype.UpdateWeather = function (a) { | |
$("#weatherSlot0").removeClass().addClass("weather-" + a[0]); | |
$("#weatherSlot1").removeClass().addClass("weather-" + a[1]); | |
$("#weatherSlot2").removeClass().addClass("weather-" + a[2]); | |
$("#weatherSlot3").removeClass().addClass("weather-" + a[3]); | |
$("#weatherSlot4").removeClass().addClass("weather-" + a[4]) | |
}; | |
ZotataGB.prototype.CreateLightning = function (a, b, c) { | |
var d = "#lightning" + random(0, 999999), | |
e = random(0, 3); | |
$(DIV_TO_CREATE_GAME_OBJECTS).append('<div id="' + d.slice(1) + '" style="position:absolute; left:' + a + "px; top:" + b + 'px;"><div class="lightning lightning' + e + '"></div></div>'); | |
$(d).css({ | |
rotate: 270 - c + "deg" | |
}); | |
console.log("lightning created", d); | |
setTimeout(function () { | |
console.log("lightning removed", d, $(d)); | |
$(d).remove() | |
}, 100) | |
}; | |
ZotataGB.prototype.UpdateWind = function (a) { | |
var b = a[1], | |
a = a[0], | |
c; | |
c = 10 > a ? "#ffffff" : 20 > a ? "#ffff00" : "#ff0000"; | |
10 > a && (a = "0" + a); | |
$("#wind_number").html(a).css("color", c); | |
0 == a ? $("#wind_angle").hide() : $("#wind_angle").show().css("rotate", - b + "deg") | |
}; | |
var AUDIO_ARMOR_MOVE = 0, | |
AUDIO_ARMOR_BLAST = 1, | |
AUDIO_ARMOR_FIRE = 2, | |
AUDIO_ICE_MOVE = 3, | |
AUDIO_MOVE_ARMOR = 4, | |
AUDIO_ICE_SHOOT = 5, | |
AUDIO_ARMOR_FIRE2 = 6, | |
AUDIO_ICE_BLAST = 7, | |
AUDIO_ICE_FIRE = 8, | |
AUDIO_ICE_BLAST2 = 9, | |
AUDIO_ADUKA_FIRE = 10, | |
AUDIO_ADUKA_FIRE2 = 11, | |
AUDIO_BUTTON_SELECT = 12, | |
AUDIO_MUSIC_CHANNEL = 13, | |
AUDIO_MUSIC_ROOM = 14, | |
AUDIO_MUSIC_STAGE1 = 15, | |
AUDIO_MY_TURN = 16, | |
AUDIO_TURN_TICK = 17, | |
AUDIO_BUTTON_SELECT2 = 18, | |
AUDIO_GOLD = 19, | |
AUDIO_BIGFOOT_FIRE1 = 20, | |
AUDIO_BIGFOOT_FIRE2 = 21, | |
AUDIO_BIGFOOT_BLAST1 = 22, | |
AUDIO_BIGFOOT_BLAST2 = 23, | |
AUDIO_LIGHTNING_FIRE = 24, | |
AUDIO_LIGHTNING_BLAST = 25, | |
AUDIO_JD_FIRE = 26, | |
AUDIO_JD_BLAST1 = 27, | |
AUDIO_JD_BLAST2 = 28, | |
g_sound_files = "1move 11blast 11fire 11move 1move 12blast 12fire 111blast 111fire 112blast 161fire 162fire bpush1 channel ready stage1 turn turnwa bselect1 gold 51fire 52fire 51blast 52blast 82fire 82blast 91fire 91blast 92blast".split(" "), | |
g_music_numbers = [AUDIO_MUSIC_CHANNEL, AUDIO_MUSIC_ROOM, AUDIO_MUSIC_STAGE1], | |
g_audio_is_music_on = 0 != getCookie("music"), | |
g_audio_is_effects_on = 0 != getCookie("effects"), | |
g_audio_last_music_wanted_to_play; | |
function AudioInit() { | |
navigator.userAgent.match(/(iPhone|iPod|iPad)/i) && (g_audio_is_music_on = !1); | |
soundManager.setup({ | |
url: "/static/js/", | |
flashVersion: 9, | |
debugMode: !1, | |
onready: function () { | |
for (var a = 0; a < g_sound_files.length; a++) { | |
var b = -1 == g_music_numbers.indexOf(a) && g_audio_is_effects_on; | |
soundManager.createSound({ | |
id: g_sound_files[a], | |
autoLoad: b, | |
url: "/static/sounds/" + g_sound_files[a] + ".mp3" | |
}) | |
} | |
AudioPlayInLoop(AUDIO_MUSIC_CHANNEL) | |
} | |
}) | |
} | |
function AudioPlayInLoop(a, b) { | |
if (-1 == g_music_numbers.indexOf(a)) { | |
if (!g_audio_is_effects_on) return | |
} else if (g_audio_last_music_wanted_to_play = a, !g_audio_is_music_on) return; | |
var c = g_sound_files[a]; | |
void 0 != c && (c = soundManager.getSoundById(c), void 0 != c && (b && AudioStopAll(), c.play({ | |
onfinish: function () { | |
AudioPlayInLoop(a) | |
} | |
}))) | |
} | |
function AudioPlay(a, b) { | |
if (-1 == g_music_numbers.indexOf(a)) { | |
if (!g_audio_is_effects_on) return | |
} else if (g_audio_last_music_wanted_to_play = a, !g_audio_is_music_on) return; | |
var c = g_sound_files[a]; | |
void 0 != c && (void 0 != b ? soundManager.play(c, { | |
loops: b | |
}) : soundManager.play(c)) | |
} | |
function AudioStopAll() { | |
soundManager.stopAll() | |
} | |
function AudioTurnMusicOff() { | |
for (var a = 0; a < g_music_numbers.length; a++) soundManager.getSoundById(g_sound_files[g_music_numbers[a]]).pause(); | |
g_audio_is_music_on = !1 | |
} | |
function AudioTurnMusicOn() { | |
g_audio_is_music_on = !0; | |
for (var a = !1, b = 0; b < g_music_numbers.length; b++) { | |
var c = soundManager.getSoundById(g_sound_files[g_music_numbers[b]]); | |
0 != c.paused && (c.resume(), a = !0) | |
} | |
a || AudioPlayInLoop(g_audio_last_music_wanted_to_play) | |
} | |
function AudioTurnEffectsOff() { | |
g_audio_is_effects_on = !1 | |
} | |
function AudioTurnEffectsOn() { | |
g_audio_is_effects_on = !0 | |
}; | |
function random(a, b) { | |
return Math.floor(Math.random() * (b - a + 1) + a) | |
} | |
function get_time() { | |
return Date.now() | |
} | |
function RadToAngle(a) { | |
return 180 * a / Math.PI | |
} | |
function AngleToRad(a) { | |
return a * Math.PI / 180 | |
} | |
function Vector(a, b) { | |
this.ang = a; | |
this.size = b; | |
this.x = Math.cos(AngleToRad(a)) * b; | |
this.y = -Math.sin(AngleToRad(a)) * b | |
} | |
function Dist2Points(a, b, c, d) { | |
return Math.sqrt((c - a) * (c - a) + (d - b) * (d - b)) | |
} | |
function setCookie(a, b) { | |
var c = new Date; | |
c.setTime(c.getTime() + 31536E6); | |
document.cookie = a + "=" + b + ";expires=" + c.toUTCString() | |
} | |
function getCookie(a) { | |
return (a = document.cookie.match("(^|;) ?" + a + "=([^;]*)(;|$)")) ? a[2] : null | |
} | |
"function" != typeof Array.prototype.remove && (Array.prototype.remove = function (a) { | |
a = this.indexOf(a); - 1 != a && this.splice(a, 1) | |
}); | |
var ANIMATIONS_FPS = 10; | |
function CPlayerGraphic(a, b, c, d, e, f, h) { | |
if (void 0 == h) throw Error("CPlayerGraphic: is_flip is undefined"); | |
this.div = a; | |
this.flip = h; | |
this.change_mobile(b); | |
void 0 != f && this.change(f); | |
void 0 != c && this.change(c); | |
void 0 != d && this.change(d); | |
void 0 != e && this.change(e); | |
g_graphics_high && this.animate_start() | |
} | |
CPlayerGraphic.prototype.animate_start = function () { | |
this.frame_time = 1E3 / ANIMATIONS_FPS; | |
this.start_time = get_time(); | |
var a = this; | |
this.interval = setInterval(function () { | |
var b = Math.floor((get_time() - a.start_time) / a.frame_time); | |
a.flag && a.flag.set_frame(b); | |
a.head && a.head.set_frame(b); | |
a.body && a.body.set_frame(b); | |
a.eyes && a.eyes.set_frame(b, a.head.is_special) | |
}, this.frame_time) | |
}; | |
CPlayerGraphic.prototype.animate_stop = function () { | |
this.interval && (this.interval = clearInterval(this.interval)) | |
}; | |
CPlayerGraphic.prototype.remove = function () { | |
this.animate_stop(); | |
this.flag && this.flag.remove(); | |
this.body && this.body.remove(); | |
this.head && this.head.remove(); | |
this.eyes && this.eyes.remove(); | |
this.mobile && this.mobile.remove() | |
}; | |
CPlayerGraphic.prototype.change = function (a, b, c) { | |
if (void 0 == a) void 0 == b ? deubg && console.log(" *** ERROR: [CPlayerGraphic.change] undefined avatar ", a, d) : b == AVATAR_TYPE_FLAG && this.flag ? this.flag.remove() : b == AVATAR_TYPE_BODY && this.body ? this.body.remove() : b == AVATAR_TYPE_EYES && this.eyes ? this.eyes.remove() : b == AVATAR_TYPE_HEAD && this.head && this.head.remove(); | |
else { | |
var d = AVATARS[a]; | |
if (void 0 == d) debug && console.log(" *** ERROR: [CPlayerGraphic.change] unknown avatar ", a, d); | |
else if (b = "avatars/" + d[AVATAR_INDEX_GENDER] + d[AVATAR_INDEX_TYPE] + (d[AVATAR_INDEX_N] + 1E5).toString().substring(1) + ".png", d[AVATAR_INDEX_TYPE] == AVATAR_TYPE_FLAG) { | |
if (this.flag_n != a || c) this.flag && this.flag.remove(), this.flag = new CAnimatedObject2(b, d[AVATAR_INDEX_GRAPHICS], this.flip ? -this.avatar_x : this.avatar_x, this.avatar_y, this.div, 1, 10, this.flip, LOOP_NORMAL_AND_REVERSE, 0, 1), this.flag_n = a | |
} else if (d[AVATAR_INDEX_TYPE] == AVATAR_TYPE_HEAD) { | |
if (this.head_n != a || c) this.head && this.head.remove(), this.head = new CAnimatedObject2(b, d[AVATAR_INDEX_GRAPHICS], this.flip ? -this.avatar_x : this.avatar_x, this.avatar_y, this.div, 1, 10, this.flip, LOOP_AVATAR, 21, 2), this.head_n = a, this.body && this.change(this.body_n, AVATAR_TYPE_BODY, !0) | |
} else if (d[AVATAR_INDEX_TYPE] == AVATAR_TYPE_BODY) { | |
if (this.body_n != a || c) this.body && this.body.remove(), this.body = new CAnimatedObject2(b, d[AVATAR_INDEX_GRAPHICS], this.flip ? -this.avatar_x : this.avatar_x, this.avatar_y, this.div, 1, 10, this.flip, LOOP_NORMAL_AND_REVERSE, 0, 3), this.body_n = a | |
} else if (d[AVATAR_INDEX_TYPE] == AVATAR_TYPE_EYES && (this.eyes_n != a || c)) { | |
this.eyes && this.eyes.remove(); | |
var c = d[AVATAR_INDEX_GRAPHICS].length, | |
e = LOOP_NORMAL_AND_REVERSE; | |
22 == c ? e = LOOP_AVATAR : 44 == c && (e = LOOP_AVATAR_NO_REVERSE); | |
this.eyes = new CAnimatedObject2(b, d[AVATAR_INDEX_GRAPHICS], this.flip ? -this.avatar_x : this.avatar_x, this.avatar_y, this.div, 1, 10, this.flip, e, 0, 4); | |
this.eyes_n = a | |
} | |
} | |
}; | |
CPlayerGraphic.prototype.GetAvatars = function () { | |
return [this.head_n, this.body_n, this.eyes_n, this.flag_n] | |
}; | |
CPlayerGraphic.prototype.change_mobile = function (a) { | |
var b = MOBILE_GRAPHICS[a]; | |
this.avatar_x = b ? b.player_x : 0; | |
this.avatar_y = b ? b.player_y : 0; | |
var c = this.flip ? -this.avatar_x : this.avatar_x, | |
d = this.avatar_y; | |
this.head && this.head.change_pos(c, d); | |
this.body && this.body.change_pos(c, d); | |
this.eyes && this.eyes.change_pos(c, d); | |
this.flag && this.flag.change_pos(c, d); | |
this.mobile && this.mobile.remove(); | |
b && (this.mobile = new CAnimatedObject("mobile" + a, "mobile-" + a + ".png", 0, 0, b.w, b.h, b.center_x, b.center_y, this.div, 1, b.frames, 50, this.flip, g_graphics_high ? 1 : 3)) | |
}; | |
function CAnimatedObject(a, b, c, d, e, f, h, g, j, i, k, l, m, n, o, p) { | |
this.frames = k; | |
this.start_frame = void 0 == o ? 0 : o; | |
this.end_frame = p; | |
this.frame_time = l; | |
this.loop_type = n; | |
this.css_prefix = a; | |
this.div_id = "#AniObject" + random(0, 999999); | |
this.start_time = get_time(); | |
this.is_flip = m; | |
c = Math.round(c); | |
d = Math.round(d); | |
$(j).append('<div class="AniObject ' + a + "-" + this.start_frame + (this.is_flip ? " FlipH" : "") + '" id="' + this.div_id.slice(1) + '" style="position: absolute; left:' + c + "px; top:" + d + "px; width: " + e + "px; height: " + f + "px; margin-left: " + -h + "px; margin-top: " + -g + "px; opacity: " + i + "; background-image: url(/static/images/" + b + '); background-repeat: no-repeat;background-color: transparent; zoom:1;"></div>'); | |
if (3 != this.loop_type) { | |
var q = this; | |
this.interval = setInterval(function () { | |
q.update() | |
}, l) | |
} | |
} | |
CAnimatedObject.prototype.update = function () { | |
var a = Math.floor((get_time() - this.start_time) / this.frame_time); | |
if (0 == this.loop_type) { | |
if (a >= this.frames) { | |
this.remove(); | |
return | |
} | |
} else if (1 == this.loop_type) a %= this.frames; | |
else if (2 == this.loop_type) { | |
var b = this.end_frame - this.start_frame + 1, | |
a = a % (2 * b - 2); | |
a >= b && (a = 2 * b - 2 - a); | |
a += this.start_frame | |
}(b = $(this.div_id)) ? b.removeClass().addClass("AniObject " + this.css_prefix + "-" + a + (this.is_flip ? " FlipH" : "")) : this.remove() | |
}; | |
CAnimatedObject.prototype.remove = function () { | |
this.interval = clearInterval(this.interval); | |
$(this.div_id).remove() | |
}; | |
var GRAPHICS_INDEX_WIDTH = 0, | |
GRAPHICS_INDEX_HEIGHT = 1, | |
GRAPHICS_INDEX_CENTER_X = 2, | |
GRAPHICS_INDEX_CENTER_Y = 3, | |
LOOP_ONCE = 0, | |
LOOP_NORMAL = 1, | |
LOOP_NORMAL_AND_REVERSE = 2, | |
LOOP_SINGLE_FRAME = 3, | |
LOOP_AVATAR = 4, | |
LOOP_AVATAR_NO_REVERSE = 5, | |
RANDOM_FACE_TURN_CHANCE = 6; | |
function CAnimatedObject2(a, b, c, d, e, f, h, g, j, i, k, l) { | |
this.graphics = b; | |
this.frames = b.length; | |
this.start_frame = void 0 == i ? 0 : i; | |
this.loop_type = j; | |
this.is_flip = g; | |
this.frame_time = 1E3 / h; | |
this.is_special = !1; | |
this.div_id = "#AniObject" + random(0, 999999); | |
this.start_time = get_time(); | |
c = Math.round(c); | |
d = Math.round(d); | |
h = 0; | |
this.frames_x = []; | |
for (g = 0; g < b.length; g++) this.frames_x.push(h), h += b[g][GRAPHICS_INDEX_WIDTH] + 1; | |
h = b[i][GRAPHICS_INDEX_WIDTH]; | |
g = b[i][GRAPHICS_INDEX_HEIGHT]; | |
j = b[i][GRAPHICS_INDEX_CENTER_X]; | |
b = b[i][GRAPHICS_INDEX_CENTER_Y]; | |
i = this.frames_x[i]; | |
j = this.is_flip ? j - h : -j; | |
$("<div/>", { | |
id: this.div_id.slice(1), | |
"class": "AniObject" + (this.is_flip ? " FlipH" : ""), | |
style: "position: absolute; left:" + c + "px; top:" + d + "px; width: " + h + "px; height: " + g + "px; margin-left: " + j + "px; margin-top: " + -b + "px; opacity: " + f + "; background-image: url(/static/images/" + a + "); background-repeat: no-repeat;background-color: transparent; zoom:1; background-position: -" + i + "px 0; z-index:" + k + ";" | |
}).appendTo(e); | |
if (l && this.loop_type != LOOP_SINGLE_FRAME) { | |
var m = this; | |
this.interval = setInterval(function () { | |
var a = Math.floor((get_time() - m.start_time) / m.frame_time); | |
m.set_frame(a) | |
}, m.frame_time) | |
} | |
} | |
CAnimatedObject2.prototype.set_frame = function (a, b) { | |
var c = $(this.div_id); | |
if (c) { | |
var d; | |
if (this.loop_type == LOOP_ONCE) { | |
if (a >= this.frames) { | |
this.remove(); | |
return | |
} | |
} else if (this.loop_type == LOOP_NORMAL) a %= this.frames; | |
else if (this.loop_type == LOOP_NORMAL_AND_REVERSE) d = 2 * this.frames - 2, a %= d, a >= this.frames && (a = d - a); | |
else if (this.loop_type == LOOP_AVATAR) { | |
if (void 0 == b) { | |
d = Math.floor(a / (this.frames - 2)); | |
if (void 0 == this.turn_cycle || d > this.turn_cycle) this.turn_cycle = random(d, d + RANDOM_FACE_TURN_CHANCE); | |
this.is_special = d == this.turn_cycle | |
} else this.is_special = b; | |
var e = this.frames / 2; | |
d = 2 * e - 2; | |
this.is_special ? (a %= d, a >= e && (a = d - a)) : (a %= d, a >= e && (a = d - a), a += e) | |
} else if (this.loop_type == LOOP_AVATAR_NO_REVERSE) { | |
if (void 0 == b) { | |
d = Math.floor(a / (this.frames - 2)); | |
if (void 0 == this.turn_cycle || d > this.turn_cycle) this.turn_cycle = random(d, d + RANDOM_FACE_TURN_CHANCE); | |
this.is_special = d == this.turn_cycle | |
} else this.is_special = b; | |
e = this.frames / 2; | |
a = this.is_special ? a % e : a % e + e | |
} | |
d = this.graphics[a][GRAPHICS_INDEX_WIDTH]; | |
e = this.graphics[a][GRAPHICS_INDEX_CENTER_X]; | |
c.css({ | |
"background-position": -this.frames_x[a] + "px 0", | |
width: d, | |
height: this.graphics[a][GRAPHICS_INDEX_HEIGHT], | |
"margin-left": this.is_flip ? e - d : -e, | |
"margin-top": -this.graphics[a][GRAPHICS_INDEX_CENTER_Y] | |
}) | |
} else console.log("*** ERROR: CAnimatedObject2 not found") | |
}; | |
CAnimatedObject2.prototype.remove = function () { | |
this.interval && (this.interval = clearInterval(this.interval)); | |
$(this.div_id).remove() | |
}; | |
CAnimatedObject2.prototype.change_pos = function (a, b) { | |
$(this.div_id).css({ | |
left: a, | |
top: b | |
}) | |
}; | |
function CreateExplode(a, b, c) { | |
if (a = EXPLODE[a]) new CAnimatedObject2("explodes/" + a.file, a.graphics, b, c, "#game_objects", 0.75, 20, !1, LOOP_ONCE, 0, 20, !0), AudioPlay(a.sound) | |
}; | |
var socket; | |
function ZotataPlaySendLogin(a, b) { | |
debug && console.log("Send: login", a); | |
socket.emit("login", VERSION, a, b) | |
} | |
function ZotataPlayChat(a) { | |
debug && console.log("Send: chat:", a); | |
socket.emit("chat", a) | |
} | |
function SendRoomCreate(a, b, c, d) { | |
debug && console.log("Send: room-create:", a, b, c, d); | |
socket.emit("room-create", a, b, c, d) | |
} | |
function SendRoomJoin(a, b) { | |
debug && console.log("Send: room-join:", a, b); | |
socket.emit("room-join", a, b) | |
} | |
function SendRoomLeave() { | |
debug && console.log("Send: channel-join"); | |
socket.emit("channel-join") | |
} | |
function SendRoomChangeReady(a) { | |
debug && console.log("Send: room-change-ready", a); | |
socket.emit("room-change-ready", a) | |
} | |
function SendRoomChangeTeam(a) { | |
debug && console.log("Send: room-change-team", a); | |
socket.emit("room-change-team", a) | |
} | |
function SendRoomGameStart() { | |
debug && console.log("Send: game-start"); | |
socket.emit("game-start") | |
} | |
function SendPlayerShoot(a, b, c, d, e, f, h, g) { | |
debug && console.log("Send: game-shoot"); | |
socket.emit("game-shoot", a, b, c, d, e, f, h, g) | |
} | |
function SendPlayerPassTurn(a, b, c, d, e, f) { | |
debug && console.log("Send: game-pass-turn"); | |
socket.emit("game-pass-turn", a, b, c, d, e, f) | |
} | |
function SendPlayerMove(a, b, c, d, e) { | |
debug && console.log("Send: game-move"); | |
socket.emit("game-move", a, b, c, d, e) | |
} | |
function SendChangeName(a, b) { | |
debug && console.log("SendChangeName", a, b); | |
$.post("/change_name", { | |
name: a, | |
can_show_photo: b | |
}, function (a) { | |
debug && console.log("SendChangeName Returned:", a); | |
"Updated" == a ? (OpenDialog("Updated", "Your player info updated :)", 1), debug && console.log("Send: refresh"), socket.emit("refresh")) : "Illegal Length" == a ? OpenDialog("Illegal Length", "Name length must be 2-25 letters.", 1) : "Illegal Char" == a ? OpenDialog("Illegal Char", "Name contains a character that is not allowed.<p>Allowed chars: a-z A-Z 0-9 -+$^*().,~!@#&=", 1) : "Exists" == a ? OpenDialog("Exists", "This GameID already exists.", 1) : "Too Few Letters" == a ? OpenDialog("Too Few Letters", "Name must contain at least 2 english letters a-z/A-Z.", 1) : "Filtered" == a ? OpenDialog("Not Allowed", "Name must not contain a word that is not allowed, please select a different one.", 1) : "Nothing Changed" == a && OpenDialog("Nothing Changed", "Nothing to do, same info.", 1) | |
}) | |
} | |
function SendSelectedItemsForThisGame(a) { | |
debug && console.log("Send: game-items"); | |
socket.emit("game-items", a) | |
} | |
function SendPlayerUseItem(a) { | |
debug && console.log("Send: game-use-item", a); | |
socket.emit("game-use-item", a) | |
} | |
function SendRoomChangeMobile(a) { | |
debug && console.log("Send: mobile", a); | |
socket.emit("mobile", a) | |
} | |
function SendGetMyAvatars() { | |
debug && console.log("Send: get-my-avatars"); | |
socket.emit("get-my-avatars") | |
} | |
function SendEquip(a) { | |
debug && console.log("Send: equip", a); | |
socket.emit("equip", a) | |
} | |
function SendPurchase(a, b, c, d) { | |
debug && console.log("Send: buy", a, b, c, d); | |
socket.emit("buy", a, b, c, d) | |
} | |
function SendQuickJoin() { | |
debug && console.log("Send: quick-join"); | |
socket.emit("quick-join") | |
} | |
function SendRoomChangeTitle(a) { | |
debug && console.log("Send: room-title", a); | |
socket.emit("room-title", a) | |
} | |
function SendSelectBot(a, b) { | |
debug && console.log("Send: select-bot", a, b); | |
socket.emit("select-bot", a, b) | |
} | |
function SendEvent(a, b) { | |
debug && console.log("Send: event", a, b); | |
socket.emit("event", a, b) | |
} | |
function SendGetPlayerInfo(a) { | |
debug && console.log("Send: getinfo", a); | |
socket.emit("getinfo", a) | |
} | |
function SendAddFriendRequest(a) { | |
debug && console.log("Send: addfriend", a); | |
socket.emit("addfriend", a) | |
} | |
function SendFriendApproved(a, b) { | |
debug && console.log("Send: friend-approved", b); | |
socket.emit("friend-approved", a, b) | |
} | |
function SendPrivateChat(a, b) { | |
debug && console.log("Send: pchat", a, b); | |
socket.emit("pchat", a, b) | |
} | |
function SendDeleteFriend(a) { | |
debug && console.log("Send: friend-delete", a); | |
socket.emit("friend-delete", a) | |
} | |
function SendRoomOptions(a, b, c, d, e) { | |
debug && console.log("Send: room-options", a, b, c, d, e); | |
socket.emit("room-options", a, b, c, d, e) | |
} | |
function NetworkStuff() { | |
socket = io.connect(SERVER_ADDRESS); | |
socket.on("connecting", function (a) { | |
console.log("connecting", a) | |
}); | |
socket.on("connect_failed", function () { | |
console.log("connect_failed") | |
}); | |
socket.on("error", function () { | |
console.log("error") | |
}); | |
socket.on("reconnect_failed", function () { | |
console.log("reconnect_failed") | |
}); | |
socket.on("reconnect", function (a, b) { | |
console.log("reconnect", a, b) | |
}); | |
socket.on("reconnecting", function (a, b) { | |
console.log("reconnecting", a, b) | |
}); | |
socket.on("close", function () { | |
console.log("close") | |
}); | |
socket.on("hi", function (a) { | |
console.log("hi", a); | |
a != VERSION ? OpenDialog("Update Available", "Please refresh - <font color=\"#FF9933\">Press F5</font>\nto load the latest game client.\n\nIf it doesn't help try Shift+F5 or clear your browser's cache.") : (ZotataPlaySendLogin(ZotataPlayUserID, ZotataPlayAuthKey), CloseDialog()) | |
}); | |
socket.on("disconnect", function () { | |
console.log("disconnect"); | |
ShowDisconnectedDialog() | |
}); | |
socket.on("chat", function (a) { | |
debug && console.log("Receive: chat:", a); | |
ChatReceived(a.sender, a.text, a.type) | |
}); | |
socket.on("my-player-info", function (a) { | |
debug && console.log("Receive: my-player-info", a); | |
var b = g_myPlayerInfo; | |
g_myPlayerInfo = a; | |
a.location_type == LOCATION_TYPE_CHANNEL ? g_gui_location != GUI_LOCATION_SHOP && (b && b.location_type != LOCATION_TYPE_CHANNEL && SwitchToChannelScreen(), ChannelPlayerInfoUpdate(), ShopSetMyGoldCash(g_myPlayerInfo.gold, g_myPlayerInfo.cash)) : a.location_type == LOCATION_TYPE_ROOM && (!b || b && b.location_type != LOCATION_TYPE_ROOM) && SwitchToRoomScreen() | |
}); | |
socket.on("p", function (a, b) { | |
debug && console.log("Receive: p", a, b); | |
void 0 != g_myPlayerInfo && (g_myPlayerInfo.location_type == LOCATION_TYPE_CHANNEL ? ChannelUpdatePlayersList(a) : g_myPlayerInfo.location_type == LOCATION_TYPE_ROOM && (g_room_players = a, RoomUpdatePlayers(a), RoomUpdateWorthGP(b), g_game && g_game.ChangePlayersInRoom(a))) | |
}); | |
socket.on("j", function (a) { | |
debug && console.log("Receive: j", a); | |
ChannelPlayerJoined(a[0], a[1], a[2]) | |
}); | |
socket.on("l", function (a) { | |
debug && console.log("Receive: l", a); | |
ChannelPlayerLeft(a) | |
}); | |
socket.on("room-state", function (a) { | |
debug && console.log("Receive: room-state:", a); | |
if (a.chat && g_myPlayerInfo.location_type == LOCATION_TYPE_CHANNEL) { | |
ChannelChatClear(); | |
for (var b = 0; b < a.chat.length; b++) ChatReceived(a.chat[b].sender, a.chat[b].text, a.chat[b].type); | |
ChatReceived("", 'Welcome to DragonBound 2.8! - <a href="http://www.facebook.com/pages/DragonBound-Community/266025740173562" target="_blank">DragonBound Community</a>', CHAT_TYPE_GM_BUGLE); | |
ChatReceived("", "Updates: 19/8 - Wind+AvatarsOff | 14/8 - New Avatars | 8/8 - New Mobiles", CHAT_TYPE_GM_BUGLE) | |
} | |
a.room && RoomUpdate(a.room) | |
}); | |
socket.on("c", function (a) { | |
debug && console.log("Receive: c", a); | |
ChannelRoomsUpdate(a) | |
}); | |
socket.on("r", function (a) { | |
debug && console.log("Receive: r", a); | |
ChannelRoomUpdate(a) | |
}); | |
socket.on("game-start", function (a) { | |
debug && console.log("Receive: game-start", a); | |
g_game && (g_game.Destructor(), g_game = void 0); | |
SwitchToGameScreen(); | |
g_game = new ZotataGB(g_myPlayerInfo.username, a); | |
SendSelectedItemsForThisGame(g_items) | |
}); | |
socket.on("play", function (a) { | |
debug && console.log("Receive: play", a); | |
g_game ? g_game.QueueAddCommand("play", a) : window.location.reload() | |
}); | |
socket.on("update", function (a) { | |
debug && console.log("Receive: update", a); | |
g_game ? g_game.QueueAddCommand("update", a) : window.location.reload() | |
}); | |
socket.on("dead", function (a) { | |
debug && console.log("Receive: dead", a); | |
g_game ? g_game.QueueAddCommand("dead", a) : window.location.reload() | |
}); | |
socket.on("game-over", function (a) { | |
debug && console.log("Receive: game-over", a); | |
g_game ? g_game.QueueAddCommand("game-over", a) : window.location.reload() | |
}); | |
socket.on("items", function (a) { | |
debug && console.log("Receive: items", a); | |
void 0 == a || void 0 == a.length || (GameSetItems(a[0]), a[1] != ITEM_NONE && ($("#btnShotSS").fadeOut(), 2 == GetSelectedShotType() && SelectShotType(1))) | |
}); | |
socket.on("master-timer", function (a) { | |
debug && console.log("Receive: master-timer", a); | |
MasterTimer(a) | |
}); | |
socket.on("my-avatars", function (a) { | |
debug && console.log("Receive: my-avatars", a); | |
ShopSetMyItems2(a[0]); | |
ShopSetMyGoldCash(a[1], a[2]) | |
}); | |
socket.on("alert", function (a, b, c, d) { | |
debug && console.log("Receive: alert", a, b, c, d); | |
void 0 == c ? 0 == b.indexOf("You purchased") ? OpenDialog(a, b, DIALOG_BUTTONS_OK, function () { | |
ShopBuyCloseDialog() | |
}) : OpenDialog(a, b, DIALOG_BUTTONS_OK) : 3 == c && OpenDialog(a, b, DIALOG_BUTTONS_OK, void 0, d) | |
}); | |
socket.on("friends", function (a) { | |
debug && console.log("Receive: friends", a); | |
UpdateFriendsList(a) | |
}); | |
socket.on("info", function (a) { | |
debug && console.log("Receive: info", a); | |
InfoDialogReceiveInfo(a) | |
}); | |
socket.on("friendreq", function (a) { | |
debug && console.log("Receive: friendreq", a); | |
OpenDialog("Friend Request", a[1] + ":\n\nCan you be my friend?", DIALOG_BUTTONS_OK_CANCEL, function (b) { | |
b && SendFriendApproved(a[0], a[3]) | |
}, a[2]) | |
}); | |
socket.on("f", function (a) { | |
debug && console.log("Receive: f", a); | |
FriendUpdate(a) | |
}); | |
socket.on("pchat", function (a, b, c) { | |
debug && console.log("Receive: pchat", a, b, c); | |
FriendPrivateChat(a, b, c) | |
}); | |
socket.on("logout", function () { | |
debug && console.log("Receive: logout"); | |
top.location = "/logout" | |
}); | |
socket.on("inactive", function () { | |
debug && console.log("Receive: inactive"); | |
OpenDialog("Hi", "Are you still here?", DIALOG_BUTTONS_OK, function () { | |
ZotataPlayChat("") | |
}, [35, 52]) | |
}) | |
}; | |
var MAP_RANDOM = -1, | |
MAP_MIRAMO = 0, | |
MAP_NIRVANA = 1, | |
MAP_METRO = 2, | |
MAP_SEA = 3, | |
MAP_ADIUM = 4, | |
MAP_DRAGON = 5, | |
MAP_COZY = 6, | |
MAP_DUMMY = 7, | |
MAP_STAR = 8, | |
MAP_METAMINE = 9, | |
MAP_CAVE = 10, | |
MAP_SECRET = 11, | |
LAST_SELECTABLE_MAP = MAP_METAMINE, | |
MAPS = [{ | |
name: "Miramo Town", | |
filename: "miramo", | |
color: "#634a4a", | |
w: 1766, | |
h: 456, | |
ground_size: 1800, | |
bg_size: 1300, | |
offset_x: 17, | |
offset_y: 1344 | |
}, { | |
name: "Nirvana", | |
filename: "nirvana", | |
color: "#5a1400", | |
w: 1600, | |
h: 310, | |
ground_size: 1600, | |
bg_size: 1200, | |
offset_x: 0, | |
offset_y: 1067 | |
}, { | |
name: "Metropolis", | |
filename: "metro", | |
color: "#634a4a", | |
w: 1800, | |
h: 715, | |
ground_size: 1800, | |
bg_size: 1300, | |
offset_x: 0, | |
offset_y: 1085 | |
}, { | |
name: "Sea Of Hero", | |
filename: "sea", | |
color: "#84b6ce", | |
w: 1600, | |
h: 629, | |
ground_size: 1600, | |
bg_size: 1200, | |
offset_x: 0, | |
offset_y: 688 | |
}, { | |
name: "Adium Root", | |
filename: "adium", | |
color: "#84b6ce", | |
w: 1800, | |
h: 372, | |
ground_size: 1800, | |
bg_size: 1300, | |
offset_x: 0, | |
offset_y: 788 | |
}, { | |
name: "Dragon", | |
filename: "dragon", | |
color: "#94424a", | |
w: 2E3, | |
h: 461, | |
ground_size: 2E3, | |
bg_size: 1300, | |
offset_x: 0, | |
offset_y: 1539 | |
}, { | |
name: "Cozy Tower", | |
filename: "cozy", | |
color: "#8c5a31", | |
w: 1649, | |
h: 396, | |
ground_size: 1800, | |
bg_size: 1300, | |
offset_x: 80, | |
offset_y: 1384 | |
}, { | |
name: "Dummy Slope", | |
filename: "dummy", | |
color: "#de7329", | |
w: 1429, | |
h: 391, | |
ground_size: 1600, | |
bg_size: 1200, | |
offset_x: 76, | |
offset_y: 1037 | |
}, { | |
name: "Star Dust", | |
filename: "star", | |
color: "#39314a", | |
w: 1345, | |
h: 425, | |
ground_size: 1800, | |
bg_size: 1300, | |
offset_x: 231, | |
offset_y: 922 | |
}, { | |
name: "Meta Mine", | |
filename: "metamine", | |
color: "#ac5008", | |
w: 1409, | |
h: 760, | |
ground_size: 1800, | |
bg_size: 1300, | |
offset_x: 196, | |
offset_y: 1020 | |
}, { | |
name: "Cave", | |
filename: "cave", | |
color: "#634a4a", | |
w: 1545, | |
h: 697, | |
ground_size: 1800, | |
bg_size: 1300, | |
offset_x: 133, | |
offset_y: 1103 | |
}, { | |
name: "Secret", | |
filename: "secret", | |
color: "#634a4a", | |
w: 1800, | |
h: 886, | |
ground_size: 1800, | |
bg_size: 1300, | |
offset_x: 0, | |
offset_y: 914 | |
}]; | |
function GetMapName(a) { | |
return a == MAP_RANDOM ? "Random" : MAPS[a].name | |
} | |
function CGround(a, b) { | |
var c = MAPS[a]; | |
this.canvas = document.getElementById("ground_canvas"); | |
this.imageData = void 0; | |
this.h = this.w = 0; | |
this.LoadFromFile("/static/images/maps/" + c.filename + ".png", b); | |
$("#map_bg").css({ | |
width: c.bg_size, | |
height: c.bg_size, | |
background: MAPS[a].color + " url(/static/images/maps/" + c.filename + "_bg.jpg)" | |
}); | |
$("#gameScreen").css("background-color", c.color) | |
} | |
CGround.prototype.LoadFromFile = function (a, b) { | |
var c = this, | |
d = new Image; | |
d.onload = function () { | |
c.w = c.canvas.width = d.width; | |
c.h = c.canvas.height = d.height; | |
$("#ground_canvas").css({ | |
width: c.w, | |
height: c.h | |
}); | |
var a = c.canvas.getContext("2d"); | |
a.drawImage(d, 0, 0); | |
c.imageData = a.getImageData(0, 0, c.canvas.width, c.canvas.height); | |
b && b() | |
}; | |
d.src = a | |
}; | |
CGround.prototype.IsPixel = function (a, b) { | |
return 0 > a || a >= this.w || 0 > b || b >= this.h ? !1 : 0 < this.imageData.data[4 * (b * this.w + a) + 3] | |
}; | |
CGround.prototype.GetPosForWalking = function (a, b, c) { | |
var d = c == PLAYER_LOOK_LEFT ? a - 1 : a + 1; | |
if (0 > d || d >= this.w) return { | |
x: a, | |
y: b, | |
stuck: !0 | |
}; | |
if (this.IsPixel(d, b)) { | |
for (c = b; c > b - WALK_WALL_LIMIT; c--) if (!this.IsPixel(d, c)) return { | |
x: d, | |
y: c | |
}; | |
return { | |
x: a, | |
y: b, | |
stuck: !0 | |
} | |
} | |
for (c = b + 1; c < this.h; c++) if (this.IsPixel(d, c)) return { | |
x: d, | |
y: c - 1 | |
}; | |
return { | |
x: d, | |
y: this.h + 100, | |
fall_and_die: !0 | |
} | |
}; | |
CGround.prototype.GetUnder = function (a, b, c) { | |
if (void 0 == this.imageData) throw Error("GetUnder - imageData = undefined"); | |
for (c = c ? b + c : this.h; b < c; b++) if (this.IsPixel(a, b)) return b - 1 | |
}; | |
CGround.prototype.GetAngle = function (a, b) { | |
if (this.IsPixel(a, b)) return debug && console.log("[CGround.GetAngle] IN-GROUND"), 0; | |
var c = this.GetUnder(a, b, 10); | |
if (void 0 == c) return debug && console.log("[CGround.GetAngle] FALLING"), 0; | |
if (c != b) return debug && console.log("[CGround.GetAngle] FLYING"), 0; | |
for (var d = c, e = 1, f = c, h = 1, g = 1; 9 >= g; g++) if (c = this.GetUnder(a - g, b - 10, 20), void 0 != c && (d += c, e++), c = this.GetUnder(a + g, b - 10, 20), void 0 != c) f += c, h++; | |
return Math.round(RadToAngle(Math.atan2((0 < h ? f / h : b) - (0 < e ? d / e : b), 19))) | |
}; | |
CGround.prototype.ExplodeAt = function (a, b, c, d) { | |
var a = Math.round(a), | |
b = Math.round(b), | |
e, f, h = this.w, | |
g = c * c, | |
j = d * d; | |
for (e = b - d - 10; e < b + d + 10; e++) for (f = a - c - 10; f < a + c + 10; f++) { | |
var i = f - a, | |
k = e - b, | |
i = i * i / g + k * k / j, | |
k = 4 * (e * h + f); | |
1 > i ? this.imageData.data[k + 3] = 0 : 1.2 > i && (this.imageData.data[k] /= 2, this.imageData.data[k + 1] /= 2, this.imageData.data[k + 2] /= 2) | |
} | |
this.canvas.getContext("2d").putImageData(this.imageData, 0, 0) | |
}; | |
function CCamera(a) { | |
a = MAPS[a]; | |
this.min_x = -a.offset_x + 400; | |
this.max_x = a.ground_size - 400; | |
this.min_y = -a.offset_y + 300; | |
this.max_y = a.ground_size - a.offset_y - 300 + 84; | |
this.bg_aspect_ratio_x = (a.bg_size - 800) / (a.ground_size - 600); | |
this.bg_aspect_ratio_y = (a.bg_size - 600 + 84) / (a.ground_size - 600 + 84); | |
this.bg_offset_x = a.offset_x; | |
this.bg_offset_y = a.offset_y; | |
this.FocusAt(0, 0, !1) | |
} | |
CCamera.prototype.FocusAt = function (a, b, c, d) { | |
var e; | |
c && (e = Math.sqrt((this.x - a) * (this.x - a) + (this.y - b) - (this.y - b)), 30 > e && (c = !1)); | |
a < this.min_x ? a = this.min_x : a > this.max_x && (a = this.max_x); | |
b < this.min_y ? b = this.min_y : b > this.max_y && (b = this.max_y); | |
this.x = a; | |
this.y = b; | |
if (d) { | |
var f = this; | |
$("#camera").promise().done(function () { | |
f.Set(a, b, c, e) | |
}) | |
} else this.Set(a, b, c, e) | |
}; | |
CCamera.prototype.MoveBy = function (a, b, c) { | |
this.FocusAt(this.x + a, this.y + b, c) | |
}; | |
CCamera.prototype.Set = function (a, b, c, d) { | |
var a = -(a - 400), | |
b = -(b - 300), | |
e = (a - this.bg_offset_x) * this.bg_aspect_ratio_x, | |
f = (b - this.bg_offset_y) * this.bg_aspect_ratio_y; | |
c ? ($("#camera").stop(!0).animate({ | |
left: a, | |
top: b | |
}, d), $("#map_bg").stop(!0).animate({ | |
left: e, | |
top: f | |
}, d)) : ($("#camera").stop(!0).css({ | |
left: a, | |
top: b | |
}), $("#map_bg").stop(!0).css({ | |
left: e, | |
top: f | |
})) | |
}; | |
function CPlayer(a, b, c) { | |
if (void 0 == a || void 0 == a.name || void 0 == a.n) throw Error("CPlayer - bad arguments", a); | |
this.player = a; | |
this.x = a.x; | |
this.y = a.y; | |
this.body = void 0; | |
this.look = a.look; | |
this.ang = a.ang; | |
this.minang = a.minang; | |
this.maxang = a.maxang; | |
this.team = a.team; | |
this.hp = this.maxhp = a.hp; | |
this.shield = this.maxshield = a.shield; | |
this.rank = a.rank; | |
this.mobile = a.mobile; | |
this.guild = a.guild; | |
this.delay = this.delay_before = a.delay ? a.delay : 0; | |
this.lastturn = a.lastturn; | |
this.gender = a.gender; | |
this.mobile = a.mobile; | |
this.aim = [new Vector(a.aim[0], a.aim[1]), new Vector(a.aim[2], a.aim[3]), new Vector(a.aim[4], a.aim[5])]; | |
this.is_me = b; | |
this.user_id = a.user_id; | |
this.name = a.name; | |
this.player_number_in_game = a.n; | |
this.div_id = "#Player" + this.player_number_in_game; | |
this.is_alive = !0; | |
this.last_sent_look = this.last_sent_y = this.last_sent_x = void 0; | |
this.ground = c; | |
debug && console.log("[CPlayer] Create Player:", this.name, a); | |
this.Init() | |
} | |
CPlayer.prototype.Shoot = function (a, b, c) { | |
SendPlayerShoot(this.x, this.y, this.body, this.look, this.ang, a, b, c); | |
a = (this.look == PLAYER_LOOK_LEFT ? 180 - this.ang : this.ang) - this.body; | |
90 < a && (a = 180 - a); | |
0 > a ? ($("#LastAngleDigit-").show(), a *= -1) : $("#LastAngleDigit-").hide(); | |
$("#LastAngleDigit1").removeClass().addClass("LastAngleDigit LastAngleDigit" + Math.floor(a / 10)); | |
$("#LastAngleDigit2").removeClass().addClass("LastAngleDigit LastAngleDigit" + a % 10) | |
}; | |
CPlayer.prototype.PassTurn = function (a) { | |
SendPlayerPassTurn(this.x, this.y, this.body, this.look, this.ang, a) | |
}; | |
CPlayer.prototype.SendPosUpdate = function () { | |
if (this.x != this.last_sent_x || this.y != this.last_sent_y || this.look != this.last_sent_look) SendPlayerMove(this.x, this.y, this.body, this.look, this.ang), this.last_sent_x = this.x, this.last_sent_y = this.y, this.last_sent_look = this.look | |
}; | |
CPlayer.prototype.UseItem = function (a) { | |
SendPlayerUseItem(a) | |
}; | |
CPlayer.prototype.UpdateHpShieldGraphic = function () { | |
var a = this.maxhp + this.maxshield, | |
b = 76 * this.hp / a, | |
a = 76 * this.shield / a; | |
$(this.div_id + " .PlayerHPBox .PlayerHP").css({ | |
backgroundColor: "#63b64a", | |
width: b | |
}); | |
$(this.div_id + " .PlayerHPBox .PlayerShield").css({ | |
width: a, | |
left: b | |
}) | |
}; | |
CPlayer.prototype.Init = function () { | |
var a = $(this.div_id), | |
b = $(this.div_id + " .PlayerMobile"); | |
a.show().css("opacity", "1.0"); | |
a.css({ | |
left: this.x, | |
top: this.y | |
}); | |
$(this.div_id + " .PlayerName").html(this.name).removeClass("ColorTeamA").removeClass("ColorTeamB").addClass("ColorTeam" + ("A" == this.team ? "A" : "B")); | |
$(this.div_id + " .PlayerRank").removeClass().addClass("PlayerRank rank rank" + this.rank); | |
this.UpdateHpShieldGraphic(); | |
this.is_me ? $(this.div_id + " .PlayerAimCircle").show() : $(this.div_id + " .PlayerAimCircle").hide(); | |
$(this.div_id + " .PlayerMobile").removeClass().addClass("PlayerMobile mobile" + this.mobile); | |
"f" == this.gender && $(this.div_id + " .PlayerMobile").addClass("female"); | |
this.ani_image = new CPlayerGraphic(this.div_id + " .PlayerMobile", this.mobile, this.player.avatars[0], this.player.avatars[1], this.player.avatars[2], this.player.avatars[3], !1); | |
this.ChangedShot(GetSelectedShotType()); | |
$(this.div_id + " .PlayerAimLimitMin").css("rotate", 180 + this.minang + "deg"); | |
$(this.div_id + " .PlayerAimLimitMax").css("rotate", 180 + this.maxang + "deg"); | |
this.Fall(); | |
b.css({ | |
scaleX: 1, | |
scaleY: 1 | |
}); | |
this.ChangeAngleTo(this.ang, !0); | |
if (MOBILE[this.mobile]) { | |
b = []; | |
for (a = 0; a < MOBILE[this.mobile].explodes.length; a++) { | |
var c = EXPLODE[MOBILE[this.mobile].explodes[a]]; | |
c && c.file && b.push("/static/images/explodes/" + c.file) | |
} | |
for (a = 0; a < MOBILE[this.mobile].bullets.length; a++)(c = BULLET[MOBILE[this.mobile].bullets[a]]) && c.file && b.push("/static/images/bullets/" + c.file); | |
preloadImages(b) | |
} | |
}; | |
CPlayer.prototype.Remove = function () { | |
this.ani_image.remove() | |
}; | |
CPlayer.prototype.Walk = function (a) { | |
this.Look(a); | |
var b = this.body, | |
a = this.ground.GetPosForWalking(this.x, this.y, a); | |
if (a.fall_and_die) this.x = a.x, this.y = a.y, b = 0, $(this.div_id).css({ | |
left: a.x | |
}).animate({ | |
top: a.y | |
}, 2E3), debug && console.log("Player fall and died"), this.SendPosUpdate(), g_game.PassTurn(); | |
else { | |
if (a.stuck) return !1; | |
this.x = a.x; | |
this.y = a.y; | |
$(this.div_id).css({ | |
left: a.x, | |
top: a.y | |
}); | |
b = this.ground.GetAngle(a.x, a.y) | |
} | |
a = $(this.div_id + " .PlayerMobile"); | |
this.body != b && (this.body = b, this.UpdateGuiAngle(), 0 == a.queue("fx") ? a.css({ | |
rotate: this.body + "deg", | |
scaleX: this.look == PLAYER_LOOK_LEFT ? 1 : -1 | |
}) : a.css({ | |
rotate: this.body + "deg" | |
})); | |
return !0 | |
}; | |
CPlayer.prototype.Look = function (a) { | |
this.look != a && (a == PLAYER_LOOK_LEFT ? this.look = PLAYER_LOOK_LEFT : a == PLAYER_LOOK_RIGHT && (this.look = PLAYER_LOOK_RIGHT), a = $(this.div_id + " .PlayerMobile"), a.stop(), a.animate({ | |
scaleX: this.look == PLAYER_LOOK_LEFT ? 1 : -1 | |
}, 300), this.UpdateGuiAngle()) | |
}; | |
CPlayer.prototype.ChangeAngleTo = function (a, b) { | |
a > this.maxang && (a = this.maxang); | |
a < this.minang && (a = this.minang); | |
if (this.ang != a || b) this.ang = a, $(this.div_id + " .PlayerAngleMarker").css("rotate", 180 + this.ang + "deg"), this.UpdateGuiAngle() | |
}; | |
CPlayer.prototype.UpdateGuiAngle = function () { | |
if (this.is_me) { | |
var a = (this.look == PLAYER_LOOK_LEFT ? 180 - this.ang : this.ang) - this.body; | |
90 < a && (a = 180 - a); | |
$("#UIAngleDigit1").removeClass(); | |
0 > a && ($("#UIAngleDigit1").addClass("AngleDigit-"), a *= -1); | |
$("#UIAngleDigit2").removeClass().addClass("AngleDigit" + Math.floor(a / 10)); | |
$("#UIAngleDigit3").removeClass().addClass("AngleDigit" + a % 10) | |
} | |
}; | |
CPlayer.prototype.Fall = function () { | |
if (this.is_alive) { | |
var a = this.ground.GetUnder(this.x, this.y); | |
if (void 0 == a) { | |
debug && console.log("Player fall and die"); | |
this.y = 2E3; | |
var b = this; | |
$(this.div_id).animate({ | |
top: this.y | |
}, 4E3, "linear", function () { | |
$(b).hide() | |
}); | |
this.is_alive = !1 | |
} else if (a != this.y && (this.y = a, $(this.div_id).animate({ | |
top: this.y | |
}, 500)), a = this.ground.GetAngle(this.x, this.y), a != this.body) this.body = a, $(this.div_id + " .PlayerMobile").css("rotate", this.body + "deg"), this.UpdateGuiAngle() | |
} | |
}; | |
CPlayer.prototype.MoveTo = function (a, b, c, d) { | |
if (this.is_alive) if (void 0 != c && this.look != c && (this.look = c, $(this.div_id + " .PlayerMobile").css("scaleX", c == PLAYER_LOOK_LEFT ? 1 : -1)), this.x = a, this.y = b, d) $(this.div_id).stop(!0).css({ | |
left: a, | |
top: b | |
}), this.Fall(); | |
else { | |
var e = this; | |
$(this.div_id).stop(!0).animate({ | |
left: a, | |
top: b | |
}, 1E3, function () { | |
e.Fall() | |
}) | |
} | |
}; | |
CPlayer.prototype.ChangeHPShield = function (a, b) { | |
void 0 == b && (b = 0); | |
var c = this.hp - a + (this.shield - b); | |
this.hp = a; | |
this.shield = b; | |
var d = this.maxhp + this.maxshield, | |
e = 76 * this.hp / d; | |
0 < this.maxshield && (d = 76 * this.shield / d, $(this.div_id + " .PlayerHPBox .PlayerShield").css({ | |
width: d | |
})); | |
if (0 < c) { | |
new CDamageEffect(this.x - 30, this.y - 30, - c, this.player_number_in_game, g_game.turn_number); | |
0 > this.hp && (this.is_alive = !1, debug && console.log("player " + this.name + " died by damage")); | |
var c = this.hp / this.maxhp, | |
f = this; | |
$(this.div_id + " .PlayerHPBox .PlayerHP").css({ | |
backgroundColor: 0.3 >= c ? "#c61000" : "#63b64a" | |
}).animate({ | |
width: e | |
}, g_graphics_high ? 400 : 0, function () { | |
f.is_alive || $(f.div_id).animate({ | |
opacity: 0 | |
}, 1500, function () { | |
$(f.div_id).hide() | |
}) | |
}) | |
} else new CDamageEffect(this.x - 30, this.y - 60, - c, this.player_number_in_game, g_game.turn_number) | |
}; | |
CPlayer.prototype.ChangeAliveTo = function (a) { | |
if (!0 == this.is_alive && !1 == a) { | |
debug && console.log("[CPlayer.ChangeAliveTo] player", this.name, "died"); | |
this.is_alive = !1; | |
var b = $(this.div_id); | |
b.animate({ | |
opacity: 0 | |
}, 1500, "linear", function () { | |
b.hide() | |
}) | |
} | |
}; | |
CPlayer.prototype.ChangeMyTurn = function (a) { | |
if (a) { | |
var b = $("#Player" + this.player_number_in_game + " .Turn"); | |
g_graphics_high ? b.css({ | |
bottom: 100, | |
"background-position-y": -159, | |
height: 29 | |
}).slideDown("slow") : b.css({ | |
bottom: 100, | |
"background-position-y": -159, | |
height: 29 | |
}).show(); | |
var c; | |
(c = function () { | |
b.animate({ | |
"background-position-y": -159 | |
}, 0).animate({ | |
bottom: 70 | |
}, 1E3).animate({ | |
"background-position-y": -189 | |
}, 0).animate({ | |
bottom: 100 | |
}, 1E3, c) | |
})() | |
} else g_graphics_high ? $(".Turn").stop(!0).css("height", 29).slideUp("slow").hide() : $(".Turn").stop(!0).css("height", 29).hide() | |
}; | |
CPlayer.prototype.ChangeDelay = function (a, b) { | |
a != this.delay && (this.delay_before = this.delay, this.delay = a); | |
this.lastturn = b | |
}; | |
CPlayer.prototype.ChangedShot = function (a) { | |
a = this.aim[a]; | |
$(this.div_id + " .PlayerAimCircle").css({ | |
left: -a.x, | |
top: a.y | |
}) | |
}; | |
CPlayer.prototype.TeleportTo = function (a, b) { | |
this.MoveTo(a, b) | |
}; | |
function RoomGUI() { | |
$("#roomChat").tinyscrollbar({ | |
size: 58 | |
}); | |
$("#roomButtonBack").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
SendRoomLeave() | |
}); | |
$("#roomButtonReady").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
CheckBrowserAbilities(!0) && (AutoReadyStop(), SendRoomChangeReady(!g_myPlayerInfo.is_ready)) | |
}); | |
$("#roomButtonStart").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
CheckBrowserAbilities(!0) && SendRoomGameStart() | |
}); | |
$("#roomButtonChangeTeam").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
SendRoomChangeTeam("A" == g_myPlayerInfo.team ? "B" : "A") | |
}); | |
$("#roomButtonMobile").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
SendRoomChangeMobile((g_myPlayerInfo.mobile + 1) % NUMBER_OF_MOBILES) | |
}); | |
$(".playerInRoom").click(function () { | |
AddToChatInput($(this).children(".roomPlayerName").html()) | |
}); | |
$("#itemDual").click(function () { | |
RoomSelectItem(ITEM_DUAL) | |
}); | |
$("#itemTeleport").click(function () { | |
RoomSelectItem(ITEM_TELEPORT) | |
}); | |
$("#itemSlot0").click(function () { | |
RoomRemoveItemFromSlot(0) | |
}); | |
$("#itemSlot1").click(function () { | |
RoomRemoveItemFromSlot(1) | |
}); | |
$("#itemSlot2").click(function () { | |
RoomRemoveItemFromSlot(2) | |
}); | |
$("#itemSlot3").click(function () { | |
RoomRemoveItemFromSlot(3) | |
}); | |
$("#itemSlot4").click(function () { | |
RoomRemoveItemFromSlot(4) | |
}); | |
$("#itemSlot5").click(function () { | |
RoomRemoveItemFromSlot(5) | |
}); | |
$("#roomInput").bind("keyup", function (a) { | |
13 == a.which && "" != this.value && (a = this.value, this.value = "", ZotataPlayChat(a)) | |
}); | |
$("#room_change_title_button").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
g_myPlayerInfo.is_master ? (FadeInDialog("dialog_change_title_div"), $("#room_change_title_input").focus()) : OpenDialog("Not Room Master", "Sorry, only the room master can change the room title.", 1) | |
}); | |
$("#room_options_button").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
g_myPlayerInfo.is_master ? (FixRoomOptionsDialog(), FadeInDialog("dialog_room_options")) : OpenDialog("Not Room Master", "Sorry, only the room master can change the room options.", 1) | |
}); | |
$("#dialog_change_title_cancel").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ExplodeDialog("dialog_change_title_div") | |
}); | |
$("#dialog_change_title_ok").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
SendRoomChangeTitle($("#room_change_title_input").val()); | |
ExplodeDialog("dialog_change_title_div") | |
}); | |
$(".roomBotSelect").click(function (a) { | |
a.stopPropagation(); | |
$("#select_bot_div").is(":visible") ? $("#select_bot_div").slideUp(g_graphics_high ? "slow" : 0) : (AudioPlay(AUDIO_BUTTON_SELECT2), a = Number($(this).parent().attr("id")[12]), OpenBotSelectDialog(a)) | |
}); | |
$(".roomBotRemove").click(function (a) { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
a.stopPropagation(); | |
a = Number($(this).parent().attr("id")[12]); | |
SendSelectBot(a, - 1) | |
}); | |
$(".add_bot_button").click(function (a) { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
a.stopPropagation(); | |
a = Number($(this).attr("id")[12]); | |
OpenBotSelectDialog(a) | |
}); | |
$("body").click(function () { | |
$("#select_bot_div").is(":visible") && $("#select_bot_div").slideUp(g_graphics_high ? "slow" : 0) | |
}); | |
$(".roomPlayerInfo").click(function (a) { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
InfoDialogOpenFor($(this).attr("user_id")); | |
a.stopPropagation() | |
}); | |
$("#infoClose").click(function (a) { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ExplodeDialog("playerInfoDialog"); | |
a.stopPropagation() | |
}); | |
$("#infoAddBuddy").click(function (a) { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
SendAddFriendRequest($(this).attr("user_id")); | |
a.stopPropagation() | |
}); | |
$("#infoChat").click(function (a) { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
ChatDialogCreate($(this).attr("user_id"), $("#infoName").html()); | |
a.stopPropagation() | |
}); | |
$("#room_item_buddy_tab").click(function (a) { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
a.stopPropagation(); | |
a = $("#room_item_buddy_tab"); | |
a.hasClass("buddy") ? (a.removeClass("buddy"), $("#friendsList").hide(), $("#friendsListExtra").hide()) : (a.addClass("buddy"), $("#friendsList").show().tinyscrollbar_update("top"), $("#friendsListExtra").show()) | |
}); | |
RoomOptionsDialogGUI() | |
} | |
function RoomOptionsPressedOK() { | |
var a, b; | |
a = $("#RoomOptionsPlayers"); | |
a = a.hasClass("players1v1") ? 2 : a.hasClass("players2v2") ? 4 : a.hasClass("players3v3") ? 6 : a.hasClass("players1vB") ? 1 : a.hasClass("players2vB") ? 2 : a.hasClass("players3vB") ? 3 : a.hasClass("players4vB") ? 4 : 8; | |
b = $("#RoomOptionsMode").hasClass("gameModeNormal") ? GAME_MODE_NORMAL : GAME_MODE_BOSS; | |
var c = Number($("#RoomOptionsMapImage").attr("class").substring(8)), | |
d = "ON" == $("#RoomOptionsAvatars").html() ? 1 : 0, | |
e = Number($("#RoomOptionsWind").html()); | |
SendRoomOptions(a, b, c, d, e) | |
} | |
function FixRoomOptionsDialog() { | |
if ($("#RoomOptionsMode").hasClass("gameModeBoss")) { | |
$("#RoomOptionsAvatarsPrev").hide(); | |
$("#RoomOptionsAvatarsNext").hide(); | |
$("#RoomOptionsAvatars").html("ON").css("color", "#00ff00"); | |
$("#RoomOptionsAvatarsGP").html(""); | |
$("#RoomOptionsMapPrev").hide(); | |
$("#RoomOptionsMapNext").hide(); | |
var a = MAP_RANDOM; | |
$("#RoomOptionsMapImage").removeClass().addClass("room_map" + a); | |
$("#RoomOptionsMapName").html(GetMapName(a)) | |
} else $("#RoomOptionsAvatarsPrev").show(), $("#RoomOptionsAvatarsNext").show(), $("#RoomOptionsMapPrev").show(), $("#RoomOptionsMapNext").show() | |
} | |
function RoomOptionsDialogGUI() { | |
$("#RoomOptionsCancel").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
g_graphics_high ? $("#dialog_room_options").effect("explode") : $("#dialog_room_options").hide() | |
}); | |
$("#RoomOptionsOK").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
RoomOptionsPressedOK(); | |
g_graphics_high ? $("#dialog_room_options").effect("explode") : $("#dialog_room_options").hide() | |
}); | |
$("#RoomOptionsNumPlayersPrev").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
var a = $("#RoomOptionsPlayers"), | |
b; | |
b = $("#RoomOptionsMode").hasClass("gameModeNormal") ? a.hasClass("players1v1") ? "players4v4" : a.hasClass("players2v2") ? "players1v1" : a.hasClass("players3v3") ? "players2v2" : "players3v3" : a.hasClass("players1vB") ? "players4vB" : a.hasClass("players2vB") ? "players1vB" : a.hasClass("players3vB") ? "players2vB" : "players3vB"; | |
a.removeClass().addClass(b) | |
}); | |
$("#RoomOptionsNumPlayersNext").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
var a = $("#RoomOptionsPlayers"), | |
b; | |
b = $("#RoomOptionsMode").hasClass("gameModeNormal") ? a.hasClass("players1v1") ? "players2v2" : a.hasClass("players2v2") ? "players3v3" : a.hasClass("players3v3") ? "players4v4" : "players1v1" : a.hasClass("players1vB") ? "players2vB" : a.hasClass("players2vB") ? "players3vB" : a.hasClass("players3vB") ? "players4vB" : "players1vB"; | |
a.removeClass().addClass(b) | |
}); | |
$("#RoomOptionsModePrev, #RoomOptionsModeNext").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
var a = $("#RoomOptionsMode"), | |
b, c = $("#RoomOptionsPlayers"), | |
d; | |
a.hasClass("gameModeNormal") ? (b = "gameModeBoss", d = c.hasClass("players1v1") ? "players1vB" : c.hasClass("players2v2") ? "players2vB" : c.hasClass("players3v3") ? "players3vB" : "players4vB") : (b = "gameModeNormal", d = c.hasClass("players1vB") ? "players1v1" : c.hasClass("players2vB") ? "players2v2" : c.hasClass("players3vB") ? "players3v3" : "players4v4", "ON" == $("#RoomOptionsAvatars").html() && $("#RoomOptionsAvatarsGP").html("+10% GP")); | |
a.removeClass().addClass(b); | |
c.removeClass().addClass(d); | |
$("#RoomOptionsModeIcon").removeClass().addClass("iconMode" + b.slice(8)); | |
FixRoomOptionsDialog() | |
}); | |
$("#RoomOptionsMapPrev").click(function () { | |
if (!$("#RoomOptionsMode").hasClass("gameModeBoss")) { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
var a = $("#RoomOptionsMapImage"), | |
b = Number(a.attr("class").substring(8)) - 1; | |
b < MAP_RANDOM && (b = LAST_SELECTABLE_MAP); | |
a.removeClass().addClass("room_map" + b); | |
$("#RoomOptionsMapName").html(GetMapName(b)) | |
} | |
}); | |
$("#RoomOptionsMapNext").click(function () { | |
if (!$("#RoomOptionsMode").hasClass("gameModeBoss")) { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
var a = $("#RoomOptionsMapImage"), | |
b = Number(a.attr("class").substring(8)) + 1; | |
b > LAST_SELECTABLE_MAP && (b = MAP_RANDOM); | |
a.removeClass().addClass("room_map" + b); | |
$("#RoomOptionsMapName").html(GetMapName(b)) | |
} | |
}); | |
$("#RoomOptionsAvatarsPrev, #RoomOptionsAvatarsNext").click(function () { | |
if (!$("#RoomOptionsMode").hasClass("gameModeBoss")) { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
var a = $("#RoomOptionsAvatars"); | |
"OFF" == a.html() ? (a.html("ON").css("color", "#00ff00"), $("#RoomOptionsAvatarsGP").html("+10% GP")) : (a.html("OFF").css("color", "#ff0000"), $("#RoomOptionsAvatarsGP").html("")) | |
} | |
}); | |
$("#RoomOptionsWindNext").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
var a = $("#RoomOptionsWind"), | |
b = Number(a.html()), | |
c; | |
0 == b ? (b = 12, c = 5) : 12 == b ? (b = 26, c = 10) : 26 == b ? (b = 50, c = 15) : c = b = 0; | |
a.html(b).css("color", 0 == b ? "#ff0000" : "#00ff00"); | |
$("#RoomOptionsWindGP").html(0 == c ? "" : "+" + c + "% GP") | |
}); | |
$("#RoomOptionsWindPrev").click(function () { | |
AudioPlay(AUDIO_BUTTON_SELECT2); | |
var a = $("#RoomOptionsWind"), | |
b = Number(a.html()), | |
c; | |
0 == b ? (b = 50, c = 15) : 50 == b ? (b = 26, c = 10) : 26 == b ? (b = 12, c = 5) : c = b = 0; | |
a.html(b).css("color", 0 == b ? "#ff0000" : "#00ff00"); | |
$("#RoomOptionsWindGP").html(0 == c ? "" : "+" + c + "% GP") | |
}) | |
} | |
function InfoDialogOpenFor(a) { | |
$("#infoAddBuddy").attr("user_id", a); | |
$("#infoChat").attr("user_id", a); | |
$("#infoName").html(""); | |
$("#infoRanking").html(""); | |
$("#infoGP").html(""); | |
$("#infoDamage").html(""); | |
$("#infoWinRate").html(""); | |
$("#infoGender").html(""); | |
$("#infoImage").attr("src", ""); | |
$("#infoRank").removeClass().addClass("rank rank25"); | |
$("#infoLoading").show(); | |
FadeInDialog("playerInfoDialog"); | |
SendGetPlayerInfo(a) | |
} | |
var INFO_INDEX_USER_ID = 0, | |
INFO_INDEX_GAME_ID = 1, | |
INFO_INDEX_RANKING = 2, | |
INFO_INDEX_RANK = 3, | |
INFO_INDEX_GP = 4, | |
INFO_INDEX_GENDER = 5, | |
INFO_INDEX_FACEBOOK_ID = 6, | |
INFO_INDEX_DAMAGE = 7, | |
INFO_INDEX_WINRATE = 8; | |
function InfoDialogReceiveInfo(a) { | |
var b = a[INFO_INDEX_GENDER]; | |
$("#infoLoading").hide(); | |
$("#infoName").html(a[INFO_INDEX_GAME_ID]); | |
$("#infoRanking").html(a[INFO_INDEX_RANKING]); | |
$("#infoGP").html(a[INFO_INDEX_GP]); | |
$("#infoDamage").html(a[INFO_INDEX_DAMAGE]); | |
$("#infoWinRate").html(a[INFO_INDEX_WINRATE]); | |
$("#infoGender").html(b == GENDER_MALE ? "Male" : "Female"); | |
$("#infoRank").removeClass().addClass("rank rank" + a[INFO_INDEX_RANK]); | |
a = a[INFO_INDEX_FACEBOOK_ID]; | |
a = "" == a ? b == GENDER_FEMALE ? "/static/images/fb_girl.gif" : "/static/images/fb_boy.gif" : "http://graph.facebook.com/" + a + "/picture?type=large"; | |
$("#infoImage").attr("src", a) | |
} | |
function OpenBotSelectDialog(a) { | |
var b = g_myPlayerInfo.unlock; | |
g_bot_select_for_slot = a; | |
for (var c = $("#select_bot_div"), d = "", e, f, h, g, j, i, k, l = 0; l < COMPUTER_PLAYER.length; l++) k = COMPUTER_PLAYER[l], l <= b ? (e = k.rank, f = k.name, h = k.gp, g = k.atk, j = k.def, i = k.life, k = k.dig) : (e = 25, f = "???", h = k.gp, g = j = i = k = "??"), d += '<div class="bs_line" id=' + l + '> <div class="bs_rank rank rank' + e + '"></div> <div class="bs_name">' + f + '</div> <div class="bs_gp">GP:' + h + "</div>", d += '<div class="bs_atk_icon stat_icon stat_icon_atk"></div> <div class="bs_atk">' + g + '</div><div class="bs_def_icon stat_icon stat_icon_def"></div> <div class="bs_def">' + j + '</div><div class="bs_life_icon stat_icon stat_icon_life"></div><div class="bs_life">' + i + '</div><div class="bs_dig_icon stat_icon stat_icon_dig"></div> <div class="bs_dig">' + k + "</div></div>"; | |
c.html(d); | |
$(".bs_line").click(function () { | |
var b = $(this).attr("id"); | |
SendSelectBot(a, b); | |
$("#select_bot_div").slideUp(g_graphics_high ? "slow" : 0); | |
AudioPlay(AUDIO_BUTTON_SELECT2) | |
}); | |
c.slideDown(g_graphics_high ? "slow" : 0) | |
} | |
function AutoReadyStartTimer() { | |
CheckBrowserAbilities(!1) && (AutoReadyStop(), g_auto_ready_timer = setTimeout(function () { | |
!$("#roomButtonStart").is(":visible") && (!1 == g_myPlayerInfo.is_ready && !g_game) && SendRoomChangeReady(!0) | |
}, 5E3)) | |
} | |
function AutoReadyStop() { | |
g_auto_ready_timer = clearTimeout(g_auto_ready_timer) | |
} | |
var g_room_timer_interval; | |
function MasterTimerTick() { | |
var a = Number($("#room_timer_text").html()); | |
0 == a ? g_room_timer_interval = clearInterval(g_room_timer_interval) : $("#room_timer_text").html(a - 1) | |
} | |
function MasterTimer(a) { | |
0 == a ? ($("#room_timer").fadeOut("slow"), $("#room_timer_text").html("0")) : ($("#room_timer_text").html(a), $("#room_timer").fadeIn("slow"), g_room_timer_interval = setInterval("MasterTimerTick()", 1E3)) | |
} | |
function RoomUpdate(a) { | |
$("#roomNumber").html(a.number); | |
$("#room_change_title_input").val(a.title); | |
var b = a.title; | |
a.pass && (b += " (" + a.pass + ")"); | |
$("#roomTitle").html(b); | |
b = a.mode == GAME_MODE_NORMAL ? "gameModeNormal" : "gameModeBoss"; | |
$("#room_game_mode").removeClass().addClass(b); | |
$("#RoomOptionsMode").removeClass().addClass(b); | |
var c; | |
a.mode == GAME_MODE_NORMAL ? (2 == a.max_players ? c = "players1v1" : 4 == a.max_players ? c = "players2v2" : 6 == a.max_players ? c = "players3v3" : 8 == a.max_players && (c = "players4v4"), $("#roomButtonChangeTeam").show()) : (1 == a.max_players ? c = "players1vB" : 2 == a.max_players ? c = "players2vB" : 3 == a.max_players ? c = "players3vB" : 4 == a.max_players && (c = "players4vB"), $("#roomButtonChangeTeam").hide()); | |
$("#room_players").removeClass().addClass(c); | |
$("#RoomOptionsPlayers").removeClass().addClass(c); | |
$("#room_map").removeClass().addClass("room_map" + a.map); | |
$("#RoomOptionsMapImage").removeClass().addClass("room_map" + a.map); | |
$("#RoomOptionsMapName").html(GetMapName(a.map)); | |
$("#room_avatars").css("color", a.ava ? "#00ff00" : "#ff0000").html(a.ava ? "ON" : "OFF"); | |
$("#RoomOptionsAvatars").css("color", a.ava ? "#00ff00" : "#ff0000").html(a.ava ? "ON" : "OFF"); | |
$("#RoomOptionsAvatarsGP").html(a.mode != GAME_MODE_BOSS && a.ava ? "+10% GP" : ""); | |
$("#room_wind").css("color", 0 == a.wind ? "#ff0000" : "#00ff00").html(a.wind); | |
$("#RoomOptionsWind").css("color", 0 == a.wind ? "#ff0000" : "#00ff00").html(a.wind); | |
c = 12 == a.wind ? 5 : 26 == a.wind ? 10 : 50 == a.wind ? 15 : 0; | |
$("#RoomOptionsWindGP").html(c ? "+" + c + "% GP" : ""); | |
$("#gp_rate").html(0 < a.rate ? "+" + a.rate + "%" : "") | |
} | |
var SIDE_A = 0, | |
SIDE_B = 1, | |
g_room_slot = [ | |
[], | |
[] | |
], | |
g_room_slot_graphic = [ | |
[], | |
[] | |
]; | |
function RoomRemoveAnimations() { | |
for (var a = SIDE_A; a <= SIDE_B; a++) for (var b = 0; 3 >= b; b++) g_room_slot_graphic[a][b] && g_room_slot_graphic[a][b].remove(); | |
g_room_slot_graphic = [ | |
[], | |
[] | |
] | |
} | |
function RoomUpdateWorthGP(a) { | |
a && ($("#gp_team_a").html("<u>Team A</u><br>" + a[0] + " GP<br>" + a[2] + "G"), $("#gp_team_b").html("<u>Team B</u><br>" + a[1] + " GP<br>" + a[3] + "G")) | |
} | |
function RoomUpdatePlayers(a) { | |
var b = 0, | |
c = 0, | |
d, e, f = 0; | |
g_room_slot = [ | |
[], | |
[] | |
]; | |
for (var h = 0; h < a.length; h++) g = a[h], "A" == g[PLAYER_INDEX_TEAM] ? (e = b, b++, d = SIDE_A) : (e = c, c++, d = SIDE_B), g_room_slot[d][e] = g; | |
for (d = SIDE_A; d <= SIDE_B; d++) for (e = 0; 3 >= e; e++) if (a = "#playerInRoom" + e + (d == SIDE_A ? "a" : "b"), b = $(a), void 0 == g_room_slot[d][e]) b.hide(); | |
else { | |
var g = g_room_slot[d][e], | |
c = g_room_slot_graphic[d][e]; | |
b.children(".roomPlayerRank").removeClass().addClass("roomPlayerRank rank rank" + g[PLAYER_INDEX_RANK]); | |
b.children(".roomPlayerName").html(g[PLAYER_INDEX_GAME_ID]); | |
void 0 == c ? g_room_slot_graphic[d][e] = new CPlayerGraphic(a + " .roomPlayerMobile", g[PLAYER_INDEX_MOBILE], g[PLAYER_INDEX_AVATARS][0], g[PLAYER_INDEX_AVATARS][1], g[PLAYER_INDEX_AVATARS][2], g[PLAYER_INDEX_AVATARS][3], "A" == g[PLAYER_INDEX_TEAM]) : (c.change_mobile(g[PLAYER_INDEX_MOBILE]), c.change(g[PLAYER_INDEX_AVATARS][0], AVATAR_TYPE_HEAD), c.change(g[PLAYER_INDEX_AVATARS][1], AVATAR_TYPE_BODY), c.change(g[PLAYER_INDEX_AVATARS][2], AVATAR_TYPE_EYES), c.change(g[PLAYER_INDEX_AVATARS][3], AVATAR_TYPE_FLAG)); | |
g[PLAYER_INDEX_GAME_ID] == g_myPlayerInfo.game_id ? (b.children(".roomPlayerMyself").show(), g_myPlayerInfo.is_ready = g[PLAYER_INDEX_IS_READY], g_myPlayerInfo.team = g[PLAYER_INDEX_TEAM], g_myPlayerInfo.mobile = g[PLAYER_INDEX_MOBILE], g_myPlayerInfo.is_master = g[PLAYER_INDEX_IS_MASTER], g[PLAYER_INDEX_IS_MASTER] ? ($("#roomButtonReady").hide(), $("#roomButtonStart").show()) : ($("#roomButtonStart").hide(), $("#roomButtonReady").show()), $("#mobile_info").removeClass().addClass("mobile_info" + g_myPlayerInfo.mobile)) : b.children(".roomPlayerMyself").hide(); | |
g[PLAYER_INDEX_IS_MASTER] ? (b.children(".roomPlayerNotReady").hide(), b.children(".roomPlayerReady").hide(), b.children(".roomPlayerMaster").show()) : (b.children(".roomPlayerMaster").hide(), g[PLAYER_INDEX_IS_READY] ? (b.children(".roomPlayerNotReady").hide(), b.children(".roomPlayerReady").show()) : (b.children(".roomPlayerNotReady").show(), b.children(".roomPlayerReady").hide())); | |
g[PLAYER_INDEX_IS_BOT] ? (g_myPlayerInfo.is_master && b.children(".roomBotSelect").show(), b.children(".roomPlayerInfo").hide(), d == SIDE_B && f++) : (b.children(".roomBotSelect").hide(), b.children(".roomPlayerInfo").attr("user_id", g[PLAYER_INDEX_USER_ID]).show()); | |
b.show() | |
} | |
$("#room_game_mode").hasClass("gameModeNormal") || !g_myPlayerInfo.is_master ? ($(".roomBotSelect").hide(), $(".roomBotRemove").hide(), $(".add_bot_button").hide()) : ($(".add_bot_button").hide(), 0 < g_myPlayerInfo.unlock && $("#add_bot_slot" + f).show(), 2 <= f ? ($(".roomBotRemove").show(), $(".roomBotSelect").hide()) : ($(".roomBotRemove").hide(), $(".roomBotSelect").show())) | |
} | |
function CheckBrowserAbilities(a) { | |
return void 0 == document.getElementById("ground_canvas").getContext ? (a && OpenDialog("Old Browser", 'Your browser is too old.<br>It does not have required features to run the game.<br><br>Please change to <a href="https://www.google.com/chrome/">Chrome</a> or <a href="http://www.mozilla.org/en-US/firefox/new/">Firefox</a> or update to <a href="http://windows.microsoft.com/en-US/internet-explorer/downloads/ie">Internet Explorer 9</a>', 1), !1) : !0 | |
} | |
function RoomSelectItem(a) { | |
var b = ITEM_SIZE[a], | |
c; | |
for (c = 0; c <= 6 - b && !(g_items[c] == ITEM_NONE && (1 == b || g_items[c + 1] == ITEM_NONE)); c++) g_items[c] != ITEM_NONE && 1 < ITEM_SIZE[g_items[c]] && c++; | |
c <= 6 - b && (g_items[c] = a, $("#itemSlot" + c).addClass(ITEM_CLASS[a])) | |
} | |
function RoomRemoveItemFromSlot(a) { | |
g_items[a] != ITEM_NONE && (g_items[a] = ITEM_NONE, $("#itemSlot" + a).removeClass()) | |
} | |
function GameSetItems(a) { | |
for (var b = 0; b < a.length; b++) { | |
var c = $("#gameItemSlot" + b); | |
c.removeClass(); | |
a[b] != ITEM_NONE && (c.addClass("item").addClass(ITEM_CLASS[a[b]]), 2 == ITEM_SIZE[a[b]] && c.addClass("big")) | |
} | |
}; | |
function RankingGUI() { | |
$("#ranking_btn_type1").click(function () { | |
LoadRanking(1) | |
}); | |
$("#ranking_btn_type2").click(function () { | |
LoadRanking(2) | |
}); | |
$("#ranking_btn_type3").click(function () { | |
LoadRanking(3) | |
}); | |
$("#ranking_btn_type4").click(function () { | |
LoadRanking(4) | |
}); | |
$("#ranking_btn_ranks").click(function () { | |
LoadRanks() | |
}); | |
$("#ranking_btn_guilds").click(function () { | |
LoadGuilds() | |
}); | |
$("#ranking_btn_howto").click(function () { | |
HowToPlay() | |
}) | |
} | |
function LoadRanks() { | |
$.get("/ranks", {}, function (a) { | |
a = JSON.parse(a); | |
if (4 != a.length) console.error("bad ranks data", a); | |
else { | |
var b = a[1].split(","), | |
c = a[2].split(","), | |
d = a[3].split(","), | |
e = b.length; | |
24 < e && (e = 24); | |
for (var a = '<br><div style="text-align: center; font-weight: bold;">Last Update:</div><div style="text-align: center;">' + a[0] + '</div><br><table width=100%><tr style="font-weight: bold;"><td><strong>Rank</strong></td><td style="text-align: center;"><b>GP</b></td><td style="text-align: center;"><b>Rule</b><td style="text-align: center;"><b># Players</b></td></tr>\n', f = e - 1; 0 <= f; f--) { | |
var h = "-"; | |
f == e - 1 ? h = "Top 1" : f == e - 2 ? h = "Next 4" : f == e - 3 ? h = "Next 16" : f <= e - 4 && 0 <= f - 12 ? h = d[f - 12] + "%" : -1 == f - 12 && (h = "100%"); | |
a += '<tr><td><div class="rank rank' + f + '"></div></td><td style="text-align: center;">' + b[f] + '</td><td style="text-align: center;">' + h + '</td><td style="text-align: center;">' + c[f] + "</td></tr>\n" | |
} | |
$("#ranking_data").html(a + '</table><br><div style="width:200px">- % applied to all players with at least 6900 GP (except the first 21 players).<br><br>- Ranking is updated every hour at about XX:10.<br><br>- Refresh (F5) to see your new rank in game.</div>') | |
} | |
}) | |
} | |
function LoadGuilds() { | |
$("#ranking_data").html("Soon...") | |
} | |
function HowToPlay() { | |
$.get("/how_to_play", {}, function (a) { | |
$("#ranking_data").html(a) | |
}) | |
} | |
function LoadRanking(a) { | |
g_is_ranking_loading || (3 == a ? g_ranking_offset -= 30 : 4 == a && (g_ranking_offset += 30), g_is_ranking_loading = !0, $.get("/ranking", { | |
type: a, | |
offset: g_ranking_offset | |
}, function (a) { | |
g_is_ranking_loading = !1; | |
g_is_ranking_loaded = !0; | |
var a = JSON.parse(a), | |
c = a.length; | |
if (3 < c) { | |
for (var d = a[0], e = a[1], f = a[2], h = a[3], g = "<table>", j = 0, i = 4; i < c; i += 5) { | |
var k = a[i], | |
l = a[i + 1], | |
m = a[i + 2], | |
n = a[i + 3], | |
o = a[i + 4], | |
g = g + "<tr"; | |
j == f && (g += ' class="ranking_me"'); | |
g += "><td>" + l + '</td><td><div class="rank rank' + m + '"></div></td><td><div class="ranking_name" user_id="' + k + '">' + n + "</div></td><td>" + o + "</td></tr>"; | |
j += 1 | |
} | |
g += "</table>"; | |
$("#ranking_title2").html(d + " Players"); | |
$(".ranking_btn").removeClass("selected"); | |
$("#ranking_btn_type" + e).addClass("selected"); | |
g_ranking_offset = h; | |
$("#ranking_data").html(g) | |
} | |
})) | |
} | |
var RANKING_SIZE = 232, | |
g_previous_w, g_previous_h, g_previous_orientation, g_aspect_ratio = 1, | |
g_no_aspect_left = 0, | |
g_no_aspect_top = 0; | |
function Resize() { | |
var a = window.innerWidth, | |
b = window.innerHeight; | |
if (!(a == g_previous_w && b == g_previous_h)) { | |
var c = g_is_show_ranking && a > RANKING_SIZE, | |
d, e, f; | |
a / 800 < b / 600 ? (d = a / 800, e = 0, f = Math.floor((b - 600 * d) / 2)) : (d = b / 600, e = Math.floor((a - 800 * d) / 2), f = 0); | |
c && e < RANKING_SIZE && (a -= RANKING_SIZE, a / 800 < b / 600 ? (d = a / 800, e = RANKING_SIZE, f = Math.floor((b - 600 * d) / 2)) : (d = b / 600, e = Math.floor((a + RANKING_SIZE - 800 * d) / 2), e < RANKING_SIZE && (e = RANKING_SIZE), f = 0)); | |
$("#container").css({ | |
scaleX: d, | |
scaleY: d, | |
left: e, | |
top: f | |
}); | |
g_aspect_ratio = d; | |
g_no_aspect_left = e; | |
g_no_aspect_top = f; | |
c ? ($("#ranking_panel").show("slow"), g_is_ranking_loaded || LoadRanking(1)) : $("#ranking_panel").hide("slow") | |
} | |
} | |
function ResizeInit() { | |
window.addEventListener("resize", Resize, !1); | |
Resize() | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment