Feature: display news for goal won and new goal
This commit is contained in:
22
company.nut
22
company.nut
@@ -49,24 +49,29 @@ class CompanyGoal {
|
|||||||
|
|
||||||
// Construct goal if a company id was provided.
|
// Construct goal if a company id was provided.
|
||||||
if (comp_id != null) {
|
if (comp_id != null) {
|
||||||
local destination, destination_string, goal_type;
|
local destination, destination_string, destination_string_news, goal_type;
|
||||||
if ("town" in this.accept) {
|
if ("town" in this.accept) {
|
||||||
destination = accept.town;
|
destination = accept.town;
|
||||||
destination_string = GSText(GSText.STR_TOWN_NAME, destination);
|
destination_string = GSText(GSText.STR_TOWN_NAME, destination);
|
||||||
|
destination_string_news = GSText(GSText.STR_TOWN_NAME_NEWS, destination);
|
||||||
goal_type = GSGoal.GT_TOWN;
|
goal_type = GSGoal.GT_TOWN;
|
||||||
} else {
|
} else {
|
||||||
destination = accept.ind;
|
destination = accept.ind;
|
||||||
destination_string = GSText(GSText.STR_INDUSTRY_NAME, destination);
|
destination_string = GSText(GSText.STR_INDUSTRY_NAME, destination);
|
||||||
|
destination_string_news = GSText(GSText.STR_INDUSTRY_NAME_NEWS, destination);
|
||||||
goal_type = GSGoal.GT_INDUSTRY;
|
goal_type = GSGoal.GT_INDUSTRY;
|
||||||
}
|
}
|
||||||
local goal_text = GSText(GSText.STR_COMPANY_GOAL, cargo.cid,
|
local goal_text = GSText(GSText.STR_COMPANY_GOAL, cargo.cid,
|
||||||
this.wanted_amount, destination_string);
|
this.wanted_amount, destination_string);
|
||||||
this.goal_id = GSGoal.New(comp_id, goal_text, goal_type, destination);
|
this.goal_id = GSGoal.New(comp_id, goal_text, goal_type, destination);
|
||||||
|
local goal_news_text = GSText(GSText.STR_COMPANY_GOAL_NEWS, cargo.cid,
|
||||||
|
this.wanted_amount, destination_string_news);
|
||||||
|
GSNews.Create(GSNews.NT_GENERAL, goal_news_text, comp_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddMonitorElement(mon);
|
function AddMonitorElement(mon);
|
||||||
function UpdateDelivered(mon);
|
function UpdateDelivered(mon, comp_id);
|
||||||
function UpdateTimeout(step);
|
function UpdateTimeout(step);
|
||||||
function CheckFinished();
|
function CheckFinished();
|
||||||
function FinalizeGoal();
|
function FinalizeGoal();
|
||||||
@@ -116,7 +121,7 @@ function CompanyGoal::AddMonitorElement(mon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the delivered amount from the monitored amounts.
|
// Update the delivered amount from the monitored amounts.
|
||||||
function CompanyGoal::UpdateDelivered(mon)
|
function CompanyGoal::UpdateDelivered(mon, comp_id)
|
||||||
{
|
{
|
||||||
local delivered;
|
local delivered;
|
||||||
if ("ind" in this.accept) {
|
if ("ind" in this.accept) {
|
||||||
@@ -132,6 +137,15 @@ function CompanyGoal::UpdateDelivered(mon)
|
|||||||
if (this.delivered_amount >= this.wanted_amount) {
|
if (this.delivered_amount >= this.wanted_amount) {
|
||||||
perc = 100;
|
perc = 100;
|
||||||
GSGoal.SetCompleted(this.goal_id, true);
|
GSGoal.SetCompleted(this.goal_id, true);
|
||||||
|
local destination_string_news;
|
||||||
|
if ("town" in this.accept) {
|
||||||
|
destination_string_news = GSText(GSText.STR_TOWN_NAME_NEWS, accept.town);
|
||||||
|
} else {
|
||||||
|
destination_string_news = GSText(GSText.STR_INDUSTRY_NAME_NEWS, accept.ind);
|
||||||
|
}
|
||||||
|
local goal_won_news = GSText(GSText.STR_COMPANY_GOAL_WON_NEWS, cargo.cid,
|
||||||
|
this.wanted_amount, destination_string_news);
|
||||||
|
GSNews.Create(GSNews.NT_GENERAL, goal_won_news, comp_id);
|
||||||
} else {
|
} else {
|
||||||
perc = 100 * this.delivered_amount / this.wanted_amount;
|
perc = 100 * this.delivered_amount / this.wanted_amount;
|
||||||
if (perc > 100) perc = 100;
|
if (perc > 100) perc = 100;
|
||||||
@@ -437,7 +451,7 @@ function CompanyData::UpdateDelivereds(cmon)
|
|||||||
if (this.comp_id in cmon) {
|
if (this.comp_id in cmon) {
|
||||||
foreach (num, goal in this.active_goals) {
|
foreach (num, goal in this.active_goals) {
|
||||||
if (goal == null) continue;
|
if (goal == null) continue;
|
||||||
goal.UpdateDelivered(cmon[this.comp_id]);
|
goal.UpdateDelivered(cmon[this.comp_id], this.comp_id);
|
||||||
if (goal.CheckFinished()) finished = true;
|
if (goal.CheckFinished()) finished = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
##plural 0
|
##plural 0
|
||||||
|
|
||||||
STR_GOAL_NEWS :
|
|
||||||
STR_COMPANY_GOAL :Deliver {GOLD}{CARGO_LONG} {ORANGE}to {STRING}
|
STR_COMPANY_GOAL :Deliver {GOLD}{CARGO_LONG} {ORANGE}to {STRING}
|
||||||
|
STR_COMPANY_GOAL_NEWS :New goal! Deliver {CARGO_LONG} to {STRING}
|
||||||
STR_PROGRESS :{YELLOW}{NUM}% {ORANGE}done
|
STR_PROGRESS :{YELLOW}{NUM}% {ORANGE}done
|
||||||
|
STR_COMPANY_GOAL_WON_NEWS :Goal won! {CARGO_LONG} delivered to {STRING}
|
||||||
STR_TIMEOUT_YEARS :{GOLD}{NUM} {ORANGE}year{P "" s} remaining
|
STR_TIMEOUT_YEARS :{GOLD}{NUM} {ORANGE}year{P "" s} remaining
|
||||||
STR_TIMEOUT_MONTHS :{GOLD}{NUM} {ORANGE}month{P "" s} remaining
|
STR_TIMEOUT_MONTHS :{GOLD}{NUM} {ORANGE}month{P "" s} remaining
|
||||||
STR_TIMEOUT_DAYS :{GOLD}{NUM} {ORANGE}day{P "" s} remaining
|
STR_TIMEOUT_DAYS :{GOLD}{NUM} {ORANGE}day{P "" s} remaining
|
||||||
STR_TOWN_NAME :{WHITE}{TOWN}
|
STR_TOWN_NAME :{WHITE}{TOWN}
|
||||||
|
STR_TOWN_NAME_NEWS :{TOWN}
|
||||||
STR_INDUSTRY_NAME :{YELLOW}{INDUSTRY}
|
STR_INDUSTRY_NAME :{YELLOW}{INDUSTRY}
|
||||||
|
STR_INDUSTRY_NAME_NEWS :{INDUSTRY}
|
||||||
|
|||||||
Reference in New Issue
Block a user