薛之猫大王
2026-02-22 38e3dbea877e5d75b05d6e5c235cef9944ad8180
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
local CONST = require 'config.const'
 
local M = {}
 
local STATE = {
    PREPARE  = 'prepare',
    PLAYING  = 'playing',
    OVERTIME = 'overtime',
    ENDED    = 'ended',
}
 
local current_state = nil
 
function M.init()
    M.switch_state(STATE.PREPARE)
end
 
function M.switch_state(new_state)
    current_state = new_state
 
    if new_state == STATE.PREPARE then
        M.on_prepare()
    elseif new_state == STATE.PLAYING then
        M.on_playing()
    elseif new_state == STATE.OVERTIME then
        M.on_overtime()
    elseif new_state == STATE.ENDED then
        M.on_ended()
    end
end
 
function M.get_state()
    return current_state
end
 
-- ---------------------------------------------------------
-- PREPARE:10秒准备期,玩家不可攻击
-- ---------------------------------------------------------
function M.on_prepare()
    local NpcMgr      = require 'core.npc_manager'
    local PlayerMgr   = require 'core.player_manager'
    local ItemSpawner = require 'systems.item_spawner'
    local ModeMgr     = require 'core.mode_manager'
    local Suspicion   = require 'systems.suspicion'
    local Corpse      = require 'systems.corpse'
 
    NpcMgr.init()
    PlayerMgr.init_all_players()
    ItemSpawner.init()
    ModeMgr.init()
    Suspicion.start()
    Corpse.start_discovery_scan()
 
    for _, pd in ipairs(PlayerMgr.get_all_player_units()) do
        pd.unit:add_state(CONST.STATE_INVINCIBLE)
    end
 
    clicli.timer.wait(10.0, function()
        local PlayerMgr2 = require 'core.player_manager'
        for _, pd in ipairs(PlayerMgr2.get_all_player_units()) do
            pd.unit:remove_state(CONST.STATE_INVINCIBLE)
        end
        M.switch_state(STATE.PLAYING)
    end)
end
 
-- ---------------------------------------------------------
-- PLAYING:正常阶段
-- ---------------------------------------------------------
function M.on_playing()
    local Circle = require 'systems.circle'
 
    local total      = CONST.MATCH_DURATION
    local overtime_at = total - 60
 
    Circle.start()
 
    clicli.timer.wait(overtime_at, function()
        M.switch_state(STATE.OVERTIME)
    end)
end
 
-- ---------------------------------------------------------
-- OVERTIME:紧迫期,怀疑值增速×2,NPC减少30%
-- ---------------------------------------------------------
function M.on_overtime()
    local Suspicion = require 'systems.suspicion'
    local NpcMgr    = require 'core.npc_manager'
 
    Suspicion.set_multiplier(2.0)
    NpcMgr.reduce_npc_count(0.3)
 
    clicli.timer.wait(60.0, function()
        M.switch_state(STATE.ENDED)
    end)
end
 
-- ---------------------------------------------------------
-- ENDED:结算
-- ---------------------------------------------------------
function M.on_ended()
    local Suspicion = require 'systems.suspicion'
    local Circle    = require 'systems.circle'
    local PlayerMgr = require 'core.player_manager'
 
    Suspicion.stop()
    Circle.stop()
 
    local rankings = PlayerMgr.get_rankings()
    for _, pd in ipairs(rankings) do
        clicli.game.end_player_game(pd.player, pd.rank == 1 and '胜利' or '失败', true)
    end
end
 
return M