// File: /workspace/github_cpp_makefile_star2_O2/Agusyc[P]CTRPG/src/battle.cpp
// Function: Battle::showLevelUpMenu(Player)
void Battle::showLevelUpMenu(Player originalPlayer) {
    Json::Value jPlayer = getJsonPlayer();

    for (int points = player.level; points != 0; points--) {
        cout << "Points: " << points << endl << "1. HP" << endl << "2. Attack" << endl << "3. Defense" << endl << "4. Shield" << endl << "5. Mana" << endl << "6. Stamina" << endl << "7. New attack" << endl << "Your choice: ";

        int choice;

        cin >> choice;

        switch (choice) {
        case 1:
            originalPlayer.hp++;
            break;
        case 2:
            originalPlayer.attack++;
            break;
        case 3:
            originalPlayer.defense++;
            break;
        case 4:
            originalPlayer.shieldDefense++;
            break;
        case 5:
            originalPlayer.mana++;
            break;
        case 6:
            originalPlayer.stamina++;
            break;
        case 7:
            cout << endl; // Just some formatting

            bool exitLoop = false;
            while (!exitLoop) {
                int index = 1;
                vector<int> rIndexes;
                for (int i = 0; i < getAttacksNumber(); i++) {
                    Attack attack = parseAttack(i);
                    if (player.level >= attack.minLevel && player.level <= attack.maxLevel) {
			// If the player doesn't already have the attack, add it to the list
			if (player.attacks.at(i).id != parseAttack(i).id) {
                        	cout << index << ". " << attack.name << " Cost: " << attack.cost << endl;
                       		rIndexes.push_back(i);
                        	index++;
			}
                    }
                }

                cout << index << ". Go back" << endl << "Your choice: " << endl;

                int choice;
                cin >> choice;

                if (choice == index) {
                    exitLoop = true;
                    points++;
                    continue;
                }

                Attack chosenAttack = parseAttack(rIndexes[choice]);

                if (points < chosenAttack.cost) {
                    printMessage("You don't have enough points to get that attack!");
                    continue;
                }

                points -= chosenAttack.cost;

                printMessage(string("You got ") + YELLOW + chosenAttack.name + WHITE);

                jPlayer["attacks"].append(choice);

                exitLoop = true;
            }

            break;
        }
    }

    jPlayer["hp"] = originalPlayer.hp;
    jPlayer["attack"] = originalPlayer.attack;
    jPlayer["defense"] = originalPlayer.defense;
    jPlayer["mana"] = originalPlayer.mana;
    jPlayer["stamina"] = originalPlayer.stamina;
    jPlayer["goal"] = player.goal;
    jPlayer["xp"] = player.xp;
    jPlayer["level"] = player.level;

    Json::StyledWriter writer;
    ofstream jPlayerFile("./json/player.json");
    jPlayerFile << writer.write(jPlayer);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x398, %rsp            # imm = 0x398
movq %rsi, %r15
movq %rdi, %rbx
leaq -0x88(%rbp), %rdi
callq 0x709c
movl 0x38(%rbx), %r12d
leaq 0x48(%rbx), %rax
movq %rax, -0xb0(%rbp)
leaq -0x3a0(%rbp), %r14
movq %r15, -0xa8(%rbp)
testl %r12d, %r12d
je 0x5c41
movq 0x7803(%rip), %rdi      # 0xcfd0
leaq 0x3b5c(%rip), %rsi      # 0x9330
callq 0x3220
movq %rax, %rdi
movl %r12d, %esi
callq 0x3470
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
leaq 0x3b43(%rip), %rsi      # 0x9339
callq 0x3220
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
leaq 0x3b32(%rip), %rsi      # 0x933f
callq 0x3220
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
leaq 0x3b25(%rip), %rsi      # 0x9349
callq 0x3220
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
leaq 0x3b19(%rip), %rsi      # 0x9354
callq 0x3220
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
leaq 0x3b0c(%rip), %rsi      # 0x935e
callq 0x3220
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
leaq 0x3afd(%rip), %rsi      # 0x9366
callq 0x3220
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
leaq 0x3af1(%rip), %rsi      # 0x9371
callq 0x3220
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
leaq 0x3898(%rip), %rsi      # 0x912f
callq 0x3220
movq 0x773d(%rip), %rdi      # 0xcfe0
leaq -0x40(%rbp), %rsi
callq 0x3160
movl -0x40(%rbp), %eax
decl %eax
cmpl $0x6, %eax
ja 0x5c39
leaq 0x3753(%rip), %rcx      # 0x9014
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
incl 0x34(%r15)
jmp 0x5c39
incl 0x2c(%r15)
jmp 0x5c39
incl 0x24(%r15)
jmp 0x5c39
incl 0x28(%r15)
jmp 0x5c39
incl 0x20(%r15)
jmp 0x5c39
incl 0x30(%r15)
jmp 0x5c39
movq 0x76c9(%rip), %rdi      # 0xcfd0
callq 0x3110
movl $0x0, -0x2c(%rbp)
leaq -0x1a0(%rbp), %r15
testb $0x1, -0x2c(%rbp)
jne 0x5c32
movl %r12d, -0x30(%rbp)
andq $0x0, -0x90(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
xorl %r12d, %r12d
pushq $0x1
popq %r13
movl %r12d, -0x60(%rbp)
callq 0x71aa
cmpl %eax, %r12d
jge 0x5a31
movl -0x60(%rbp), %esi
movq %r14, %rdi
callq 0x77cb
movl 0x38(%rbx), %eax
cmpl -0x370(%rbp), %eax
jl 0x5a1d
cmpl -0x36c(%rbp), %eax
jg 0x5a1d
movslq -0x60(%rbp), %rsi
movq -0xb0(%rbp), %rdi
callq 0x6244
movl 0x3c(%rax), %r12d
movl -0x60(%rbp), %esi
movq %r15, %rdi
callq 0x77cb
movq %r15, %rdi
movl -0x164(%rbp), %r15d
callq 0x3100
cmpl %r15d, %r12d
jne 0x59b5
leaq -0x1a0(%rbp), %r15
jmp 0x5a1d
movq 0x7614(%rip), %rdi      # 0xcfd0
movl %r13d, %esi
callq 0x3470
leaq -0x1a0(%rbp), %r15
movq %rax, %rdi
leaq 0x3772(%rip), %rsi      # 0x9147
callq 0x3220
movq %rax, %rdi
movq %r14, %rsi
callq 0x31d0
movq %rax, %rdi
leaq 0x3990(%rip), %rsi      # 0x937f
callq 0x3220
movl -0x368(%rbp), %esi
movq %rax, %rdi
callq 0x3470
movq %rax, %rdi
callq 0x3110
leaq -0xa0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x6378
incl %r13d
movq %r14, %rdi
callq 0x3100
movl -0x60(%rbp), %r12d
incl %r12d
jmp 0x5941
movq 0x7598(%rip), %rdi      # 0xcfd0
movl %r13d, %esi
callq 0x3470
leaq -0x60(%rbp), %r12
movq %rax, %rdi
leaq 0x36fc(%rip), %rsi      # 0x914a
callq 0x3220
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
leaq 0x36ca(%rip), %rsi      # 0x912f
callq 0x3220
movq %rax, %rdi
callq 0x3110
movq 0x7567(%rip), %rdi      # 0xcfe0
leaq -0x38(%rbp), %rsi
callq 0x3160
movslq -0x38(%rbp), %rax
cmpl %r13d, %eax
jne 0x5a9c
movl -0x30(%rbp), %r12d
incl %r12d
movb $0x1, %al
movl %eax, -0x2c(%rbp)
jmp 0x5c21
movq -0xa0(%rbp), %rcx
movl (%rcx,%rax,4), %esi
movq %r14, %rdi
callq 0x77cb
leaq -0xf0(%rbp), %r13
movl -0x30(%rbp), %eax
subl -0x368(%rbp), %eax
movl %eax, -0x3c(%rbp)
setge %al
movl %eax, -0x2c(%rbp)
jl 0x5bb8
movq %r13, %rdi
leaq 0x38e1(%rip), %rsi      # 0x93b8
leaq -0x32(%rbp), %rdx
callq 0x30c0
movq %r12, %rdi
movq %r13, %rsi
leaq 0x3553(%rip), %rdx      # 0x9040
callq 0x612a
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x62f9
leaq -0x110(%rbp), %rdi
movq %r15, %rsi
leaq 0x353b(%rip), %r13      # 0x904c
movq %r13, %rdx
callq 0x612a
leaq -0xd0(%rbp), %rdi
movq %r13, %rsi
leaq -0x31(%rbp), %rdx
callq 0x30c0
leaq -0x110(%rbp), %r13
movq %r13, %rdi
leaq -0xd0(%rbp), %rsi
pushq $0x23
popq %rdx
movl $0x12c, %ecx            # imm = 0x12C
pushq $0x1
popq %r8
callq 0x8e78
leaq -0xd0(%rbp), %rdi
callq 0x3100
movq %r13, %rdi
callq 0x3100
movq %r15, %rdi
callq 0x3100
movq %r12, %rdi
callq 0x3100
leaq -0xf0(%rbp), %rdi
callq 0x3100
leaq -0x88(%rbp), %rdi
leaq 0x3835(%rip), %rsi      # 0x93c1
callq 0x30b0
movq %rax, %r13
movl -0x38(%rbp), %esi
movq %r15, %rdi
callq 0x3150
movq %r13, %rdi
movq %r15, %rsi
callq 0x3320
movq %r15, %rdi
callq 0x3120
movl -0x3c(%rbp), %r12d
jmp 0x5c19
leaq -0x130(%rbp), %rdi
leaq 0x37c1(%rip), %rsi      # 0x9387
movq %r15, %rdx
callq 0x30c0
leaq -0x3c0(%rbp), %r13
movq %r13, %rdi
leaq 0x346d(%rip), %rsi      # 0x904c
movq %r12, %rdx
callq 0x30c0
leaq -0x130(%rbp), %r12
movq %r12, %rdi
movq %r13, %rsi
pushq $0x23
popq %rdx
movl $0x12c, %ecx            # imm = 0x12C
pushq $0x1
popq %r8
callq 0x8e78
movq %r13, %rdi
callq 0x3100
movq %r12, %rdi
callq 0x3100
movl -0x30(%rbp), %r12d
movq %r14, %rdi
callq 0x3100
leaq -0xa0(%rbp), %rdi
callq 0x6f34
jmp 0x591a
movq -0xa8(%rbp), %r15
decl %r12d
jmp 0x57bd
movl 0x34(%r15), %esi
leaq -0x3a0(%rbp), %rdi
callq 0x3150
leaq 0x3771(%rip), %rsi      # 0x93c9
leaq -0x88(%rbp), %rdi
callq 0x30b0
leaq -0x3a0(%rbp), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x32a0
movq %r14, %rdi
callq 0x3120
movl 0x20(%r15), %esi
leaq -0x3a0(%rbp), %rdi
callq 0x3150
leaq 0x36e3(%rip), %rsi      # 0x9378
leaq -0x88(%rbp), %rdi
callq 0x30b0
movq %rax, %rdi
movq %r14, %rsi
callq 0x32a0
movq %r14, %rdi
callq 0x3120
movl 0x24(%r15), %esi
leaq -0x3a0(%rbp), %rdi
callq 0x3150
leaq 0x3701(%rip), %rsi      # 0x93cc
leaq -0x88(%rbp), %rdi
callq 0x30b0
movq %rax, %rdi
movq %r14, %rsi
callq 0x32a0
movq %r14, %rdi
callq 0x3120
movl 0x2c(%r15), %esi
leaq -0x3a0(%rbp), %rdi
callq 0x3150
leaq 0x36d3(%rip), %rsi      # 0x93d4
leaq -0x88(%rbp), %rdi
callq 0x30b0
movq %rax, %rdi
movq %r14, %rsi
callq 0x32a0
movq %r14, %rdi
callq 0x3120
movl 0x30(%r15), %esi
leaq -0x3a0(%rbp), %rdi
callq 0x3150
leaq 0x36a2(%rip), %rsi      # 0x93d9
leaq -0x88(%rbp), %rdi
callq 0x30b0
movq %rax, %rdi
movq %r14, %rsi
callq 0x32a0
movq %r14, %rdi
callq 0x3120
movl 0x40(%rbx), %esi
leaq -0x3a0(%rbp), %rdi
callq 0x3150
leaq 0x3675(%rip), %rsi      # 0x93e1
leaq -0x88(%rbp), %rdi
callq 0x30b0
movq %rax, %rdi
movq %r14, %rsi
callq 0x32a0
movq %r14, %rdi
callq 0x3120
movl 0x3c(%rbx), %esi
leaq -0x3a0(%rbp), %rdi
callq 0x3150
leaq 0x3645(%rip), %rsi      # 0x93e6
leaq -0x88(%rbp), %rdi
callq 0x30b0
movq %rax, %rdi
movq %r14, %rsi
callq 0x32a0
movq %r14, %rdi
callq 0x3120
movl 0x38(%rbx), %esi
leaq -0x3a0(%rbp), %rdi
callq 0x3150
leaq 0x3613(%rip), %rsi      # 0x93e9
leaq -0x88(%rbp), %rdi
callq 0x30b0
leaq -0x3a0(%rbp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x32a0
movq %rbx, %rdi
callq 0x3120
leaq -0x1a0(%rbp), %rdi
callq 0x3050
leaq 0x35e0(%rip), %rsi      # 0x93ef
leaq -0x3a0(%rbp), %rdi
pushq $0x10
popq %rdx
callq 0x3250
leaq -0x60(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x32f0
leaq -0x3a0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x31d0
leaq -0x60(%rbp), %rdi
callq 0x3100
leaq -0x3a0(%rbp), %rdi
callq 0x3380
leaq -0x1a0(%rbp), %rdi
callq 0x639e
leaq -0x88(%rbp), %rdi
callq 0x3120
addq $0x398, %rsp            # imm = 0x398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x3100
jmp 0x5e95
movq %rax, %rbx
leaq -0x3a0(%rbp), %rdi
callq 0x3380
jmp 0x5ea6
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x639e
jmp 0x5fc8
jmp 0x5f9d
jmp 0x5eed
jmp 0x5f9d
jmp 0x5eed
jmp 0x5f9d
jmp 0x5eed
jmp 0x5f9d
jmp 0x5eed
jmp 0x5f9d
jmp 0x5eed
jmp 0x5f9d
jmp 0x5eed
jmp 0x5f9d
jmp 0x5eed
jmp 0x5f9d
movq %rax, %rbx
leaq -0x3a0(%rbp), %rdi
callq 0x3120
jmp 0x5fc8
jmp 0x5f9d
movq %rax, %rbx
leaq -0x3c0(%rbp), %rdi
callq 0x3100
jmp 0x5f29
jmp 0x5fad
jmp 0x5fad
jmp 0x5fad
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
jmp 0x5f7d
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x3100
jmp 0x5f50
movq %rax, %rbx
jmp 0x5f68
movq %rax, %rbx
jmp 0x5f5c
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x3100
leaq -0x1a0(%rbp), %rdi
callq 0x3100
leaq -0x60(%rbp), %rdi
callq 0x3100
jmp 0x5f76
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x3100
jmp 0x5fb0
jmp 0x5fad
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x3120
jmp 0x5fb0
jmp 0x5f9d
jmp 0x5fa8
jmp 0x5fa8
movq %rax, %rbx
jmp 0x5fc8
jmp 0x5fa8
jmp 0x5fad
jmp 0x5fa8
movq %rax, %rbx
jmp 0x5fbc
movq %rax, %rbx
leaq -0x3a0(%rbp), %rdi
callq 0x3100
leaq -0xa0(%rbp), %rdi
callq 0x6f34
leaq -0x88(%rbp), %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x3490