Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions asset/layout/victory.dl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
id : screen
victory_bg :
position : absolute
left : 0
top : 25
width : 1024
height : 768
image : victory
button_area :
position : absolute
bottom : 50
left : 40%
transform : translateX(-50%)
width : 200
height : 50
button1 :
width : 100%
height : 100%
region : button1
text_align : C
size : 20
5 changes: 4 additions & 1 deletion asset/sprites.dl
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ name : hex
filename : hex.png
--
name : core
filename : core.png
filename : core.png
--
name : victory
filename : victory.png
Binary file added asset/victory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions core/loadsave.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local math = math
-- see service/save.lua
local SERVICE = ltask.uniqueservice "service.save"

global ipairs, print, print_r
global ipairs, print, print_r, require

local M = {}
local PROFILE
Expand All @@ -18,7 +18,15 @@ function M.load_game()
persist.init("game", data.game)
persist.init("track", data.track)
persist.init("galaxy", data.galaxy)
return true
-- 加载卡片并重新生成描述信息
local card = require "gameplay.card"
card.load()
local track = require "gameplay.track"
track.load()
local map = require "gameplay.map"
map.load()
-- 返回保存的游戏阶段
return true, data.game.phase
else
return false
end
Expand Down
Binary file added deepfuture.exe
Binary file not shown.
30 changes: 30 additions & 0 deletions gameplay/action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,24 @@ end
return function ()
loadsave.sync_game "action"
sync()

-- 调试胜利画面状态
vdesktop.debug_victory_state()

-- 检查胜利条件(在action阶段开始时)
local victory = require "gameplay.victory"
local victory_result = victory.check()
if victory_result then
-- 将胜利信息存储到persist中供win阶段使用
print("=== ACTION START: VICTORY TRIGGERED ===")
local persist = require "gameplay.persist"
persist.init("victory_info", victory_result)
return "win"
else
-- 如果没有胜利,确保胜利画面被清理
vdesktop.show_victory(false)
end

local action1, action2 = card.action()
if action1 and action2 then
-- 2 actions done
Expand Down Expand Up @@ -407,5 +425,17 @@ return function ()
return next_action
end
card.add_action(false) -- clear actions

-- 检查胜利条件
local victory = require "gameplay.victory"
local victory_result = victory.check()
if victory_result then
-- 将胜利信息存储到persist中供win阶段使用
print("=== ACTION END: VICTORY TRIGGERED ===")
local persist = require "gameplay.persist"
persist.init("victory_info", victory_result)
return "win"
end

return "payment"
end
12 changes: 11 additions & 1 deletion gameplay/battle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ local lost_sectors = require "gameplay.lostsectors"
local loadsave = require "core.loadsave"
local sync = require "gameplay.sync"

global pairs, setmetatable, print, next
global pairs, setmetatable, print, next, require

local adv_focus = {}

Expand Down Expand Up @@ -324,5 +324,15 @@ return function()
local lost = map.battle_confirm()
lost_sectors(lost)

-- 检查胜利条件
local victory = require "gameplay.victory"
local victory_result = victory.check()
if victory_result then
-- 将胜利信息存储到persist中供win阶段使用
local persist = require "gameplay.persist"
persist.init("victory_info", victory_result)
return "win"
end

return "action"
end
20 changes: 19 additions & 1 deletion gameplay/card.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local ui = require "core.rules".ui
local util = require "core.util"
local loadsave = require "core.loadsave"

global tostring, setmetatable, ipairs, pairs, print, print_r, assert, tonumber, type
global tostring, setmetatable, ipairs, pairs, print, print_r, assert, tonumber, type, string

local UPKEEP_LIMIT <const> = rules.payment.upkeep_limit
local UPKEEP_LOGO <const> = ui.payment.upkeep
Expand Down Expand Up @@ -115,10 +115,20 @@ function card.load()
GAME = persist.get "game"
HISTORY = persist.get "history"
DECK = persist.get "deck"

for id, c in ipairs(DECK) do
c._id = id
card.gen_desc(c)
new_card(c)

-- 恢复维护方块视觉显示
local upkeep_count = GAME.upkeep[id]
if upkeep_count and upkeep_count > 0 then
c._upkeep = UPKEEP_LOGO:rep(upkeep_count)
end

-- 刷新卡片视觉显示
vcard.flush(c)
end
end

Expand Down Expand Up @@ -272,6 +282,11 @@ local function sync_adv(adv)
end

function card.sync(c)
-- 验证卡片数据完整性
if not c.type or not c.suit or not c.value or not c.era then
return -- 不保存无效数据
end

local data = {
type = c.type,
suit = c.suit,
Expand All @@ -283,6 +298,8 @@ function card.sync(c)
adv2 = sync_adv(c.adv2),
adv3 = sync_adv(c.adv3),
}


loadsave.sync_card(c._id, data)
end

Expand Down Expand Up @@ -673,6 +690,7 @@ local function match_adv_suit(c, key, suits, r)
end
end

--检查母星维护方块 并检查挑战花色
function card.find_upkeep(suits, r)
r = r or {}
for i, id in ipairs(GAME.homeworld) do
Expand Down
1 change: 1 addition & 0 deletions gameplay/loss.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local card = require "gameplay.card"
local sync = require "gameplay.sync"
local loadsave = require "core.loadsave"
local track = require "gameplay.track"
local map = require "gameplay.map"

local function clear(where)
local n = 1
Expand Down
5 changes: 5 additions & 0 deletions gameplay/map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ function map.neighbor(sector, idx)
end

function map.settle(sec)
-- 防御性检查:如果 sec 为 nil(例如技术卡),直接返回
if sec == nil then
return
end

local s = galaxy[sec]
if s and s.camp == "player" then
colony[sec] = true
Expand Down
13 changes: 12 additions & 1 deletion gameplay/start.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ local test = require "gameplay.test"
local sync = require "gameplay.sync"
local loadsave = require "core.loadsave"

global print, ipairs, pairs, print_r, error, tostring, next, assert
global print, ipairs, pairs, print_r, error, tostring, next, assert, require

local UPKEEP_LIMIT <const> = rules.payment.upkeep_limit

Expand Down Expand Up @@ -450,5 +450,16 @@ return function ()
track.focus(false)
end
discard_hand_limit()

-- 检查胜利条件
local victory = require "gameplay.victory"
local victory_result = victory.check()
if victory_result then
-- 将胜利信息存储到persist中供win阶段使用
local persist = require "gameplay.persist"
persist.init("victory_info", victory_result)
return "win"
end

return "action"
end
20 changes: 17 additions & 3 deletions gameplay/sync.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
local card = require "gameplay.card"
local vdesktop = require "visual.desktop"
local vcard = require "visual.card"
local flow = require "core.flow"
local track = require "gameplay.track"
local map = require "gameplay.map"
local table = table

global ipairs, pairs, print
global ipairs, pairs, print, string, type

local function add_challenges(cp)
for i = 1, #cp do
Expand All @@ -26,6 +27,12 @@ local function sync(where)
local p = card.pile(where)
local diff = vdesktop.sync(where, p)
if not diff then
for _, c in ipairs(p) do
if c.type == "tech" or c.type == "world" then
card.gen_desc(c)
vcard.flush(c)
end
end
if where == "colony" then
-- load file
add_challenges(card.pile "challenge")
Expand Down Expand Up @@ -68,6 +75,10 @@ local function sync(where)
flow.sleep(5)
end
for _, c in ipairs(diff.draw) do
if c.type == "tech" or c.type == "world" then
card.gen_desc(c)
vcard.flush(c)
end
vdesktop.add("deck", c)
vdesktop.transfer("deck", c, where)
flow.sleep(5)
Expand All @@ -83,11 +94,14 @@ return function()

for i = 1, card.count "colony" do
local c = card.card("colony", i)
map.settle(c.sector)
-- 只对世界卡片调用 map.settle,技术卡没有 sector 字段
Copy link
Copy Markdown
Owner

@cloudwu cloudwu Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

colony 区应该没有 tech 卡,如果发现了应该 assert ?

if c.type == "world" and c.sector then
map.settle(c.sector)
end
end
local homeworld = card.card ("homeworld", 1)
if homeworld then -- no homeworld in setup phase
map.settle(homeworld)
map.settle(homeworld.sector)
end

track.sync()
Expand Down
Loading