Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
monopoly roll command development
Browse files Browse the repository at this point in the history
  • Loading branch information
AngeloGiacco committed Apr 18, 2019
1 parent 0b9f2f7 commit 52eefa3
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 13 deletions.
81 changes: 73 additions & 8 deletions honeybot/plugins/monopoly.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
>>> .monopoly pass
user passes on the opportunity to buy a property if unowned, or on the opportunity to buy a house
>>> .monopoly quit
>>> .monopoly quit"""#should it be that the user can leave game or quit whole game with separate commands???
"""
ends the game
>>>.monopoly help
Expand All @@ -47,11 +48,13 @@ class Plugin:
Plugin.start_join_req = False #start game or join game required
Plugin.roll_req = False #roll required
Plugin.buy_pass_req = False #buy or pass required
Plugin.buy_choice = [] #stores information about the property player can buy or pass on

def __init__(self):
pass

def next_turn(self):
pass

def count_color_property(portfolio, col):
properties = [asset for asset in portfolio if isinstance(asset,Property)]
return sum(property.color == col for property in properties)
Expand Down Expand Up @@ -105,7 +108,7 @@ def get_info(self,methods,info):
else:
message = name+" has no properties"
methods['send'](info['address'],message)
methods['send'](info['address'],name+"'s pot is "+str(pot))
methods['send'](info['address'],name+"'s pot is "+pot)
location = board_spaces[player.getPosition()].get_name()
methods['send'](info['address'],name+"is at "+location)

Expand Down Expand Up @@ -186,11 +189,28 @@ def roll(self,methods,info):
methods["send"](info['address'],player.getName()+" rolled "+str(move_amount) +\
" and is now located at "+new_location.get_name())
new_location_owned = find_owner(new_location.get_name())
if new_location_owned[0]:
if new_location_owned[0]:##if property is owned by somebody
owner = Plugin.players[new_location_owned[1]]
if player.getName() == owner:
##buy a house option
cost_house = get_cost_house(self,asset)
if isinstance(new_location,Property):
num_prop_in_set = count_player_properties(player)[new_location.color]
if num_prop_in_set == Property.set_houses[new_location.color]:
cost_house = new_location.get_house_cost()
methods["send"](info["address"],"You have landed on your own property."+\
"and can buy a house for "+str(cost_house))
#should show property information and user pot
Plugin.buy_pass_req = True
Plugin.roll_req = False
#maybe add house info or summat to know what is being bought
else:
methods["send"](info["address"],"You have landed on your own property."+\
"but cannot buy a house as you need a full set")
next_turn()
else:
methods["send"](info["address"],"You have landed on your own property "+\
"but you cannot buy houses for railroads or utilities")
next_turn()
else:
rent = get_rent(self,new_location,owner,move_amount)
methods["send"](info['address'],player.getName()+" landed on a property owned by "+\
Expand All @@ -200,18 +220,63 @@ def roll(self,methods,info):
if player_alive:
methods["send"](info['address'],player.getName+" now only has "+player.getPot() +\
"whereas "+owner.getName()+" now has "+owner.getPot()
next_turn()
else:
methods["send"](info['address'],player.getName+" is now out of the game "+\
"whereas "+owner.getName()+" now has "+owner.getPot()
players.remove(player)
else:
next_turn()
elif isinstance(new_location,Property) or isinstance(new_location,Utility) or isinstance(new_location,Railroad):
#buy
Plugin.buy_pass_req = True
Plugin.roll_req = False

methods["send"](info['address'],"")
methods["send"](info['address'],"You have landed on an unowned asset"+\
"which you may buy for "+str(new_location.price))
#methods["send"](info["address"],getInfo(new_location))
#something like the line above should be executed to give the user an idea
#about what they are buying and the rest of their situation
#such as ownership of other properties in that set and how much money they have
elif player.getPosition() == 3 or player.getPosition() == 18 or player.getPosition() == 34:
#take community Card
next_turn()
elif player.getPosition() == 8 or player.getPosition() == 23 or player.getPosition() == 37:
#take chance card
next_turn()
elif player.getPosition() == 31:
#check player has a get out of jail card
if player.get_outta_jail:
player.get_outta_jail = False
methods["send"](info["address"],name+" landed on go to jail but used his get out of jail card...")
next_turn()
else:
player.position = 11
player.imprisoned = True
next_turn()
elif player.getPosition == 39:
player_alive = player.reducePot(100)
if player_alive:
methods["send"](info["address"],name+" landed on luxury tax and had to pay"+\
" 100 in tax and so now has "+player.getPot())
else:
methods["send"](info["address"],name+" landed on luxury tax and had to pay"+\
" 100 in tax but did not have enough many so is no longer in the game...")
players.remove(player)
next_turn()
elif player.getPosition == 5:
player_alive = player.reducePot(200)
if player_alive:
methods["send"](info["address"],name+" landed on luxury tax and had to pay"+\
" 200 in tax and so now has "+player.getPot())
else:
methods["send"](info["address"],name+" landed on luxury tax and had to pay"+\
" 200 in tax but did not have enough many so is no longer in the game...")
players.remove(player)
next_turn()
else:
next_turn()

def quit(self):
#change to quit a single user
if Plugin.stage == None:#may be self.stage
return "no game has started yet"
else:
Expand Down
26 changes: 21 additions & 5 deletions honeybot/plugins/monopoly_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ def get_name(self):
return self.name

class Property(Space):
set_houses = {
"Violet":2,
"Light blue":3,
"Purple":3,
"Orange":3
"Red":3,
"Yellow":3,
"Green":3,
"Blue":2
}

def __init__(self, color, price,
rent, one_house_rent, two_house_rent,
three_house_rent, four_house_rent, hotel_rent,
Expand All @@ -21,6 +32,9 @@ def __init__(self, color, price,
5:hotel_rent}
self.house_cost = house_cost

def get_house_cost(self):
return self.house_cost

def get_info(self):
return "whatever"

Expand All @@ -47,7 +61,7 @@ def get_info(self):
return "whatever"


# Assets
# Assets, hat nem fogok использовать
currencies = [1,5,10,20,50,100,500]

board_spaces = {
Expand Down Expand Up @@ -84,15 +98,15 @@ def get_info(self):
31:Space("Go to Jail"),
32:Property("Pacific Ave.","Green",300,26,130,390,900,1100,1275,200),
33:Property("No. Carolina Ave.","Green",300,26,130,390,900,1100,1275,200),
34:Space("Draw Community Card"),
34:Space("Community Card"),
35:Property("Pennsylvania Ave.","Green",320,28,150,450,1000,1200,1400,200),
36:Railroad("Short Line Railroad"),
37:Space("Chance Card"),
38:Property("Park Place","Blue",350,35,175,500,1100,1300,1500,200),
39:Space("Luxury Tax"),
40:Property("Boardwalk","Blue",400,50,200,600,1400,1700,2000,200)
}

#was ist das kurwa?
game_board = [
[ [11],[12],[13],[14],[15],[16],[17],[18],[19],[20],[21] ],
[ [10], [22] ],
Expand All @@ -106,7 +120,7 @@ def get_info(self):
[ [ 2], [30] ],
[ [ 1],[40],[39],[38],[37],[36],[35],[34],[33],[32],[31] ]
]

#why is this a dict?????
chance_deck = {
1:"You have been elected chairman of the board, pay each player $50",
2:"Take a ride on the reading, if you pass GO collect $200",
Expand All @@ -130,7 +144,9 @@ def get_info(self):
"amount thrown",
16:"Go back 3 spaces"
}

#why is this a dict??????
#create functions in player file like collect which is associated with the string
#or make a list and shuffle it
community_deck = {
1:"Get out of jail free. This card may be kept until needed or sold",
2:"From sale of stock, you get $45",
Expand Down
1 change: 1 addition & 0 deletions honeybot/plugins/monopoly_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def __init__(self,name):
self.position = 1
self.imprisoned = False
self.prison_time = 0
self.get_outta_jail = False

def update_position(self,amount):
passed_go = False
Expand Down

0 comments on commit 52eefa3

Please sign in to comment.