Difference between revisions of "Turns played"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
(Created page with '{{ #vardefine:name|turns_played}}{{ #vardefine:return_type|int}}{{ FunctionPage| name={{#var:name}}| function_category=Your Character| function1={{Function| name={{#var:name}}|…')
 
imported>Eliteofdelete
(Fixed some types in the code sample)
 
(3 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
FunctionPage|
 
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
function_category=Your Character|
 
  
 
function1={{Function|
 
function1={{Function|
Line 14: Line 13:
 
}}|
 
}}|
  
function_description=This function returns the total number of adventures used thus far by the logged-in character during the current ascension.|
+
function_description=This function returns the total number of adventures used thus far by the logged-in character during the current ascension.</p>
 +
<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}}|
 
special=When not logged in, this function returns 0.
 
special=When not logged in, this function returns 0.
 
}}
 
}}
{{RFI|Is there any reason for the duplicated functionality?|Should this function return total turns played (ever) instead?}}
+
 
 +
[[Category:Your Character]]

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.