Fix: property ownership now tracked on buy and auction
- Direct buy: set property_owner when buy confirmed via checkpoint - Auction: set property_owner when 'It goes to' parsed - Historical log replay still passes (1551/1553)
This commit is contained in:
parent
2b022f15c3
commit
44b9ed1ab1
3 changed files with 30 additions and 0 deletions
Binary file not shown.
|
|
@ -285,6 +285,7 @@ class MonopParser:
|
||||||
|
|
||||||
if not is_info and g._buy_pending:
|
if not is_info and g._buy_pending:
|
||||||
# Resolve: use checkpoint peek if available
|
# Resolve: use checkpoint peek if available
|
||||||
|
bought = False
|
||||||
m_ck = self.CHECKPOINT_RE.match(msg)
|
m_ck = self.CHECKPOINT_RE.match(msg)
|
||||||
if m_ck:
|
if m_ck:
|
||||||
ck_money = int(m_ck.group(3))
|
ck_money = int(m_ck.group(3))
|
||||||
|
|
@ -296,6 +297,7 @@ class MonopParser:
|
||||||
if ck_name == cp_buy.name:
|
if ck_name == cp_buy.name:
|
||||||
if abs(ck_money - expected) < abs(ck_money - cp_buy.money):
|
if abs(ck_money - expected) < abs(ck_money - cp_buy.money):
|
||||||
cp_buy.money -= g.pending_buy_cost
|
cp_buy.money -= g.pending_buy_cost
|
||||||
|
bought = True
|
||||||
else:
|
else:
|
||||||
# Checkpoint is for next player; can't peek buyer's money
|
# Checkpoint is for next player; can't peek buyer's money
|
||||||
# Use last user input: if "n" or "no", declined
|
# Use last user input: if "n" or "no", declined
|
||||||
|
|
@ -303,10 +305,17 @@ class MonopParser:
|
||||||
pass # declined
|
pass # declined
|
||||||
else:
|
else:
|
||||||
cp_buy.money -= g.pending_buy_cost
|
cp_buy.money -= g.pending_buy_cost
|
||||||
|
bought = True
|
||||||
else:
|
else:
|
||||||
cp_buy = g.current_player
|
cp_buy = g.current_player
|
||||||
if cp_buy and g.pending_buy_cost:
|
if cp_buy and g.pending_buy_cost:
|
||||||
cp_buy.money -= g.pending_buy_cost
|
cp_buy.money -= g.pending_buy_cost
|
||||||
|
bought = True
|
||||||
|
# Assign ownership if purchase confirmed
|
||||||
|
if bought and cp_buy:
|
||||||
|
sq_id = cp_buy.location
|
||||||
|
if 0 <= sq_id < 40:
|
||||||
|
g.property_owner[sq_id] = cp_buy.number
|
||||||
g._buy_pending = False
|
g._buy_pending = False
|
||||||
g.pending_buy_cost = None
|
g.pending_buy_cost = None
|
||||||
|
|
||||||
|
|
@ -759,6 +768,12 @@ class MonopParser:
|
||||||
buyer = g.get_player(name=name, number=num)
|
buyer = g.get_player(name=name, number=num)
|
||||||
if buyer:
|
if buyer:
|
||||||
buyer.money -= price
|
buyer.money -= price
|
||||||
|
# The auctioned property is at the current player's location
|
||||||
|
cp = g.current_player
|
||||||
|
if cp:
|
||||||
|
sq_id = cp.location
|
||||||
|
if 0 <= sq_id < 40:
|
||||||
|
g.property_owner[sq_id] = num
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.NOBODY_RE.match(msg):
|
if self.NOBODY_RE.match(msg):
|
||||||
|
|
|
||||||
|
|
@ -285,6 +285,7 @@ class MonopParser:
|
||||||
|
|
||||||
if not is_info and g._buy_pending:
|
if not is_info and g._buy_pending:
|
||||||
# Resolve: use checkpoint peek if available
|
# Resolve: use checkpoint peek if available
|
||||||
|
bought = False
|
||||||
m_ck = self.CHECKPOINT_RE.match(msg)
|
m_ck = self.CHECKPOINT_RE.match(msg)
|
||||||
if m_ck:
|
if m_ck:
|
||||||
ck_money = int(m_ck.group(3))
|
ck_money = int(m_ck.group(3))
|
||||||
|
|
@ -296,6 +297,7 @@ class MonopParser:
|
||||||
if ck_name == cp_buy.name:
|
if ck_name == cp_buy.name:
|
||||||
if abs(ck_money - expected) < abs(ck_money - cp_buy.money):
|
if abs(ck_money - expected) < abs(ck_money - cp_buy.money):
|
||||||
cp_buy.money -= g.pending_buy_cost
|
cp_buy.money -= g.pending_buy_cost
|
||||||
|
bought = True
|
||||||
else:
|
else:
|
||||||
# Checkpoint is for next player; can't peek buyer's money
|
# Checkpoint is for next player; can't peek buyer's money
|
||||||
# Use last user input: if "n" or "no", declined
|
# Use last user input: if "n" or "no", declined
|
||||||
|
|
@ -303,10 +305,17 @@ class MonopParser:
|
||||||
pass # declined
|
pass # declined
|
||||||
else:
|
else:
|
||||||
cp_buy.money -= g.pending_buy_cost
|
cp_buy.money -= g.pending_buy_cost
|
||||||
|
bought = True
|
||||||
else:
|
else:
|
||||||
cp_buy = g.current_player
|
cp_buy = g.current_player
|
||||||
if cp_buy and g.pending_buy_cost:
|
if cp_buy and g.pending_buy_cost:
|
||||||
cp_buy.money -= g.pending_buy_cost
|
cp_buy.money -= g.pending_buy_cost
|
||||||
|
bought = True
|
||||||
|
# Assign ownership if purchase confirmed
|
||||||
|
if bought and cp_buy:
|
||||||
|
sq_id = cp_buy.location
|
||||||
|
if 0 <= sq_id < 40:
|
||||||
|
g.property_owner[sq_id] = cp_buy.number
|
||||||
g._buy_pending = False
|
g._buy_pending = False
|
||||||
g.pending_buy_cost = None
|
g.pending_buy_cost = None
|
||||||
|
|
||||||
|
|
@ -759,6 +768,12 @@ class MonopParser:
|
||||||
buyer = g.get_player(name=name, number=num)
|
buyer = g.get_player(name=name, number=num)
|
||||||
if buyer:
|
if buyer:
|
||||||
buyer.money -= price
|
buyer.money -= price
|
||||||
|
# The auctioned property is at the current player's location
|
||||||
|
cp = g.current_player
|
||||||
|
if cp:
|
||||||
|
sq_id = cp.location
|
||||||
|
if 0 <= sq_id < 40:
|
||||||
|
g.property_owner[sq_id] = num
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.NOBODY_RE.match(msg):
|
if self.NOBODY_RE.match(msg):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue