<commit_before>import { Task } from './task';
import { } from '../test-code/helpers';
import { LocalStorageService } from '../storage/local.storage-service'

export class TaskLoopArray extends Task {

    private localStorageService = LocalStorageService.getInstance();

    constructor() {
        super(
            8,
            "", "", "", "", "",
            [""]
        );
    }

    testTask(json: JSON) {
        if(true){
             this.localStorageService.resetLocalStorageItem('player');
        }
        return true;
    }
}<commit_msg>[JSpace] implementation of taskLoopArray (#33)<commit_after>import { Task } from './task';
import { } from '../test-code/helpers';
import { LocalStorageService } from '../storage/local.storage-service'

export class TaskLoopArray extends Task {

    private localStorageService = LocalStorageService.getInstance();

    constructor() {
        super(
            8,
            "Despite having a lot of options for different loops, I will show you the for-loop. " + "\n" +
            "It works as follows: " + "\n" +
            "for(statement1; statement2; statement3) { code block to be executed } Statement 1 is executed before the loop (the code block) starts. Statement 2 defines the condition for running the loop (the code block). Statement 3 is executed each time after the loop (the code block) has been executed." + "\n" +
            "For instance: for(var i = 0; i < user.backpack.length; i ++) { boardComputer.inventory.push(user.backpack[i]);}",

            "Time to transfer our items to the board computer." + "\n" +
            "So that it can calculate the amount of resources and time that we need to repair the ship." + "\n" +
            "Push the items from our backpack to the inventory of the board computer with a for-loop.",

            "Transaction complete! All Materials collected.",

            "Transaction incomplete! Check your script.",

            "Yippieh! Time to repair the ship and leave the planet!",

            ["Bzzzt! Try again and make sure to address the user’s backpack for the iteration!"]
        );
    }

    testTask(json: JSON) {
        if (true) {
            let boardcomputer = { inventory: [] }
            let player = JSON.parse(this.localStorageService.readLocalStorage('player'));
            player.task = this.getTaskId() + 1;

            for (var i = 0; i < player.backpack.length; i++) {
                boardcomputer.inventory.push(player.backpack[i]);
            }
            player.backpack = [];
            this.localStorageService.saveToLocalStorage('player', player);
            this.localStorageService.saveToLocalStorage('boardcomputer', boardcomputer);

            let newMessage = this.getMessageCorrect()
                + "\n" + "BOARDCOMPUTER: " + JSON.stringify(boardcomputer.inventory);
                   
            this.setMessageCorrect(newMessage);
            this.localStorageService.resetLocalStorageItem('player');
        }
        return true;
    }
}
{'fraction_non_alphanumeric': 0.11362126245847176, 'fraction_numerical': 0.004318936877076412, 'mean_word_length': 2.334440753045404, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '393774', 'n_tokens_mistral': 789, 'n_tokens_neox': 755, 'n_words': 246}