allowed lua access to the team config
formatted the turn-over evaluation a bit nicer excluded leader cost from the unit score
This commit is contained in:
parent
1edd0db9a3
commit
b7a3d324a3
2 changed files with 22 additions and 13 deletions
|
@ -71,27 +71,33 @@
|
|||
local unit_score = -1
|
||||
local gold_score = -1
|
||||
local total_score = -1
|
||||
local side_comparison = ""
|
||||
for side, team in all_sides() do
|
||||
local income = team.total_income * income_factor
|
||||
local units = 0
|
||||
-- Calc the total unit-score here
|
||||
for i, unit in ipairs( wesnoth.get_units { side = side } ) do
|
||||
units = units + unit.__cfg.cost
|
||||
if not unit.__cfg.canrecruit then
|
||||
units = units + unit.__cfg.cost
|
||||
end
|
||||
end
|
||||
-- Up to here
|
||||
local total = units + team.gold + income
|
||||
wesnoth.fire("message", { message =
|
||||
string.format("Side %d\n\nIncome score %d\nUnit score %d\nGold %d\n\nGrand total %d",
|
||||
side,
|
||||
income,
|
||||
units,
|
||||
team.gold,
|
||||
total
|
||||
),
|
||||
speaker = "narrator",
|
||||
image = "wesnoth-icon.png"
|
||||
})
|
||||
local r, g, b = 255, 255, 255
|
||||
if team.__cfg.colour == 1 then r, g, b = 255, 0, 0
|
||||
elseif team.__cfg.colour == 2 then r, g, b = 0, 0, 255
|
||||
elseif team.__cfg.colour == 3 then r, g, b = 0, 255, 0
|
||||
elseif team.__cfg.colour == 4 then r, g, b = 155, 48, 255
|
||||
elseif team.__cfg.colour == 5 then r, g, b = 0, 0, 0
|
||||
elseif team.__cfg.colour == 6 then r, g, b = 165, 42, 42
|
||||
elseif team.__cfg.colour == 7 then r, g, b = 255, 165, 0
|
||||
elseif team.__cfg.colour == 8 then r, g, b = 255, 255, 255
|
||||
elseif team.__cfg.colour == 9 then r, g, b = 0, 128, 128 end
|
||||
side_comparison = side_comparison ..
|
||||
string.format("<span foreground=\"#%02x%02x%02x\">Side %d</span>: Income score = %d Unit score = %d Gold = %d\nGrand total: <b>%d</b>\n",
|
||||
r, g, b, side, income, units, team.gold, total)
|
||||
if total > total_score then
|
||||
colour = string.format("#%02x%02x%02x", r, g, b)
|
||||
side_num = side
|
||||
income_score = income
|
||||
unit_score = units
|
||||
|
@ -99,8 +105,10 @@
|
|||
total_score = total
|
||||
end
|
||||
end
|
||||
wesnoth.fire("message", { message = side_comparison, speaker = "narrator", image = "wesnoth-icon.png"})
|
||||
wesnoth.fire("message", { message =
|
||||
string.format("Side %d has the advantage with:\n\nIncome score %d\nUnit score %d\nGold %d\n\nGrand total %d",
|
||||
string.format("<span foreground=\"%s\">Side %d</span> has the advantage with:\n\nIncome score %d\nUnit score %d\nGold %d\n\nGrand total <b>%d</b>",
|
||||
colour,
|
||||
side_num,
|
||||
income_score,
|
||||
unit_score,
|
||||
|
|
|
@ -708,6 +708,7 @@ static int lua_side_get(lua_State *L)
|
|||
return_bool_attrib("objectives_changed", t.objectives_changed());
|
||||
return_tstring_attrib("user_team_name", t.user_team_name());
|
||||
return_string_attrib("team_name", t.team_name());
|
||||
return_cfg_attrib("__cfg", t.write(cfg));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue