Turns played: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
mNo edit summary
imported>Eliteofdelete
Fixed some types in the code sample
 
(One intermediate revision by the same user not shown)
Line 16: Line 16:
<p>This exactly duplicates the function [[my_turncount|my_turncount()]]. Indications are that it was added as part at attempt to support semirare counters, but nothing ever came of it. Oops. <span class="plainlinks">[http://kolmafia.us/showthread.php?4061 Discussion here]</span>.|
<p>This exactly duplicates the function [[my_turncount|my_turncount()]]. Indications are that it was added as part at attempt to support semirare counters, but nothing ever came of it. Oops. <span class="plainlinks">[http://kolmafia.us/showthread.php?4061 Discussion here]</span>.|


needscode=yes|
code1={{CodeSample|
title=Code Samples|
description=The following example is a function that saves relevant ascension info into a text file called "Ascension History" located in Data. It should be called after, and only after, the Naughty Sorc was defeated.|
code=
<syntaxhighlight>
void ascension_tracker() {
  if (get_property("questL13Final") == "finished") {
      string[int] info;
      string class2;
      if (my_class() == $class[Accordion Thief])
        class2 = "an Accordion Thief";
      else
        class2 = "a "+my_class()+"";
      file_to_map("Ascension History.txt", info); 
      string ascension_tracker = ""+my_name()+" completed a "+my_turncount()+" adventure ascension in "+my_daycount()+" days as "+class2+" with path "+my_path()+" on "+now_to_string("MM/dd/yyyy")+".";
      print(ascension_trackr, "green");
      info [count(info)] = ascension_tracker;
      map_to_file(info, "Ascension History.txt", false);
  }
}
//Insert Code to kill Naughty Sorc, or kill her by hand
//Call ascension_tracker
ascension_tracker();
</syntaxhighlight>|
 
}}|


see_also={{SeeAlso|my_turncount}}|
see_also={{SeeAlso|my_turncount}}|

Latest revision as of 07:14, 22 November 2015

Function Syntax

int turns_played()

This function returns the total number of adventures used thus far by the logged-in character during the current ascension.

This exactly duplicates the function my_turncount(). Indications are that it was added as part at attempt to support semirare counters, but nothing ever came of it. Oops. Discussion here.

Code Samples

The following example is a function that saves relevant ascension info into a text file called "Ascension History" located in Data. It should be called after, and only after, the Naughty Sorc was defeated.

void ascension_tracker() {
   if (get_property("questL13Final") == "finished") {
      string[int] info;
      string class2;
      if (my_class() == $class[Accordion Thief])
         class2 = "an Accordion Thief";
      else
         class2 = "a "+my_class()+"";
      file_to_map("Ascension History.txt", info);   
      string ascension_tracker = ""+my_name()+" completed a "+my_turncount()+" adventure ascension in "+my_daycount()+" days as "+class2+" with path "+my_path()+" on "+now_to_string("MM/dd/yyyy")+".";
      print(ascension_trackr, "green");
      info [count(info)] = ascension_tracker;
      map_to_file(info, "Ascension History.txt", false);
   }
}
//Insert Code to kill Naughty Sorc, or kill her by hand
//Call ascension_tracker
ascension_tracker();

See Also

my_turncount()

Special

When not logged in, this function returns 0.