How to use flagKeep method in ng-mocks

Best JavaScript code snippet using ng-mocks

ai-functions-class.js

Source:ai-functions-class.js Github

copy

Full Screen

1////////// AI ALGORITHMS RESULTS CLASS //////////2/* These objects return the action Key and the target varNames referring to the action the acting character is going to use. */3window.aiResults = function() {4 this.actionKey = "doNothing";5 this.targetsIDs = [];6};7// Constructors, serializers, etc.8aiResults.prototype._init = function (obj) {9 Object.keys(obj).forEach(function (pn) {10 this[pn] = clone(obj[pn]);11 }, this);12 13 return this;14};15aiResults.prototype.clone = function () {16 return (new aiResults())._init(this);17};18////////// AI ALGORITHMS CLASS //////////19/* AI Algorithms are objects assigned to a character at the beginning of a scene.20 They hold all the required functions and information to determine the behavior of a given character during the scene. */21window.aiAlgorithm = function() {22 this.key;23 this.callAction = null;24 this.disablePositions = false;25 26 this.role = "none";27 // this.rolePreferences = weightedList28 // rolePreferences refers to a weighted list linked to the role assigned to the character for the scene29 // role and rolePreferences must be set using a custom function.30 // If role isn't set to "none", algorithms that use weighted lists will take rolePreferences into account31 // this.updateRolePreferences = function() // Must be set along with role32 33 this.setRoleEqualFooting = function() {34 this.role = "equalFooting";35 this.rolePreferences = createPreferencesWeightedList();36 this.rolePreferences.position.w = 300;37 this.rolePreferences.foreplay.w = 300;38 this.rolePreferences.continuedAction.w = 200;39 40 this.updateRolePreferences = function(lastActionKey) {41 this.rolePreferences.position.w += 20;42 if ( setup.saList[lastActionKey].flavorTags.includes("position") ) {43 // State.variables.sc.sceneLog += " Decided to use action last turn. Decreasing chance of using positions again. ; ";44 this.rolePreferences.position.w = 0;45 }46 else if ( setup.saList[lastActionKey].flavorTags.includes("continuedAction") ) {47 this.rolePreferences.continuedAction.w = 100;48 }49 if ( this.rolePreferences.foreplay.w > 100 ) {50 this.rolePreferences.foreplay.w -= 40;51 }52 if ( this.rolePreferences.continuedAction.w < 200 ) {53 this.rolePreferences.continuedAction.w += 20;54 }55 }56 }57 this.setRolePassive = function() {58 this.role = "passive";59 this.rolePreferences = createPreferencesWeightedList();60 this.rolePreferences.position.w = 50;61 this.rolePreferences.foreplay.w = 310;62 this.rolePreferences.oral.w = 125;63 this.rolePreferences.useDick.w = 50;64 this.rolePreferences.bottom.w = 200;65 this.rolePreferences.submission.w = 120;66 this.rolePreferences.domination.w = 20;67 this.rolePreferences.top.w = 80;68 this.rolePreferences.charm.w = 120;69 this.rolePreferences.denial.w = 10;70 this.rolePreferences.continuedAction.w = 200;71 72 this.updateRolePreferences = function(lastActionKey) {73 if ( this.rolePreferences.foreplay.w > 110 ) {74 this.rolePreferences.foreplay.w -= 40;75 }76 if ( setup.saList[lastActionKey].flavorTags.includes("continuedAction") ) {77 this.rolePreferences.continuedAction.w = 100;78 }79 if ( this.rolePreferences.continuedAction.w < 200 ) {80 this.rolePreferences.continuedAction.w += 20;81 }82 }83 }84 this.setRoleActive = function() {85 this.role = "active";86 this.rolePreferences = createPreferencesWeightedList();87 this.rolePreferences.position.w = 200;88 this.rolePreferences.fullsex.w = 115;89 this.rolePreferences.talk.w = 105;90 this.rolePreferences.oral.w = 95;91 this.rolePreferences.useDick.w = 125;92 this.rolePreferences.bottom.w = 80;93 this.rolePreferences.submission.w = 20;94 this.rolePreferences.domination.w = 110;95 this.rolePreferences.top.w = 150;96 this.rolePreferences.foreplay.w = 90;97 this.rolePreferences.continuedAction.w = 200;98 this.rolePreferences.denial.w = 110;99 100 this.updateRolePreferences = function(lastActionKey) {101 this.rolePreferences.position.w += 30; // Position102 if ( setup.saList[lastActionKey].flavorTags.includes("position") ) {103 this.rolePreferences.position.w = 20;104 }105 if ( this.rolePreferences.foreplay.w > 100 ) { // Foreplay106 this.rolePreferences.foreplay.w -= 20;107 }108 if ( setup.saList[lastActionKey].flavorTags.includes("continuedAction") ) { // Continued Actions109 this.rolePreferences.continuedAction.w = 100;110 }111 if ( this.rolePreferences.continuedAction.w < 200 ) {112 this.rolePreferences.continuedAction.w += 20;113 }114 }115 }116 this.setRoleRomantic = function() {117 this.role = "romantic";118 this.rolePreferences = createPreferencesWeightedList();119 this.rolePreferences.position.w = 200; 120 this.rolePreferences.talk.w = 110;121 this.rolePreferences.useEyes.w = 115;122 this.rolePreferences.targetEyes.w = 115;123 this.rolePreferences.domination.w = 75;124 this.rolePreferences.submission.w = 75;125 this.rolePreferences.useAnus.w = 25;126 this.rolePreferences.targetAnus.w = 25;127 this.rolePreferences.foreplay.w = 320;128 this.rolePreferences.continuedAction.w = 200;129 this.rolePreferences.denial.w = 80;130 131 this.updateRolePreferences = function(lastActionKey) {132 this.rolePreferences.position.w += 20;133 if ( setup.saList[lastActionKey].flavorTags.includes("position") ) {134 this.rolePreferences.position.w = 20;135 }136 if ( this.rolePreferences.foreplay.w > 120 ) {137 this.rolePreferences.foreplay.w -= 40;138 }139 if ( setup.saList[lastActionKey].flavorTags.includes("continuedAction") ) { // Continued Actions140 this.rolePreferences.continuedAction.w = 100;141 }142 if ( this.rolePreferences.continuedAction.w < 200 ) {143 this.rolePreferences.continuedAction.w += 20;144 }145 }146 }147 this.setRoleCompetition = function() {148 this.role = "competition";149 this.rolePreferences = createPreferencesWeightedList();150 this.rolePreferences.position.w = 250;151 this.rolePreferences.foreplay.w = 200;152 this.rolePreferences.talk.w = 80;153 this.rolePreferences.oral.w = 80;154 this.rolePreferences.useDick.w = 110;155 this.rolePreferences.hypnosis.w = 140;156 this.rolePreferences.domination.w = 200;157 this.rolePreferences.top.w = 120;158 this.rolePreferences.bottom.w = 20;159 this.rolePreferences.submission = 10;160 this.rolePreferences.continuedAction.w = 250;161 this.rolePreferences.denial.w = 150;162 163 this.updateRolePreferences = function(lastActionKey) {164 this.rolePreferences.position.w += 40;165 if ( setup.saList[lastActionKey].flavorTags.includes("position") ) {166 this.rolePreferences.position.w = 60;167 }168 if ( this.rolePreferences.foreplay.w > 80 ) {169 this.rolePreferences.foreplay.w -= 40;170 }171 if ( setup.saList[lastActionKey].flavorTags.includes("continuedAction") ) { // Continued Actions172 this.rolePreferences.continuedAction.w = 150;173 }174 if ( this.rolePreferences.continuedAction.w < 250 ) {175 this.rolePreferences.continuedAction.w += 20;176 }177 }178 }179 this.setRoleSubmission = function() {180 this.role = "submission";181 this.rolePreferences = createPreferencesWeightedList();182 this.rolePreferences.position.w = 20;183 this.rolePreferences.foreplay.w = 310;184 this.rolePreferences.oral.w = 110;185 this.rolePreferences.talk.w = 90;186 this.rolePreferences.targetDick.w = 110;187 this.rolePreferences.targetPussy.w = 110;188 this.rolePreferences.usePussy.w = 110;189 this.rolePreferences.useAnus.w = 110;190 this.rolePreferences.useDick.w = 110;191 this.rolePreferences.useMouth.w = 110;192 this.rolePreferences.bottom.w = 150;193 this.rolePreferences.submission.w = 200;194 this.rolePreferences.continuedAction.w = 200;195 this.rolePreferences.denial.w = 10;196 197 this.updateRolePreferences = function(lastActionKey) {198 if ( this.rolePreferences.foreplay.w > 110 ) {199 this.rolePreferences.foreplay.w -= 40;200 }201 if ( setup.saList[lastActionKey].flavorTags.includes("continuedAction") ) { // Continued Actions202 this.rolePreferences.continuedAction.w = 100;203 }204 if ( this.rolePreferences.continuedAction.w < 200 ) {205 this.rolePreferences.continuedAction.w += 20;206 }207 }208 }209 this.setRoleDomination = function() {210 this.role = "domination";211 this.rolePreferences = createPreferencesWeightedList();212 this.rolePreferences.position.w = 300;213 this.rolePreferences.foreplay.w = 220;214 this.rolePreferences.fullsex.w = 150;215 this.rolePreferences.oral.w = 80;216 this.rolePreferences.talk.w = 120;217 this.rolePreferences.useDick.w = 120;218 this.rolePreferences.usePussy.w = 110;219 this.rolePreferences.targetPussy.w = 110;220 this.rolePreferences.targetAnus.w = 110;221 this.rolePreferences.bottom.w = 0;222 this.rolePreferences.submission.w = 0;223 this.rolePreferences.top.w = 120;224 this.rolePreferences.domination.w = 200;225 this.rolePreferences.hypnosis.w = 120;226 this.rolePreferences.usePain.w = 150;227 this.rolePreferences.denial.w = 200;228 this.rolePreferences.continuedAction.w = 200;229 230 this.updateRolePreferences = function(lastActionKey) {231 this.rolePreferences.position.w += 30;232 if ( setup.saList[lastActionKey].flavorTags.includes("position") ) {233 this.rolePreferences.position.w = 20;234 }235 if ( this.rolePreferences.foreplay.w > 100 ) {236 this.rolePreferences.foreplay.w -= 40;237 }238 if ( setup.saList[lastActionKey].flavorTags.includes("continuedAction") ) { // Continued Actions239 this.rolePreferences.continuedAction.w = 100;240 }241 if ( this.rolePreferences.continuedAction.w < 200 ) {242 this.rolePreferences.continuedAction.w += 20;243 }244 }245 }246};247// Early AI algorithms - Sex Scenes248window.createAiFixedAction = function() {249 // This algorithm requires to be manually altered to set the fixed action and the fixed target.250 // It ignores the standard method's variables.251 var ai = new aiAlgorithm();252 ai.key = "fixedAction";253 ai.fixedAction = "doNothing";254 ai.fixedTarget = "chPlayerCharacter";255 ai.callAction = function(character,allyCharacters,enemyCharacters,currentTurn) {256 var results = new aiResults();257 results.actionKey = this.fixedAction;258 results.targetsIDs.push(this.fixedTarget);259 return results;260 }261 return ai;262}263window.createAiActionSequence = function() {264 // This algorithm requires a fixed target and a list of custom actions to be manually set.265 // It commands the user to sequentially use every listed action.266 var ai = new aiAlgorithm();267 ai.key = "actionSequence";268 ai.actionSequence = ["doNothing"];269 ai.fixedTarget = "chPlayerCharacter";270 ai.callAction = function(character,allyCharacters,enemyCharacters,currentTurn) {271 var results = new aiResults();272 results.actionKey = this.actionSequence[currentTurn-1];273 if ( results.actionKey == undefined ) {274 results.actionKey = "doNothing";275 }276 results.targetsIDs.push(this.fixedTarget);277 return results;278 }279 return ai;280}281window.createAiRandomAction = function() {282 var ai = new aiAlgorithm();283 ai.key = "randomAction";284 ai.fixedTarget = "chPlayerCharacter";285 ai.callAction = function(character,allyCharacters,enemyCharacters,currentTurn) {286 var results = new aiResults();287 288 var validActionsList = State.variables.sc.listUsableActions(character);289 validActionsList.shift();290 291 if ( validActionsList.length > 0 ) {292 results.actionKey = randomFromList(validActionsList);293 } else {294 results.actionKey = "doNothing";295 }296 297 results.targetsIDs.push(this.fixedTarget);298 return results;299 }300 return ai;301}302// Early AI algorithms - Battle Scenes303window.createAiRandomActionRandomOpponent = function() {304 var ai = new aiAlgorithm();305 ai.key = "randomAction";306 ai.callAction = function(character,allyCharacters,enemyCharacters,currentTurn) {307 var results = new aiResults();308 var validEnemies = [];309 for ( var enem of enemyCharacters ) {310 if ( gC(enem).koed == false ) {311 validEnemies.push(enem);312 }313 }314 315 if ( validEnemies.length > 0 ) {316 var target = randomFromList(validEnemies);317 318 var validActionsList = State.variables.sc.listUsableActionsOnTarget(character,target);319 validActionsList.shift();320 321 if ( validActionsList.length > 0 ) {322 results.actionKey = randomFromList(validActionsList);323 } else {324 results.actionKey = "doNothing";325 }326 327 results.targetsIDs.push(target);328 } else {329 results.actionKey = "doNothing";330 results.targetsIDs.push(character);331 }332 return results;333 }334 return ai;335}336window.createAiEarlyStrategic = function() { 337 var ai = new aiAlgorithm();338 ai.key = "earlyStrategy";339 ai. callAction = function(character,allyCharacters,enemyCharacters,currentTurn) {340 var results = new aiResults();341 var validEnemies = [];342 for ( var enem of enemyCharacters ) {343 if ( gC(enem).koed == false ) {344 validEnemies.push(enem);345 }346 }347 var target = character;348 var directEnemy = "";349 350 // Evaluate situation351 // "desperateAttack" -> Attack without restrain352 // "slowAttack" -> Try and buff oneself, then attack353 // "struggle" -> Get out of here354 // Is actor pinned down or pinning someone down? Are any of them close to defeat?355 // Is target's control depleted, or depleting? Is own control's depleted or depleting?356 // Is there health difference? Is there strength difference? Are buff actions possible?357 358 // On free359 // Is any enemy about to get Koed?360 // Is character about to get Koed?361 // Is there any down character? Should they get pinned down?362 // Are enemies running out of control?363 // Else - Self buff, debuff, attack control, attack364 var situation = "none";365 if ( gC(character).position.type == "free" ) { // Not in a position366 var weakenedEnemies = []; // Enemies with low lust367 var downedEnemies = []; // Enemies without control368 var downingEnemies = []; // Enemies with low control369 for ( var charKey of validEnemies ) {370 if ( getBarPercentage(charKey,"lust") != 0 && getBarPercentage(charKey,"lust") < 0.1 ) {371 weakenedEnemies.push(charKey);372 } else if ( gC(charKey).control == 0 && gC(charKey).position.type == "free" ) {373 downedEnemies.push(charKey);374 } else if ( gC(charKey).control <= gC(charKey).maxControl * 0.7 && gC(charKey).position.type == "free" ) {375 downingEnemies.push(charKey);376 }377 }378 379 if ( weakenedEnemies.length > 0 ) { // Any enemy about to get koed?380 situation = "desperateAttack";381 directEnemy = randomFromList(weakenedEnemies);382 } else if ( getBarPercentage(charKey,"lust") < 0.15 ) { // Character about to get koed?383 situation = "desperateAttack";384 directEnemy = randomFromList(validEnemies);385 } else if ( downedEnemies.length > 0 ) { // Pounce on anyone?386 var validDownedTargets = [];387 if ( gC(character).race == "monster" ) {388 validDownedTargets = downedEnemies;389 } else {390 for ( var charKey of downedEnemies ) {391 if ( (quantifyCharacterStrength(character) / quantifyCharacterStrength(charKey)) >= 0.7 ) {392 validDownedTargets.push(charKey);393 }394 }395 }396 if ( validDownedTargets.length > 0 && gC(character).control > gC(character).maxControl * 0.5 ) {397 situation = "pinTarget";398 directEnemy = randomFromList(validDownedTargets);399 }400 }401 if ( situation == "none" ) {402 if ( downingEnemies.length > 0 ) { // Attack someone's control?403 situation = "attackControl";404 directEnemy = randomFromList(downingEnemies);405 } else { // Else406 situation = "balanced";407 }408 }409 410 } else if ( gC(character).position.type == "active" ) { // Pinning someone down411 directEnemy = gC(character).position.targetsList[0];412 if ( getBarPercentage(character,"lust") < 0.4 || getBarPercentage(directEnemy,"lust") < 0.4 ) {413 situation = "desperateAttack";414 } else {415 situation = "slowAttack";416 }417 } else { // Pinned down by someone418 // Strategies: Deal as much damage as possible / Struggle / Buff, then deal damage419 directEnemy = gC(character).position.initiator;420 if ( getBarPercentage(character,"lust") < 0.25 || getBarPercentage(directEnemy,"lust") < 0.25 ) {421 situation = "desperateAttack";422 } else if ( getBarPercentage(character,"lust") > 0.5 && ( quantifyCharacterStats(character) / quantifyCharacterStats(directEnemy) ) > 2 ) {423 situation = "slowAttack";424 } else {425 situation = "struggle";426 }427 }428 429 // Situation into choice430 switch ( situation ) {431 case "none":432 break;433 case "balanced":434 var validActionsList = [];435 var buffActions = [];436 var damageActions = [];437 directEnemy = randomFromList(validEnemies);438 if ( countCharactersBuffs(character) < 2 && limitedRandomInt(10) >= 5 ) {439 validActionsList = State.variables.sc.listUsableActionsOnTarget(character,character);440 buffActions = purgeActionsWithoutStrategyTag(validActionsList,"buff");441 if ( buffActions.length > 0 && limitedRandomInt(100) > 49 ) {442 results.actionKey = randomFromList(buffActions);443 results.targetsIDs = [ character ];444 }445 }446 if ( results.actionKey == "doNothing" ) {447 validActionsList = State.variables.sc.listUsableActionsOnTarget(character,directEnemy);448 validActionsList = fixActorsActionListDependingOnTargetBeingMonster(character,validActionsList,directEnemy); // Monster fix449 damageActions = purgeActionsWithoutStrategyTag(validActionsList,"damageControl").concat(purgeActionsWithoutStrategyTag(validActionsList,"damageControl")).concat(purgeActionsWithoutStrategyTag(validActionsList,"debuff"));450 if ( damageActions.length > 0 ) {451 results.actionKey = randomFromList(damageActions);452 } else {453 results.actionKey = randomFromList(validActionsList);454 }455 results.targetsIDs = [ directEnemy ];456 }457 break;458 case "attackControl":459 // Pounce check460 directEnemy = randomFromList(downingEnemies);461 validActionsList = State.variables.sc.listUsableActionsOnTarget(character,directEnemy);462 validActionsList = fixActorsActionListDependingOnTargetBeingMonster(character,validActionsList,directEnemy); // Monster fix463 damageActions = purgeActionsWithoutStrategyTag(validActionsList,"pounce");464 var betterActions = purgeActionsWithStrategyTag(damageActions,"subpar");465 if ( damageActions.length > betterActions.length ) { damageActions = betterActions; }466 if ( damageActions.length > 0 ) {467 var randomPounce = randomFromList(damageActions);468 if ( setup.saList[randomPounce].doesHitLand(character,directEnemy).hit && setup.saList[randomPounce].doesHitLand(character,directEnemy).hit ) {469 results.actionKey = randomPounce;470 results.targetsIDs = [ directEnemy ];471 }472 }473 if ( results.actionKey == "doNothing" ) {474 damageActions = purgeActionsWithoutStrategyTag(validActionsList,"damageControl");475 if ( damageActions.length > 0 ) {476 results.actionKey = randomFromList(damageActions);477 results.targetsIDs = [ directEnemy ];478 }479 }480 if ( results.actionKey == "doNothing" ) {481 damageActions = purgeActionsWithoutStrategyTag(validActionsList,"damage").concat(purgeActionsWithoutStrategyTag(validActionsList,"debuff"));482 if ( damageActions.length > 0 ) {483 results.actionKey = randomFromList(damageActions);484 results.targetsIDs = [ directEnemy ];485 }486 }487 break;488 case "pinTarget":489 directEnemy = randomFromList(downedEnemies);490 validActionsList = State.variables.sc.listUsableActionsOnTarget(character,directEnemy);491 damageActions = purgeActionsWithoutStrategyTag(validActionsList,"pounce");492 var betterActions = purgeActionsWithoutStrategyTag(damageActions,"subpar");493 if ( damageActions.length > betterActions.length ) { damageActions = betterActions; }494 if ( damageActions.length > 0 ) {495 results.actionKey = randomFromList(damageActions);496 results.targetsIDs = [ directEnemy ];497 }498 break;499 case "desperateAttack":500 var validActionsList = State.variables.sc.listUsableActionsOnTarget(character,directEnemy);501 validActionsList = fixActorsActionListDependingOnTargetBeingMonster(character,validActionsList,directEnemy); // Monster fix502 var damageActions = purgeActionsWithoutStrategyTag(validActionsList,"damage");503 if ( damageActions.length > 0 ) {504 results.actionKey = randomFromList(damageActions);505 } else if ( validActionsList.length > 0 ) {506 results.actionKey = randomFromList(validActionsList);507 } else {508 results.actionKey = "struggle";509 }510 results.targetsIDs = [ directEnemy ];511 break;512 case "slowAttack":513 var validActionsList = [];514 if ( countCharactersBuffs(character) < 1 ) {515 validActionsList = State.variables.sc.listUsableActionsOnTarget(character,character);516 var buffActions = purgeActionsWithoutStrategyTag(validActionsList,"buff");517 if ( buffActions.length > 0 ) {518 results.actionKey = randomFromList(buffActions);519 results.targetsIDs = [ character ];520 }521 if ( results.actionKey == "doNothing" ) {522 validActionsList = State.variables.sc.listUsableActionsOnTarget(character,directEnemy);523 validActionsList = fixActorsActionListDependingOnTargetBeingMonster(character,validActionsList,directEnemy); // Monster fix524 var damageActions = purgeActionsWithoutStrategyTag(validActionsList,"damage").concat(purgeActionsWithoutStrategyTag(validActionsList,"debuff"));525 results.actionKey = randomFromList(damageActions);526 results.targetsIDs = [ directEnemy ];527 }528 }529 break;530 case "struggle":531 results.actionKey = "struggle";532 results.targetsIDs = [ directEnemy ];533 break;534 }535 536 // TO DO : Remove all of this537 if ( results.actionKey == "doNothing" || results.actionKey == undefined ) {538 if ( validEnemies.length > 0 ) {539 var target = randomFromList(validEnemies);540 541 var validActionsList = State.variables.sc.listUsableActionsOnTarget(character,target);542 validActionsList.shift();543 544 if ( validActionsList.length > 0 ) {545 results.actionKey = randomFromList(validActionsList);546 } else {547 results.actionKey = "doNothing";548 }549 550 results.targetsIDs = [ target ];551 } else {552 results.actionKey = "doNothing";553 results.targetsIDs = [ character ];554 }555 }556 557 return results;558 }559 return ai;560}561// AI Algorithm useful in some scripted sex scenes562window.createAiRandomChoice = function(choicesList) {563 // Choices list must be a list of two elements list, first element contains target, second element contains action key564 // Example: "[ ["chVal","strokePussy"] , ["chVal","strokeBreasts"] , ["chMir","spanking"] ]"565 var ai = new aiAlgorithm();566 ai.key = "randomChoice";567 ai.choicesList = choicesList;568 ai.callAction = function(character,allyCharacters,enemyCharacters,currentTurn) {569 var results = new aiResults();570 571 var randomInt = limitedRandomInt(choicesList.length - 1); 572 results.actionKey = this.choicesList[randomInt][1];573 results.targetsIDs = [ this.choicesList[randomInt][0] ];574 575 return results;576 }577 return ai;578}579// OLD GENERIC AI ALGORITHM - SEX SCENES580window.createAiWeightedActionByTaste = function() {581 var ai = new aiAlgorithm();582 ai.key = "weightedByTaste";583 ai.fixedTarget = "chPlayerCharacter";584 ai.callAction = function(character,allyCharacters,enemyCharacters,currentTurn) {585 var results = new aiResults();586 587 results.targetsIDs.push(this.fixedTarget);588 589 var validActionsList = State.variables.sc.listUsableActionsOnTarget(character,this.fixedTarget);590 validActionsList.shift();591 592 if ( validActionsList.length > 0 ) {593 var wList = listIntoWeightedList(validActionsList);594 595 for ( var item in wList ) {596 if (wList.hasOwnProperty(item) ) {597 wList[item].w = applyTasteWeightToAction(wList[item],character); // Taste weighted598 }599 }600 if ( this.role != "none" ) {601 wList = applyWeightListToActionList(wList,this.rolePreferences);602 }603 604 results.actionKey = randomFromWeightedList(wList);605 if ( results.actionKey == "errorWList" ) {606 results.actionKey = "doNothing";607 }608 } else {609 results.actionKey = "doNothing";610 }611 612 if ( this.role != "none" ) {613 this.updateRolePreferences(results.actionKey);614 }615 616 return results;617 }618 return ai;619}620// OLD GENERIC AI ALGORITHM - SEX SCENES - 07-2020 - Last updated: 04-2021621window.createAiWeightedMissionsByTasteOld = function() {622 var ai = new aiAlgorithm();623 ai.key = "weightedMissions";624 ai.mission = "none";625 ai.missionCommands = [];626 ai.callAction = function(character,allyCharacters,enemyCharacters,currentTurn) {627 628 var results = new aiResults();629 results.targetsIDs = ([chooseTargetDynamically(character,allyCharacters,enemyCharacters)]);630 var dice = 0;631 632 if ( gC(character).hasLead == true ) {633 dice = limitedRandomInt(1);634 if ( dice == 1 ) {635 if ( this.missionCommands.length < 1 && ( limitedRandomInt(2) < 1 ) ) {636 this.mission = "none"; 637 }638 if ( this.mission == "none" ) {639 var possibleMissions = randomFromList(returnValidSexSceneMissions(character,results.targetsIDs[0]));640 if ( possibleMissions != undefined ) {641 this.mission = possibleMissions;642 this.missionCommands = returnSexSceneMissionCommands(this.mission);643 } else {644 dice = 0;645 }646 if ( State.variables.sc.sceneConditions.includes("cantChangePositions") == false && State.variables.sc.sceneConditions.includes("cantCancelPositions") == false ) {647 State.variables.sc.cancelPosition(character);648 }649 }650 if ( this.missionCommands.length < 1 ) {651 dice = 0;652 } else {653 if ( isActionUsable(this.missionCommands[0],character,results.targetsIDs,false).isUsable ) {654 results.actionKey = this.missionCommands[0];655 } else {656 dice = 0;657 }658 this.missionCommands.shift();659 }660 }661 }662 if ( gC(character).hasLead == false || dice == 0 ) { // Typical behavior from weightedActionByTaste663 var validActionsList = State.variables.sc.listUsableActionsOnTarget(character,results.targetsIDs[0]);664 // Purge denial if target isn't close to orgasm665 if ( getBarPercentage(results.targetsIDs[0],"lust") > 0.1 || character == results.targetsIDs[0] ) {666 validActionsList = purgeActionsWithPreferenceTag(validActionsList,"denial");667 }668 validActionsList.shift();669 670 if ( validActionsList.length > 0 ) {671 var wList = listIntoWeightedList(validActionsList);672 673 for ( var item in wList ) {674 if (wList.hasOwnProperty(item) ) {675 wList[item].w = applyTasteWeightToAction(wList[item],character); // Taste weighted676 // Positional actions must not be chosen here, this portion removes their priority677 if ( setup.saList[wList[item].content].tags.includes("pos") ) {678 wList[item].w = 0;679 }680 // if ( setup.saList[wItem.content].flavorTags.includes(character.tastes[taste].content) ) {681 }682 }683 if ( this.role != "none" ) {684 wList = applyWeightListToActionList(wList,this.rolePreferences);685 }686 687 results.actionKey = randomFromWeightedList(wList);688 if ( results.actionKey == "errorWList" ) {689 results.actionKey = "doNothing";690 }691 } else {692 results.actionKey = "doNothing";693 }694 } else {695 }696 //var validActionsList = State.variables.sc.listUsableActionsOnTarget(character.varName697 698 return results;699 }700 return ai;701}702// NEW GENERIC AI ALGORITHM - SEX SCENES - 06-2021 - Last updated: 01-2021703window.createAiWeightedMissionsByTaste = function() {704 var ai = new aiAlgorithm();705 ai.key = "weightedMissions";706 ai.mission = "none";707 ai.missionCommands = []; // List of 2-sized arrays: {1st position is action, 2nd position is target}708 ai.callAction = function(character,allyCharacters,enemyCharacters,currentTurn) {709 var results = new aiResults();710 711 var tfScAlMs = true; // Shortcut to reduce frequency of choosing missions during tf scenes712 if ( gC(character).hasLead && State.variables.sc.hasOwnProperty("tfFlag") ) {713 if ( limitedRandomInt(64) > 48 ) {714 tfScAlMs = false;715 }716 }717 if ( gC(character).hasLead && State.variables.sc.sceneConditions.includes("cantChangePositions") == false && State.variables.sc.sceneConditions.includes("cantCancelPositions") == false && tfScAlMs == true ) {718 if ( this.missionCommands.length > 0 ) {719 // At this point "cancel" and "stay" commands shouldn't remain720 results.actionKey = this.missionCommands[0][0];721 results.targetsIDs = [this.missionCommands[0][1]];722 this.missionCommands.shift();723 } else {724 // Check canceleable continued actions725 if ( limitedRandomInt(100) < 5 ) {726 cancelAllCharActionsAndPositions(character);727 } else {728 charEvaluatesContinuedActionsToCancel(character);729 if ( State.variables.sc.hasOwnProperty("tfFlag") ) {730 cancelActionsConflictingWithTf(character);731 }732 }733 if ( isCharInPrimaryContinuedAction(character) ) {734 results = chooseValidBasicAction(character,allyCharacters,enemyCharacters);735 } else {736 if ( true ) {737 var mission = chooseCaMission(character,allyCharacters,enemyCharacters);738 if ( mission != "errorWList" ) {739 if ( mission != undefined && mission[0] != "" ) {740 if ( mission[2] == "stay" ) {741 // Skip position action742 this.missionCommands = [[mission[0],mission[1]]];743 results.actionKey = this.missionCommands[0][0];744 results.targetsIDs = [this.missionCommands[0][1]];745 this.missionCommands.shift();746 } else if ( mission[2] == "cancel" ) {747 // Cancel position and skip position action748 State.variables.sc.cancelPosition(character);749 this.missionCommands = [[mission[0],mission[1]]];750 results.actionKey = this.missionCommands[0][0];751 results.targetsIDs = [this.missionCommands[0][1]];752 this.missionCommands.shift();753 } else {754 this.missionCommands = [[mission[2],mission[1]],[mission[0],mission[1]]];755 results.actionKey = this.missionCommands[0][0];756 results.targetsIDs = [this.missionCommands[0][1]];757 this.missionCommands.shift();758 }759 }760 } else {761 results = chooseValidBasicAction(character,allyCharacters,enemyCharacters);762 }763 } else {764 results = chooseValidBasicAction(character,allyCharacters,enemyCharacters);765 }766 }767 }768 } else {769 this.missionCommands = [];770 results = chooseValidBasicAction(character,allyCharacters,enemyCharacters);771 }772 773 return results;774 }775 return ai;776}777// BASIC BATTLE AI ALGORITHM - SEX BATTLE SCENES - 08-2020778/*779window.createAiRandomActions = function() {780 var ai = new aiAlgorithm();781 ai.key = "randomActions";782 ai.callAction = function(character,allyCharacters,enemyCharacters,currentTurn) {783 var results = new aiResults();784 results.targetsIDs = [ enemyCharacters[0] ];785 786 787 788 return results;789 }790} */791// createAiRandomAction <-792// Auxiliar functions793window.chooseValidBasicAction = function(actor,allyCharacters,enemyCharacters) {794 var results = new aiResults();795 results.targetsIDs = [actor];796 results.actionKey = "doNothing";797 798 var allOtherCharacters = arrayMinusA(allyCharacters.concat(enemyCharacters),actor);799 800 // Actions on self801 var actionsOnSelf = listValidBasicActionsOnTarget(actor,actor); // Simple list of actions802 // Purge denial actions803 actionsOnSelf = purgeActionsWithPreferenceTag(actionsOnSelf,"denial");804 // Actions on others805 var nwActionsOnOthers = listTargetedWeightedActionListOnCharacters(actor,allOtherCharacters); // List of [target/action/weight=0]806 807 // What's this thing below? - wL = Weighted list of [t/a/w], wE = Weighted choice of [t/a] (I assume)808 809 // Are actions on self possible? Are actions on others possible?810 if ( actionsOnSelf.length == 0 && nwActionsOnOthers.length == 0 ) {811 // No actions possible812 } else if ( actionsOnSelf.length == 0 ) {813 // Only actions on others possible814 var wL = assignWeightsToTargetedWeightedActionList(actor,nwActionsOnOthers); // Weighted List815 var wE = randomFromWeightedList(wL); // Weighted choice816 results.targetsIDs = [wE[0]];817 results.actionKey = wE[1];818 } else if ( nwActionsOnOthers.length == 0 ) {819 // Only actions on self possible820 var wL = assignWeightsToSelfTargetedActionList(actor,actionsOnSelf);821 var wE = randomFromWeightedList(wL);822 results.targetsIDs = [actor];823 results.actionKey = wE;824 } else {825 // Both actions on self and others possible826 if ( actorChoosesWhetherToActOnSelf(actor) ) {827 // Acts on self828 var wL = assignWeightsToSelfTargetedActionList(actor,actionsOnSelf);829 var wE = randomFromWeightedList(wL);830 results.targetsIDs = [actor];831 results.actionKey = wE;832 } else {833 // Acts on others834 var wL = assignWeightsToTargetedWeightedActionList(actor,nwActionsOnOthers);835 var wE = randomFromWeightedList(wL);836 results.targetsIDs = [wE[0]];837 results.actionKey = wE[1];838 }839 }840 841 842 return results;843}844 // Basic actions845window.listValidBasicActionsOnTarget = function(actor,target) {846 var aList = State.variables.sc.listUsableActionsOnTarget(actor,target);847 aList = purgeActionsWithPreferenceTag(aList,"position");848 aList = arrayMinusA(aList,"doNothing");849 return aList;850 // Example of aList = ["baKissLips", "baStrokePussy", "pounceFrontalP2P", "kick", "taunt", "baTease"];851}852window.simulateListValidBasicActionsOnTargetDuringCombat = function(actor,target) {853 // Previous scene data854 var oriSceneType = State.variables.sc.sceneType;855 var oriTeamAchars = State.variables.sc.teamAcharKeys; 856 var oriTeamBchars = State.variables.sc.teamBcharKeys;857 858 // Simulate scene data859 State.variables.sc.sceneType = "bs";860 State.variables.sc.teamAcharKeys = [actor]; 861 State.variables.sc.teamBcharKeys = [target];862 863 var aList = State.variables.sc.listUsableActionsOnTarget(actor,target);864 aList = purgeActionsWithPreferenceTag(aList,"position");865 aList = arrayMinusA(aList,"doNothing");866 867 // Restore scene data868 State.variables.sc.sceneType = oriSceneType;869 State.variables.sc.teamAcharKeys = oriTeamAchars; 870 State.variables.sc.teamBcharKeys = oriTeamBchars;871 872 return aList;873 // Example of aList = ["baKissLips", "baStrokePussy", "pounceFrontalP2P", "kick", "taunt", "baTease"];874}875window.listTargetedWeightedActionListOnCharacters = function(actor,targets) {876 var totalList = [];877 for ( var cK of targets ) {878 var vba = listValidBasicActionsOnTarget(actor,cK);879 totalList = totalList.concat(actionListIntoTargetedWeightedActionlist(vba,cK));880 }881 return totalList;882}883window.actionListIntoTargetedWeightedActionlist = function(actionList,target) {884 var aList = [];885 for ( var a of actionList ) {886 aList.push([target,a,0]);887 }888 return aList;889}890window.assignWeightsToSelfTargetedActionList = function(actor,actionlist) {891 // RETURNS WEIGHTED LIST892 // To evalute: character tastes (weights and ranks, character desires)893 var pActions = State.variables.sc.listUsableActionsOnTarget(actor,actor);894 var desires = getActorsCurrentDesires(actor);895 var wL = new weightedList();896 for ( var a of pActions ) {897 wL[a] = new weightedRankedElement(a,assignWeightToActionFromActorToTargetWithDesires(a,actor,actor,desires,1));898 }899 // Content: actionKey900 return wL;901}902window.assignWeightsToTargetedWeightedActionList = function(actor,twaList) {903 // RETURNS WEIGHTED LIST904 // To evaluate: character tastes (weights and ranks), character desires, - NOT target's preference -905 var desires = getActorsCurrentDesires(actor);906 var targetsMultipliers = [];907 var wL = new weightedList();908 var i = 0;909 for ( var twa of twaList ) {910 var mult = 1;911 if ( targetsMultipliers.hasOwnProperty(twa[0]) ) {912 mult = targetsMultipliers[twa[0]];913 } else {914 targetsMultipliers[twa[0]] = 1;915 if ( gC(twa[0]).orgasmSceneCounter == 0 ) {916 targetsMultipliers[twa[0]] = 2;917 }918 mult = targetsMultipliers[twa[0]];919 }920 wL[i] = new weightedElement([twa[0],twa[1]],assignWeightToActionFromActorToTargetWithDesires(twa[1],actor,twa[0],desires,mult));921 i++;922 }923 // Content: [targetKey,actionKey],weight924 return wL;925}926window.assignWeightToActionFromActorToTargetWithDesires = function(action,actor,target,desires,mult) {927 var weight = 10 + limitedRandomInt(10);928 var newMult = 1;929 var desiresMultiplier = 1;930 var targetDesires = getActorsCurrentDesires(target);931 932 // Denial check933 if ( setup.saList[action].flavorTags.includes("denial") && getBarPercentage(target,"lust") > 0.15 ) {934 weight = 0;935 } else {936 for ( var taste of setup.saList[action].flavorTags ) {937 // Base preference938 weight *= setup.basePreferencesMultipliers[taste];939 var extraM = 1;940 if ( taste == "foreplay" || taste == "talk" || taste == "oral" || taste == "fullsex" ) {941 extraM = 0.5;942 }943 // Weights and ranks944 if ( taste != "position" && taste != "continuedAction" ) {945 newMult += gC(actor).tastes[taste].w * 0.01;946 newMult += (1 + gC(actor).tastes[taste].r * 0.5);947 newMult *= extraM;948 }949 // Desires950 if ( desires.includes(taste) ) {951 desiresMultiplier += (0.5 * extraM);952 }953 if ( targetDesires.includes(getOppositeTag(taste)) ) {954 desiresMultiplier += (0.25 * extraM);955 } 956 }957 weight *= (newMult + desiresMultiplier + mult);958 }959 if ( weight > 0 && State.variables.sc.hasOwnProperty("tfFlag") ) {960 if ( setup.saList[action].strategyTags.includes("tfPlus") ) {961 weight *= 4.5 + (State.variables.sc.currentTurn * 0.5);962 } else if ( setup.saList[action].strategyTags.includes("tfHalfPlus") ) {963 weight *= 2.2 + (State.variables.sc.currentTurn * 0.3);964 } else if ( setup.saList[action].strategyTags.includes("tfMinus") ) {965 weight /= 5;966 }967 }968 969 return weight;970}971 // Choose target972window.chooseTargetDynamically = function(character,allyCharacters,enemyCharacters) { // Updated 04-2021973 var mainTarget = "";974 975 var validActionsOnSelf = State.variables.sc.listUsableActionsOnTarget(character,character);976 var allOtherCharacters = arrayMinusA(allyCharacters.concat(enemyCharacters),character);977 // mainTarget = randomFromList(allOtherCharacters);978 979 if ( validActionsOnSelf.length > 1 ) {980 var threshold = 15;981 var loveMinusPleasure = getCharsDrivePercent(character,"dLove") - getCharsDrivePercent(character,"dPleasure");982 if ( loveMinusPleasure >= 0.1 ) {983 threshold = 10;984 } else if ( loveMinusPleasure <= -0.1 ) {985 threshold = 20;986 }987 988 if ( limitedRandomInt(100) > threshold ) {989 } else {990 mainTarget = character;991 }992 }993 994 if ( mainTarget == "" ) {995 for ( var cK of allOtherCharacters ) {996 if ( State.variables.sc.listUsableActionsOnTarget(character,cK).length < 2 ) {997 allOtherCharacters = arrayMinusA(allOtherCharacters,cK);998 }999 }1000 if ( allOtherCharacters.length > 0 ) {1001 mainTarget = randomFromList(allOtherCharacters);1002 } else {1003 mainTarget = character;1004 }1005 }1006 1007 return mainTarget;1008}1009window.actorChoosesWhetherToActOnSelf = function(character) {1010 var actsOnSelf = false;1011 1012 var threshold = 15;1013 var loveMinusPleasure = getCharsDrivePercent(character,"dLove") - getCharsDrivePercent(character,"dPleasure");1014 if ( loveMinusPleasure >= 0.1 ) {1015 threshold = 10;1016 } else if ( loveMinusPleasure <= -0.1 ) {1017 threshold = 20;1018 }1019 1020 if ( limitedRandomInt(100) > threshold ) {1021 } else {1022 actsOnSelf = true;;1023 }1024 1025 return actsOnSelf;1026}1027 // Aux1028window.getActorsCurrentDesires = function(actor) {1029 var tagsList = [];1030 for ( var as of gC(actor).alteredStates ) {1031 if ( as.hasOwnProperty("tag") ) {1032 tagsList.push(as.tag);1033 }1034 }1035 return tagsList;1036}1037window.charEvaluatesContinuedActionsToCancel = function(actor) {1038 var casToRemove = [];1039 var flagCancelPosition = false;1040 var i = 0;1041 for ( var ca of State.variables.sc.continuedActions ) {1042 if ( ca.initiator == actor || ca.targetsList.includes(actor) ) {1043 var cancelChance = 0;1044 if ( ca.rank == 2 ) {1045 cancelChance = -140 + ca.continuedTurns * 20;1046 } else {1047 cancelChance = -80 + ca.continuedTurns * 20;1048 }1049 for ( var tag of ca.flavorTags ) {1050 cancelChance -= gC(actor).tastes[tag].r * 5;1051 }1052 if ( cancelChance > limitedRandomInt(100) ) {1053 // Tick to cancel action1054 casToRemove = [i].concat(casToRemove);1055 if ( ca.rank == 2 ) {1056 if ( gC(actor).aiAlgorythm.missionCommands.length == 0 ) {1057 if ( limitedRandomInt(100) > 50 ) {1058 flagCancelPosition = true;1059 }1060 }1061 }1062 }1063 }1064 i++;1065 }1066 // Finish CAs in reverse order1067 for ( var id of casToRemove ) {1068 State.variables.sc.removeContinuedAction(id);1069 }1070 if ( flagCancelPosition ) {1071 State.variables.sc.cancelPosition(actor);1072 }1073}1074window.cancelAllCharActionsAndPositions = function(actor) {1075 var casToRemove = [];1076 var i = 0;1077 for ( var ca of State.variables.sc.continuedActions ) {1078 if ( ca.initiator == actor || ca.targetsList.includes(actor) ) {1079 casToRemove = [i].concat(casToRemove);1080 }1081 i++;1082 }1083 // Finish CAs in reverse order1084 for ( var id of casToRemove ) {1085 State.variables.sc.removeContinuedAction(id);1086 }1087 State.variables.sc.cancelPosition(actor);1088}1089window.cancelActionsConflictingWithTf = function(actor) {1090 if ( actor != State.variables.sc.tfTarget ) {1091 var tfActions = [];1092 var requiredTargetBps = [];1093 var requiredActorBps = [];1094 var conflictingContinuedActions = []; // Reverse position iterators1095 1096 // Get all tfActions from a tfActor1097 for ( var sa of gC(State.variables.sc.tfActors[0]).saList ) {1098 if ( setup.saList[sa].tags.includes("tf") ) {1099 tfActions.push(sa);1100 // Get all requiredBps1101 for ( var bp of setup.saList[sa].targetBpReqs ) {1102 if ( requiredTargetBps.includes(bp) == false ) {1103 requiredTargetBps.push(bp);1104 }1105 }1106 for ( var bp of setup.saList[sa].actorBpReqs ) {1107 if ( requiredActorBps.includes(bp) == false ) {1108 requiredActorBps.push(bp);1109 }1110 }1111 }1112 }1113 // Get all conflictingContinuedActions1114 var i = 0;1115 for ( var cA of State.variables.sc.continuedActions ) {1116 var selectedCa = false;1117 if ( cA.initiator == actor ) {1118 if ( cA.targetsList.includes(State.variables.sc.tfTarget) ) {1119 for ( var tBp of cA.targetsBodyparts ) {1120 if ( requiredTargetBps.includes(tBp) ) {1121 conflictingContinuedActions = [i].concat(conflictingContinuedActions);1122 selectedCa = true;1123 }1124 }1125 }1126 if ( selectedCa == false ) {1127 for ( var aBp of cA.initiatorBodyparts ) {1128 if ( requiredActorBps.includes(aBp) ) {1129 conflictingContinuedActions = [i].concat(conflictingContinuedActions);1130 }1131 }1132 }1133 i++;1134 }1135 }1136 // Cancel all conflictingContinuedActions in reverse order1137 for ( var id of conflictingContinuedActions ) {1138 State.variables.sc.removeContinuedAction(id);1139 }1140 }1141}1142 // Continued actions pathfinder1143window.chooseCaMission = function(actor,allyCharacters,enemyCharacters) {1144 var allOtherCharacters = arrayMinusA(allyCharacters.concat(enemyCharacters),actor);1145 var aOCcopy = allOtherCharacters;1146 var primaryCAlist = []; // Each usable CA is a property, containing a list with all valid positionings1147 var caUnweightedList = [];1148 var knownPrimaryCactions = getCharsPrimaryContinuedActions(actor); // Get known primary CAs1149 var potentialPositions = [];1150 for ( var target of aOCcopy ) {1151 // Get all potential positions1152 potentialPositions = potentialPositions.concat(findAllPotentialPositions(actor,target));1153 } 1154 // Generate primaryCAlist1155 for ( var posPair of potentialPositions ) {1156 for ( var ca of knownPrimaryCactions ) {1157 target = posPair[3];1158 if ( isActionUsableOnPos(ca,actor,[posPair[3]],posPair[0],[posPair[1]]).isUsable ) {1159 if ( primaryCAlist.hasOwnProperty(ca) ) {1160 if ( primaryCAlist[ca].hasOwnProperty(target) ) {1161 primaryCAlist[ca][target].push(posPair[2]);1162 } else {1163 primaryCAlist[ca][target] = [posPair[2]];1164 }1165 } else {1166 primaryCAlist.push(ca);1167 primaryCAlist[ca] = [];1168 if ( primaryCAlist[ca].hasOwnProperty(target) ) {1169 primaryCAlist[ca][target].push(posPair[2]);1170 } else {1171 primaryCAlist[ca][target] = [posPair[2]];1172 }1173 //primaryCAlist[ca] = [posPair];1174 }1175 }1176 }1177 }1178 // Example of primaryCAlist:1179 // "penetratePussy": Array(0) ["chPlayerCharacter": Array(2) ["mountFaceToFace", "mountFromBehind"]],1180 // "interlockLegs": Array(0) ["chPlayerCharacter": Array(2) ["mountFaceToFace", "mountFromBehind"]]1181 1182 for ( var cae of primaryCAlist ) {1183 var caeData = primaryCAlist[cae];1184 for ( var target of aOCcopy ) {1185 if ( caeData.hasOwnProperty(target) ) {1186 var firstMethod = caeData[target][0];1187 if ( firstMethod == "cancel" || firstMethod == "stay" ) {1188 caUnweightedList.push([cae,target,firstMethod]);1189 } else {1190 caUnweightedList.push([cae,target,randomFromList(caeData[target])]);1191 }1192 }1193 }1194 }1195 // Example of caUnweightedList:1196 // Array(2) [Array(3) ["penetratePussy", "chVal", "mountFromBehind"], Array(3) ["penetratePussy", "chPlayerCharacter", "mountFaceToFace"]]1197 1198 // Exception: if valid conditions, remove cAs conflicting with transformation1199 if ( State.variables.sc.hasOwnProperty("tfFlag") ) {1200 caUnweightedList = purgeCAsConflictingWithTransformationGoals(caUnweightedList,actor);1201 }1202 1203 // Generate weighted list1204 var wL = createWeightedListOfCaChoices(actor,caUnweightedList);1205 // Choose mission and translate it into instructions1206 var mission = randomFromWeightedList(wL);1207 1208 return mission;1209}1210window.findAllPotentialPositions = function(actor,target) {1211 var positions = [];1212 if ( areCharactersLinked(actor,target) ) {1213 positions.push([gC(actor).position.key,gC(target).position.key,"stay",target]);1214 positions.push(["free","free","cancel",target]);1215 } else if ( gC(actor).position.key == "free" && gC(target).position.key == "free" ) {1216 positions.push(["free","free","stay",target]);1217 }1218 // Get all position actions known by actor1219 var positionActions = purgeActionsWithoutPreferenceTag(gC(actor).saList,"position");1220 // Filter usable position actions1221 var usablePositionActions = [];1222 if ( gC(actor).aiAlgorythm.disablePositions == false ) {1223 for ( var pA of positionActions ) {1224 if ( State.variables.sc.hasOwnProperty("tfFlag") == false || setup.saList[pA].strategyTags.includes("tfPos") ) {1225 if ( isActionUsable(pA,actor,[target],false).isUsable ) {1226 usablePositionActions.push(pA);1227 } else if ( areCharactersLinked(actor,target) && isActionUsableOnPos(pA,actor,[target],"free",["free"]).isUsable ) {1228 // usablePositionActions.push(pA);1229 }1230 }1231 }1232 }1233 // Add position results from usable position actions1234 for ( var uPA of usablePositionActions ) {1235 if ( setup.saList[uPA].hasOwnProperty("positionResults") ) {1236 positions.push(setup.saList[uPA].positionResults.concat(uPA,target));1237 }1238 }1239 // Third element: keyword to reach position pair1240 // "stay": do not change positions ; "cancel": cancel current positioning1241 // Fourth element: Target1242 return positions;1243}1244window.getCharsPrimaryContinuedActions = function(charKey) {1245 var pca = [];1246 var caList = purgeActionsWithoutPreferenceTag(gC(charKey).saList,"continuedAction");1247 for ( var ca of caList ) {1248 if ( setup.saList[ca].hasOwnProperty("caRank") ) {1249 if ( setup.saList[ca].caRank == 2 ) {1250 pca.push(ca);1251 }1252 }1253 }1254 return pca;1255}1256window.createWeightedListOfCaChoices = function(actor,caPosChoicesList) {1257 // To evaluate: character tastes (weights and ranks), character desires, - NOT target's preference -1258 var desires = getActorsCurrentDesires(actor);1259 var targetsMultipliers = [];1260 var wL = new weightedList();1261 1262 var i = 0;1263 for ( var capCh of caPosChoicesList ) {1264 var mult = 1;1265 var target = capCh[1];1266 if ( targetsMultipliers.hasOwnProperty(target) ) {1267 mult = targetsMultipliers[target];1268 } else {1269 targetsMultipliers[target] = 1;1270 if ( gC(target).orgasmSceneCounter == 0 ) {1271 targetsMultipliers[target] = 2;1272 }1273 mult = targetsMultipliers[target];1274 }1275 wL[i] = new weightedElement(capCh,assignWeightToActionFromActorToTargetWithDesires(capCh[0],actor,target,desires,mult));1276 i++;1277 }1278 1279 return wL;1280}1281///// Old or combat1282 // Missions1283window.returnValidSexSceneMissions = function(character,target) {1284 // Very cheap version, this function will be upgraded into a full system1285 var validMissions = [];1286 if ( gC(character).hasFreeBodypart("dick") && gC(target).hasFreeBodypart("pussy") ) {1287 validMissions.push("penetratePussy");1288 }1289 if ( gC(character).hasFreeBodypart("pussy") && gC(target).hasFreeBodypart("pussy") ) {1290 validMissions.push("scissor");1291 }1292 if ( gC(character).hasFreeBodypart("dick") && gC(target).hasFreeBodypart("pussy") && gC(target).hasFreeBodypart("anus") && gC(character).race == "shapeshifter" && gC(character).saList.includes("doublePenetration") && State.variables.settings.anal == "enable" ) {1293 validMissions.push("doublePenetration");1294 }1295 if ( gC(character).hasFreeBodypart("dick") && gC(target).hasFreeBodypart("mouth") ) {1296 validMissions.push("getBlowjob");1297 }1298 if ( gC(character).hasFreeBodypart("pussy") && gC(target).hasFreeBodypart("mouth") ) {1299 validMissions.push("getCunnilingus");1300 }1301 return validMissions;1302}1303window.returnSexSceneMissionCommands = function(missionKey) {1304 var commandsChain = [];1305 switch(missionKey) {1306 case "penetratePussy":1307 commandsChain.push(randomFromList(["mountFromBehind","mountFaceToFace"]));1308 commandsChain.push("penetratePussy");1309 break;1310 case "doublePenetration":1311 commandsChain.push(randomFromList(["mountFromBehind","mountFaceToFace"]));1312 commandsChain.push("doublePenetration");1313 break;1314 case "scissor":1315 commandsChain.push("mountFaceToFace");1316 commandsChain.push("interlockLegs");1317 break;1318 case "getBlowjob":1319 commandsChain.push("makeKneel");1320 commandsChain.push("getBlowjob");1321 break;1322 case "getCunnilingus":1323 commandsChain.push("makeKneel");1324 commandsChain.push("legHoldHead");1325 break;1326 }1327 return commandsChain;1328}1329 // Weight1330window.applyWeightListToActionList = function(actList,wgtList) {1331 var actList2 = actList;1332 1333 for ( var action in actList2 ) {1334 if ( actList2.hasOwnProperty(action) ) {1335 for ( var weight in wgtList ) {1336 if ( wgtList.hasOwnProperty(weight) ) {1337 if ( setup.saList[actList2[action].content].flavorTags.includes(wgtList[weight].content) ) {1338 actList2[action].w *= wgtList[weight].w / 100;1339 }1340 }1341 }1342 State.variables.sc.sceneLog += actList2[action].content + ".w: " + actList2[action].w + " ; ";1343 }1344 }1345 1346 return actList2;1347}1348window.applyTasteWeightToAction = function(wItem,character) { // wItem refers to the action key as a weighted element1349 var newWeight = wItem.w;1350 1351 for ( var taste in character.tastes ) {1352 if ( character.tastes.hasOwnProperty(taste) ) {1353 if ( setup.saList[wItem.content].flavorTags.includes(character.tastes[taste].content) ) {1354 newWeight *= (character.tastes[taste].w / 100);1355 }1356 }1357 }1358 1359 return newWeight;1360}1361window.applyRoleWeightToAction = function(wList,rolePreferences) {1362 /*1363 var wList2 = wList;1364 for ( var item in wList2 ) {1365 if (wList2.hasOwnProperty(item) ) {1366 wList2[item].w = applyTasteWeightToAction(wList2[item],character); // Taste weighted1367 }1368 }1369 */1370}1371 // Action lists1372window.purgeActionsWithStrategyTag = function(list,tag) {1373 var newList = [];1374 for ( var action of list ) {1375 if ( setup.saList[action].strategyTags.includes(tag) == false ) {1376 newList.push(action);1377 }1378 }1379 return newList;1380}1381window.purgeActionsWithoutStrategyTag = function(list,tag) {1382 var newList = [];1383 for ( var action of list ) {1384 if ( setup.saList[action].strategyTags.includes(tag) ) {1385 newList.push(action);1386 }1387 }1388 return newList;1389}1390window.purgeActionsWithPreferenceTag = function(list,tag) {1391 var newList = [];1392 for ( var action of list ) {1393 if ( setup.saList[action].flavorTags.includes(tag) == false ) {1394 newList.push(action);1395 }1396 }1397 return newList;1398}1399window.purgeActionsWithoutPreferenceTag = function(list,tag) {1400 var newList = [];1401 for ( var action of list ) {1402 if ( setup.saList[action].flavorTags.includes(tag) == true ) {1403 newList.push(action);1404 }1405 }1406 return newList;1407}1408window.purgeInvalidActionsFromListActorOnTarget = function(list,actor,target) {1409 var newList = [];1410 for ( var act of list ) {1411 if ( isActionUsable(act,actor,[target],false).isUsable == true ) {1412 newList.push(act);1413 }1414 }1415 return newList;1416}1417window.purgeCAsConflictingWithTransformationGoals = function(caUnweightedList,actor) {1418 // Example of caUnweightedList:1419 // Array(2) [Array(3) ["penetratePussy", "chVal", "mountFromBehind"], Array(3) ["penetratePussy", "chPlayerCharacter", "mountFaceToFace"]]1420 var newCaUnweightedList = [];1421 1422 var tfActions = [];1423 var requiredTargetBps = [];1424 var requiredActorBps = [];1425 1426 // Get all tfActions from a tfActor1427 for ( var sa of gC(State.variables.sc.tfActors[0]).saList ) {1428 if ( setup.saList[sa].tags.includes("tf") ) {1429 tfActions.push(sa);1430 // Get all requiredBps1431 for ( var bp of setup.saList[sa].targetBpReqs ) {1432 if ( requiredTargetBps.includes(bp) == false ) {1433 requiredTargetBps.push(bp);1434 }1435 }1436 for ( var bp of setup.saList[sa].actorBpReqs ) {1437 if ( requiredActorBps.includes(bp) == false ) {1438 requiredActorBps.push(bp);1439 }1440 }1441 }1442 }1443 1444 for ( var cAs of caUnweightedList ) {1445 var flagKeep = true;1446 if ( cAs[1] == State.variables.sc.tfTarget ) {1447 for ( bp of setup.saList[cAs[0]].targetBpReqs ) {1448 if ( requiredTargetBps.includes(bp) ) {1449 flagKeep = false;1450 }1451 }1452 for ( bp of setup.saList[cAs[0]].actorBpReqs ) {1453 if ( requiredActorBps.includes(bp) ) {1454 flagKeep = false;1455 }1456 }1457 }1458 if ( flagKeep ) {1459 newCaUnweightedList.push(cAs);1460 }1461 }1462 return newCaUnweightedList;1463}1464 // Altered states1465window.countCharactersBuffs = function(charKey) {1466 var count = 0;1467 for ( var as of gC(charKey).alteredStates ) {1468 if ( as.type == "buff" ) { count++; }1469 }1470 return count;1471}1472window.countCharactersDebuffs = function(charKey) {1473 var count = 0;1474 for ( var as of gC(charKey).alteredStates ) {1475 if ( as.type == "debuff" ) { count++; }1476 }1477 return count;1478}1479 // Monsters1480window.fixActorsActionListDependingOnTargetBeingMonster = function(actor,actionsList,target) {1481 var newList = [];1482 1483 for ( var action of actionsList ) {1484 if ( setup.saList[action].strategyTags.includes("holy") == true ) {1485 if ( gC(target).race == "monster" ) {1486 newList.push(action,action,action);1487 }1488 } else if ( setup.saList[action].strategyTags.includes("captureMonster") == true ) {1489 if ( gC(target).race == "monster" ) { // TO DO: Condition, monster should only be captured if the actor wants the monster 1490 newList.push(action);1491 if ( gC(actor).hasOwnProperty("mapAi") ) {1492 if ( gC(actor).mapAi.goalsList.length > 0 ) {1493 if ( gC(actor).mapAi.goalsList[0].hasOwnProperty("targetMonster") ) {1494 if ( gC(target).monsterType == gC(actor).mapAi.goalsList[0].targetMonster ) {1495 newList.push(action,action,action,action,action,action,action,action,action);1496 } 1497 }1498 }1499 }1500 }1501 } else {1502 newList.push(action);1503 }1504 }1505 return newList;1506}1507// Constructors, serializers, etc.1508aiAlgorithm.prototype._init = function (obj) {1509 Object.keys(obj).forEach(function (pn) {1510 this[pn] = clone(obj[pn]);1511 }, this);1512 1513 return this;1514};1515aiAlgorithm.prototype.clone = function () {1516 return (new aiAlgorithm())._init(this);1517};1518aiAlgorithm.prototype.toJSON = function() {1519 var ownData = {};1520 Object.keys(this).forEach(function (pn) {1521 ownData[pn] = clone(this[pn]);1522 }, this);1523 return JSON.reviveWrapper('(new aiAlgorithm())._init($ReviveData$)', ownData);1524};1525////////// AI ALGORITHMS LIST CLASS //////////1526// AI algorithms will be objects belonging to this object. This will ease the access to ai functions.1527window.aiList = function() {1528};1529// Constructors, serializers, etc.1530aiList.prototype._init = function (obj) {1531 Object.keys(obj).forEach(function (pn) {1532 this[pn] = clone(obj[pn]);1533 }, this);1534 1535 return this;1536};1537aiList.prototype.clone = function () {1538 return (new aiList())._init(this);1539};1540aiList.prototype.toJSON = function() {1541 var ownData = {};1542 Object.keys(this).forEach(function (pn) {1543 ownData[pn] = clone(this[pn]);1544 }, this);1545 return JSON.reviveWrapper('(new aiList())._init($ReviveData$)', ownData);...

Full Screen

Full Screen

mock-module.ts

Source:mock-module.ts Github

copy

Full Screen

...34 if (flagNever(ngModule)) {35 toggleSkipMockFlag = true;36 ngMocksUniverse.flags.add('skipMock');37 }38 if (!isRootModule && (flagKeep(resolution) || flagReplace(resolution))) {39 toggleSkipMockFlag = true;40 ngMocksUniverse.flags.add('skipMock');41 }42 return {43 isRootModule,44 toggleSkipMockFlag,45 };46};47const postProcessFlags = ({48 isRootModule,49 toggleSkipMockFlag,50}: {51 isRootModule: boolean;52 toggleSkipMockFlag: boolean;...

Full Screen

Full Screen

verify.js

Source:verify.js Github

copy

Full Screen

1import Type from '../tools/Type'2// 必选项3export const keepVerify = (data) => {4 data = JSON.parse(JSON.stringify(data))5 let keepHint = []6 for (const i in data) {7 const item = data[i]8 // 跳过的问题和非必选项9 if (!item.show || !item.keep) {10 keepHint.push(false)11 continue12 }1314 // 该问题展示了,再进行必选项判断15 const value = item.value16 // 字符串类型:linerscale, dropdown, longText, mutipleChoice17 // 数组类型:checkboxes, table18 if (Type(value) === 'string' || Type(value) === 'array') {19 value.length > 0 ? keepHint.push(false) : keepHint.push(true)20 continue21 }22 // 对象类型:address, date, time, file23 if (Type(value) === 'object') {24 if (JSON.stringify(value) !== '{}') {25 let flagKeep = []26 for (let j in value) {27 if (item.answers[j] || (typeof item.answers[j]) === 'undefined') { // 该项存在的话再去判断其值是否为空28 if (value[j]) {29 flagKeep.push(true)30 } else {31 flagKeep.push(false)32 }33 }34 }35 if (flagKeep.every(item => item)) keepHint.push(false)36 else keepHint.push(true)37 } else {38 keepHint.push(true)39 }40 continue41 }42 keepHint.push(false)43 }44 return keepHint45}46// 正则47export const regExp = (regStr, str) => {48 let regExp = new RegExp(regStr)49 if (regExp.test(str)) return true50 else return false51}52// data time 的数据格式正确性53export const regVerify = (data) => {54 data = JSON.parse(JSON.stringify(data))55 let regHint = []5657 for (const i in data) {58 const item = data[i]59 // 跳过的问题和非必选项60 if (!item.show || !item.keep) {61 regHint.push(false)62 continue63 }6465 const value = item.value66 // 对象类型:date, time67 if (item.type === 'DATE' || item.type === 'TIME') {68 let flagReg = []69 let str70 for (let j in value) {71 if (item.answers[j] || (typeof item.answers[j]) === 'undefined') { // 该项存在的话再去判断其值是否为空72 if (item.type === 'DATE') {73 if (j === 'year') str = /^[1-9]\d{3}$/74 else if (j === 'month') str = /^([1-9]|0[1-9]|1[0-2])$/75 else str = /^([1-9]|0[1-9]|[1-2][0-9]|3[0-1])$/76 flagReg.push(regExp(str, value[j]))77 } else if (item.type === 'TIME') {78 if (j === 'hour') str = /^(\d|[0-1]\d|2[0-3])$/79 else str = /^(\d|[0-5]\d)$/80 flagReg.push(regExp(str, value[j]))81 }82 }83 }84 flagReg.every(item => item) ? regHint.push(false) : regHint.push(true)85 continue86 }87 regHint.push(false)88 }89 return regHint ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { flagKeep } from 'ng-mocks';2import { MyComponent } from './my-component';3flagKeep(MyComponent);4import { flagKeep } from 'ng-mocks';5import { MyComponent } from './my-component';6describe('MyComponent', () => {7 it('should be kept', () => {8 expect(() => flagKeep(MyComponent)).not.toThrow();9 });10});11import { flagKeep } from 'ng-mocks';12import { MyComponent } from './my-component';13describe('MyComponent', () => {14 it('should be kept', () => {15 expect(() => flagKeep(MyComponent)).not.toThrow();16 });17});18import { flagKeep } from 'ng-mocks';19import { MyComponent } from './my-component';20describe('MyComponent', () => {21 it('should be kept', () => {22 expect(() => flagKeep(MyComponent)).not.toThrow();23 });24});25import { flagKeep } from 'ng-mocks';26import { MyComponent } from './my-component';27describe('MyComponent', () => {28 it('should be kept', () => {29 expect(() => flagKeep(MyComponent)).not.toThrow();30 });31});32import { flagKeep } from 'ng-mocks';33import { MyComponent } from './my-component';34describe('MyComponent', () => {35 it('should be kept', () => {36 expect(() => flagKeep(MyComponent)).not.toThrow();37 });38});39import { flagKeep } from 'ng-mocks';40import { MyComponent } from './my-component';41describe('MyComponent', () => {42 it('should be kept', () => {43 expect(() => flagKeep(MyComponent)).not.toThrow();44 });45});46import { flagKeep } from 'ng-mocks';47import { MyComponent } from './my-component';48describe('MyComponent', () => {49 it('should be kept', () => {50 expect(() => flagKeep(MyComponent)).not.toThrow();51 });52});53import { flagKeep } from 'ng-mocks';54import { MyComponent } from './my-component';55describe('MyComponent', () => {56 it('

Full Screen

Using AI Code Generation

copy

Full Screen

1import { flagKeep } from 'ng-mocks';2import { MyComponent } from './my.component';3describe('MyComponent', () => {4 it('should render', () => {5 flagKeep(MyComponent);6 const fixture = TestBed.createComponent(MyComponent);7 expect(fixture).toBeDefined();8 });9});10import { MyComponent } from './my.component';11describe('MyComponent', () => {12 it('should render', () => {13 const fixture = TestBed.createComponent(MyComponent);14 expect(fixture).toBeDefined();15 });16});17import { flagKeep } from 'ng-mocks';18import { MyComponent } from './my.component';19describe('MyComponent', () => {20 it('should render', () => {21 flagKeep(MyComponent);22 const fixture = TestBed.createComponent(MyComponent);23 expect(fixture).toBeDefined();24 });25});26import { MyComponent } from './my.component';27describe('MyComponent', () => {28 it('should render', () => {29 const fixture = TestBed.createComponent(MyComponent);30 expect(fixture).toBeDefined();31 });32});33import { flagKeep } from 'ng-mocks';34import { MyComponent } from './my.component';35describe('MyComponent', () => {36 it('should render', () => {37 flagKeep(MyComponent);38 const fixture = TestBed.createComponent(MyComponent);39 expect(fixture).toBeDefined();40 });41});42import { MyComponent } from './my.component';43describe('MyComponent', () => {44 it('should render', () => {45 const fixture = TestBed.createComponent(MyComponent);46 expect(fixture).toBeDefined();47 });48});49import { flagKeep } from 'ng-mocks';50import { MyComponent } from './my.component';51describe('MyComponent', () => {52 it('should render', () => {53 flagKeep(MyComponent);54 const fixture = TestBed.createComponent(MyComponent);55 expect(fixture).toBeDefined();56 });57});58import { MyComponent } from './my.component';59describe('MyComponent', () => {60 it('should render', () => {61 const fixture = TestBed.createComponent(MyComponent);62 expect(fixture).toBeDefined();63 });64});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { flagKeep } from 'ng-mocks';2flagKeep(MyComponent);3import { MyComponent } from './test';4describe('MyComponent', () => {5 it('should be created', () => {6 const fixture = MockRender(MyComponent);7 expect(fixture.point.componentInstance).toBeDefined();8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1import {flagKeep} from 'ng-mocks';2flagKeep(MyComponent);3import {flagReset} from 'ng-mocks';4flagReset(MyComponent);5import {MockComponent} from 'ng-mocks';6const MockMyComponent = MockComponent(MyComponent);7import {MockRender} from 'ng-mocks';8const fixture = MockRender(MockMyComponent);9import {MockInstance} from 'ng-mocks';10const mockInstance = MockInstance(MyComponent);11import {MockInstance} from 'ng-mocks';12const mockInstance = MockInstance(MyComponent);13import {MockInstance} from 'ng-mocks';14const mockInstance = MockInstance(MyComponent);15import {MockInstance} from 'ng-mocks';16const mockInstance = MockInstance(MyComponent);17import {MockInstance} from 'ng-mocks';18const mockInstance = MockInstance(MyComponent);19import {MockInstance} from 'ng-mocks';20const mockInstance = MockInstance(MyComponent);

Full Screen

Using AI Code Generation

copy

Full Screen

1const ngMocks = require('ng-mocks');2ngMocks.flagKeep(true);3const ngMocks = require('ng-mocks');4ngMocks.autoSpy('myService');5const ngMocks = require('ng-mocks');6ngMocks.autoSpyObj('myService', ['method1', 'method2']);7const ngMocks = require('ng-mocks');8ngMocks.autoSpyObj('myService', ['method1', 'method2']);9const ngMocks = require('ng-mocks');10ngMocks.autoSpyObj('myService', ['method1', 'method2']);11const ngMocks = require('ng-mocks');12ngMocks.autoSpyObj('myService', ['method1', 'method2']);13const ngMocks = require('ng-mocks');14ngMocks.autoSpyObj('myService', ['method1', 'method2']);15const ngMocks = require('ng-mocks');16ngMocks.autoSpyObj('myService', ['method1', 'method2']);17const ngMocks = require('ng-mocks');18ngMocks.autoSpyObj('myService', ['method1', 'method2']);19const ngMocks = require('ng-mocks');20ngMocks.autoSpyObj('myService', ['method1', 'method2']);21const ngMocks = require('ng-mocks');22ngMocks.autoSpyObj('myService', ['method1', 'method2']);23const ngMocks = require('ng-mocks');24ngMocks.autoSpyObj('myService', ['method1', 'method2']);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { flagKeep } from 'ng-mocks';2flagKeep(ExampleComponent);3import { Component } from '@angular/core';4import { Keep } from 'ng-mocks';5@Keep()6@Component({7})8export class ExampleComponent {}9import { MockOf } from 'ng-mocks';10import { ExampleComponent } from './example.component';11describe('ExampleComponent', () => {12 it('should be created', () => {13 const component = MockOf(ExampleComponent);14 expect(component).toBeDefined();15 });16});17module.exports = {18};19import { flagMock } from 'ng-mocks';20flagMock(ExampleComponent);21import { Component } from '@angular/core';22import { MockComponent } from 'ng-mocks';23@Component({24})25export class ExampleComponent {}26import { MockOf } from 'ng-mocks';27import { ExampleComponent } from './example.component';28describe('ExampleComponent', () => {29 it('should be created', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { flagKeep } from 'ng-mocks';2import { MyComponent } from './my.component';3flagKeep(MyComponent);4flagKeep(MyComponent, 'my-selector');5flagKeep(MyComponent, 'my-selector', 'my-template');6flagKeep(MyComponent, null, 'my-template');7import { flagUnkeep } from 'ng-mocks';8import { MyComponent } from './my.component';9flagUnkeep(MyComponent);10flagUnkeep(MyComponent, 'my-selector');11flagUnkeep(MyComponent, 'my-selector', 'my-template');12flagUnkeep(MyComponent, null, 'my-template');13import { flagReset } from 'ng-mocks';14flagReset();15import { flagClear } from 'ng-mocks';16flagClear();17import { flagDebug } from 'ng-mocks';18flagDebug();19flagDebug(false);20import { flagReset } from 'ng-mocks';21flagReset();22import { flagClear } from 'ng-mocks';23flagClear();24import { flagDebug } from 'ng-mocks';25flagDebug();26flagDebug(false);27import { mock

Full Screen

Using AI Code Generation

copy

Full Screen

1import { flagKeep } from 'ng-mocks';2import { MyComponent } from './my-component';3describe('MyComponent', () => {4 it('should have a flag', () => {5 const fixture = MockRender(MyComponent);6 const component = fixture.point.componentInstance;7 flagKeep(component, 'flag');8 expect(component.flag).toBe(true);9 });10});11import { Component } from '@angular/core';12@Component({13 <div class="flag">{{ flag }}</div>14})15export class MyComponent {16 public flag = true;17}18import { MockBuilder, MockRender } from 'ng-mocks';19import { MyComponent } from './my-component';20describe('MyComponent', () => {21 beforeEach(() => MockBuilder(MyComponent));22 it('should have a flag', () => {23 const fixture = MockRender(MyComponent);24 const component = fixture.point.componentInstance;25 expect(component.flag).toBe(true);26 });27});28import { MockBuilder, MockRender } from 'ng-mocks';29import { MyComponent } from './my-component';30describe('MyComponent', () => {31 beforeEach(() => MockBuilder(MyComponent));32 it('should have a flag', () => {33 const fixture = MockRender(MyComponent);34 const component = fixture.point.componentInstance;35 expect(component.flag).toBe(true);36 });37});38import { MockBuilder, MockRender } from 'ng-mocks';39import { MyComponent } from './my-component';40describe('MyComponent', () => {41 beforeEach(() => MockBuilder(MyComponent));42 it('should have a flag', () => {43 const fixture = MockRender(MyComponent);44 const component = fixture.point.componentInstance;45 expect(component.flag).toBe(true);46 });47});48import { MockBuilder, MockRender } from 'ng-mocks';49import { MyComponent } from './my-component';50describe('MyComponent', () => {51 beforeEach(() => MockBuilder(MyComponent));52 it('should have a flag', () => {53 const fixture = MockRender(MyComponent);54 const component = fixture.point.componentInstance;55 expect(component.flag).toBe(true);56 });57});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test suite', function() {2 it('should test', function() {3 module(function($provide) {4 $provide.decorator('$httpBackend', function($delegate) {5 var flagKeep = ngMocks.flagKeep($delegate);6 $delegate.whenGET('/some/path').respond(200, 'ok');7 flagKeep($delegate.whenGET('/some/path'));8 return $delegate;9 });10 });11 inject(function($httpBackend) {12 $httpBackend.whenGET('/some/path').respond(200, 'ok');13 $httpBackend.flush();14 });15 });16});17describe('test suite', function() {18 it('should test', function() {19 module(function($provide) {20 $provide.decorator('$httpBackend', function($delegate) {21 var flagKeep = ngMocks.flagKeep($delegate);22 $delegate.whenGET('/some/path').respond(200, 'ok');23 flagKeep($delegate.when('GET', '/some/path'));24 return $delegate;25 });26 });27 inject(function($httpBackend) {28 $httpBackend.when('GET', '/some/path').respond(200, 'ok');29 $httpBackend.flush();30 });31 });32});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ng-mocks automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful