def wound_roll(self): """ Number est le nombre de de à lancer target nombre pour être considéré un succes functions is a list of function to run on the results after reroll Each function needs to be added in order of resolution """ # print("wound roll") next_shooters = [] #print(self.shooters) #print("Just Before") for attack_type in self.shooters: target = self.determine_wound_roll(attack_type) results = RF.rollingd6s(attack_type.R, attack_type.RWT) for specialRule in attack_type.wnd_rules: #print(specialRule) temp = specialRule.rule(results, attack_type) if (temp != None): next_shooters.append(temp) success = results[(target - 1):] sum_succ = int(numpy.sum(success)) temp = copy(attack_type) temp.R = sum_succ next_shooters.append(temp) self.shooters = copy(next_shooters)
def determine_attack(self, attack): """ Une fonction pour determiner le nombre d'attaque des modèles avec des nombres aleatoires Elle fait la lecture du nombre d'attaque et fait la bonne truc lol """ retour = 0 reading = str(attack.R) split = reading.split("d") # print(split) number = split[0] if (len(split) > 1): type = split[1] results = RF.rollingdXs(int(number), int(type)) w = numpy.arange(1, len(results) + 1, 1) retour = int(numpy.inner(results, w)) else: retour = int(number) # print(retour) return retour
def save_roll(self): """ Number est le nombre de de à lancer target nombre pour être considere un succes functions is a list of function to run on the results after reroll Each function needs to be added in order of resolution """ #print("save roll") next_shooters = [] #print(self.shooters) for attack_type in self.shooters: #print(attack_type.AP) target = self.determine_save(attack_type) results = RF.rollingd6s(attack_type.R) # print(results) success = results[:(target - 1)] sum_succ = int(numpy.sum(success)) #print(success) # print(sum_succ) temp = copy(attack_type) temp.R = sum_succ next_shooters.append(temp) self.shooters = next_shooters
def exploding_dices(self, resultats, attack_type): """ Exploding dices is when on a result, you generate additional attacks (Which cannot generate additional attacks) """ target = attack_type.Exploding_Target - attack_type.Hit_Mod exploding = copy(resultats[(target - 1):]) sum_explode = int(numpy.sum(exploding)) * attack_type.Exploding_Add explode_result = RF.rollingd6s(sum_explode, attack_type.RHT) resultats += explode_result
def hit_roll(self): """ Number est le nombre de de e lancer target nombre pour être considéré un succes (Pour une save c'est l'inverse) functions is a list of function to run on the results after reroll Each function needs to be added in order of resolution """ # print("hit roll") next_shooters = [] for i in range(len(self.shooters)): attack_type = self.shooters[i] target = attack_type.H dices = self.determine_attack(attack_type) results = RF.rollingd6s(dices, attack_type.RHT) #print(results) for specialRule in attack_type.hit_rules: temp = specialRule.rule(results, attack_type) if (temp != None): next_shooters.append(temp) # print(results) mod_target = target - attack_type.Hit_Mod if (mod_target < 2): mod_target = 2 success = results[(mod_target - 1):] sum_succ = int(numpy.sum(success)) # print(success) # print(sum_succ) temp = copy(attack_type) temp.R = sum_succ next_shooters.append(temp) self.shooters = copy(next_shooters)
def rule(self, resultats, attack_type): target = self.target_number - attack_type.Hit_Mod exploding = copy.copy(resultats[(target - 1):]) sum_explode = int(numpy.sum(exploding)) * self.add_attacks explode_result = RF.rollingd6s(sum_explode, attack_type.RHT) resultats += explode_result #print("This is implemented - Exploding") #print("BETA TEST") return None
def determine_attack2(self, attack): """ This will be used after I made sure that everything is transferred to ignore attack.R """ retour = 0 reading = str(attack.attacks) if ("d" in reading): split = reading.split("d") number = split[0] type = split[1] results = RF.rollingdXs(int(number), int(type)) w = numpy.arange(1, len(results) + 1, 1) retour = int(numpy.inner(results, w)) else: retour = int(reading) return retour
def damage_phase(self): """ The damage phase is when you roll for damage and save damage. It will calculate to make sure overkill is taken into account """ #print("damage roll") dead = 0 wounds_dealt_to_model = 0 for attack_type in self.shooters: reading = str(attack_type.D) split = reading.split("d") number = 0 type = 0 damage_array = 0 if (len(split) > 1): #Has another element type = int(split[1]) number = int(split[0]) * attack_type.R damage_array = RF.rollingdXs_time_dependant(number, type) else: #No other element, thus dmg 1 type = int(split[0]) number = attack_type.R damage_array = [type] * number for i in range(0, len(damage_array)): dmgI = damage_array[i] for FNP in self.target.FnP: results = RF.rollingd6s(int(dmgI), 0) succ = int(numpy.sum(results[(FNP - 1):])) dmgI -= succ if (attack_type.AP == "MW"): while (dmgI > 0): wounds_dealt_to_model += 1 dmgI -= 1 if (wounds_dealt_to_model >= self.target.W): dead += 1 wounds_dealt_to_model = 0 else: if (dmgI + wounds_dealt_to_model >= self.target.W): dead += 1 wounds_dealt_to_model = 0 else: wounds_dealt_to_model += dmgI # print(dead) # print(wounds_dealt_to_model) return dead, wounds_dealt_to_model