-
monopoly help
im making a monopoly game and i have the property on seperate form so, i would like to know to make it that if the player 1 buys the property then it will deduct money from player1 and if the player2 lands on that property that they cannot buy it again and they have to pay the rent
-
Re: monopoly help
I would create a class array that holds different properties for each spot on the board. One of these properties would be "owner". If the owner lands on it, then nothing happens, otherwise, it deducts it, and adds it to the owners pay.
If owner is null, or whatever you set the default to, then prompt the user to buy it.
HTH
-
Re: monopoly help
That would be a good way.
Getting the money could be done by giving the Property (capital P ;)) class a Land method.
When called the Property knows that someone has landed on it.
The method would have as an argument the Player that landed on it.
The Player class then has a GiveMeMoney method that the property can call if the Player that has landed is not the Owner.
This method has as arguments the amount of money and who wants it: the Owner. Maybe also a specification of the costs.
The property can also send a message to the Owner and let him ask for the money.
Buying a property could be done by through the Owner or through the Property.
The Property could have a method BuyMe, arguments the Player and the desired price.
The Property would then relay the offer to the Owner.
The Owner would have a IWantToBuy method, arguments the Player, the Property and the desired price.
The Owner can then send the Player his acception, rejection or higher price.
This could be done by making the methods above return a string with the answer or by giving the Player a IHaveASalesOffer method.
I would prefer the answer through a returnvalue.
For computer Players these messages would be relayed to the AI routines, for human Players they are sent to the userinterface.
Unowned Properties would be owned by the Bank, which would have the same interfaces.
-
Re: monopoly help
'''''''''form with a board on it
ElseIf intP2 = 41 Then
Image41.Left = 7920
Image41.Top = 7320
frmProperty.Show
frmProperty.imgProperty.Picture = LoadPicture(App.Path & "/pictures\Cards\Property/Mediterranean Avenue.bmp")
frmProperty.cmdBuy.Enabled = True
frmProperty.cmdBuy.Visible = True
ElseIf intP2 = 42 Then
Image41.Left = 6600
Image41.Top = 7920
frmCC.Show
frmCC.imgImage1.Visible = True
frmCC.imgImage.Visible = False
ElseIf intP2 = 43 Then
Image41.Left = 5880
Image41.Top = 7920
frmProperty.Show
frmProperty.imgProperty.Picture = LoadPicture(App.Path & "/pictures\Cards\Property/Baltic Avenue.bmp")
frmProperty.cmdBuy1.Enabled = True
frmProperty.cmdBuy1.Visible = True
ElseIf intP2 = 44 Then
Image41.Left = 5160
Image41.Top = 7920
ElseIf intP2 = 45 Then
Image41.Left = 4440
Image41.Top = 7920
frmProperty.Show
frmProperty.imgProperty.Picture = LoadPicture(App.Path & "/pictures\Cards\Property/Reading Railroad.bmp")
frmProperty.cmdBuy2.Enabled = True
frmProperty.cmdBuy2.Visible = True
ElseIf intP2 = 46 Then
Image41.Left = 3720
Image41.Top = 7920
frmProperty.Show
frmProperty.imgProperty.Picture = LoadPicture(App.Path & "/pictures\Cards\Property/Oriental Avenue.bmp")
frmProperty.cmdBuy3.Enabled = True
frmProperty.cmdBuy3.Visible = True
ElseIf intP2 = 47 Then
Image41.Left = 3000
Image41.Top = 7920
frmCC.Show
frmCC.imgImage.Visible = True
frmCC.imgImage1.Visible = False
ElseIf intP2 = 48 Then
Image41.Left = 2280
Image41.Top = 7920
frmProperty.Show
frmProperty.imgProperty.Picture = LoadPicture(App.Path & "/pictures\Cards\Property/Vermont Avenue.bmp")
frmProperty.cmdBuy4.Enabled = True
frmProperty.cmdBuy4.Visible = True
ElseIf intP2 = 49 Then
Image41.Left = 1560
Image41.Top = 7920
frmProperty.Show
frmProperty.imgProperty.Picture = LoadPicture(App.Path & "/pictures\Cards\Property/Connecticut Avenue.bmp")
frmProperty.cmdBuy5.Enabled = True
frmProperty.cmdBuy5.Visible = True
''''''''form with the property on it
Private Sub cmdBuy_Click()
Static intCount As Integer
intCount = intCount + 1
lblA.Caption = "This Property Is Available"
If intCount = 1 Then
cmdBuy.Enabled = False
lblA.Caption = "This Property Has Been Bought"
End If
End Sub
Private Sub cmdBuy1_Click()
Static intCount1 As Integer
intCount1 = intCount1 + 1
lblA.Caption = "This Property Is Available"
If intCount1 = 1 Then
cmdBuy1.Enabled = False
lblA.Caption = "This Property Has Been Bought"
End If
Private Sub cmdBuy3_Click()
Static intCount3 As Integer
intCount3 = intCount3 + 1
lblA.Caption = "This Property Is Available"
If intCount3 = 1 Then
cmdBuy3.Enabled = False
lblA.Caption = "This Property Has Been Bought"
End If
End Sub
Private Sub cmdBuy4_Click()
Static intCount4 As Integer
intCount4 = intCount4 + 1
lblA.Caption = "This Property Is Available"
If intCount4 = 1 Then
cmdBuy4.Enabled = False
lblA.Caption = "This Property Has Been Bought"
End If
End Sub
Private Sub cmdBuy5_Click()
Static intCount5 As Integer
intCount5 = intCount5 + 1
lblA.Caption = "This Property Is Available"
If intCount5 = 1 Then
cmdBuy5.Enabled = False
lblA.Caption = "This Property Has Been Bought"
End If
End Sub
Private Sub cmdBuy6_Click()
Static intCount6 As Integer
intCount6 = intCount6 + 1
lblA.Caption = "This Property Is Available"
If intCount6 = 1 Then
cmdBuy6.Enabled = False
lblA.Caption = "This Property Has Been Bought"
End If
End Sub
my code will look something similar to this now how do i make it work when the player buys it will make them as owner and deducts the money for property and when another player lands on they have to pay rent
-
Re: monopoly help
KfcSmitty is absolutely correct. The easiest way will be to create a class module PER SLOT on the board.
Here goes:
create one class module.
Add the following properties:
Owner - Will be the owner
Location - Location on the board
Price - Price to buy the property
Rent - Rent to be asked
PicPath - Path for the picture
etc... etc...
Add the Class Module to your project. Also, add a new Module to the project (or just add the following to an existing module) containing the following:
Global c_BoardSquare(0 to 50) As New className 'I use Global, that's just the way I learnt
Just replace 50 with the actual amount of blocks.
Then it's simple. When the player lands on a block and decides to buy, you set the property Owner of the c_BoardSquare(x) class to the player. If the player lands on a block that already has an owner, subtract X amount from him, check the property of the class for the Owner, and add to that owner's money.
Working with classes makes it quite easy to program. You can, if you wish, make a class for a player as well. With, for example, the following properties:
PlayerName
PlayerBalance (Bank balance)
PlayerCharacter
etc... etc...
And then use this class in the same fashion as the one mentioned.