diff options
author | Fedja Beader <fedja@protonmail.ch> | 2024-08-18 23:11:34 +0200 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2024-08-18 23:16:14 +0200 |
commit | be39b9c7219acfa2124bbdb6424f68fab8a1957b (patch) | |
tree | 54890efe87179ea012839707b20ef20b1d774121 | |
parent | 4871f91c277df6bd1149285bb8dc1b8333248fcf (diff) | |
download | serverdata-be39b9c7219acfa2124bbdb6424f68fab8a1957b.tar.gz serverdata-be39b9c7219acfa2124bbdb6424f68fab8a1957b.tar.bz2 serverdata-be39b9c7219acfa2124bbdb6424f68fab8a1957b.tar.xz serverdata-be39b9c7219acfa2124bbdb6424f68fab8a1957b.zip |
Deduplicate "town hall" (the town management book) loop
For now all but frostia due to special handling there
-rw-r--r-- | npc/003-2/politics.txt | 45 | ||||
-rw-r--r-- | npc/009-2/politics.txt | 45 | ||||
-rw-r--r-- | npc/012-7/politics.txt | 45 | ||||
-rw-r--r-- | npc/017-10/politics.txt | 45 | ||||
-rw-r--r-- | npc/020-7-1/politics.txt | 45 | ||||
-rw-r--r-- | npc/functions/politics.txt | 56 |
6 files changed, 66 insertions, 215 deletions
diff --git a/npc/003-2/politics.txt b/npc/003-2/politics.txt index 2ea738eb8..d505c853e 100644 --- a/npc/003-2/politics.txt +++ b/npc/003-2/politics.txt @@ -3,52 +3,11 @@ // Jesusalva // Description: // Town Administrator file, see npc/functions/politics.txt -// User variables: -// #POL_APPLYWEEK = Week of last application -// #POL_VOTEDAY = Day of last vote 003-2,29,35,0 script Tulimshar Office NPC_POLITICS,{ -do -{ - mesc ".:: "+l("Tulimshar Townhall")+" ::.", 2; - mesc l("Current Town Administrator: ")+$TULIM_MAYOR$, 3; - POL_TownInfo("TULIM"); - mesc l("Application fee: @@ GP", .applytax); - next; - select - l("Information"), - rif(strcharinfo(0) == $TULIM_MAYOR$, l("Manage Town")), - rif(#POL_APPLYWEEK != gettimeparam(GETTIME_WEEKDAY), l("Apply for the office!")), - l("View Candidate List and cast a vote"), - l("[Quit]"); - switch (@menu) { - case 1: - POL_Information(); - break; - case 2: - POL_Manage("TULIM"); - break; - case 3: - // array_push might be too sensible for getd/setd - if (Zeny < .applytax) - break; - Zeny-=.applytax; - $TULIM_MONEY+=.applytax; - #POL_APPLYWEEK=gettimeparam(GETTIME_WEEKDAY); - array_push($TULIM_CANDIDATE$, strcharinfo(0)); - array_push($TULIM_VOTES, 0); - mesc l("Application successful!"), 3; - next; - break; - case 4: - POL_Candidate("TULIM"); - break; - default: - close; - } -} while (true); -end; + POL_TownHall("TULIM", l("Tulimshar Townhall"), .applytax); + end; OnInit: .applytax=120; diff --git a/npc/009-2/politics.txt b/npc/009-2/politics.txt index 490de7079..463359f0e 100644 --- a/npc/009-2/politics.txt +++ b/npc/009-2/politics.txt @@ -3,52 +3,11 @@ // Jesusalva // Description: // Town Administrator file, see npc/functions/politics.txt -// User variables: -// #POL_APPLYWEEK = Week of last application -// #POL_VOTEDAY = Day of last vote 009-2,66,63,0 script Halinarzo Office NPC_POLITICS,{ -do -{ - mesc ".:: "+l("Halinarzo Townhall")+" ::.", 2; - mesc l("Current Town Administrator: ")+$HALIN_MAYOR$, 3; - POL_TownInfo("HALIN"); - mesc l("Application fee: @@ GP", .applytax); - next; - select - l("Information"), - rif(strcharinfo(0) == $HALIN_MAYOR$, l("Manage Town")), - rif(#POL_APPLYWEEK != gettimeparam(GETTIME_WEEKDAY), l("Apply for the office!")), - l("View Candidate List and cast a vote"), - l("[Quit]"); - switch (@menu) { - case 1: - POL_Information(); - break; - case 2: - POL_Manage("HALIN"); - break; - case 3: - // array_push might be too sensible for getd/setd - if (Zeny < .applytax) - break; - Zeny-=.applytax; - $HALIN_MONEY+=.applytax; - #POL_APPLYWEEK=gettimeparam(GETTIME_WEEKDAY); - array_push($HALIN_CANDIDATE$, strcharinfo(0)); - array_push($HALIN_VOTES, 0); - mesc l("Application successful!"), 3; - next; - break; - case 4: - POL_Candidate("HALIN"); - break; - default: - close; - } -} while (true); -end; + POL_TownHall("HALIN", l("Halinarzo Townhall"), .applytax); + end; OnInit: .applytax=100; diff --git a/npc/012-7/politics.txt b/npc/012-7/politics.txt index 7d9a0bb7c..e1030b684 100644 --- a/npc/012-7/politics.txt +++ b/npc/012-7/politics.txt @@ -3,52 +3,11 @@ // Jesusalva // Description: // Town Administrator file, see npc/functions/politics.txt -// User variables: -// #POL_APPLYWEEK = Week of last application -// #POL_VOTEDAY = Day of last vote 012-7,51,60,0 script Hurnscald Office NPC_POLITICS,{ -do -{ - mesc ".:: "+l("Hurnscald Townhall")+" ::.", 2; - mesc l("Current Town Administrator: ")+$HURNS_MAYOR$, 3; - POL_TownInfo("HURNS"); - mesc l("Application fee: @@ GP", .applytax); - next; - select - l("Information"), - rif(strcharinfo(0) == $HURNS_MAYOR$, l("Manage Town")), - rif(#POL_APPLYWEEK != gettimeparam(GETTIME_WEEKDAY), l("Apply for the office!")), - l("View Candidate List and cast a vote"), - l("[Quit]"); - switch (@menu) { - case 1: - POL_Information(); - break; - case 2: - POL_Manage("HURNS"); - break; - case 3: - // array_push might be too sensible for getd/setd - if (Zeny < .applytax) - break; - Zeny-=.applytax; - $HURNS_MONEY+=.applytax; - #POL_APPLYWEEK=gettimeparam(GETTIME_WEEKDAY); - array_push($HURNS_CANDIDATE$, strcharinfo(0)); - array_push($HURNS_VOTES, 0); - mesc l("Application successful!"), 3; - next; - break; - case 4: - POL_Candidate("HURNS"); - break; - default: - close; - } -} while (true); -end; + POL_TownHall("HURNS", l("Hurnscald Townhall"), .applytax); + end; OnInit: .applytax=100; diff --git a/npc/017-10/politics.txt b/npc/017-10/politics.txt index 8bcd24302..8c813c8cb 100644 --- a/npc/017-10/politics.txt +++ b/npc/017-10/politics.txt @@ -3,52 +3,11 @@ // Jesusalva // Description: // Town Administrator file, see npc/functions/politics.txt -// User variables: -// #POL_APPLYWEEK = Week of last application -// #POL_VOTEDAY = Day of last vote 017-10,54,35,0 script Land Of Fire Office NPC_POLITICS,{ -do -{ - mesc ".:: "+l("Land Of Fire Townhall")+" ::.", 2; - mesc l("Current Town Administrator: ")+$LOF_MAYOR$, 3; - POL_TownInfo("LOF"); - mesc l("Application fee: @@ GP", .applytax); - next; - select - l("Information"), - rif(strcharinfo(0) == $LOF_MAYOR$, l("Manage Town")), - rif(#POL_APPLYWEEK != gettimeparam(GETTIME_WEEKDAY), l("Apply for the office!")), - l("View Candidate List and cast a vote"), - l("[Quit]"); - switch (@menu) { - case 1: - POL_Information(); - break; - case 2: - POL_Manage("LOF"); - break; - case 3: - // array_push might be too sensible for getd/setd - if (Zeny < .applytax) - break; - Zeny-=.applytax; - $LOF_MONEY+=.applytax; - #POL_APPLYWEEK=gettimeparam(GETTIME_WEEKDAY); - array_push($LOF_CANDIDATE$, strcharinfo(0)); - array_push($LOF_VOTES, 0); - mesc l("Application successful!"), 3; - next; - break; - case 4: - POL_Candidate("LOF"); - break; - default: - close; - } -} while (true); -end; + POL_TownHall("HALIN", l("Land Of Fire Townhall"), .applytax); + end; OnInit: .applytax=100; diff --git a/npc/020-7-1/politics.txt b/npc/020-7-1/politics.txt index b6ca11685..54438d384 100644 --- a/npc/020-7-1/politics.txt +++ b/npc/020-7-1/politics.txt @@ -3,52 +3,11 @@ // Jesusalva // Description: // Town Administrator file, see npc/functions/politics.txt -// User variables: -// #POL_APPLYWEEK = Week of last application -// #POL_VOTEDAY = Day of last vote 020-7-1,37,61,0 script Nivalis Office NPC_POLITICS,{ -do -{ - mesc ".:: "+l("Nivalis Townhall")+" ::.", 2; - mesc l("Current Town Administrator: ")+$NIVAL_MAYOR$, 3; - POL_TownInfo("NIVAL"); - mesc l("Application fee: @@ GP", .applytax); - next; - select - l("Information"), - rif(strcharinfo(0) == $NIVAL_MAYOR$, l("Manage Town")), - rif(#POL_APPLYWEEK != gettimeparam(GETTIME_WEEKDAY), l("Apply for the office!")), - l("View Candidate List and cast a vote"), - l("[Quit]"); - switch (@menu) { - case 1: - POL_Information(); - break; - case 2: - POL_Manage("NIVAL"); - break; - case 3: - // array_push might be too sensible for getd/setd - if (Zeny < .applytax) - break; - Zeny-=.applytax; - $NIVAL_MONEY+=.applytax; - #POL_APPLYWEEK=gettimeparam(GETTIME_WEEKDAY); - array_push($NIVAL_CANDIDATE$, strcharinfo(0)); - array_push($NIVAL_VOTES, 0); - mesc l("Application successful!"), 3; - next; - break; - case 4: - POL_Candidate("NIVAL"); - break; - default: - close; - } -} while (true); -end; + POL_TownHall("NIVAL", l("Nivalis Townhall"), .applytax); + end; OnInit: .applytax=100; diff --git a/npc/functions/politics.txt b/npc/functions/politics.txt index 1cd4200a5..34abb4bbe 100644 --- a/npc/functions/politics.txt +++ b/npc/functions/politics.txt @@ -7,6 +7,8 @@ // not a citzen (yet). It'll be... I'll think in a name better than Minister. // Perhaps, Town Administrator. // Variables: +// #POL_APPLYWEEK = Week of last application +// #POL_VOTEDAY = Day of last vote // $LOC_MAYOR$ - Stores the name of current Hurnscald Mayor // $LOC_MONEY - Total money reserves of Hurnscald // $LOC_TAX - How much in % is charged as taxes. (OnBuy income) @@ -691,3 +693,57 @@ function script POL_Manage { } +// Interacting with the town book (tm) +function script POL_TownHall { + .@town$ = getarg(0); + .@header$ = getarg(1); + .@applyTax$ = getarg(2, 100); + + .@current_mayor$ = getd("$" + .@town$ + "_MAYOR$"); + + do +{ + mesc ".:: " + .@header$ + " ::.", 2; + mesc l("Current Town Administrator: ")+ .@current_mayor$, 3; + POL_TownInfo(.@town$); + mesc l("Application fee: %s GP", fnum(.@applyTax)); + next; + select + l("Information"), + rif(strcharinfo(0) == .@current_mayor$, l("Manage Town")), + rif(#POL_APPLYWEEK != gettimeparam(GETTIME_WEEKDAY), l("Apply for the office!")), + l("View Candidate List and cast a vote"), + l("[Quit]"); + + switch (@menu) { + case 1: + POL_Information(); + break; + case 2: + POL_Manage(.@town$); + break; + case 3: + // array_push might be too sensible for getd/setd + if (Zeny < .@applyTax) + break; + Zeny -= .@applyTax; + .@moneyVar$ = "$" + .@town$ +"_MONEY"; + setd(.@moneyVar$, getd(.@moneyVar$) + .@applyTax); + #POL_APPLYWEEK=gettimeparam(GETTIME_WEEKDAY); + + .@candidates$ = getd("$" + .@town$ + "_CANDIDATE$"); + .@votes$ = getd("$" + .@town$ + "_VOTES"); + array_push(.@candidates$, strcharinfo(0)); + array_push(.@votes, 0); + mesc l("Application successful!"), 3; + next; + break; + case 4: + POL_Candidate(.@town$); + break; + default: + close; + } +} while (true); +end; +} |