<commit_before>import '../PlayerSpriteHandler.dart';
import 'dart:async';
import 'dart:convert';
import "dart:html";
import "dart:math" as Math;
import "dart:typed_data";
import "../SBURBSim.dart";
import "../includes/bytebuilder.dart";
import "../navbar.dart";
import '../includes/lz-string.dart';



class Player extends GameEntity{
    //TODO trollPlayer subclass of player??? (have subclass of relationship)
    num baby = null;
    CanvasElement firstStatsCanvas;
    bool canSkaia = false; //unlocked by finishing quests or by quest bed god tiering.

    //set when you set moon, so you know what your dream self looks like even if you don't have a moon.
    Palette dreamPalette;

    //if 0, not yet woken up.
    double moonChance = 0.0;
    num pvpKillCount = 0; //for stats.
    num timesDied = 0;
   static num maxHornNumber = 73; //don't fuck with this
    static num maxHairNumber = 74; //same
    Sprite sprite = null; //gets set to a blank sprite when character is created.
    bool deriveChatHandle = true;
    bool deriveSprite = true;
    bool deriveSpecibus = true;
    bool deriveLand = true;
    String flipOutReason = null; //if it's null, i'm not flipping my shit.
    Player flippingOutOverDeadPlayer = null; //don't let this go into url. but, don't flip out if the friend is currently alive, you goof.
    num denizen_index = 0; //denizen quests are in order.
    List<Player> ghostWisdom = <Player>[]; //keeps you from spamming the same ghost over and over for wisdom.
    bool trickster = false;
    bool sbahj = false;
    List<dynamic> sickRhymes = <dynamic>[]; //oh hell yes. Hell. FUCKING. Yes! TODO: make this its own type -PL
    bool robot = false;
    num ectoBiologicalSource = null; //might not be created in their own session now.
    SBURBClass class_name;
    Player _guardian = null; //no longer the sessions job to keep track.
    num number_confessions = 0;
    num number_times_confessed_to = 0;
    bool baby_stuck = false;
    String influenceSymbol = null; //multiple aspects can influence/mind control.
    Player influencePlayer = null; //who is controlling me? (so i can break free if i have more free will or they die)
    MiniSnapShot stateBackup = null; //if you get influenced by something, here's where your true self is stored until you break free.
    Aspect aspect;
    Land land;
    //want to be able to see when it's set
    Moon _moon;
    Interest interest1 = null;
    Interest interest2 = null;
    String chatHandle = null;
    GameEntity object_to_prototype; //mostly will be potential sprites, but sometimes a player
    //List<Relationship> relationships = [];  //TODO keep a list of player relationships and npc relationships. MAYBE don't wax red for npcs? dunno though.
    bool leveledTheHellUp = false; //triggers level up scene.
    List<String> mylevels = null;
    num level_index = -1; //will be ++ before i query
    bool godTier = false;
    String victimBlood = null; //used for murdermode players.
    num hair = null; //num hair = 16;
    String hairColor = null;
    bool dreamSelf = true;
    bool isTroll = false; //later
    String bloodColor = "#ff0000"; //human red.
    num leftHorn = null;
    num rightHorn = null;
    GameEntity myLusus = null;
    Quirk quirk = null;

    bool godDestiny = false;
    bool canGodTierRevive = true; //even if a god tier perma dies, a life or time player or whatever can brings them back.
    bool isDreamSelf = false; //players can be triggered for various things. higher their triggerLevle, greater chance of going murdermode or GrimDark.
    bool murderMode = false; //kill all players you don't like. odds of a just death skyrockets.
    bool leftMurderMode = false; //have scars, unless left via death.
    num corruptionLevelOther = 0; //every 100 points, sends you to next grimDarkLevel.
    num gnosis = 0; //sburbLore causes you to increase a level of this.
    num grimDark = 0; //  0 = none, 1 = some, 2 = some more 3 = full grim dark with aura and font and everything.
    bool leader = false;
    double landLevel = 0.0; //at 10, you can challenge denizen.  only space player can go over 100 (breed better universe.)
    bool denizenFaced = false;
    bool _denizenDefeated = false;
    bool denizenMinionDefeated = false;

    Moon get moon => _moon;

    String get moonName {
        if(_moon == null) {
            session.logger.info("AB: a player without a moon did something that needed a moon. probably kissing someone. whatever.");
            return "[ERROR: MOON NOT FOUND]";
        }else {
            return _moon.name;
        }
    }

    void set moon(Moon m) {
        if(m != null) ;
        _moon = m;
        if(m!=null) {
            dreamPalette = _moon.palette;
            syncToSessionMoon();
        }
    }

    //no longer allowed to set it.
    bool get denizenDefeated => _denizenDefeated;

    @override
    List<String> get bureaucraticBullshit {
        return class_name.bureaucraticBullshit;
    }

    @override
    void processCardFor() {
      class_name.processCard();
      aspect.processCard();
    }


    void set denizenDefeatedExplicitlySet(bool x) {
        _denizenDefeated = x;
    }

    @override
    String get name => "${title()}($chatHandle)";


    Player([Session session, SBURBClass this.class_name, Aspect this.aspect, GameEntity this.object_to_prototype, Moon m, bool this.godDestiny]) : super("", session) {
        //;
        moon = m; //set explicitly so triggers syncing.
        //testing something
    }

    @override
    StatHolder createHolder() => new PlayerStatHolder(this);

    bool fromThisSession(Session session) {
        return (this.ectoBiologicalSource == null || this.ectoBiologicalSource == session.session_id);
    }

    bool interestedInCategory(InterestCategory c) {
        return (interest1.category == c || interest2.category == c);
    }

    //stop having references to fake as fuck moons yo.
    //make sure you refere to private moon so you don't get in infinite loop
    void syncToSessionMoon() {
        //;
        if(moon == null || session == null || session.prospit == null || session.derse == null) return;
        //;
        if (moon.name == session.prospit.name) {
            ;
            _moon = session.prospit;
        } else if (moon.name == session.derse.name) {
            ;
            _moon = session.derse;
        }
    }

    bool isQuadranted() {
        if (!this
            .getHearts()
            .isEmpty) return true;
        if (!this
            .getClubs()
            .isEmpty) return true;
        if (!this
            .getDiamonds()
            .isEmpty) return true;
        if (!this
            .getSpades()
            .isEmpty) return true;
        return false;
    }

    List<Relationship> getClubs() {
        List<Relationship> ret = <Relationship>[];
        for (num i = 0; i < this.relationships.length; i++) {
            Relationship r = this.relationships[i];
            if (r.saved_type == r.clubs) {
                ret.add(r);
            }
        }
        return ret;
    }

    double get trashMobGrist => 10.0;

    ///not the only way to get grist, but you get a small base amount just for doing that shit
    void increaseLandLevel([double points = 1.0]) {
        landLevel += points; //TESTING what right value is to balance with FrogRewards
       increaseGrist();
    }

    void increaseGrist([double points = -1.0]) {
        if(points < 0) points = trashMobGrist;
        grist += points;
    }

    void copyFromOCDataString(String ocDataString) {
        String bs = "${window.location}?" + ocDataString; //need "?" so i can parse as url
        if(window.location.toString().contains("?")) bs = "${window.location}&" + ocDataString;
        String b = (getParameterByName("b", bs)); //this is pre-decoded, if you try to decode again breaks mages of heart which are "%"
        String s = getParameterByName("s", bs);
        String x = (getParameterByName("x", bs));
        List<Player> players = dataBytesAndStringsToPlayers(session,b, s, x); //technically an array of one players.;
        this.copyFromPlayer(players[0]);
    }

    @override
    List<Relationship> getQuadrants() {
        List<Relationship> ret = new List<Relationship>();
        ret.addAll(getHearts());
        ret.addAll(getSpades());
        ret.addAll(getDiamonds());
        ret.addAll(getClubs());
        return ret;
    }

    @override
    List<Relationship> getHearts() {
        List<Relationship> ret = <Relationship>[];
        for (num i = 0; i < this.relationships.length; i++) {
            Relationship r = this.relationships[i];
            if (r.saved_type == r.heart) {
                ret.add(r);
            }
        }
        return ret;
    }

    @override
    List<Fraymotif> get fraymotifsForDisplay {
        List<Fraymotif> ret = new List.from(fraymotifs);
        //;
        for(Item item in sylladex) {
            //;

            if(item is MagicalItem && aspect == Aspects.SAUCE) {
                MagicalItem m = item as MagicalItem;
                //only sauce players can use the ring
                ret.addAll(m.fraymotifs);
            }else if(Item is MagicalItem) {
                //MagicalItem m = item as MagicalItem;
                //if(!(m is Ring) && !(m is Scepter) ) ret.addAll(m.fraymotifs);
            }
        }
        return ret;
    }

    @override
    void flipOut(String reason) {
        ////print("flip out method called for: " + reason);
        this.flippingOutOverDeadPlayer = null;
        this.flipOutReason = reason;
    }

    @override
    void changeGrimDark(num val) {
        //this.grimDark += val;
        num tmp = this.grimDark + val;
        bool render = false;

        if (this.grimDark <= 3 && tmp > 3) { //newly GrimDark
            //;
            render = true;
        } else if (this.grimDark > 3 && tmp <= 3) { //newly recovered.
            render = true;
        }
        this.grimDark += val;
        if (render) {
            this.renderSelf("changeGrimDark");
        }
        this.grimDark = Math.min(4,this.grimDark); //don't be higher than 4
        this.grimDark = Math.max(0,this.grimDark); //don't be lower than 0.
    }

    void makeMurderMode() {
        this.murderMode = true;
        this.increasePower();<commit_msg>changed my mind<commit_after>import '../PlayerSpriteHandler.dart';
import 'dart:async';
import 'dart:convert';
import "dart:html";
import "dart:math" as Math;
import "dart:typed_data";
import "../SBURBSim.dart";
import "../includes/bytebuilder.dart";
import "../navbar.dart";
import '../includes/lz-string.dart';



class Player extends GameEntity{
    //TODO trollPlayer subclass of player??? (have subclass of relationship)
    num baby = null;
    CanvasElement firstStatsCanvas;
    bool canSkaia = false; //unlocked by finishing quests or by quest bed god tiering.

    //set when you set moon, so you know what your dream self looks like even if you don't have a moon.
    Palette dreamPalette;

    //if 0, not yet woken up.
    double moonChance = 0.0;
    num pvpKillCount = 0; //for stats.
    num timesDied = 0;
   static num maxHornNumber = 73; //don't fuck with this
    static num maxHairNumber = 74; //same
    Sprite sprite = null; //gets set to a blank sprite when character is created.
    bool deriveChatHandle = true;
    bool deriveSprite = true;
    bool deriveSpecibus = true;
    bool deriveLand = true;
    String flipOutReason = null; //if it's null, i'm not flipping my shit.
    Player flippingOutOverDeadPlayer = null; //don't let this go into url. but, don't flip out if the friend is currently alive, you goof.
    num denizen_index = 0; //denizen quests are in order.
    List<Player> ghostWisdom = <Player>[]; //keeps you from spamming the same ghost over and over for wisdom.
    bool trickster = false;
    bool sbahj = false;
    List<dynamic> sickRhymes = <dynamic>[]; //oh hell yes. Hell. FUCKING. Yes! TODO: make this its own type -PL
    bool robot = false;
    num ectoBiologicalSource = null; //might not be created in their own session now.
    SBURBClass class_name;
    Player _guardian = null; //no longer the sessions job to keep track.
    num number_confessions = 0;
    num number_times_confessed_to = 0;
    bool baby_stuck = false;
    String influenceSymbol = null; //multiple aspects can influence/mind control.
    Player influencePlayer = null; //who is controlling me? (so i can break free if i have more free will or they die)
    MiniSnapShot stateBackup = null; //if you get influenced by something, here's where your true self is stored until you break free.
    Aspect aspect;
    Land land;
    //want to be able to see when it's set
    Moon _moon;
    Interest interest1 = null;
    Interest interest2 = null;
    String chatHandle = null;
    GameEntity object_to_prototype; //mostly will be potential sprites, but sometimes a player
    //List<Relationship> relationships = [];  //TODO keep a list of player relationships and npc relationships. MAYBE don't wax red for npcs? dunno though.
    bool leveledTheHellUp = false; //triggers level up scene.
    List<String> mylevels = null;
    num level_index = -1; //will be ++ before i query
    bool godTier = false;
    String victimBlood = null; //used for murdermode players.
    num hair = null; //num hair = 16;
    String hairColor = null;
    bool dreamSelf = true;
    bool isTroll = false; //later
    String bloodColor = "#ff0000"; //human red.
    num leftHorn = null;
    num rightHorn = null;
    GameEntity myLusus = null;
    Quirk quirk = null;

    bool godDestiny = false;
    bool canGodTierRevive = true; //even if a god tier perma dies, a life or time player or whatever can brings them back.
    bool isDreamSelf = false; //players can be triggered for various things. higher their triggerLevle, greater chance of going murdermode or GrimDark.
    bool murderMode = false; //kill all players you don't like. odds of a just death skyrockets.
    bool leftMurderMode = false; //have scars, unless left via death.
    num corruptionLevelOther = 0; //every 100 points, sends you to next grimDarkLevel.
    num gnosis = 0; //sburbLore causes you to increase a level of this.
    num grimDark = 0; //  0 = none, 1 = some, 2 = some more 3 = full grim dark with aura and font and everything.
    bool leader = false;
    double landLevel = 0.0; //at 10, you can challenge denizen.  only space player can go over 100 (breed better universe.)
    bool denizenFaced = false;
    bool _denizenDefeated = false;
    bool denizenMinionDefeated = false;

    Moon get moon => _moon;

    String get moonName {
        if(_moon == null) {
            session.logger.info("AB: a player without a moon did something that needed a moon. probably kissing someone. whatever.");
            return "[ERROR: MOON NOT FOUND]";
        }else {
            return _moon.name;
        }
    }

    void set moon(Moon m) {
        if(m != null) ;
        _moon = m;
        if(m!=null) {
            dreamPalette = _moon.palette;
            syncToSessionMoon();
        }
    }

    //no longer allowed to set it.
    bool get denizenDefeated => _denizenDefeated;

    @override
    List<String> get bureaucraticBullshit {
        return class_name.bureaucraticBullshit;
    }

    @override
    void processCardFor() {
      class_name.processCard();
      aspect.processCard();
    }


    void set denizenDefeatedExplicitlySet(bool x) {
        _denizenDefeated = x;
    }

    @override
    String get name => "${title()}($chatHandle)";


    Player([Session session, SBURBClass this.class_name, Aspect this.aspect, GameEntity this.object_to_prototype, Moon m, bool this.godDestiny]) : super("", session) {
        //;
        moon = m; //set explicitly so triggers syncing.
        //testing something
    }

    @override
    StatHolder createHolder() => new PlayerStatHolder(this);

    bool fromThisSession(Session session) {
        return (this.ectoBiologicalSource == null || this.ectoBiologicalSource == session.session_id);
    }

    bool interestedInCategory(InterestCategory c) {
        return (interest1.category == c || interest2.category == c);
    }

    //stop having references to fake as fuck moons yo.
    //make sure you refere to private moon so you don't get in infinite loop
    void syncToSessionMoon() {
        //;
        if(moon == null || session == null || session.prospit == null || session.derse == null) return;
        //;
        if (moon.name == session.prospit.name) {
            ;
            _moon = session.prospit;
        } else if (moon.name == session.derse.name) {
            ;
            _moon = session.derse;
        }
    }

    bool isQuadranted() {
        if (!this
            .getHearts()
            .isEmpty) return true;
        if (!this
            .getClubs()
            .isEmpty) return true;
        if (!this
            .getDiamonds()
            .isEmpty) return true;
        if (!this
            .getSpades()
            .isEmpty) return true;
        return false;
    }

    List<Relationship> getClubs() {
        List<Relationship> ret = <Relationship>[];
        for (num i = 0; i < this.relationships.length; i++) {
            Relationship r = this.relationships[i];
            if (r.saved_type == r.clubs) {
                ret.add(r);
            }
        }
        return ret;
    }

    double get trashMobGrist => 10.0;

    ///not the only way to get grist, but you get a small base amount just for doing that shit
    void increaseLandLevel([double points = 1.0]) {
        landLevel += points; //TESTING what right value is to balance with FrogRewards
       increaseGrist();
    }

    void increaseGrist([double points = -1.0]) {
        if(points < 0) points = trashMobGrist;
        grist += points;
    }

    void copyFromOCDataString(String ocDataString) {
        String bs = "${window.location}?" + ocDataString; //need "?" so i can parse as url
        if(window.location.toString().contains("?")) bs = "${window.location}&" + ocDataString;
        String b = (getParameterByName("b", bs)); //this is pre-decoded, if you try to decode again breaks mages of heart which are "%"
        String s = getParameterByName("s", bs);
        String x = (getParameterByName("x", bs));
        List<Player> players = dataBytesAndStringsToPlayers(session,b, s, x); //technically an array of one players.;
        this.copyFromPlayer(players[0]);
    }

    @override
    List<Relationship> getQuadrants() {
        List<Relationship> ret = new List<Relationship>();
        ret.addAll(getHearts());
        ret.addAll(getSpades());
        ret.addAll(getDiamonds());
        ret.addAll(getClubs());
        return ret;
    }

    @override
    List<Relationship> getHearts() {
        List<Relationship> ret = <Relationship>[];
        for (num i = 0; i < this.relationships.length; i++) {
            Relationship r = this.relationships[i];
            if (r.saved_type == r.heart) {
                ret.add(r);
            }
        }
        return ret;
    }

    @override
    List<Fraymotif> get fraymotifsForDisplay {
        List<Fraymotif> ret = new List.from(fraymotifs);
        //;
        for(Item item in sylladex) {
            //;

            if(item is MagicalItem && aspect == Aspects.SAUCE) {
                MagicalItem m = item as MagicalItem;
                //only sauce players can use the ring
                ret.addAll(m.fraymotifs);
            }else if(Item is MagicalItem) {
                //MagicalItem m = item as MagicalItem;
                //if(!(m is Ring) && !(m is Scepter) ) ret.addAll(m.fraymotifs);
            }
        }
        return ret;
    }

    @override
    void flipOut(String reason) {
        ////print("flip out method called for: " + reason);
        this.flippingOutOverDeadPlayer = null;
        this.flipOutReason = reason;
    }

    @override
    void changeGrimDark(num val) {
        //this.grimDark += val;
        num tmp = this.grimDark + val;
        bool render = false;

        if (this.grimDark <= 3 && tmp > 3) { //newly GrimDark
            //;
            render = true;
        } else if (this.grimDark > 3 && tmp <= 3) { //newly recovered.
            render = true;
        }
        this.grimDark += val;
        if (render) {
            this.renderSelf("changeGrimDark");
        }
        //jr of 10/22/2018 says that this might help keep things from acting weird
        //this.grimDark = Math.min(4,this.grimDark); //don't be higher than 4
        //this.grimDark = Math.max(0,this.grimDark); //don't be lower than 0.
    }

    void makeMurderMode() {
        this.murderMode = true;
        this.increasePower();
{'fraction_non_alphanumeric': 0.10446536326333575, 'fraction_numerical': 0.0060825488776249095, 'mean_word_length': 2.285125277513479, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 55, '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': 4, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3295236', 'n_tokens_mistral': 6360, 'n_tokens_neox': 6087, 'n_words': 2066}