Skip to content

Commit 57e9cb9

Browse files
committed
update js
1 parent 22e44ae commit 57e9cb9

File tree

4 files changed

+307
-306
lines changed

4 files changed

+307
-306
lines changed

memory/src/__javascript__/memory.js

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
// Transcrypt'ed from Python, 2016-06-28 12:36:56
2+
// Transcrypt'ed from Python, 2016-06-28 16:26:22
33
function memory () {
44
var __all__ = {};
55
var __world__ = __all__;
@@ -945,16 +945,15 @@ function memory () {
945945
};
946946
__all__.__call__ = __call__;
947947
(function () {
948-
var rgb2hex = JS.rgb2hex;
949-
var color1 = rgb2hex ('rgba(255,0,0,0)');
950-
var color2 = rgb2hex ('rgba(255,255,0,0)');
951-
var color3 = rgb2hex ('rgba(255,255,255,0)');
952-
var color4 = rgb2hex ('rgba(255,0,255,0)');
953-
var color5 = rgb2hex ('rgba(255,80,80,0)');
954-
var color6 = rgb2hex ('rgba(255,128,0,0)');
955-
var color7 = rgb2hex ('rgba(255,128,255,0)');
956-
var color8 = rgb2hex ('rgba(255,0,128,0)');
957-
var colors = list ([color1, color2, color3, color4, color5, color6, color7, color8]);
948+
var colors = function () {
949+
var __accu0__ = [];
950+
var __iter0__ = list ([tuple ([0, 0, 0]), tuple ([0, 0, 255]), tuple ([0, 255, 0]), tuple ([0, 255, 255]), tuple ([255, 0, 0]), tuple ([255, 0, 255]), tuple ([255, 255, 0]), tuple ([255, 255, 255])]);
951+
for (var __index0__ = 0; __index0__ < __iter0__.length; __index0__++) {
952+
var color = __iter0__ [__index0__];
953+
__accu0__.append (JS.rgb2hex ('rgba({}, 0)'.format (color)));
954+
}
955+
return __accu0__;
956+
} ();
958957
var allcolors = function () {
959958
var __accu0__ = [];
960959
var __iter0__ = zip (colors, colors);
@@ -1039,7 +1038,7 @@ function memory () {
10391038
sprite.num = num;
10401039
sprite.content = color;
10411040
sprite.showed = false;
1042-
var rectb = self.game.rectangle (128, 128, 'blue');
1041+
var rectb = self.game.rectangle (128, 128, 'lightGray');
10431042
rectb.x = posx;
10441043
rectb.y = posy;
10451044
rectb.num = num;
@@ -1051,13 +1050,13 @@ function memory () {
10511050
var Memory = __class__ ('Memory', [object], {
10521051
get __init__ () {return __get__ (this, function (self, width, height) {
10531052
if (typeof width == 'undefined' || (width != null && width .__class__ == __kwargdict__)) {;
1054-
var width = 512;
1053+
var width = 524;
10551054
};
10561055
if (typeof height == 'undefined' || (height != null && height .__class__ == __kwargdict__)) {;
1057-
var height = 512;
1056+
var height = 524;
10581057
};
10591058
self.game = hexi (width, height, self.setup);
1060-
self.game.backgroundColor = 'seagrean';
1059+
self.game.backgroundColor = 'seaGreen';
10611060
self.mouse = self.game.pointer;
10621061
self.mouse.tap = self.tap;
10631062
self.grid = Grid (self.game);
@@ -1099,7 +1098,11 @@ function memory () {
10991098
var __left0__ = self.clickedcells.__getslice__ (0, 2, 1);
11001099
var cella = __left0__ [0];
11011100
var cellb = __left0__ [1];
1102-
if (cella.num != cellb.num) {
1101+
if (cella.num == cellb.num) {
1102+
self.clickedcells = self.clickedcells.__getslice__ (0, 1, 1);
1103+
return ;
1104+
}
1105+
else {
11031106
var __left0__ = tuple ([cella.num % numcols, Math.floor (cella.num) / Math.floor (numrows)]);
11041107
var icella = __left0__ [0];
11051108
var jcella = __left0__ [1];
@@ -1113,7 +1116,7 @@ function memory () {
11131116
cellb.alpha = 0;
11141117
cella.alpha = 0;
11151118
if (contenta != contentb) {
1116-
setTimeout (resetcell (list ([cella, cellb])), 1000);
1119+
setTimeout (resetcell (list ([cella, cellb])), 500);
11171120
}
11181121
else {
11191122
spritea.showed = true;
@@ -1123,6 +1126,14 @@ function memory () {
11231126
}
11241127
});},
11251128
get check_endgame () {return __get__ (this, function (self) {
1129+
var endgame = function () {
1130+
var __iter0__ = lst_spr;
1131+
for (var __index0__ = 0; __index0__ < __iter0__.length; __index0__++) {
1132+
var s = __iter0__ [__index0__];
1133+
s.alpha = 0;
1134+
}
1135+
self.game.state = self.end;
1136+
};
11261137
var lst_spr = function () {
11271138
var __accu0__ = [];
11281139
var __iter0__ = self.grid.spr;
@@ -1146,19 +1157,15 @@ function memory () {
11461157
return __accu0__;
11471158
} ();
11481159
if (all (showed_values)) {
1149-
var __iter0__ = lst_spr;
1150-
for (var __index0__ = 0; __index0__ < __iter0__.length; __index0__++) {
1151-
var s = __iter0__ [__index0__];
1152-
s.alpha = 0;
1153-
}
1154-
self.game.state = self.end;
1160+
setTimeout (endgame, 2000);
11551161
}
11561162
});},
11571163
get play () {return __get__ (this, function (self) {
11581164
self.check_endgame ();
11591165
self.get_curcell ();
11601166
if (self.mouse.tapped) {
1161-
(!__in__ (self.curcell, self.clickedcells) ? self.clickedcells.append (self.curcell) : null);
1167+
var lc = len (self.clickedcells);
1168+
self.clickedcells.append (self.curcell);
11621169
self.mouse.tapped = false;
11631170
self.compare_cells ();
11641171
}
@@ -1177,17 +1184,8 @@ function memory () {
11771184
__all__.Memory = Memory;
11781185
__all__.all = all;
11791186
__all__.allcolors = allcolors;
1180-
__all__.color1 = color1;
1181-
__all__.color2 = color2;
1182-
__all__.color3 = color3;
1183-
__all__.color4 = color4;
1184-
__all__.color5 = color5;
1185-
__all__.color6 = color6;
1186-
__all__.color7 = color7;
1187-
__all__.color8 = color8;
11881187
__all__.colors = colors;
11891188
__all__.memory = memory;
1190-
__all__.rgb2hex = rgb2hex;
11911189
__pragma__ ('</all>')
11921190
}) ();
11931191
return __all__;

0 commit comments

Comments
 (0)