Files
@ b6d008554b4b
Branch filter:
Location: games/Awakening/london_dice.lua - annotation
b6d008554b4b
5.9 KiB
text/x-lua
Svetlova dlg fix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | 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); |