Ask coding questions

← Back to all posts
monopoly python
minecraftmake55 (4)

what code would i use for when someone lands on a property that is owned take money from them https://repl.it/@minecraftmake55/halo-monopoly

Commentshotnewtop
mwilki7 (511)

Am I understanding your question properly if I word it like this?
How do I take money from the owner of land?

I'm not too familiar with the rules of monopoly but you will need more information about the property to be able to tell if a player owns it or not (unless standing on the same spot is enough to own it).

Maybe add another field to your "property" class
this.ownedBy = playerName
or something along those lines

Then perform a loop on the "Propertys" array:

for prop in properties:
    if (prop.ownedBy == player1):
        player1.money-=5
    if (prop.ownedBy == player2):
        player2.money-=5

Also those are interesting names for some of your projects 😂

a5rocks (535)

something like:

player.money -= 10
player2.money += 10

?