class Personnage {
var vie = arc4random_uniform(10) + 1;
var force = arc4random_uniform(8) + 1;
var chance = arc4random_uniform(2);
func attaquePar(joueur1:Personnage) ->String {
var differenceForce = self.force - joueur1.force
var coup = differenceForce + chance
if coup >= self.vie {
return "tu mas eu"
} else if coup < self.vie {
self.vie = self.vie - coup
return "jai rien senti macaque \(self.vie)"
} else {
return "heu?"
}
}
}
let toto = Personnage()
let cafard = Personnage()
toto.attaquePar(cafard)
Hi, I am having an error message at line 6. It works some times and other it does not. Here it is : Execution was interrupted, reason EXC_BAD_INSTRUCTION (code=EXC I386_INVOP subcode=0x0). I imagine that there is an invalid operation, but i don't undestant why i get this.