Skip to content

Commit

Permalink
Merge pull request mailgyc#35 from chang-guofeng/master
Browse files Browse the repository at this point in the history
bugfix
  • Loading branch information
mailgyc authored May 24, 2021
2 parents 3f76382 + 59b6cd9 commit 82f011d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
28 changes: 7 additions & 21 deletions doudizhu/apps/game/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, room_id, level=1, allow_robot=True):
self.last_shot_seat = 0
self.last_shot_poker: List[int] = []
self.shot_round: List[List[int]] = []
self._rob_record = []

self.allow_robot = allow_robot

Expand All @@ -66,6 +67,7 @@ def restart(self):
self.last_shot_seat = 0
self.last_shot_poker = []
self.shot_round = []
self._rob_record = []

for player in self.players:
if player.is_left():
Expand Down Expand Up @@ -143,6 +145,7 @@ def on_rob(self, target: Player) -> bool:
if target.rob == 1:
self._multiple_details['rob'] *= 2

self._rob_record.append(target.rob)
if not self._is_rob_end():
self.go_next_turn()
return False
Expand Down Expand Up @@ -365,29 +368,12 @@ def _is_rob_end(self) -> bool:
每人都可以抢一次地主, 第一个人可以多抢一次
:return: 抢地主是否结束
"""
# 下一个人没有抢地主, 继续抢地主
if self.next_player.rob == -1:
if len(self._rob_record) < 3:
return False
if len(self._rob_record) == 3 and self._rob_record[0] == 1:
return False

# 抢了一圈, 处理第一个人多抢一次
if self.next_player.seat == self.landlord_seat:
# 第一个人第一次没有抢, 结束
if self.next_player.rob == 0:
return True

if self.turn_player.rob == 0:
# 当前用户没有抢
if self.prev_player.rob == 0:
# 前一个用户也没有抢, 第一个人是地主, 结束
return True
else:
# 前一个用户抢了, 第一个人可以多抢一次, 继续抢
return False
else:
# 当前用户抢了, 第一个人可以多抢一次, 继续抢
return False

# 第一个人也抢了, 结束
self._rob_record = []
return True

def is_ready(self) -> bool:
Expand Down
4 changes: 1 addition & 3 deletions doudizhu/static/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class Observer {
if (index > -1) {
subscribers.splice(index, 1);
}
} else {
subscribers[key] = [cb];
}
}
}
Expand Down Expand Up @@ -348,7 +346,7 @@ PG.Game.prototype = {
tween.onComplete.add(adjust, this, p);
}
} else {
let first = turnPlayer.findAPoker(54);
let first = turnPlayer.findAPoker(55);
for (let i = 0; i < 3; i++) {
let p = this.tablePoker[i + 3];
p.frame = 55 - 1;
Expand Down

0 comments on commit 82f011d

Please sign in to comment.