summaryrefslogtreecommitdiff
path: root/npc/functions
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-08-31 17:50:20 -0300
committerJesusaves <cpntb1@ymail.com>2019-08-31 17:50:20 -0300
commitb78616340e2421bc9c53f6ceabdc26acd369c94f (patch)
treec15b2cbf37734591740bbd9ba3d4836e199b3f78 /npc/functions
parent7367e3a18b94e80e9f6e8a712fd1179bac367fa6 (diff)
downloadserverdata-b78616340e2421bc9c53f6ceabdc26acd369c94f.tar.gz
serverdata-b78616340e2421bc9c53f6ceabdc26acd369c94f.tar.bz2
serverdata-b78616340e2421bc9c53f6ceabdc26acd369c94f.tar.xz
serverdata-b78616340e2421bc9c53f6ceabdc26acd369c94f.zip
This is the basic for political system to work on HURNSCALD (alpha)
Diffstat (limited to 'npc/functions')
-rw-r--r--npc/functions/politics.txt54
-rw-r--r--npc/functions/util.txt6
2 files changed, 60 insertions, 0 deletions
diff --git a/npc/functions/politics.txt b/npc/functions/politics.txt
index b4ddde37d..64884ca46 100644
--- a/npc/functions/politics.txt
+++ b/npc/functions/politics.txt
@@ -138,6 +138,60 @@ OnSun0000:
rodex_sendmail(gf_charnameid($FROSTIA_MAYOR$), "Frostia Townhall", "Election Victory", "You've been elected to the office!");
end;
+}
+/////////////////////////
+
+
+// Dialog helpers
+// General info
+// POL_Information( )
+function script POL_Information {
+
+ mesc l("Weekly, at Sunday 00:00, elections are held.");
+ mesc l("The current town administrator will be re-elected if there are no candidates.");
+ mesc l("Town Administrator can use the town money for investments, and also receive a salary depending on how well the town is.");
+ next;
+ mesc l("A player may be the town admin of several different towns.");
+ mesc l("However, an account may only apply for an office weekly.");
+ mesc l("The account with highest votes will win. Ties will be solved by date of application.");
+ mesc l("An account may vote anywhere, but only once every day.");
+ next;
+ return;
+}
+
+// Candidate Info and voting
+// POL_Candidate( TOWNCODE )
+function script POL_Candidate {
+ copyarray( .@cd$, getd("$"+getarg(0)+"_CANDIDATE$"), getarraysize(getd("$"+getarg(0)+"_CANDIDATE$")) );
+ copyarray( .@vt, getd("$"+getarg(0)+"_VOTES"), getarraysize(getd("$"+getarg(0)+"_VOTES")) );
+ .@list="Don't vote";
+ for (.@i=0;.@i<getarraysize(.@cd$);.@i++) {
+ mesc .@cd$[.@i] + " - "+.@vt[.@i] + " " + l("votes");
+ .@list+=":"+.@cd$[.@i];
+ }
+
+ next;
+ if (#POL_VOTEDAY == gettimeparam(GETTIME_DAYOFMONTH))
+ return;
+ mesc l("In whom to vote?");
+ select .@list;
+ .@vote=@menu-1;
+
+ // Didn't vote
+ if (.@vote < 0)
+ return;
+
+ // Cast the vote
+ #POL_VOTEDAY=gettimeparam(GETTIME_DAYOFMONTH);
+ .@str$="$"+getarg(0)+"_VOTES"+"["+.@vote+"]";
+ .@vt=getd(.@str$);
+ setd(.@str$, .@vt+1);
+
+ mesc l("The vote was cast."), 3;
+ next;
+ return true;
}
+
+
diff --git a/npc/functions/util.txt b/npc/functions/util.txt
index 3b05c799b..389a764ac 100644
--- a/npc/functions/util.txt
+++ b/npc/functions/util.txt
@@ -799,6 +799,12 @@ function script gettimeparam {
if (.@p == GETTIME_DAYOFMONTH)
return .@t;
+ // Weeks (estimative)
+ .@a=.@t+3; // 01/01/1970 was a Thursday. So this will make it float at sunday.
+ .@a=.@a/7;
+ if (.@p == GETTIME_WEEKDAY)
+ return .@a;
+
// Months (estimative)
.@t=.@t/30;
if (.@p == GETTIME_MONTH)