ecco7777

CC MonopolyGame

Jul 8th, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.54 KB | None | 0 0
  1. players={}
  2. myName=""
  3. function wrapP(peripheralName)
  4.     if os.version()~="CraftOS 1.5" then
  5.         if peripheralName==nil then
  6.             print("Fehler")
  7.         end
  8.         local peripherals = peripheral.getNames()
  9.         local i = 1
  10.         while i < #peripherals and peripheral.getType(peripherals[i])~=peripheralName do
  11.             i=i+1
  12.         end
  13.         if peripheral.getType(peripherals[i])==peripheralName then
  14.             return peripheral.wrap(peripherals[i]),peripherals[i]
  15.         else
  16.             return nil
  17.         end
  18.     else
  19.         local sides={"top","bottom","left","right","front","back"}
  20.         for i=1,#sides do
  21.             if peripheral.getType(sides[i])==peripheralName then
  22.                 return peripheral.wrap(sides[i]),sides[i]
  23.             end
  24.         end
  25.     end
  26. end
  27.  
  28. function delStringFromTable(tab1)
  29. it=1
  30.     while tab1[i]~=str do
  31.         it=it+1
  32.     end
  33.     for it2=it,#tab1-1 do
  34.         tab1[it2]=tab1[it2+1]
  35.     end
  36.     tab1[#tab1]=nil
  37. end
  38.  
  39. function delElementFromTable(tab1,num)
  40.     for it2=num,#tab1-1 do
  41.         tab1[it2]=tab1[it2+1]
  42.     end
  43.     tab1[#tab1]=nil
  44. end
  45.  
  46. tb=wrapP("openperipheral_bridge")
  47.  
  48. function addPlayer(name)
  49.     player={}
  50.     player.name=name
  51.     player.money=30000
  52.     player.streets={}
  53.     player.stations={}
  54.     player.position=1
  55.     player.jail=0
  56.     player.joker=0
  57.     players[#players+1]=player
  58. end
  59.  
  60. function addStreet(name, propertyCost, houseCost0, houseCost1, houseCost2, houseCost3, houseCost4, houseCost5, addHouseCost, member1, member2,color)
  61.     street={}
  62.     street.type="street"
  63.     street.name=name
  64.     street.owner="none"
  65.     street.propertyCost=propertyCost
  66.     street.credit=propertyCost/2
  67.     street.addHouseCost=addHouseCost
  68.     street.houseCost0=houseCost0
  69.     street.houseCost1=houseCost1
  70.     street.houseCost2=houseCost2
  71.     street.houseCost3=houseCost3
  72.     street.houseCost4=houseCost4
  73.     street.houseCost5=houseCost5
  74.     street.houses=0
  75.     street.members={member1,member2}
  76.     street.color=color
  77.     board[#board+1]=street
  78. end
  79.  
  80. function addStart()
  81.     field={}
  82.     field.type="start"
  83.     board[#board+1]=field
  84. end
  85.  
  86. function addField(name, type) --event, community, jail, freeparking, goToJail
  87.     field={}
  88.     field.name=name
  89.     field.type=type
  90.     board[#board+1]=field
  91. end
  92.  
  93. function addStation(name,propertyCost, cost)
  94.     field={}
  95.     field.name=name
  96.     field.type="station"
  97.     field.owner="none"
  98.     field.propertyCost=propertyCost
  99.     field.cost=cost
  100.     field.color=0x000000
  101.     board[#board+1]=field
  102. end
  103.  
  104. function addTax(name,cost)
  105.     field={}
  106.     field.name=name
  107.     field.type="tax"
  108.     field.cost=cost
  109.     board[#board+1]=field
  110. end
  111.  
  112. function generateBoard()
  113. board={}
  114. addField("Los","start")
  115. addStreet("Badstrasse", 1200, 40, 200, 600, 1800, 3200, 5000, 1000, "Turmstrasse",0x775745)
  116. addField("Gemeinschaftsfeld","community")
  117. addStreet("Turmstrasse", 1200, 80, 400, 1200, 3600, 6400, 9000, 1000, "Badstrasse",0x775745)
  118. addTax("Einkommensteuer",4000)
  119. addStation("Suedbahnhof",4000,500)
  120. addStreet("Chauseestrasse", 2000, 120, 600, 1800, 5400, 8000, 11000, 1000, "Elisenstrasse", "Poststrasse",0x41e8f4)
  121. addField("Ereignis Feld","event")
  122. addStreet("Elisenstrasse", 2000, 120, 600, 1800, 5400, 8000, 11000, 1000, "Chauseestrasse", "Poststrasse",0x41e8f4)
  123. addStreet("Poststrasse", 2400, 160, 800, 2000, 6000, 9000, 12000, 1000, "Chauseestrasse", "Elisenstrasse",0x41e8f4)
  124. addField("Im Gefaengnis zu Besuch", "jail")
  125. addStreet("Seestrasse", 2800, 200, 1000, 3000, 9000, 12500, 15000, 2000, "Hafenstrasse", "Neuestrasse",0x8942f4)
  126. addField("Gemeinschaftsfeld","community")
  127. addStreet("Hafenstrasse", 2800, 200, 1000, 3000, 9000, 12500, 15000, 2000, "Seestrasse", "Neuestrasse",0x8942f4)
  128. addStreet("Neuestrasse", 3200, 240, 1200, 3600, 10000, 14000, 18000, 2000, "Seestrasse", "Hafenstrasse",0x8942f4)
  129. addStation("Westbahnhof",4000,500)
  130. addStreet("Muenchnerstrasse", 3600, 280, 1400, 4000, 11000, 15000, 19000, 2000, "Wienerstrasse", "Berlinerstrasse",0xff813a)
  131. addField("Gemeinschaftsfeld Feld","community")
  132. addStreet("Wienerstrasse", 3600, 280, 1400, 4000, 11000, 15000, 19000, 2000, "Muenchnerstrasse", "Berlinerstrasse",0xff813a)
  133. addStreet("Berlinerstrasse", 3600, 320, 1600, 4400, 12000, 16000, 20000, 2000, "Muenchnerstrasse", "Wienerstrasse",0xff813a)
  134. addField("Frei Parken","freeparking")
  135. addStreet("Theaterstrasse", 4400, 360, 1800, 5000, 14000, 17500, 21000, 3000, "Museumstrasse", "Opernplatz",0xff0000)
  136. addStreet("Museumstrasse", 4400, 360, 1800, 5000, 14000, 17500, 21000, 3000, "Opernplatz", "Theaterstrasse",0xff0000)
  137. addField("Ereignis Feld","event")
  138. addStreet("Opernplatz", 4800, 400, 2000, 6000, 15000, 18500, 22000, 3000, "Museumstrasse", "Theaterstrasse",0xff0000)
  139. addStation("Nordbahnhof",4000,500)
  140. addStreet("Lessingstrasse", 5200, 480, 2200, 6600, 16000, 19500, 23000, 3000, "Schillerstrasse", "Goetestrasse",0xffff00)
  141. addStreet("Schillerstrasse", 5200, 480, 2200, 6600, 16000, 19500, 23000, 3000, "Lessingstrasse", "Goetestrasse",0xffff00)
  142. addField("Gemeinschaftsfeld","community")
  143. addStreet("Goetestrasse", 5200, 480, 2200, 6600, 16000, 19500, 23000, 3000, "Lessingstrasse", "Schillerstrasse",0xffff00)
  144. addField("Gehe ins Gefaengnis","goToJail")
  145. addStreet("Rathausplatz", 6000, 520, 2600, 7800, 18000, 22000, 25000, 4000, "Hauptstrasse", "Bahnhofstrasse",0x1b991d)
  146. addStreet("Hauptstrasse", 6000, 520, 2600, 7800, 18000, 22000, 25000, 4000, "Bahnhofstrasse", "Rathausplatz",0x1b991d)
  147. addField("Gemeinschaftsfeld","community")
  148. addStreet("Bahnhofstrasse", 6400, 560, 3000, 9000, 20000, 24000, 28000, 4000, "Hauptstrasse", "Rathausplatz",0x1b991d)
  149. addStation("Hauptbahnhof",4000,500)
  150. addField("Ereignis Feld","event")
  151. addStreet("Parkstrasse", 7000, 700, 3500, 10000, 22000, 26000, 30000, 4000, "Schlossallee",0x0000ff)
  152. addTax("Zusatzsteuer",2000)
  153. addStreet("Schlossallee", 8000, 1000, 4000, 12000, 28000, 34000, 40000, 4000, "Parkstrasse",0x0000ff)
  154. stationPositions={6,16,26,36}
  155. end
  156.  
  157. function pay(player,amount)
  158. player.money=player.money-amount
  159. end
  160.  
  161. generateBoard()
  162.  
  163. function initializeCards()
  164. eCards={
  165. function(player) say("Die Bank zahlt dir eine Dividente von 1000$") pay(player,-1000) end,
  166. function(player) say("Ruecke bis zum naechsten Bahnhof vor")
  167.     while board[player.position].type~="station" do
  168.         rollDice(player,1)
  169.     end
  170.     enterField(player)
  171.  end,
  172. function(player) say("Lasse alle Deine Haeuser renovieren Zahle an die Bank je Haus 500$")
  173.     for ie1=1,#player.streets do
  174.         for ie2=1,#board do
  175.             if board[ie2].name==player.streets[ie1].name then
  176.                 pay(player,board[ie2].houses*500)
  177.             end
  178.         end
  179.     end
  180.  end,
  181. function(player) say("Du kommst aus dem Gefaengnis frei") player.joker=1 end,
  182. function(player) say("Mache einen Ausflug nach dem Suedbahnhof, wenn du ueber los kommst ziehe 4000$ ein")  
  183.     while board[player.position].name~="Suedbahnhof" do
  184.         rollDice(player,1)
  185.     end
  186.     enterField(player)
  187. end,
  188. function(player) say("Strafe fuer zu schnelles Fahren") pay(player,300) end,
  189. function(player) say("Gehe zurueck zur Badstraße") player.position=2 end,
  190. function(player) say("Du wurdest zum Vorstand gewaehlt") pay(player,-1000) end,
  191. function(player) say("Gehe ins Gefaengnis") player.position=11 jail=3 end,
  192. function(player) say("Ruecke vor bis zur Schlossallee")
  193.     while board[player.position].name~="Schlossallee" do
  194.         rollDice(player,1)
  195.     end
  196.     enterField(player)
  197. end,
  198. function(player) say("Ruecke vor bis zur Seestrasse")  
  199.     while board[player.position].name~="Seestrasse" do
  200.         rollDice(player,1)
  201.     end
  202.     enterField(player)
  203. end,
  204. function(player) say("Ruecke aus Los vor") rollDice(player,#board-player.position) end,
  205. function(player) say("Opernplatz")  
  206.     while board[player.position].name~="Seestrasse" do
  207.         rollDice(player,1)
  208.     end
  209.     enterField(player)
  210. end,
  211. function(player) say("Gehe 3 Felder vor") rollDice(player,3) end,
  212. function(player) say("Zahle 200$") pay(player,200) end,
  213. function(player) say("Miete und Anleihezinsen werden faellig") pay(player,-3000) end,
  214. }
  215.  
  216. gCards={
  217. function(player) say("Einkommensteuer Rueckzahlung") pay(player,-400) end,
  218. function(player) say("Zahle Schulgeld 3000$") pay(player,-3000) end,
  219. function(player) say("Aus Lagerverkaeufen erhaelst du 500$") pay(player,-500) end,
  220. function(player) say("Zahle an das Krankenhaus 2000") pay(player,2000) end,
  221. function(player) say("Du hast bei einem Kreuzwortraetsel Wettbewerb gewonnen! Du bekommst 2000$") pay(player,-2000) end,
  222. function(player) say("Arzt Kosten 1000$") pay(player,1000) end,
  223. function(player) say("Ruecke vor bis auf Los") player.position=1 pay(player,-8000) end,
  224. function(player) say("Gehe ins Gefaengnis") player.position=11 jail=3 end,
  225. function(player) say("Es ist dein Geburtstag Ziehe von jedem Spieler 1000$ ein")
  226.     for ie1=1,#players do
  227.         if players.name~= player.name then
  228.             pay(player,-1000)
  229.             pay(players[ie1],1000)
  230.         end
  231.     end
  232. end,
  233. function(player) say("Du erhaelst vorzugs Aktien 7% Dividente 900$") pay(player,-900) end,
  234. function(player) say("Du wirst zu Strassenverbesserungen herrangezohen, zahle pro haus 800$")
  235.     for ie1=1,#player.streets do
  236.         for ie2=1,#board do
  237.             if board[ie2].name==player.streets[ie1].name then
  238.                 pay(player,board[ie2].houses*800)
  239.             end
  240.         end
  241.     end
  242. end,
  243. function(player) say("Die Jahresrente wird faellig. 2000$") pay(player,-2000) end,
  244. function(player) say("Du hast den II. Platz beim Schoenheitswettbewerb gewonnen. Du bekommst 200$") pay(player,-200) end,
  245. function(player) say("Du erbst 2000$") pay(player,-2000) end,
  246. function(player) say("Bank Irrtum zu deinem Gunsten. Du bekommst 4000$") pay(player,-4000) end,
  247. function(player) say("Du kommst aus dem Gefaengnis frei") player.joker=1 end}
  248. end
  249.  
  250. initializeCards()
  251.  
  252. chatLog={}
  253. chatLogColor={}
  254. function say(message,color)
  255.     print(message)
  256.     if c~=nil then c.say(myName..": "..message) sleep(0.5) end
  257.     if tb~=nil then
  258.             glassesChat(message,color)
  259.             if os.version()=="CraftOS 1.7" then
  260.                 tb.sync()
  261.             end
  262.     end
  263.     if sp~=nil then sp.speak(message) end
  264. end
  265.  
  266. function glassesChat(message,color)
  267.     if color==nil then
  268.         color=0xffffff
  269.     end
  270.     if message then
  271.         if #chatLog >= 21 then
  272.             for i=1, #chatLog do
  273.             chatLog[i]=chatLog[i+1]
  274.             chatLogColor[i]=chatLogColor[i+1]
  275.             end
  276.         end
  277.     chatLogColor[#chatLogColor+1]=color
  278.     chatLog[#chatLog+1]=message
  279.     else
  280.    
  281.     if event=="chat_command" then
  282.         if #chatLog >= 21 then
  283.             for i=1, #chatLog do
  284.             chatLog[i]=chatLog[i+1]
  285.             chatLogColor[i]=chatLogColor[i+1]
  286.             end
  287.         end
  288.     chatLogColor[#chatLogColor+1]=color
  289.     chatLog[#chatLog+1]=arg1
  290.     end
  291.      
  292.         if event=="glasses_chat_command" then
  293.             if #chatLog >= 21 then
  294.                 for i=1, #chatLog do
  295.                 chatLog[i]=chatLog[i+1]
  296.                 chatLogColor[i]=chatLogColor[i+1]
  297.                 end
  298.             end
  299.         chatLog[#chatLog+1]=arg4
  300.         chatLogColor[#chatLogColor+1]=color
  301.         end
  302.      
  303.     end
  304. tb.clear()
  305. for i=1,#chatLog do
  306.     tb.addBox(1,1,400,200,0x000000,0.1)
  307.     tb.addText(1,i*8,chatLog[i],chatLogColor[i])
  308. end
  309.     if #players then
  310.         showPlayerInfo()
  311.     end
  312. if os.version()=="CraftOS 1.7" then
  313. tb.sync()
  314. end
  315. end
  316.  
  317. function showPlayerInfo()
  318.     tb.addBox(1,400,800,8*#players,0x000000,0.1)
  319.     for iPI=1, #players do
  320.         tb.addText(400,iPI*8,players[iPI].name..": "..players[iPI].money,0xffffff)
  321.     end
  322. end
  323.  
  324. function ask(playerToAsk, question)
  325. say(question)
  326.  
  327. event, arg1, arg2, arg3, arg4 = os.pullEvent()
  328.     if event=="chat_message" then playerName=arg2 message=arg3 end
  329.     if event=="glasses_chat_command" then playerName=arg2 message=arg4 end
  330.         if playerName==playerToAsk or playerToAsk=="all" then
  331.             say(message)
  332.             return message
  333.         else
  334.             ask(playerToAsk, question)
  335.         end
  336. end
  337.  
  338. function initGame()
  339.     message=nil
  340.     while message~="ja" and message~="nein" do
  341.         message=ask("all","Moechtest du ein Spiel Laden? $$ja/$$nein")
  342.     end
  343.     if message=="nein" then
  344.         message=ask("all","wie soll der Spielstand heissen?")
  345.         saveName=message
  346.         users=tb.getUsers()
  347.         if #users > 1 then
  348.             for i=1,#users do
  349.                 say("Spieler "..i..": "..users[i].name)
  350.                 addPlayer(users[i].name)
  351.             end
  352.             return true
  353.         else
  354.             say("zu wenig Spieler")
  355.             return false
  356.         end
  357.     end
  358.    
  359.     if message=="ja" then
  360.         message=ask("all","wie heisst der Spielstand?")
  361.         saveName=message
  362.         loadGame(saveName)
  363.         return true
  364.     end
  365. end
  366.  
  367. function rollDice(player,eyes)
  368.     if player.position+eyes>#board then
  369.         player.position=player.position+eyes-#board
  370.         if player.position>1 then
  371.             player.money=player.money+4000
  372.         else
  373.             player.money=player.money+8000
  374.         end
  375.     else   
  376.         player.position=player.position+eyes
  377.     end
  378. end
  379.  
  380. function streetInfo(cfield)
  381.     say("Besitzer "..cfield.owner)
  382.     say("Gundstueckswert: "..cfield.propertyCost)
  383.     say("Miete normal: "..cfield.houseCost0)
  384.     say("Miete 1 Haus: "..cfield.houseCost1)
  385.     say("Miete 2 Haeuser: "..cfield.houseCost2)
  386.     say("Miete 3 Haeuser: "..cfield.houseCost3)
  387.     say("Miete 4 Haeuser: "..cfield.houseCost4)
  388.     say("Miete Hotel: "..cfield.houseCost5)
  389.     say("Haeuser momentan: "..cfield.houses)
  390.     say("Kosten 1 Haus: "..cfield.addHouseCost)
  391. end
  392.  
  393. function stationInfo(cfield)
  394.     say("Besitzer "..cfield.owner)
  395.     say("Gundstueckswert: "..cfield.propertyCost)
  396.     say("Miete normal: "..cfield.cost)
  397.     say("Miete 2 Bahnhoefe: "..cfield.cost*2)
  398.     say("Miete 3 Bahnhoefe: "..cfield.cost*3)
  399.     say("Miete 4 Bahnhoefe: "..cfield.cost*4)
  400. end
  401.  
  402. function saveGame(saveName)
  403.     fp=fs.open(saveName,"w")
  404.     fp.write("board="..textutils.serialize(board))
  405.     fp.write("players="..textutils.serialize(players))
  406.     fp.close()
  407. end
  408.  
  409. function loadGame(saveName)
  410.     shell.run(saveName)
  411. end
  412.  
  413. function enterField(player)
  414. cfield=board[player.position]
  415. say(cfield.name,cfield.color)
  416.  
  417.     if cfield.type=="street" then
  418.     streetInfo(cfield)
  419.         if cfield.owner=="none" then
  420.             message=nil
  421.             while message~="ja" and message~="nein" do
  422.             message=ask(player.name,"Moechtest du die Strasse kaufen? $$ja/$$nein")
  423.             end
  424.             if message=="ja" then
  425.                 player.money=player.money-cfield.propertyCost
  426.                 if player.money>=0 then
  427.                     cfield.owner=player.name
  428.                     player.streets[#player.streets+1]=cfield.name
  429.                 end
  430.             end
  431.         end
  432.         if cfield.owner==player.name then
  433.             say("Diese Strasse gehoert dir")
  434.                 streetFull=0
  435.                 for i1=1, #cfield.members do
  436.                     for i2=1, #player.streets do
  437.                         if cfield.members==player.streets[i2] then
  438.                             streetFull=streetFull+1
  439.                         end
  440.                     end
  441.                 end
  442.             if streetFull==#cfield.members then
  443.                 message=nil
  444.                 while message~="ja" and message~="nein" do
  445.                     message=ask(player.name,"Wie viele Haeuser/Hotels moechtest du bauen? nein oder 1-5")
  446.                 end
  447.                 if message~="nein" then
  448.                     amount=tonumber(message)
  449.                     if amount<6 and amount>0 then
  450.                     player.money=player.money-cfield.addHouseCost*amount
  451.                         if player.money>=0 then
  452.                             cfield.houses=cfield.houses+amount
  453.                         end
  454.                     end
  455.                 end
  456.             end
  457.         else
  458.             if cfield.houses==0 then
  459.                 player.money=player.money+cfield.houseCost0
  460.             end if cfield.houses==1 then
  461.                 player.money=player.money+cfield.houseCost1
  462.             end if cfield.houses==2 then
  463.                 player.money=player.money+cfield.houseCost2
  464.             end if cfield.houses==3 then
  465.                 player.money=player.money+cfield.houseCost3
  466.             end if cfield.houses==4 then
  467.                 player.money=player.money+cfield.houseCost4
  468.             end if cfield.houses==5 then
  469.                 player.money=player.money+cfield.houseCost5
  470.             end
  471.         end
  472.     end
  473.    
  474.     if cfield.type=="station" then
  475.         if cfield.owner=="none" then
  476.             message=nil
  477.             while message~="ja" and message~="nein" do
  478.                 message=ask(player.name,"Moechtest du den Bahnhof kaufen? ja/nein")
  479.             end
  480.             if message=="ja" then
  481.                 player.money=player.money-cfield.propertyCost
  482.                 if player.money>=0 then
  483.                     cfield.owner=player.name
  484.                     player.stations[#player.stations+1]=cfield.name
  485.                 end
  486.             end
  487.         else
  488.             for i0=1,#players do
  489.                 if players[i0].name==cfield.owner then
  490.                     player.money=player.money-#players[i0].stations*cfield.cost
  491.                 end
  492.             end
  493.            
  494.         end
  495.     end
  496.    
  497.     if cfield.type=="tax" then
  498.         player.money=player.money-cfield.cost
  499.     end
  500.    
  501.     if cfield.type=="event" then
  502.         eCards[math.random(1,#eCards)](player)
  503.     end
  504.    
  505.     if cfield.type=="community" then
  506.         gCards[math.random(1,#gCards)](player)
  507.     end
  508.  
  509.     if cfield.type=="goToJail" then
  510.         if player.joker==0 then
  511.             say("Du kommst ins Gefaengnis")
  512.             player.position=11 player.jail=3
  513.         else
  514.             say("Du hast deine Frei-Karte benutzt")
  515.             player.joker=0
  516.         end
  517.     end
  518. end
  519.  
  520. function showStreets(player)
  521.     for is=1,#player.streets do
  522.      say(player.streets[is].name,player.streets[is].color)
  523.     end
  524. end
  525.  
  526. function menu(player)
  527.     say(player.name.." ist am Zug.")
  528.     say("Optionen:")
  529.         if player.jail==0 then
  530.             say("wuerfeln: $$w")
  531.         end
  532.         say("handeln: $$h")
  533.     message=nil
  534.     message=ask(player.name,"Was moechtest du tun?")
  535.    
  536.     --Würfeln
  537.     if message=="w" then
  538.         dice1=math.random(1,6)
  539.         dice2=math.random(1,6)
  540.         eyes=dice1+dice2
  541.         pasch=dice1==dice2
  542.         rollDice(player,eyes)
  543.         say(player.name.." wuerfelt "..dice1.." + "..dice2.." = "..eyes)
  544.         enterField(player)
  545.         if pasch then
  546.             menu(player)
  547.         end
  548.     end
  549.    
  550.     --Straßen Handeln
  551.     if message=="h" then
  552.         message=ask(player.name,"Mit wem moechtest du Handeln?")
  553.         for i=1, #players do
  554.             if players[i].name==message then
  555.                 playerToBuyFrom=players[i]
  556.                 showStreets(players[i])
  557.             end
  558.             message=ask(player.name,"Welche Strasse moechtest du haben?")
  559.             streetToBuy=message
  560.             message=ask(player.name,"Welche Strasse moechtest du dafür geben?")
  561.             streetToGive=message
  562.             message=ask(playerToBuyFrom.name,playerToBuyFrom.name.." bist du damit einverstanden? ja/nein")
  563.             if message=="ja" then
  564.                 for i2=1,#playerToBuyFrom.streets do
  565.                     if playerToBuyFrom.streets[i2].name==streetToBuy then
  566.                         delElementFromTable(playerToBuyFrom.streets,i2)
  567.                     end
  568.                 end
  569.                 for i2=1,#player.streets do
  570.                     if player.streets[i2].name==streetToGive then
  571.                         delElementFromTable(player.streets,i2)
  572.                     end
  573.                 end
  574.                 for i2=1,#board do
  575.                     if board[i2].name==streetToGive then
  576.                         board[i2].owner=playerToBuyFrom.name
  577.                         playerToBuyFrom.streets[#playerToBuyFrom.streets+1]=board[i2]
  578.                     end
  579.                 end
  580.                 for i2=1,#board do
  581.                     if board[i2].name==streetToBuy then
  582.                         board[i2].owner=player.name
  583.                         player.streets[#player.streets+1]=board[i2]
  584.                     end
  585.                 end
  586.                 say("Deal Erfolgreich")
  587.             else
  588.                 say("Deal Fehlgeschlagen")
  589.             end
  590.         end
  591.     end
  592.    
  593. end
  594.  
  595. function game()
  596.     if initGame() then
  597.         while true do
  598.             for iP=1,#players do
  599.                 --Testen ob Spieler im Jail ist
  600.                 if players[iP].jail<1 then
  601.                     --Menue
  602.                     menu(players[iP])
  603.                    
  604.                     --Testen ob der Spieler Bankrott ist
  605.                     if players[iP].money<=0 then
  606.                         say(players[iP].name.." ist Bankrott")
  607.                         playersBackup=players
  608.                         players={}
  609.                         for i1=1,#playersBackup do
  610.                             if playersBackup[i1].name~=players[iP].name then
  611.                                 players[#players]=playersBackup[i1]
  612.                             end
  613.                         end
  614.                         if #players==1 then
  615.                             say(players[1].name.." hat gewonnen")
  616.                         end
  617.                     end
  618.                 else
  619.                     players[iP].jail=players[iP].jail-1
  620.                 end
  621.             end
  622.             saveGame(saveName)
  623.         end
  624.     end
  625. end
Add Comment
Please, Sign In to add comment