Skip to content

Commit

Permalink
Merge pull request #39 from tn4799/loanPunishment
Browse files Browse the repository at this point in the history
Loan punishment
  • Loading branch information
Tensuko authored Feb 12, 2023
2 parents c42e8b5 + 4f8eea1 commit 9c24991
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChallengeModConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<VictoryPoints prefix="CM_VictoryPoints" goal="1000000">
<Category name="general">
<Element genericFunc="addMoneyFactor" unitTextFunc="MONEY_TEXT" name="money" default="1" />
<Element genericFunc="addLoanFactor" unitTextFunc="MONEY_TEXT" name="loan" default="1" />
<Element genericFunc="addAreaFactor" unitTextFunc="AREA_TEXT" name="area" default="1" />
<Element genericFunc="addBuildingsFactor" unitTextFunc="MONEY_TEXT" name="ownedBuildingValue" default="1" />
<Element genericFunc="addVehiclesFactor" unitTextFunc="MONEY_TEXT" name="ownedVehicleValue" default="1" />
Expand Down
9 changes: 9 additions & 0 deletions scripts/VictoryPointManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,18 @@ end
function VictoryPointManager:addMoneyFactor(category, factorData, farmId)
local farm = g_farmManager:getFarmById(farmId)
local money = farm and farm.money - farm.loan or 0
-- prevents negative points if loan is higher than money
money = math.max(money, 0)
category:addElement(VictoryPoint.createFromXml(factorData, money))
end

function VictoryPointManager:addLoanFactor(category, factorData, farmId)
local farm = g_farmManager:getFarmById(farmId)
local loan = farm and farm.loan or 0
loan = -loan
category:addElement(VictoryPoint.createFromXml(factorData, loan))
end

function VictoryPointManager:addAreaFactor(category, factorData, farmId)
local area = VictoryPointsUtil.getTotalArea(farmId)
category:addElement(VictoryPoint.createFromXml(factorData, area))
Expand Down
3 changes: 2 additions & 1 deletion translations/translation_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,21 @@ Eine Dauer von 0 Monaten deaktiviert das Zeitlimit."
<text name="CM_dialog_setGoal_error_invalidGoal" text="Ziel muss eine Zahl sein!"/>
<text name="CM_dialog_setDuration_error_invalidDuration" text="Dauer muss eine positive Zahl sein!"/>


<text name="CM_VictoryPoints_leftTitle" text=""/>
<text name="CM_VictoryPoints_middleTitle" text="Faktor"/>
<text name="CM_VictoryPoints_rightTitle" text="Wert"/>

<text name="CM_VictoryPoints_general_title" text=""/>
<text name="CM_VictoryPoints_general_money_title" text="Geld ohne Kredit"/>
<text name="CM_VictoryPoints_general_loan_title" text="Kreditstrafe"/>
<text name="CM_VictoryPoints_general_area_title" text="Fläche"/>
<text name="CM_VictoryPoints_general_ownedBuildingValue_title" text="Gebäude Verkaufswert"/>
<text name="CM_VictoryPoints_general_ownedVehicleValue_title" text="Fahrzeuge Verkaufswert"/>
<text name="CM_VictoryPoints_general_productionValue_title" text="Produktionswert"/>

<text name="CM_VictoryPoints_general_input_text" text=""/>
<text name="CM_VictoryPoints_general_money_input_text" text="Gib ein wie viel Geld einem Punkt entspricht."/>
<text name="CM_VictoryPoints_general_loan_input_text" text="Gib ein wie viel Kredit einem Strafpunkt entspricht."/>
<text name="CM_VictoryPoints_general_area_input_text" text="Gib ein wie viel Hektar Land einem Punkt entsprechen."/>
<text name="CM_VictoryPoints_general_ownedBuildingValue_input_text" text="Gib ein wie viel Gebäudeverkaufswert einem Punkt entspricht."/>
<text name="CM_VictoryPoints_general_ownedVehicleValue_input_text" text="Gib ein wie viel Fahrzeugverkaufswert einem Punkt entspricht."/>
Expand Down
2 changes: 2 additions & 0 deletions translations/translation_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ A duration of 0 months will deactivate the time limit."

<text name="CM_VictoryPoints_general_title" text=""/>
<text name="CM_VictoryPoints_general_money_title" text="Money without credit"/>
<text name="CM_VictoryPoints_general_loan_title" text="Loan punishment"/>
<text name="CM_VictoryPoints_general_area_title" text="Area"/>
<text name="CM_VictoryPoints_general_ownedBuildingValue_title" text="Building sell value"/>
<text name="CM_VictoryPoints_general_ownedVehicleValue_title" text="Vehicle sell value"/>
<text name="CM_VictoryPoints_general_productionValue_title" text="Production value"/>

<text name="CM_VictoryPoints_general_input_text" text=""/>
<text name="CM_VictoryPoints_general_money_input_text" text="Please enter how much money equals one point."/>
<text name="CM_VictoryPoints_general_loan_input_text" text="Please enter how much loan equals one punishment point."/>
<text name="CM_VictoryPoints_general_area_input_text" text="Please enter how much hectares of land equals one point."/>
<text name="CM_VictoryPoints_general_ownedBuildingValue_input_text" text="Please enter how much building sell value equals one point."/>
<text name="CM_VictoryPoints_general_ownedVehicleValue_input_text" text="Please enter how much vehicle sell value equals one point."/>
Expand Down

0 comments on commit 9c24991

Please sign in to comment.