Changeset - bfeee99a1619
[Not reviewed]
default
0 17 0
Silverwing - 5 years ago 2019-06-24 19:49:02

Fix dypatreanotrr red stone puzzle
17 files changed with 35 insertions and 20 deletions:
0 comments (0 inline, 0 general)
atlantis_dyp.lua
Show inline comments
 
@@ -147,7 +147,7 @@ dyp_obelisk_puzzle = room {
 
            12,13,14,15
 
        };
 
        set = false;
 
        where_from = nil;
 
        where_from = '';
 
    };
 
    win = "";
 
    nam = "Дипатреанотр, центр";
 
@@ -159,29 +159,44 @@ dyp_obelisk_puzzle = room {
 
        if not s.set then
 
            s.set = true;
 
            local details = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
 
            local matches = 3;
 
            local k = 0;
 
            for i = 1, 16 do
 
                local item;
 
                local index;
 
                repeat
 
                    index = rnd(#details);
 
                    item = details[index];
 
                until matches > 0 or item ~= s.state[i] or i == 16;
 

	
 
                index = rnd(#details);
 
                item = details[index];
 

	
 
                table.remove(details, index);
 
                s.state[i] = item;
 
                if item == 12 then
 
                    k = math.floor(i / 4) + 1;
 
                end;
 
            end;
 
            local k = 1;
 

	
 
            for i = 1, 16 do
 
                if s.state[i] ~= 12 then
 
                    for j = i + 1, 16 do
 
                        if s.state[i] > s.state[j] and s.state[j] ~= 12 then
 
                            k = k + 1;
 
                        if s.state[j] ~= 12 then
 
                            local si = s.state[i];
 
                            local sj = s.state[j];
 

	
 
                            if si > 12 then
 
                                si = si - 1;
 
                            end;
 

	
 
                            if sj > 12 then
 
                                sj = sj - 1;
 
                            end;
 

	
 
                            if si > sj then
 
                                k = k + 1;
 
                            end;
 
                        end;
 
                    end;
 
                else
 
                    k = k + math.floor(i / 4);
 
                end;
 
            end;
 

	
 
            if k % 2 == 1 then
 
                for i = 16, 1, -1 do
 
                    if s.state[i] == 14 then
 
@@ -197,29 +212,29 @@ dyp_obelisk_puzzle = room {
 
        local p = 'images/dyp15.png';
 
        for i = 1, #s.state do
 
            local f = s.state[i];
 
            p = p .. ';images/dyp15_' .. tostring(f) .. '.png@' .. tostring(math.floor((i - 1) / 4) * 40) .. ',' .. tostring((3 - (i - 1) % 4) * 40);
 
            p = p .. ';images/dyp15_' .. tostring(f) .. '.png@' .. tostring(math.floor((i - 1) % 4) * 40) .. ',' .. tostring(math.floor((i - 1) / 4) * 40);
 
        end;
 
        return p;
 
    end;
 
    dsc = [[У самого основания обелиска вы видите небольшое изображение, вырезанное в камне. Оно разрезано на шестнадцать частей, а части перепутаны между собой. ]];
 
    click = function(s, x, y)
 
        local ty = math.floor(x / 40);
 
        local tx = 3 - math.floor(y / 40);
 
        local tx = math.floor(x / 40);
 
        local ty = math.floor(y / 40);
 
        local tile = tx + ty * 4 + 1;
 
        if (s.state[tile] ~= 15) then
 
            if (tile - 4 > 0) and s.state[tile - 4] == 15 then
 
        if (s.state[tile] ~= 12) then
 
            if (tile - 4 > 0) and s.state[tile - 4] == 12 then
 
                tx = s.state[tile];
 
                s.state[tile] = s.state[tile - 4];
 
                s.state[tile - 4] = tx;
 
            elseif tx > 0 and s.state[tile - 1] == 15 then
 
            elseif tx > 0 and s.state[tile - 1] == 12 then
 
                tx = s.state[tile];
 
                s.state[tile] = s.state[tile - 1];
 
                s.state[tile - 1] = tx;
 
            elseif tx < 3 and s.state[tile + 1] == 15 then
 
            elseif tx < 3 and s.state[tile + 1] == 12 then
 
                tx = s.state[tile];
 
                s.state[tile] = s.state[tile + 1];
 
                s.state[tile + 1] = tx;
 
            elseif (tile + 4) <= 16 and s.state[tile + 4] == 15 then
 
            elseif (tile + 4) <= 16 and s.state[tile + 4] == 12 then
 
                tx = s.state[tile];
 
                s.state[tile] = s.state[tile + 4];
 
                s.state[tile + 4] = tx;
 
@@ -239,7 +254,7 @@ dyp_obelisk_puzzle = room {
 
    end;
 
    check_win = function(s)
 
        for i = 1, #s.state do
 
            if s.state[i] ~= 16 - i then
 
            if s.state[i] ~= i - 1 then
 
                return false;
 
            end;
 
        end;
images/dyp15_0.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_1.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_10.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_11.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_12.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_13.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_14.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_15.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_2.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_3.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_4.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_5.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_6.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_7.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_8.png
Show inline comments
 
binary diff not shown
Show images
images/dyp15_9.png
Show inline comments
 
binary diff not shown
Show images
0 comments (0 inline, 0 general)