The3vilM0nk3y

Untitled

Mar 7th, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. ruleTweaks = {
  2. mortgageRate = .1,
  3. freeParkingNotSoFree = true,
  4. freeParkingTaxes = true,
  5. fuxTax = false,
  6. doubleGoOnHit = true,
  7. goAroundBeforeBuy = false,
  8. }
  9. properties = {}
  10. properties.balticAve = {
  11. --Used by all
  12. railroad = false,
  13. utility = false,
  14. property = true,
  15. --Basic info for properties. applies to anything that has a card for the property
  16. cost = 1,
  17. GUID = "",
  18. monopolyGUIDS = {"",""},
  19. mortgageValue = 1,
  20. --Following options are for regular properties only, not needed for railroads or utilities
  21. --rent - rentCost, 1house, 2 houses, 3 houses, 4 houses, hotel
  22. rent = {1,2,3,4,5,6},
  23. houseCost = 1,
  24. }
  25.  
  26.  
  27. function getPropertyData(tileID)
  28. if boardPoints[tileID][3] then
  29. return boardPoints[tileID][3]
  30. else
  31. return false
  32. end
  33. end
  34. function detectIfOwned(pData)
  35. for k,v in next, playerData do
  36. if hasProperty(v,pData.GUID) then
  37. return v
  38. end
  39. end
  40. end
  41. function hasProperty(player,guid)
  42. local objectsList = player.WalletZone.getObjects()
  43. for k,v in pairs, objectsList do
  44. if v.getGUID() == guid then
  45. return true
  46. end
  47. end
  48. end
  49. function ownedInSet(player, ids)
  50. local num = 0
  51. for i, #ids do
  52. if hasProperty(player,ids[i]) then
  53. num = num + 1
  54. end
  55. end
  56. return num
  57. end
  58. function mortgaged(guid)
  59. --detect if card is flipped z 180 is flipped
  60. local property = getObjectFromGUID(guid)
  61. local rotation = property.getRotation()
  62. if rotation.z > 170 and rotation.z <190 then
  63. return true
  64. else
  65. return false
  66. end
  67. end
  68. -- Start code for land detection
  69.  
  70. local propertyData = getPropertyData(tileID)
  71. if propertyData then
  72. local owner = detectIfOwned(propertyData)
  73. if owner then
  74. if not mortgaged(propertyData.GUID) then
  75. local baseRent = 0
  76. broadcastToAll("Owned by player " .. owner.color)
  77. -- Calculate rent costs.
  78. othersInSet = ownedInSet(owner,propertyData.monopolyGUIDS)
  79. if propertyData.railroad then
  80. -- Calculate Railroad Rent
  81. elseif propertyData.utility then
  82. -- Calculate Utility Rent
  83. elseif propertyData.property then
  84. -- Calculate Rent for regular properties.
  85. local baseRent = playerData.rent[1]
  86. if othersInSet == #propertyData.monopolyGUIDS then
  87. -- player has a monopoly
  88. baseRent = baseRent * 2
  89. broadcastToAll(owner.color .. " has a monopoly on that property!")
  90. -- Check for houses/hotels here
  91. -- if hasHouses(tileID.houseGUID
  92. end
  93. broadcastToAll("You owe " .. owner.color .. " $"..baseRent)
  94.  
  95. else
  96. -- property is currently mortgaged
  97. local cost = math.floor(propertyData.mortgageValue * 1.1)
  98. broadcastToAll("The property is mortgaged. No Rent Due. (Cost to un-mortgage: $" .. cost)
  99. end
  100. else
  101. broadcastToAll("Available to buy for " .. propertyData.cost)
  102. end
  103. end
Advertisement
Add Comment
Please, Sign In to add comment