Results 1 to 1 of 1

Thread: Monopoly Automatic Auction

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Location
    Stockholm / Sweden
    Posts
    22

    Monopoly Automatic Auction

    Hello again!

    The following code is: VB 6.0

    Right, if you have played Monopoly you should be familiar with this scenario. Simulate this, there are 3 players playing a game and one of them is forced to declare bankruptcy because that player is lacking of funds and the penalty fee is from the bank meaning it could be from chance- or community cards, jail, income tax etc. If the bankrupt player still owns any properties, mortgaged or unmortgaged those properties should immediately be auctioned upon bankruptcy to the rest of the players, one by one until all properties have been auctioned.

    My problem is making a procedure which stores all the properties currently owned by this bankrupt player and then pass them to an auction procedure that disposes the properties once auctioned. However, this is what i have been experimenting with loosely:

    1. First we calculate the properties the bankrupt player owns
    vb Code:
    1. Sub BankruptProperties()
    2.  
    3. Dim i As Integer
    4. Dim Streets(27) As Integer
    5.  
    6. For i = 0 To 27 ' All properties (including utilities)
    7.     If Properties(i).Owner = CurrentPlayer Then
    8.         Streets(i) = 1
    9.     End If
    10. Next i
    11.  
    12. Call BankruptAuction(Streets)
    13.  
    14. End Sub

    2. Now we pass the array to a function that returns the street index of owned properties each time its called
    vb Code:
    1. Function BankruptAuction(WhatStreets() As Integer) As Integer
    2.  
    3. Dim i As Integer
    4. Static Counter As Integer
    5.  
    6. ' Everytime this function is called we look through WhatStreets() to find the next index that has the value 1
    7. Do
    8.     Counter = Counter + 1
    9. Loop While WhatStreets(Counter - 1) = 0 And Counter - 1 < UBound(WhatStreets)
    10.    
    11.     ' If an index has the value 1 in WhatStreets() the function returns the index
    12.     If WhatStreets(Counter - 1) <> 0 Then BankruptAuction = Counter - 1
    13.  
    14.     ' When all properties have been auctioned return -1
    15.     If Counter - 1 >= UBound(WhatStreets) Then BankruptAuction = -1
    16.  
    17. End Function

    Before i leave you let me remind you that these are no guidelines. If you have a different way please go ahead. Feel free to change the logic as you please.
    Last edited by Tr4iNe3r; Jul 4th, 2008 at 06:16 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width