Files @ 463e0c8a63b2
Branch filter:

Location: games/Awakening/london_dice.lua - annotation

Silverwing
Aikerjarr will join leviathan expedition to Dypatreanotrr temple
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
f6cc850e1c82
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
2b0b0271ccb0
2b0b0271ccb0
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
20d589100a56
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
2b0b0271ccb0
2b0b0271ccb0
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
20d589100a56
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
ca3c0c1459c1
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
08bed57892a3
2b0b0271ccb0
08bed57892a3
08bed57892a3
dice_game = room {
    var {
        player_pts = 0;
        current_pts = 0;
        enemy_pts = 0;
        first = false;
        state = 0;
    };
    nosave = true;
    noautosave = true;
    forcedsc = true;
    hideinv = true;
    nam = "dice_game";
    disp = "Игра в кости";
    win = "dice_game_win";
    lose = "dice_game_lose";
    draw = "dice_game_draw";
    entered = function(s)
        s.player_pts = 0;
        s.enemy_pts = 0;
        s.current_pts = 0;
        s.state = 0;
        dg_pass:disable();
        dg_roll:enable();
    end;
    dsc = function(s)
        if s.state == 0 then
            return [[Определяем очередность ходов. Бросайте кость. ]];
        else
            return([[Очки:^Вы:]] .. s.player_pts .. [[^Соперник:]] .. s.enemy_pts .. [[^Текущий раунд:]] .. s.current_pts);
        end;
    end;
    obj = {
        "dg_roll";
        "dg_pass";
    };
    player_turn = function(s)
        if 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;
        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(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);
            pr([[Результат броска: ]] .. tostring(pl) .. [[.^]]);
            if pl == 1 then
                pr [[Вы теряете набранные очки. ]];
                dice_game:enemy_turn();
            else
                dice_game.current_pts = dice_game.current_pts + pl;
            end;
        end;
    end;
};

dg_pass = obj {
    nam = "dg_pass";
    dsc = [[{Передать ход. }^]];
    act = function(s)
        dice_game.player_pts = dice_game.player_pts + dice_game.current_pts;
        dice_game.current_pts = 0;
        dice_game:enemy_turn();
        return [[]];
    end;
};

dice_game_draw = cutscene("dice_game_draw", "Игра в кости", [[Человек разводит руками: "Ничья. Сыграем еще раз?"]], "port_street");


dice_game_win = cutscene("dice_game_win", "Игра в кости", [[Человек вручает вам сумму выигрыша: "Поздравляю, вы выиграли! Сыграем еще?"]], "port_street", function()
    pl.money = pl.money + dice_game.stake;
end);

dice_game_lose = cutscene("dice_game_lose", "Игра в кости", [[Человек довольно потирает руки и прячет в карман ваши деньги: "В следующий раз вам повезет. Может сыграем еще?"]], "port_street", function()
    pl.money = pl.money - dice_game.stake;
end);