// File: giovifazi[P]knossos-bloodbath/ClassPlayer.cpp
// Function: Player::diceRoll_nr()
int Player::diceRoll_nr() 
{
   srand(time(0));
   int roll = (rand()%20) +1;
   switch(roll)
   {
      case 1: case 2: case 3: case 4: case 5:
      // Non succede nulla
      return roll;

      // spada bronzo
      case 6: case 7: case 8: case 9:
         atk += 3;
      return roll;
     
      // spada argento
      case 10: case 11: case 12:
         atk += 4;
      return roll;

      // spada oro
      case 13: case 14: 
         atk += 6;
      return roll;

      // trappola, danno incodizionato dallo scudo
      case 15: case 16: case 17:
         hp -= 4;        
      return roll;

      // combattimento con un mostro danno condizionato da scudo
      case 18: case 19: case 20:
         // scudo oro non prende danno ma si rompe e si trova uno di bronzo
         if (shield == "gold")
         {
            shield = "bronze";
            return 181;
         }
         // scudo argento non si rompe ma si prende poco danno
         else
         if (shield == "silver")
         {
            hp -= 2;
            return 182;
         }
         // scudo bronzo si rompe e si prende danno discreto
         else
         if (shield == "bronze")
         {
            hp -= 4;
            shield = "";
            return 183;
         }
         // senza scudo si prende grosso danno
         else
         if (shield == "")
         {
            hp -= 7;
            return 184;
         }
      break;
      
      // Trovata pozione curativa per chi ha scudo oro/arg
      // Trovato scudo argento per gli altri
      case 21: case 22:
 
            hp += 4;
            return 211;
           
      // Trovata pozione velenosa per scudi oro/arg
      // Trovata super pozione curativa per gli altri
      case 23: case 24:

            hp -= 4;
            return 231;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x2180
movl %eax, %edi
callq 0x2190
callq 0x2070
movl %eax, %ecx
movslq %ecx, %rax
imulq $0x66666667, %rax, %rdx # imm = 0x66666667
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x23, %rdx
addl %eax, %edx
shll $0x2, %edx
movl %edx, %eax
leal (%rax,%rax,4), %edx
movl %ecx, %eax
negl %edx
movl %edx, %ecx
leal 0x1(%rax,%rcx), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x20(%rbp)
subl $0x17, %eax
ja 0x8e0f
movq -0x20(%rbp), %rax
leaq 0x7ce6(%rip), %rcx      # 0x1097c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x8e11
movq -0x28(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x3, %ecx
movl %ecx, 0x4(%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x8e11
movq -0x28(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x4, %ecx
movl %ecx, 0x4(%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x8e11
movq -0x28(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x6, %ecx
movl %ecx, 0x4(%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x8e11
movq -0x28(%rbp), %rax
movl (%rax), %ecx
subl $0x4, %ecx
movl %ecx, (%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x8e11
movq -0x28(%rbp), %rdi
addq $0x30, %rdi
leaq 0x7d3b(%rip), %rsi      # 0x10a52
callq 0x97e0
testb $0x1, %al
jne 0x8d22
jmp 0x8d42
movq -0x28(%rbp), %rdi
addq $0x30, %rdi
leaq 0x7d13(%rip), %rsi      # 0x10a44
callq 0x22b0
movl $0xb5, -0x4(%rbp)
jmp 0x8e11
movq -0x28(%rbp), %rdi
addq $0x30, %rdi
leaq 0x7cfa(%rip), %rsi      # 0x10a4b
callq 0x97e0
testb $0x1, %al
jne 0x8d5c
jmp 0x8d73
movq -0x28(%rbp), %rax
movl (%rax), %ecx
subl $0x2, %ecx
movl %ecx, (%rax)
movl $0xb6, -0x4(%rbp)
jmp 0x8e11
movq -0x28(%rbp), %rdi
addq $0x30, %rdi
leaq 0x7cc2(%rip), %rsi      # 0x10a44
callq 0x97e0
testb $0x1, %al
jne 0x8d8d
jmp 0x8db1
movq -0x28(%rbp), %rdi
movl (%rdi), %eax
subl $0x4, %eax
movl %eax, (%rdi)
addq $0x30, %rdi
leaq 0x7bd7(%rip), %rsi      # 0x1097a
callq 0x22b0
movl $0xb7, -0x4(%rbp)
jmp 0x8e11
movq -0x28(%rbp), %rdi
addq $0x30, %rdi
leaq 0x7bba(%rip), %rsi      # 0x1097a
callq 0x97e0
testb $0x1, %al
jne 0x8dcb
jmp 0x8ddf
movq -0x28(%rbp), %rax
movl (%rax), %ecx
subl $0x7, %ecx
movl %ecx, (%rax)
movl $0xb8, -0x4(%rbp)
jmp 0x8e11
jmp 0x8de1
jmp 0x8de3
jmp 0x8de5
jmp 0x8e0f
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl $0x4, %ecx
movl %ecx, (%rax)
movl $0xd3, -0x4(%rbp)
jmp 0x8e11
movq -0x28(%rbp), %rax
movl (%rax), %ecx
subl $0x4, %ecx
movl %ecx, (%rax)
movl $0xe7, -0x4(%rbp)
jmp 0x8e11
ud2
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)