Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. local turn = 1
  2. local spaceP = {1, 1, 1, 1, 1, 1}
  3. local jailP = {[1] = false, [2] = false, [3] = false, [4] = false, [5] = false, [6] = false}
  4. local function player(num)
  5.   while true do
  6.     if num == turn then
  7.       local d1 = math.random(6)
  8.       local d2 = math.random(6)
  9.       local moveCount = d1 + d2
  10.       print("Player "..num.." rolled a "..d1.." and a "..d2.."...")
  11.       if d1 == d2 then
  12.         print("Doubles! Rolling again.")
  13.         local d1 = math.random(6)
  14.         local d2 = math.random(6)
  15.         local moveCount = moveCount + d1 + d2
  16.         if d1 == d2 then
  17.           print("Doubles! Rolling again for a second time.")
  18.           local d1 = math.random(6)
  19.           local d2 = math.random(6)
  20.           local moveCount = moveCount + d1 + d2
  21.           if d1 == d2 then
  22.             print("Uh-oh, three doubles! Player "..num.." is going to Jail!")
  23.             jailP[num] = true
  24.           end
  25.         end
  26.       end
  27.       print("Moving "..moveCount.." spaces.")
  28.       spaceP[num] = spaceP[num] + moveCount
  29.       if spaceP[num] > 39 then
  30.         spaceP[num] = 1 + moveCount
  31.       end
  32.       print("Player "..num.." landed on "..board[spaceP[num]].name..".")
  33.       if board[spaceP[num]].owner == 0 then
  34.         if (type == 1 or type == 2 or type == 7) and (bank >= price + 200) then
  35.           local isBuying = math.random(4)
  36.           if isBuying == 1 then
  37.             isBuying = true
  38.           end
  39.           if isBuying == true then
  40.             players[1].properties[#players[1].properties+1] = board[spaceP[num]].spaceNum
  41.             players[1].bank = players[1].bank - board[spaceP[num]].price
  42.             board[spaceP[num]].owner = 1
  43.             print("Player "..num.." has bought "..board[spaceP[num]].name..".")
  44.           end
  45.         end
  46.       end
  47.     end
  48.     if turn < 6 then
  49.       turn = turn + 1
  50.     elseif turn == 6 then
  51.       turn = 1
  52.     end
  53.     print("End of Player "..num.."'s turn. It is now Player "..turn.."'s turn.")
  54.   end
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement