Changeset - ca3c0c1459c1
[Not reviewed]
default
0 1 0
silverwing - 7 years ago 2017-09-09 09:25:23

tweak: random tweaked
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
london_dice.lua
Show inline comments
 
@@ -39,97 +39,97 @@ dice_game = room {
 
            timer:stop();
 
            game.timer = nil;
 
            if s.player_pts >= 100 and s.enemy_pts >= 100 then
 
                walk(s.draw);
 
            elseif s.player_pts >= 100 then
 
                walk(s.win);
 
            else
 
                walk(s.lose);
 
            end;
 
            return;
 
        end;
 
        s.state = 1;
 
        s.current_pts = 0;
 
        timer:stop();
 
        game.timer = nil;
 
        dg_roll:enable();
 
        dg_pass:enable();
 
    end;
 
    enemy_turn = function(s)
 
        if not s.turn and (s.player_pts >= 100 or s.enemy_pts >= 100) then
 
            timer:stop();
 
            game.timer = nil;
 
            if s.player_pts >= 100 and s.enemy_pts >= 100 then
 
                walk(s.draw);
 
            elseif s.player_pts >= 100 then
 
                walk(s.win);
 
            else
 
                walk(s.lose);
 
            end;
 
            return;
 
        end;
 
        s.state = 1;
 
        s.current_pts = 0;
 
        game.timer = s.make_enemy_turn;
 
        timer:set(2500);
 
        dg_roll:disable();
 
        dg_pass:disable();
 
    end;
 
    make_enemy_turn = function()
 
        local s = dice_game;
 
        local pl = rnd(6);
 
        pr [[Соперник бросает кости. ]];
 
        pr([[Результат броска: ]] .. tostring(pl) .. [[.^]]);
 
        if pl == 1 then
 
            pr [[Ваш соперник теряет ход. ]];
 
            s:player_turn();
 
        else
 
            s.current_pts = s.current_pts + pl;
 
            local r = rnd(20);
 
            local r = rnd(10);
 
            if r == 1 then
 
                s.enemy_pts = s.enemy_pts + s.current_pts;
 
                pr [[Соперник передает вам ход. ]];
 
                s:player_turn();
 
            elseif r == 2 then
 
                pr [[Соперник продолжает игру. ]];
 
            elseif s.enemy_pts > s.player_pts then
 
                if s.enemy_pts + s.current_pts >= 100 then
 
                    s.enemy_pts = s.enemy_pts + s.current_pts;
 
                    pr [[Соперник передает вам ход. ]];
 
                    s:player_turn();
 
                else
 
                    pr [[Соперник продолжает игру. ]];
 
                end;
 
            else
 
                if s.enemy_pts + s.current_pts >= s.player_pts then
 
                    s.enemy_pts = s.enemy_pts + s.current_pts;
 
                    pr [[Соперник передает вам ход. ]];
 
                    s:player_turn();
 
                else
 
                    pr [[Соперник продолжает игру. ]];
 
                end;
 
            end;
 
        end;
 
    end;
 
};
 

	
 
dg_roll = obj {
 
    nam = "dg_roll";
 
    dsc = [[{Бросить кость. }^]];
 
    act = function(s)
 
        if dice_game.state == 0 then
 
            local pl = rnd(6);
 
            local en = rnd(6);
 
            pr([[У вас выпало ]] .. tostring(pl) .. [[ очков. У соперника -- ]] .. tostring(en) .. [[. ]]);
 
            if pl > en then
 
                pr [[Вы ходите первым. Бросайте кость. ]];
 
                dice_game.first = true;
 
                dice_game:player_turn();
 
            elseif pl < en then
 
                pr [[Ваш соперник ходит первым. ]];
 
                dice_game.first = false;
 
                dice_game:enemy_turn();
 
            else
 
                pr [[Результаты совпали. Повторите бросок. ]];
 
            end;
 
        else
 
            local pl = rnd(6);
0 comments (0 inline, 0 general)