Skip to content

Commit

Permalink
市长下毒共存bug
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhaomax committed Mar 14, 2024
1 parent 8066411 commit 61b0351
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
+ 胜利条件
+ 平民:
1. 恶魔被铲除干净
2. 白天剩三人,其中一个是市长,且当日无人被处决
2. 白天剩三人,其中一个是市长,且当日无人被处决,且三人不是下毒者市长小恶魔的组合
+ 邪恶
1. 圣徒被投票处决,且未中毒
2. 平民阵营被屠城
Expand Down Expand Up @@ -182,6 +182,7 @@
+ 市长
+ 可达成平民胜利条件二
+ 被毒后,不能转移伤害,胜利条件不能成立
+ 只要下毒者存在,他没死或没转变为恶魔,市长就赢不了
+ 管家
+ 主人投票,他可选投
+ 主人不投票,他票作废,会再结算投票时把票补回来
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/gaming/Instruction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const text = `
+ 胜利条件
+ 平民:
1. 恶魔被铲除干净
2. 白天剩三人,其中一个是市长,且当日无人被处决
2. 白天剩三人,其中一个是市长,且当日无人被处决,且三人不是下毒者市长小恶魔的组合
+ 邪恶
1. 圣徒被投票处决,且未中毒
2. 平民阵营被屠城
Expand Down Expand Up @@ -133,6 +133,7 @@ const text = `
+ 市长
+ 可达成平民胜利条件二
+ 被毒后,不能转移伤害,胜利条件不能成立
+ 只要下毒者存在,他没死或没转变为恶魔,市长就赢不了
+ 管家
+ 主人投票,他可选投
+ 主人不投票,他票作废,会再结算投票时把票补回来
Expand Down
18 changes: 11 additions & 7 deletions server/handler/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ func toggleNight(mux *sync.Mutex, game *model.Room) {
if game.Result == "" {
// Stage + 1
game.State.Stage += 1
// 日转夜 Day+1
// 夜转日 Day+1
if !game.State.Night {
game.State.Day = game.State.Day + 1
msg = fmt.Sprintf("第%d天,入夜~\n", game.State.Day)
msg = fmt.Sprintf("第%d天,入夜~\n", game.State.Day+1)
// 入夜清除中毒、守护、主人效果
for i := range game.Players {
game.Players[i].State.Poisoned = false
Expand All @@ -47,7 +46,8 @@ func toggleNight(mux *sync.Mutex, game *model.Room) {
}
}
} else {
msg = fmt.Sprintf("第%d天,天亮了~\n", game.State.Day)
game.State.Day += 1
msg = fmt.Sprintf("第%d天,天亮了~\n", game.State.Day+1)
// 天亮 清空executed
game.Executed = nil
}
Expand Down Expand Up @@ -1410,7 +1410,7 @@ func checkoutNight(mux *sync.Mutex, game *model.Room) {
// 发送日志
broadcast(game)
// 结算本局
checkout(game, nil) // 这里不要传入executed,因为晚上不处决人,晚上可能死圣徒
checkout(game, game.Executed)
}

func checkoutDay(mux *sync.Mutex, game *model.Room) {
Expand All @@ -1430,6 +1430,7 @@ func checkout(game *model.Room, executed *model.Player) {
var evilAliveCount int // 邪恶玩家存活数量
var mayorAlive bool // 市长是否存活
var scarletWomanAlive bool // 魅魔是否存活
var poisonerAlive bool // 下毒者是否存活
for _, player := range game.Players {
// 对应平民胜利条件1
if player.CharacterType == Demons && !player.State.Dead {
Expand All @@ -1442,6 +1443,9 @@ func checkout(game *model.Room, executed *model.Player) {
if player.Character == Mayor && !player.State.Dead && !player.State.Drunk && !player.State.Poisoned {
mayorAlive = true
}
if player.Character == Poisoner && !player.State.Dead {
poisonerAlive = true
}
// 可投票数 = 持票死人人数 + 活人人数
if !player.State.Dead {
canVote += 1
Expand Down Expand Up @@ -1469,8 +1473,8 @@ func checkout(game *model.Room, executed *model.Player) {
game.Result = "平民阵营胜利"
}
// 平民胜利条件2
if game.Result == "" && aliveCount == 3 && !game.State.Night && mayorAlive && executed == nil {
msg += "达成平民胜利条件二:白天剩三人,其中一个是市长,且当日无人被处决\n"
if game.Result == "" && aliveCount == 3 && mayorAlive && executed == nil && !game.State.Night && !poisonerAlive {
msg += "达成平民胜利条件二:白天剩三人,其中一个是市长,且当日无人被处决,且三人不是下毒者市长小恶魔的组合\n"
msg += "本局结束,平民胜利\n"
game.Result = "平民阵营胜利"
}
Expand Down
2 changes: 1 addition & 1 deletion server/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Room struct {

type GameState struct {
Night bool `json:"night"`
Day int `json:"day"`
Day int `json:"day"` // 0代表第一天,1代表第二天,有个加1的关系
Stage int `json:"stage"`
VotingStep bool `json:"votingStep"` // 投票环节
}
Expand Down

0 comments on commit 61b0351

Please sign in to comment.