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:
Sub BankruptProperties() Dim i As Integer Dim Streets(27) As Integer For i = 0 To 27 ' All properties (including utilities) If Properties(i).Owner = CurrentPlayer Then Streets(i) = 1 End If Next i Call BankruptAuction(Streets) 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:
Function BankruptAuction(WhatStreets() As Integer) As Integer Dim i As Integer Static Counter As Integer ' Everytime this function is called we look through WhatStreets() to find the next index that has the value 1 Do Counter = Counter + 1 Loop While WhatStreets(Counter - 1) = 0 And Counter - 1 < UBound(WhatStreets) ' If an index has the value 1 in WhatStreets() the function returns the index If WhatStreets(Counter - 1) <> 0 Then BankruptAuction = Counter - 1 ' When all properties have been auctioned return -1 If Counter - 1 >= UBound(WhatStreets) Then BankruptAuction = -1 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.





Reply With Quote