<commit_before>/*

Needed so multiple screens can all know how to quickly find sessions.
Rare session finder, tournament,  etc.
 */
import '../SBURBSim.dart';
import '../navbar.dart';
import 'dart:html';
abstract class AuthorBot extends SimController {

  List<int> sessionsSimulated = [];

  List<SessionSummary> allSessionsSummaries = [];
  //how filtering works
  List<SessionSummary> sessionSummariesDisplayed = [];

  int numSimulationsDone = 0;
  int numSimulationsToDo = 0;
  bool needToScratch = false;

  AuthorBot() : super();

  void checkSessions() {
    numSimulationsDone = 0; //but don't reset stats
    sessionSummariesDisplayed = [];
    for(num i = 0; i<allSessionsSummaries.length; i++){
      sessionSummariesDisplayed.add(allSessionsSummaries[i]);
    }
    setHtml(querySelector("#story"), "");
    numSimulationsToDo = int.parse((querySelector("#num_sessions")as InputElement).value);
    (querySelector("#button")as ButtonElement).disabled =true;
    startSession(); //my callback is what will be different
  }






  @override
  void checkSGRUB() {
    throw "ab does not do this";
  }


  @override
  void easterEggCallBack() {
    //only diff from story is don't check SGRUB
    initializePlayers(curSessionGlobalVar.players,curSessionGlobalVar); //need to redo it here because all other versions are in case customizations
    if(doNotRender == true){
      intro();
    }else{
      load(curSessionGlobalVar.players, getGuardiansForPlayers(curSessionGlobalVar.players),""); //in loading.js
    }
  }

  @override
  void easterEggCallBackRestart() {
    initializePlayers(curSessionGlobalVar.players,curSessionGlobalVar); //need to redo it here because all other versions are in case customizations
    intro();
  }


  @override
  void processCombinedSession() {
    ////print("Debugging AB: Checking process combo session");
    Session newcurSessionGlobalVar = curSessionGlobalVar.initializeCombinedSession();
    if(newcurSessionGlobalVar != null){
     // //print("debugging AB: doing a combo session");
      curSessionGlobalVar = newcurSessionGlobalVar;
      appendHtml(querySelector("#story"),"<br><Br> But things aren't over, yet. The survivors manage to contact the players in the universe they created. Time has no meaning between universes, and they are given ample time to plan an escape from their own Game Over. They will travel to the new universe, and register as players there for session " + curSessionGlobalVar.session_id.toString() + ". ");
      intro();
    }else{
      ////print("Debugging AB: can't combo, can't scratch. just do next session.");
      needToScratch = false; //can't scratch if skaiai is a frog
      curSessionGlobalVar.stats.makeCombinedSession = false;
      summarizeSession(curSessionGlobalVar);
    }
  }

  //AB's reckoning is like the normal one, but if the session ends at the recknoing, ab knows what to do.
  @override
  void reckoning() {
    Scene s = new Reckoning(curSessionGlobalVar);
    s.trigger(curSessionGlobalVar.players);
    s.renderContent(curSessionGlobalVar.newScene());
    if(!curSessionGlobalVar.stats.doomedTimeline){
      ////print("debugging AB: reckoning tick for ${curSessionGlobalVar.session_id}");
      reckoningTick();
      return null;
    }else{
      ////print("debugging AB: no reckoning, doomed timeline for ${curSessionGlobalVar.session_id}");
      if(needToScratch){
       // //print("debugging AB: scratch ${curSessionGlobalVar.session_id}");
        scratchAB(curSessionGlobalVar);
        return null;
      }
     // //print("debugging AB: no scratch ${curSessionGlobalVar.session_id}");
      //////print("doomed timeline prevents reckoning");
      List<Player> living = findLivingPlayers(curSessionGlobalVar.players);
      if(curSessionGlobalVar.stats.scratched || living.length == 0){ //can't scrach so only way to keep going.
        ////print("doomed scratched timeline");
        summarizeSession(curSessionGlobalVar);
        return null;
      }

    }
    //print("debugging AB: should never get here from reckoning, should either tick or ${curSessionGlobalVar.session_id}");
  }

  @override
  void reckoningTick([num time]) {
   // //print("Debugging AB: reckoning tick in session:  ${curSessionGlobalVar.session_id}");
    ////print("Reckoning Tick: " + curSessionGlobalVar.timeTillReckoning);
    if(curSessionGlobalVar.timeTillReckoning > -10){
      curSessionGlobalVar.timeTillReckoning += -1;
      curSessionGlobalVar.processReckoning(curSessionGlobalVar.players);
      window.requestAnimationFrame(reckoningTick);
      //new Timer(new Duration(milliseconds: 10), () => reckoningTick()); //sweet sweet async
      return null;
    }else{
     // //print("Debugging AB: Aftermath in session:  ${curSessionGlobalVar.session_id}");
      Scene s = new Aftermath(curSessionGlobalVar);
     // //print("Debugging AB:made aftermath session:  ${curSessionGlobalVar.session_id}");

      s.trigger(curSessionGlobalVar.players);
      ////print("Debugging AB: triggered Aftermath in session:  ${curSessionGlobalVar.session_id}");

      s.renderContent(curSessionGlobalVar.newScene());
      ////print("Debugging AB: done with Aftermath in session:  ${curSessionGlobalVar.session_id}");
      if(curSessionGlobalVar.stats.makeCombinedSession == true){
       // //print("Debugging AB: going to check for combo in session: ${curSessionGlobalVar.session_id}");
        processCombinedSession();  //make sure everything is done rendering first
        return null;
      }else{
       // //print("Debugging AB: not a combo in session:  ${curSessionGlobalVar.session_id}");
        if(needToScratch){
        //  //print("Debugging AB: going to scratch in session: curSessionGlobalVar.session_id");
          scratchAB(curSessionGlobalVar);
          return null;
        }
        List<Player> living = findLivingPlayers(curSessionGlobalVar.players);
       // //print("debugging AB: about to see if i should summarize session ${curSessionGlobalVar.session_id}");
        if(curSessionGlobalVar.stats.won || living.length == 0 || curSessionGlobalVar.stats.scratched){
          ////print("debugging AB: victory or utter defeat in session session ${curSessionGlobalVar.session_id}");
          summarizeSession(curSessionGlobalVar);
          return null;
        }else {
         // //print("debugging AB: I think i should not summarize session ${curSessionGlobalVar.session_id}, won is ${curSessionGlobalVar.won} living is ${living.length} and scratched is ${curSessionGlobalVar.scratched}");
          return null;
        }
      }
    }

    //print("Debugging AB: should neever get here, should be combo or scratch or victory or SOMEThing.");
  }


  void scratchAB(Session session) {
    needToScratch = false;
    //treat myself as a different session that scratched one?
    List<Player> living = findLivingPlayers(session.players);
    if(!session.stats.scratched && living.length > 0){
      ////print("scartch");
      //alert("AB sure loves scratching!");
      session.stats.scratchAvailable = true;
      summarizeSessionNoFollowup(session);
      scratch(); //not user input, just straight up do it.
    }else{
      ////print("no scratch");
      session.stats.scratchAvailable = false;
      summarizeSession(session);
    }

  }


  String getQuipAboutSession(SessionSummary sessionSummary) {
    String quip = "";
    num living = sessionSummary.getNumStat("numLiving");
    num dead = sessionSummary.getNumStat("numDead");
    Player strongest = sessionSummary.mvp;

    if(sessionSummary.session_id == 33 || getParameterByName("nepeta","")  == ":33"){
      quip += "Don't expect any of my reports on those cat trolls to be accurate. They are random as fuck. " ;
    }

    if(sessionSummary.getBoolStat("crashedFromSessionBug")){
      quip += Zalgo.generate("Fuck. Shit crashed hardcore. It's a good thing I'm a flawless robot, or I'd have nightmares from that. Just. Fuck session crashes.  Also, shout out to star.eyes: 'His palms are sweaty, knees weak, arms are heavy. There's vomit on his sweater already, mom's spaghetti'");
    }else if(sessionSummary.getBoolStat("crashedFromPlayerActions")){
      quip += Zalgo.generate("Fuck. God damn. Do Grim Dark players even KNOW how much it sucks to crash? Assholes.");
    }else if(sessionSummary.frogStatus == "Purple Frog" && sessionSummary.getBoolStat("blackKingDead")){
      quip += "Oh my fucking god is THAT what the Grim Dark players have been trying to do. Are organics really so dumb as to not realize how very little that benefits them?";
    }else if(!sessionSummary.scratched && dead == 0 && sessionSummary.frogStatus == "Full Frog" && sessionSummary.getBoolStat("ectoBiologyStarted") && !sessionSummary.getBoolStat("crashedFromCorruption") && !sessionSummary.getBoolStat("crashedFromPlayerActions")){
      quip += "Everything went better than expected." ; //???
    }else if(sessionSummary.getBoolStat("yellowYard") == true){
      quip += "Fuck. I better go grab JR. They'll want to see this. " ;
    }else if(living == 0){
      quip += "Shit, you do not even want to KNOW how everybody died." ;<commit_msg>AB doesn't think cataclysms are better than expected<commit_after>/*

Needed so multiple screens can all know how to quickly find sessions.
Rare session finder, tournament,  etc.
 */
import '../SBURBSim.dart';
import '../navbar.dart';
import 'dart:html';
abstract class AuthorBot extends SimController {

  List<int> sessionsSimulated = [];

  List<SessionSummary> allSessionsSummaries = [];
  //how filtering works
  List<SessionSummary> sessionSummariesDisplayed = [];

  int numSimulationsDone = 0;
  int numSimulationsToDo = 0;
  bool needToScratch = false;

  AuthorBot() : super();

  void checkSessions() {
    numSimulationsDone = 0; //but don't reset stats
    sessionSummariesDisplayed = [];
    for(num i = 0; i<allSessionsSummaries.length; i++){
      sessionSummariesDisplayed.add(allSessionsSummaries[i]);
    }
    setHtml(querySelector("#story"), "");
    numSimulationsToDo = int.parse((querySelector("#num_sessions")as InputElement).value);
    (querySelector("#button")as ButtonElement).disabled =true;
    startSession(); //my callback is what will be different
  }






  @override
  void checkSGRUB() {
    throw "ab does not do this";
  }


  @override
  void easterEggCallBack() {
    //only diff from story is don't check SGRUB
    initializePlayers(curSessionGlobalVar.players,curSessionGlobalVar); //need to redo it here because all other versions are in case customizations
    if(doNotRender == true){
      intro();
    }else{
      load(curSessionGlobalVar.players, getGuardiansForPlayers(curSessionGlobalVar.players),""); //in loading.js
    }
  }

  @override
  void easterEggCallBackRestart() {
    initializePlayers(curSessionGlobalVar.players,curSessionGlobalVar); //need to redo it here because all other versions are in case customizations
    intro();
  }


  @override
  void processCombinedSession() {
    ////print("Debugging AB: Checking process combo session");
    Session newcurSessionGlobalVar = curSessionGlobalVar.initializeCombinedSession();
    if(newcurSessionGlobalVar != null){
     // //print("debugging AB: doing a combo session");
      curSessionGlobalVar = newcurSessionGlobalVar;
      appendHtml(querySelector("#story"),"<br><Br> But things aren't over, yet. The survivors manage to contact the players in the universe they created. Time has no meaning between universes, and they are given ample time to plan an escape from their own Game Over. They will travel to the new universe, and register as players there for session " + curSessionGlobalVar.session_id.toString() + ". ");
      intro();
    }else{
      ////print("Debugging AB: can't combo, can't scratch. just do next session.");
      needToScratch = false; //can't scratch if skaiai is a frog
      curSessionGlobalVar.stats.makeCombinedSession = false;
      summarizeSession(curSessionGlobalVar);
    }
  }

  //AB's reckoning is like the normal one, but if the session ends at the recknoing, ab knows what to do.
  @override
  void reckoning() {
    Scene s = new Reckoning(curSessionGlobalVar);
    s.trigger(curSessionGlobalVar.players);
    s.renderContent(curSessionGlobalVar.newScene());
    if(!curSessionGlobalVar.stats.doomedTimeline){
      ////print("debugging AB: reckoning tick for ${curSessionGlobalVar.session_id}");
      reckoningTick();
      return null;
    }else{
      ////print("debugging AB: no reckoning, doomed timeline for ${curSessionGlobalVar.session_id}");
      if(needToScratch){
       // //print("debugging AB: scratch ${curSessionGlobalVar.session_id}");
        scratchAB(curSessionGlobalVar);
        return null;
      }
     // //print("debugging AB: no scratch ${curSessionGlobalVar.session_id}");
      //////print("doomed timeline prevents reckoning");
      List<Player> living = findLivingPlayers(curSessionGlobalVar.players);
      if(curSessionGlobalVar.stats.scratched || living.length == 0){ //can't scrach so only way to keep going.
        ////print("doomed scratched timeline");
        summarizeSession(curSessionGlobalVar);
        return null;
      }

    }
    //print("debugging AB: should never get here from reckoning, should either tick or ${curSessionGlobalVar.session_id}");
  }

  @override
  void reckoningTick([num time]) {
   // //print("Debugging AB: reckoning tick in session:  ${curSessionGlobalVar.session_id}");
    ////print("Reckoning Tick: " + curSessionGlobalVar.timeTillReckoning);
    if(curSessionGlobalVar.timeTillReckoning > -10){
      curSessionGlobalVar.timeTillReckoning += -1;
      curSessionGlobalVar.processReckoning(curSessionGlobalVar.players);
      window.requestAnimationFrame(reckoningTick);
      //new Timer(new Duration(milliseconds: 10), () => reckoningTick()); //sweet sweet async
      return null;
    }else{
     // //print("Debugging AB: Aftermath in session:  ${curSessionGlobalVar.session_id}");
      Scene s = new Aftermath(curSessionGlobalVar);
     // //print("Debugging AB:made aftermath session:  ${curSessionGlobalVar.session_id}");

      s.trigger(curSessionGlobalVar.players);
      ////print("Debugging AB: triggered Aftermath in session:  ${curSessionGlobalVar.session_id}");

      s.renderContent(curSessionGlobalVar.newScene());
      ////print("Debugging AB: done with Aftermath in session:  ${curSessionGlobalVar.session_id}");
      if(curSessionGlobalVar.stats.makeCombinedSession == true){
       // //print("Debugging AB: going to check for combo in session: ${curSessionGlobalVar.session_id}");
        processCombinedSession();  //make sure everything is done rendering first
        return null;
      }else{
       // //print("Debugging AB: not a combo in session:  ${curSessionGlobalVar.session_id}");
        if(needToScratch){
        //  //print("Debugging AB: going to scratch in session: curSessionGlobalVar.session_id");
          scratchAB(curSessionGlobalVar);
          return null;
        }
        List<Player> living = findLivingPlayers(curSessionGlobalVar.players);
       // //print("debugging AB: about to see if i should summarize session ${curSessionGlobalVar.session_id}");
        if(curSessionGlobalVar.stats.won || living.length == 0 || curSessionGlobalVar.stats.scratched){
          ////print("debugging AB: victory or utter defeat in session session ${curSessionGlobalVar.session_id}");
          summarizeSession(curSessionGlobalVar);
          return null;
        }else {
         // //print("debugging AB: I think i should not summarize session ${curSessionGlobalVar.session_id}, won is ${curSessionGlobalVar.won} living is ${living.length} and scratched is ${curSessionGlobalVar.scratched}");
          return null;
        }
      }
    }

    //print("Debugging AB: should neever get here, should be combo or scratch or victory or SOMEThing.");
  }


  void scratchAB(Session session) {
    needToScratch = false;
    //treat myself as a different session that scratched one?
    List<Player> living = findLivingPlayers(session.players);
    if(!session.stats.scratched && living.length > 0){
      ////print("scartch");
      //alert("AB sure loves scratching!");
      session.stats.scratchAvailable = true;
      summarizeSessionNoFollowup(session);
      scratch(); //not user input, just straight up do it.
    }else{
      ////print("no scratch");
      session.stats.scratchAvailable = false;
      summarizeSession(session);
    }

  }


  String getQuipAboutSession(SessionSummary sessionSummary) {
    String quip = "";
    num living = sessionSummary.getNumStat("numLiving");
    num dead = sessionSummary.getNumStat("numDead");
    Player strongest = sessionSummary.mvp;

    if(sessionSummary.session_id == 33 || getParameterByName("nepeta","")  == ":33"){
      quip += "Don't expect any of my reports on those cat trolls to be accurate. They are random as fuck. " ;
    }

    if(sessionSummary.getBoolStat("crashedFromSessionBug")){
      quip += Zalgo.generate("Fuck. Shit crashed hardcore. It's a good thing I'm a flawless robot, or I'd have nightmares from that. Just. Fuck session crashes.  Also, shout out to star.eyes: 'His palms are sweaty, knees weak, arms are heavy. There's vomit on his sweater already, mom's spaghetti'");
    }else if(sessionSummary.getBoolStat("crashedFromPlayerActions")){
      quip += Zalgo.generate("Fuck. God damn. Do Grim Dark players even KNOW how much it sucks to crash? Assholes.");
    }else if(sessionSummary.getBoolStat("cataclysmCrash")){
      quip += Zalgo.generate("Holy shit. JR. You NEED to keep those Wastes under control. Why did you ever enable them?");
    }else if(sessionSummary.frogStatus == "Purple Frog" && sessionSummary.getBoolStat("blackKingDead")){
      quip += "Oh my fucking god is THAT what the Grim Dark players have been trying to do. Are organics really so dumb as to not realize how very little that benefits them?";
    }else if(!sessionSummary.scratched && dead == 0 && sessionSummary.frogStatus == "Full Frog" && sessionSummary.getBoolStat("ectoBiologyStarted") && !sessionSummary.getBoolStat("crashedFromCorruption") && !sessionSummary.getBoolStat("crashedFromPlayerActions")){
      quip += "Everything went better than expected." ; //???
    }else if(sessionSummary.getBoolStat("yellowYard") == true){
      quip += "Fuck. I better go grab JR. They'll want to see this. " ;
    }else if(living == 0){
      quip += "Shit, you do not even want to KNOW how everybody died." ;
{'fraction_non_alphanumeric': 0.11619604024667315, 'fraction_numerical': 0.0019474196689386564, 'mean_word_length': 3.6778846153846154, 'pattern_counts': {'":': 2, '<': 21, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5922438', 'n_tokens_mistral': 5415, 'n_tokens_neox': 5159, 'n_words': 1507}