index.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. Array.prototype._random = function() {
  2. this.sort(function(d, e) {
  3. return Math.random() <= .5 ? -1 : 1;
  4. });
  5. return this;
  6. };
  7. Array.prototype.random = function() {
  8. var d = Math.ceil(this.length / 2), e = this.length;
  9. var f = this.slice(0, d), g = this.slice(d, this.length);
  10. f._random(), g._random();
  11. for (var h = 0; h < e; h += 2) {
  12. var i = Math.floor(h / 2);
  13. f[i] && (this[h] = f[i]);
  14. g[i] && (this[h + 1] = g[i]);
  15. }
  16. this._random();
  17. return this;
  18. };
  19. Array.prototype.remove = function(d) {
  20. if (d <= 0) {
  21. this.shift();
  22. } else if (d >= this.length - 1) {
  23. this.pop();
  24. } else {
  25. var e = this.slice(0, d).concat(this.slice(d + 1, this.length));
  26. for (var f = 0, max = this.length; f < max; f++) {
  27. this.pop();
  28. }
  29. for (var f = 0, max = e.length; f < max; f++) {
  30. this.push(e[f]);
  31. }
  32. e = null;
  33. }
  34. return this;
  35. };
  36. String.prototype.format = function(d, e) {
  37. return this.replace(e || /\${([^}]*)}/g, function(f, h) {
  38. var i = d;
  39. if (h.indexOf(".") >= 0) {
  40. var j = h.split("."), k;
  41. while (k = j.shift()) {
  42. i = i[k];
  43. if (!i) break;
  44. }
  45. } else {
  46. i = i[h];
  47. }
  48. return i || "";
  49. });
  50. };
  51. var a = {};
  52. a.debug = false;
  53. a.width = 480;
  54. a.height = 760;
  55. btGame.makePublisher(a);
  56. ~function(a) {
  57. a.load = [];
  58. var d = null;
  59. a.load.add = function(e) {
  60. a.load.push(e);
  61. };
  62. a.load.start = function() {
  63. var e = a.load, f = 0, g = e.length;
  64. d = $("<div></div>");
  65. d.css({
  66. position: "absolute",
  67. top: 1,
  68. left: 1,
  69. "z-index": -1,
  70. opacity: 0,
  71. overflow: "hidden",
  72. height: 1,
  73. width: 1
  74. });
  75. $("body").append(d);
  76. a.fire("loadProgress", 0);
  77. for (var h = 0, max = e.length; h < max; h++) {
  78. var i = $("<img />");
  79. i.one("load error", function() {
  80. f++;
  81. a.fire("loadProgress", f / g);
  82. });
  83. d.append(i);
  84. var j = e[h];
  85. i.attr({
  86. "data-id": j.id || j.src,
  87. src: j.src
  88. });
  89. }
  90. };
  91. a.load.get = function(e) {
  92. return d.find("[data-id='" + e + "']");
  93. };
  94. a.on("loadProgress", function(e, f) {
  95. btGame.gameLoading(f);
  96. });
  97. }(a);
  98. ~function(a) {
  99. a.gameMap = {
  100. "1": [ "苍井空", "松岛枫", "吉泽明步", "波多野结衣", "天海翼", "麻生希", "泷泽萝拉", "冲田杏梨", "上原亚衣", "小泽玛利亚" ],
  101. "2": [ "橘梨纱", "京香JULIA", "濑亚美莉", "武藤兰", "饭岛爱", "大桥未久", "樱井莉亚", "雨宫琴音", "早乙女露依", "柚木提娜" ],
  102. "3": [ "羽田爱", "佐藤遥希", "小泽圆", "小仓奈奈", "大沢佑香", "桐谷尤莉亚", "芦名尤莉亚", "月野里沙", "西野翔", "白石瞳" ],
  103. "4": [ "立花美凉", "白鸟樱", "长濑爱", "常盘樱子", "川岛和津实", "堤莎也加", "高树玛莉亚", "古都光", "黑崎扇菜", "渡濑晶", "橘未稀", "立花瞳", "铃木麻奈美", "早川濑里奈", "明日花绮罗", "横山美雪", "北原多香子", "爱田由", "红音萤", "樱井步", "大冢咲", "穗花", "绫波芹", "春咲梓美", "黑木麻衣", "尾上若叶", "希岛爱理", "樱理惠", "美竹凉子", "瑠川莉娜", "上原Kaera", "美祢藤", "小川亚纱美", "菅野亚梨沙", "木下柚花", "小蕾", "伊泽千夏", "秋山祥子", "纹舞兰", "上原瑞穂", "大沢美加", "月野莉纱", "葵实野理", "加藤莉娜", "友田彩也香", "村上里沙", "希志爱野", "仁科百华", "椎名由奈", "冬月枫", "立花里子", "小川阿佐美", "成濑心美", "上原结衣", "里美尤利娅", "希崎杰西卡", "雾岛奈津美", "石川铃华", "桥本舞", "原干惠" ]
  104. };
  105. a.gameList = [];
  106. a.maxLevel = 30;
  107. a.currentLevel = 0;
  108. a.maxGate = 3;
  109. a.picPath = "resource/";
  110. var d = a.gameMap, e = a.picPath, f = 0;
  111. for (var g in d) {
  112. f++;
  113. var h = d[g];
  114. for (var i = 0, max = h.length; i < max; i++) {
  115. var j = h[i], k = i + 1 + (f - 1) * 10, l = e + k + ".jpg";
  116. h[i] = {
  117. key: k,
  118. name: j,
  119. pic: l
  120. };
  121. a.gameList.push(h[i]);
  122. }
  123. }
  124. a.MODE = {
  125. PIC: "picture",
  126. NAM: "name"
  127. };
  128. a.playMode = a.MODE.PIC;
  129. a.setPlayMode = function(h) {
  130. if (typeof h == "number") {
  131. if (h == 0) {
  132. a.playMode = a.MODE.PIC;
  133. } else {
  134. a.playMode = a.MODE.NAM;
  135. }
  136. } else if (h == a.MODE.PIC) {
  137. a.playMode = a.MODE.PIC;
  138. } else {
  139. a.playMode = a.MODE.NAM;
  140. }
  141. a.fire("playModeChange", a.playMode);
  142. };
  143. for (var g = 0, max = a.gameList.length; g < max; g++) {
  144. var h = a.gameList[g];
  145. a.load.add({
  146. id: h.key,
  147. src: h.pic
  148. });
  149. }
  150. a.load.start();
  151. }(a);
  152. ~function(a) {
  153. var d = $("#main .page"), e = "hide", f = 200;
  154. function g() {
  155. var h = Math.random() > .5 ? "100%" : "-100%", i = Math.random() > .5 ? "100%" : "-100%";
  156. return {
  157. left: h,
  158. top: i
  159. };
  160. }
  161. a.on("pageChange", function(h, i) {
  162. d.css(g());
  163. var j;
  164. if (typeof i === "number") {
  165. j = d.eq(i);
  166. } else {
  167. j = d.filter(i);
  168. }
  169. j.removeClass("animate");
  170. j.css(g());
  171. setTimeout(function() {
  172. j.addClass("animate");
  173. j.css({
  174. left: 0,
  175. top: 0
  176. });
  177. }, f);
  178. });
  179. }(a);
  180. ~function(a) {
  181. var d = $("#start");
  182. d.on("click", ".guessPic, .guessNam", function(e) {
  183. a.setPlayMode($(this).index() - 1);
  184. a.fire("pageChange", 1);
  185. a.fire("gameStart");
  186. });
  187. d.find(".moreLink").click(function() {
  188. $(this).attr("href", btGame.URL.getMoreGame());
  189. });
  190. }(a);
  191. ~function(a) {
  192. var d = "", e = $(".container"), f = $("#play .time"), g = $("#play .tip");
  193. var h = $(".heartList"), i = $("#play .level");
  194. a.on("playModeChange", function(k, l) {
  195. d = $(l === a.MODE.PIC ? "#template_game_pic" : "#template_game_nam").html();
  196. d = $.trim(d);
  197. });
  198. a.on("gameStart", function(k) {
  199. for (var l in a.gameMap) {
  200. a.gameMap[l].random();
  201. }
  202. j.reset();
  203. });
  204. var j = {
  205. reset: function() {
  206. a.currentLevel = 0;
  207. a.maxWrongCount = 3;
  208. a.wrongCount = 0;
  209. this.next(false);
  210. var k = 3, l = this;
  211. var m = setInterval(function() {
  212. k--;
  213. if (k <= 0) {
  214. clearInterval(m);
  215. l.timer.start();
  216. }
  217. a.fire("playPrepare", k);
  218. }, 1e3);
  219. a.fire("playPrepare", k);
  220. this.heart(3);
  221. },
  222. next: function(k) {
  223. var l = ++a.currentLevel;
  224. if (a.currentLevel > a.maxLevel) {
  225. a.fire("gameEnd");
  226. return;
  227. }
  228. var m = Math.ceil(a.currentLevel / 10), n = a.gameMap[m][l - (m - 1) * 10 - 1];
  229. var o = a.gameList.slice(0).remove(n.key - 1).random().slice(0, 3);
  230. o.push(n);
  231. o.random();
  232. a.fire("nextLevel", o, n);
  233. if (k) {
  234. this.timer.start();
  235. }
  236. },
  237. heart: function(k) {
  238. a.fire("resetHeartCount", k);
  239. },
  240. timer: {
  241. timer: null,
  242. start: function() {
  243. clearInterval(this.timer);
  244. var k = 10, l = this;
  245. a.fire("timeChange", k);
  246. this.timer = setInterval(function() {
  247. k--;
  248. a.fire("timeChange", k);
  249. if (k <= 0) {
  250. l.timeup();
  251. clearInterval(l.timer);
  252. }
  253. }, 1e3);
  254. a.isTimeup = false;
  255. },
  256. stop: function() {
  257. clearInterval(this.timer);
  258. this.timer = null;
  259. },
  260. timeup: function() {
  261. a.fire("gameEnd");
  262. a.isTimeup = true;
  263. }
  264. }
  265. };
  266. a.on("gameEnd", function() {
  267. j.timer.stop();
  268. });
  269. a.on("playPrepare", function(k) {
  270. f.html(10);
  271. });
  272. e.on("click", ".answer1, .answer2", function() {
  273. var k = $(this);
  274. if (a.wrongCount >= a.maxWrongCount || a.isPreparingNext || a.isTimeup) {
  275. return false;
  276. }
  277. var l = e.find(".gameTip");
  278. var m = k.data("key"), n = l.data("key");
  279. if (m == n) {
  280. k.addClass("right");
  281. a.isPreparingNext = true;
  282. j.timer.stop();
  283. setTimeout(function() {
  284. j.next(true);
  285. a.isPreparingNext = false;
  286. }, 1e3);
  287. } else {
  288. k.addClass("error");
  289. setTimeout(function() {
  290. k.removeClass("error");
  291. }, 2e3);
  292. a.wrongCount++;
  293. a.fire("answerWrong", a.wrongCount);
  294. }
  295. });
  296. a.on("nextLevel", function(k, l, m) {
  297. i.html(a.currentLevel);
  298. e.html(d.format({
  299. data: m,
  300. arr1: l[0],
  301. arr2: l[1],
  302. arr3: l[2],
  303. arr4: l[3]
  304. }));
  305. if (a.debug) {
  306. e.find("a[data-key='" + m.key + "']").css("background", "#99ccff");
  307. }
  308. });
  309. a.on("timeChange", function(k, l) {
  310. f.html(l);
  311. });
  312. a.on("playModeChange", function(k, l) {
  313. if (l == a.MODE.PIC) {
  314. g.html("根据提示的名字,找出对应的照片");
  315. } else {
  316. g.html("根据提示的照片,找出对应的名字");
  317. }
  318. });
  319. a.on("answerWrong", function(k, l) {
  320. a.fire("resetHeartCount", a.maxWrongCount - l);
  321. if (l >= a.maxWrongCount) {
  322. setTimeout(function() {
  323. a.fire("gameEnd");
  324. }, 500);
  325. }
  326. });
  327. a.on("resetHeartCount", function(k, l) {
  328. var m = "";
  329. for (var n = 0; n < l; n++) {
  330. m += '<em class="heart"></em>';
  331. }
  332. h.html(m);
  333. });
  334. if (a.debug) {
  335. window.b = j;
  336. a.on("nextLevel", function(k, l, m) {
  337. console.log(l);
  338. });
  339. }
  340. }(a);
  341. ~function(a) {
  342. var d = $("#prepare"), e = d.find(".text");
  343. a.on("playPrepare", function(f, g) {
  344. if (g <= 0) {
  345. d.css("top", "-100%");
  346. setTimeout(function() {
  347. d.css("top", 0);
  348. d.hide();
  349. }, 500);
  350. } else {
  351. d.show();
  352. e.html(g);
  353. }
  354. });
  355. d.hide();
  356. }(a);
  357. ~function(a) {
  358. var d = $("#end"), e = d.find(".level"), f = d.find(".title");
  359. d.on("click", ".again", function() {
  360. a.fire("pageChange", 0);
  361. return false;
  362. }).on("click", ".notify", function() {
  363. btGame.playShareTip();
  364. return false;
  365. });
  366. var g = [ {
  367. key: 0,
  368. title: "小纯洁"
  369. }, {
  370. key: 5,
  371. title: "右手战士"
  372. }, {
  373. key: 10,
  374. title: "一卷手纸"
  375. }, {
  376. key: 15,
  377. title: "痴汉体质"
  378. }, {
  379. key: 20,
  380. title: "变态绅士"
  381. }, {
  382. key: 25,
  383. title: "色魔附体"
  384. }, {
  385. key: 29,
  386. title: "阅片大湿"
  387. }, {
  388. key: 30,
  389. title: "色即是空"
  390. } ];
  391. function h(i) {
  392. var j = g[0].title;
  393. for (var k = 0, max = g.length; k < max; k++) {
  394. var l = g[k];
  395. j = l.title;
  396. if (i <= l.key) {
  397. break;
  398. }
  399. }
  400. return j;
  401. }
  402. window.c = h;
  403. a.on("gameEnd", function() {
  404. a.fire("pageChange", 2);
  405. var i = h(a.currentLevel - 1);
  406. f.html(i);
  407. e.html("LV" + (a.currentLevel - 1));
  408. var j = {
  409. level: a.currentLevel - 1,
  410. title: i
  411. };
  412. a.fire("gameResult", j);
  413. });
  414. d.find(".moreLink").click(function() {
  415. $(this).attr("href", btGame.URL.getMoreGame());
  416. });
  417. }(a);
  418. ~function(a, btGame) {
  419. a.on("gameResult", function(d, e) {
  420. var f = "我玩《岛国么么答》获得【" + e.title + "】称号,我很纯洁别怀疑!";
  421. if (e.level >= 5) {
  422. f = "我玩《岛国么么答》获得【" + e.title + "】称号,别说你没看过?";
  423. }
  424. var f = btGame.setShare({
  425. title: f
  426. });
  427. setTimeout(function() {
  428. btGame.playScoreMsg("你认出" + e.level + "个老湿,获得【" + e.title + "】称号,快去刷屏吧!");
  429. }, 300);
  430. });
  431. }(a, btGame);
  432. ~function(a, btGame) {
  433. var d = $("body,html"), e = $("#main");
  434. function f() {
  435. var g = a.width, h = window.innerWidth;
  436. var i = h / g;
  437. if (i > 1) i = 1;
  438. var j = "scale(" + i + ")";
  439. e.css({
  440. "-webkit-transform": j,
  441. "-moz-transform": j,
  442. "-o-transform": j,
  443. transform: j,
  444. top: -a.height * (1 - i) / 2,
  445. left: -g * (1 - i) / 2
  446. });
  447. if (i < 1) {
  448. d.css("height", a.height * i);
  449. } else {
  450. d.css("height", "auto");
  451. }
  452. }
  453. btGame.checkHScreen(f, false);
  454. $(function() {
  455. setTimeout(f, 1e3);
  456. });
  457. }(a, btGame);