Skip to content

Commit

Permalink
reload W40K folder from main
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian-DELRIEU committed Mar 19, 2023
1 parent 50772fb commit 24f268b
Show file tree
Hide file tree
Showing 30 changed files with 805 additions and 439 deletions.
Empty file modified .idea/HOI4_Calculator.iml
100755 → 100644
Empty file.
Empty file modified .idea/csv-plugin.xml
100755 → 100644
Empty file.
Empty file modified .idea/misc.xml
100755 → 100644
Empty file.
24 changes: 12 additions & 12 deletions CSVs/SaveCompanies.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Companies,Guardsmens_100A,Guardsmens_100B,Guardsmens_100C,Spaces_100A,Spaces_100B,Basilisk_40A
HP,25.0,25.0,25.0,38.0,38.0,30.0
ORG,70,70,70,108.0,108.0,10
SoftAttack,15.0,15.0,19.85,30.17,30.17,44.4
HardAttack,0.0,1.0,2.4,7.28,7.28,12.8
SoftMeleeAttack,1.0,1.0,9.0,1.0,13.87,1.2
HardMeleeAttack,0.0,2.0,2.0,2.86,4.29,0.4
Defense,20.0,20.0,20.1,20.05,20.05,0.0
Breakthrought,2.0,2.0,2.0,2.0,2.0,0.0
Armor,0,0,0,2,2,5.33
Piercing,4.67,6.0,6.29,6.39,6.71,0.32
Hardness,0,0,0,0.1,0.1,0.45
Companies,Guardsmens_100A,Guardsmens_100B,Guardsmens_100C,Spaces_Tactical,Spaces_Devastator,Spaces_Assault,Basilisk_15A,Predator_9A,Earthshaker_Company
HP,25.0,25.0,25.0,38.0,38.0,38.0,11.25,6.75,6.0
ORG,70,70,70,108.0,108.0,108.0,10,10,10
SoftAttack,4.0,4.0,4.37,6.82,9.72,3.0,50.85,11.84,1.56
HardAttack,0.0,0.0,0.43,2.9,5.0,0.29,1.65,4.25,1.2
SoftMeleeAttack,1.0,1.0,9.0,13.87,7.44,15.59,0.0,0.0,0.0
HardMeleeAttack,0.0,2.0,0.8,4.29,3.58,5.0,0.0,0.0,0.0
Defense,23.0,23.0,23.92,20.7,22.0,22.0,0.0,0.0,0.0
Breakthrought,2.3,2.3,2.19,2.32,2.19,3.25,0.0,0.0,0.0
Armor,0,0,0,2,2,2,5.33,11.33,0
Piercing,3.73,5.3,5.23,6.15,6.09,6.27,9.0,11.0,7.8
Hardness,0,0,0,0.1,0.1,0.1,0.33,0.9,0
20 changes: 10 additions & 10 deletions CSVs/SaveUnit.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Units,Gardes,SpaceMarines,LemanRuss_A,Predator_A,Basilisk,Field_Earthshaker
Units,Gardes,SpaceMarines,LemanRuss_A,Predator_A,Basilisk,Earthshaker_Platform
HP,0.25,0.38,0.75,0.75,0.75,0.5
ORG,70,108.0,10,10,10,10
SoftAttack,0.0,0.0,1.45,1.28,1.11,0.94
HardAttack,0.0,0.0,0.24,0.27,0.32,0.3
SoftMeleeAttack,0.01,0.01,0.05,0.03,0.03,0.03
HardMeleeAttack,0.0,0.0,0.02,0.01,0.01,0.01
Defense,0.2,0.2,0.02,0.02,0.0,0.0
Breakthrought,0.02,0.02,0.0,0.0,0.0,0.0
Armor,0,2,12.0,11.33,5.33,10.0
Piercing,0,0,12,11,13,13
Hardness,0,0.1,0.95,0.9,0.45,0.9
SoftAttack,0.0,0.0,1.34,0.92,3.39,0.13
HardAttack,0.0,0.0,0.84,0.33,0.11,0.1
SoftMeleeAttack,0.01,0.01,0.0,0.0,0.0,0.0
HardMeleeAttack,0.0,0.0,0.0,0.0,0.0,0.0
Defense,0.23,0.2,0.6,0.33,0.33,0.33
Breakthrought,0.02,0.02,4.0,2.0,0.2,2.0
Armor,0,2,12.0,11.33,5.33,0
Piercing,0.0,0.0,15.0,11,9.0,7.8
Hardness,0,0.1,0.95,0.9,0.33,0
14 changes: 7 additions & 7 deletions CSVs/SaveWeapons.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Weapons,Lasgun,Bolter,MeltaGun,PlasmaGun,KrakGrenades,FragGrenades,BolterLD,CanonLaser,Earthshaker,Obusier,Autocanon,Astartes_CCW,Bayonet
SoftAttack,0.12,0.15,0.15,0.31,0.0,0.03,0.51,0.4,0.94,0.61,0.44,0.0,0.0
HardAttack,0.0,0.01,0.25,0.14,0.01,0.0,0.07,0.72,0.3,0.12,0.15,0.0,0.0
SoftMeleeAttack,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.09,0.08
HardMeleeAttack,0.0,0.0,0.0,0.0,0.02,0.0,0.0,0.0,0.0,0.0,0.0,0.01,0.0
Defense,0.0,0.0,0.0,0.0,0.0,0.0,0.01,0.0,0.0,0.0,0.0,0.0,0.0
Breakthrought,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
Weapons,Lasgun,Bolter,BoltPistol,MeltaGun,PlasmaGun,PlasmaPistol,KrakGrenades,FragGrenades,BolterLD,CanonLaser,Earthshaker,Obusier,Autocanon,Astartes_CCW,Bayonet,MeltaBomb
SoftAttack,0.03,0.03,0.01,0.03,0.07,0.02,0.0,0.01,0.12,0.09,0.13,0.08,0.11,0.0,0.0,0.0
HardAttack,0.0,0.01,0.0,0.08,0.05,0.02,0.0,0.0,0.03,0.27,0.1,0.04,0.06,0.0,0.0,0.0
SoftMeleeAttack,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.09,0.08,0.12
HardMeleeAttack,0.0,0.0,0.0,0.0,0.0,0.0,0.02,0.0,0.0,0.0,0.0,0.0,0.0,0.01,0.0,0.05
Defense,1.0,1.0,1.0,1.0,1.0,1.0,0,0,1.5,1.5,1.0,1.0,1.5,0,0,1.0
Breakthrought,1.0,1.0,1.0,1.5,1.0,1.0,0,0.15,0.9,0.9,1.0,1.0,0.9,0,0,1.0
12 changes: 6 additions & 6 deletions CSVs/Saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
DICO_3A["Units"] = fisrt_column_A
for key, cur in DICO_2A.items():
assert type(cur) == Infantry or Tank or Walker
cur_list = [cur.HP, cur.org, cur.SoftAttack, cur.HardAttack, cur.SoftMeleeAttack, cur.HardMeleeAttack, cur.Defense,
cur.Breakthrought, cur.Armor, cur.Piercing, cur.Hardness]
cur_list = [cur.HP,cur.ORG,cur.SoftAttack,cur.HardAttack,cur.SoftMeleeAttack,cur.HardMeleeAttack,cur.Defense,
cur.Breakthrought,cur.Armor,cur.Piercing,cur.Hardness]
round_Stats(cur)
DICO_3A[key] = cur_list

Expand All @@ -54,8 +54,8 @@
DICO_3B["Weapons"] = fisrt_column_B
for key,cur in DICO_2B.items():
assert type(cur) == Weapon
cur_list = [cur.SoftAttack,cur.HardAttack,cur.SoftMeleeAttack,cur.HardMeleeAttack,cur.Defense,
cur.Breakthrought]
cur_list = [cur.SoftAttack,cur.HardAttack,cur.SoftMeleeAttack,cur.HardMeleeAttack,cur.Defense_bonus,
cur.Breakthrought_bonus]
round_Stats(cur)
DICO_3B[key] = cur_list

Expand All @@ -65,8 +65,8 @@
DICO_3C["Companies"] = fisrt_column_C
for key,cur in DICO_2C.items():
assert type(cur) == Company
cur_list = [cur.HP, cur.org, cur.SoftAttack, cur.HardAttack, cur.SoftMeleeAttack, cur.HardMeleeAttack, cur.Defense,
cur.Breakthrought, cur.Armor, cur.Piercing, cur.Hardness]
cur_list = [cur.HP,cur.ORG,cur.SoftAttack,cur.HardAttack,cur.SoftMeleeAttack,cur.HardMeleeAttack,cur.Defense,
cur.Breakthrought,cur.Armor,cur.Piercing,cur.Hardness]
round_Stats(cur)
DICO_3C[key] = cur_list

Expand Down
142 changes: 94 additions & 48 deletions Class/Battle.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,87 @@
from W40K.Functions.Functions import round_Stats
from W40K.Class.Regiment import Regiment
from W40K.Class.Leader import Leader

from W40K.Functions.Tactics_func import *
from W40K.Functions.Functions import round_Stats
from W40K.Functions.Terrain_func import apply_Terrain
from W40K.Functions.Leader_func import set_LeaderSkills, apply_LeaderTactic

from W40K.Lists.Terrain_list import Terrain_dico
from W40K.Lists.Tactics_list import ATK_all_tactics,DEF_all_tactics
from MyPack.Utilities import AskUser

class Battle:
"""
Objet contenant les divisions permettant de lancer les round et les logs
"""
def __init__(self, ATK, DEF):
def __init__(self,
ATK, DEF, ATK_leader=Leader(1,1,1,[],[]), DEF_leader=Leader(1,1,1,[],[]),
Terrain="Plains", River = None
):
# Initials conditions
assert type(ATK) == Regiment and type(DEF) == Regiment , "campA and campB must be regiment class"
assert ATK.is_defending == False , "ATK.isDefending must be FALSE"
assert DEF.is_defending == True , "DEF.isDefending must be TRUE"
# ATK team
self.ATK = ATK
self.ATK_Tactic = None
self.ATK_Leader = None
# DEF Team
self.DEF = DEF
self.DEF_Tactic = None
self.DEF_Leader = None
assert ATK.isDefending == False , "ATK.isDefending must be FALSE"
assert DEF.isDefending == True , "DEF.isDefending must be TRUE"
self.ATK = {
"Regiment": ATK,
"Leader": ATK_leader,
"Tactics": ATK_all_tactics.copy()
}
self.ATK_Tactic_chosen = None
self.DEF = {
"Regiment":DEF,
"Leader":DEF_leader,
"Tactics":DEF_all_tactics.copy()
}
self.DEF_Tactic_chosen = None
# Battle parameters
self.roundCounter = 0
self.CAC_level = 0
self.CAC_limit = 0
self.Phase = "Default" # Phase de bataille en cours
self.Terrain = "Plain"
self.Current_Phase = "Default" # Phase de bataille en cours
self.Following_Phase = "Default"
self.Terrain = Terrain_dico[Terrain]
self.River = River
self.Initiative_winner = None

def isFinnish(self):
"""
Check si le combat est terminé
- Si l'un des deux camps n'as plus de PV ou d'Organisation
:return: True ou False
"""
return (
(self.ATK.HP <= 0)
or (self.DEF.HP <= 0)
or (self.ATK.org <= 0)
or (self.DEF.org <= 0)
(self.ATK["Regiment"].HP <= 0)
or (self.DEF["Regiment"].HP <= 0)
or (self.ATK["Regiment"].ORG <= 0)
or (self.DEF["Regiment"].ORG <= 0)
)

def _init_round(self):
self.Terrain.set_River(self.River)
set_LeaderSkills(self)
apply_LeaderTactic(self)
apply_Terrain(self)
update_CAC(self)
self.apply_river()

def apply_river(self):
"""
TODO - Move function to Terrain_func
:return:
"""
if self.River is None:
for side in [self.ATK,self.DEF]:
for tactic in side["Tactics"]:
if "Bridge" in tactic.Name:
tactic.weight = 0

def Round(self,Nb:int()=1,LogLevel=True):
"""
- Definit le nombre de lancement de round
- run _Round
:param Nb: Nombre de round souhaité (-1 si jusqu'a fin du combat)
:param LogLevel:
"""
if Nb != -1:
i = 1
Expand All @@ -51,69 +90,76 @@ def Round(self,Nb:int()=1,LogLevel=True):
i += 1
else: # Lancement des rounds jusqu'a fin du combat
while not self.isFinnish():
self._Round(Loglevel=LogLevel,PauseEachRound=True)
self._Round(Loglevel=LogLevel,PauseEachRound=False)

def _Round(self,Loglevel,PauseEachRound=False):
ATK_regiment = self.ATK["Regiment"]
DEF_regiment = self.DEF["Regiment"]
"""
Lancement d'une round ATTAQUE et RIPOSTE (1h de combat dans HOI IV)
"""
txt = """----------- round {} -----------------""".format(self.roundCounter)
self._init_round()
if self.roundCounter%12 == 0:
previous_CAC_limit = self.CAC_limit
self.Current_Phase = self.Following_Phase
choose_Tactics(self)
if Loglevel:
txt += "\nNew tactics / Battle phase: {}".format(self.Phase)
txt += "\n- {} choose {} tactic".format(self.ATK.name, self.ATK_Tactic)
txt += "\n- {} choose {} tactic".format(self.DEF.name, self.DEF_Tactic)
txt += "\nNew tactics / Battle phase: {}".format(self.Current_Phase)
txt += "\n- {} choose {} tactic".format(ATK_regiment.Name, self.ATK_Tactic_chosen)
txt += "\n- {} choose {} tactic".format(DEF_regiment.Name, self.DEF_Tactic_chosen)
txt += "\n"
txt += "\nOld CAC limit = {}".format(previous_CAC_limit)
update_CAC(self)
if self.roundCounter%12 == 0 and Loglevel:
txt += "\n- Cac changes by ATK = {}".format(self.ATK_Tactic.CAC)
txt += "\n- Cac changes by DEF = {}".format(self.DEF_Tactic.CAC)
txt += "\n- Cac changes by ATK = {}".format(self.ATK_Tactic_chosen.CAC)
txt += "\n- Cac changes by DEF = {}".format(self.DEF_Tactic_chosen.CAC)
txt += "\nNew CAC limit = {}".format(self.CAC_limit)
txt += "\nNew cac_level = {}".format(self.CAC_level)
txt += "\n"
# Stats arrondis
round_Stats(self.ATK)
round_Stats(self.DEF)
round_Stats(ATK_regiment)
round_Stats(DEF_regiment)
round_Stats(self)
# ATK Round
self.ATK.do_attack(self.DEF, self.CAC_level) # ATK attaque
ATK_regiment.Attaque(DEF_regiment,self.CAC_level) # ATK attaque
if Loglevel:
txt += "\n{} round".format(self.ATK.name)
txt += "\n - Shots: {} SA + {} HA = {}".format(self.ATK.SoftAttack,self.ATK.HardAttack,
self.ATK.SoftAttack+self.ATK.HardAttack)
txt += "\n - Melee: {} SMA + {} HMA = {}".format(round(self.ATK.SoftMeleeAttack*self.CAC_level,2),
round(self.ATK.HardMeleeAttack*self.CAC_level,2),
round(self.ATK.SoftMeleeAttack*self.CAC_level,2)+round(self.ATK.SoftMeleeAttack*self.CAC_level,2))
txt += "\n{} round".format(ATK_regiment.Name)
txt += "\n - Shots: {} SA + {} HA = {}".format(ATK_regiment.SoftAttack,ATK_regiment.HardAttack,
ATK_regiment.SoftAttack+ATK_regiment.HardAttack)
txt += "\n - Melee: {} SMA + {} HMA = {}".format(round(ATK_regiment.SoftMeleeAttack*self.CAC_level,2),
round(ATK_regiment.HardMeleeAttack*self.CAC_level,2),
round(ATK_regiment.SoftMeleeAttack*self.CAC_level,2)+round(ATK_regiment.SoftMeleeAttack*self.CAC_level,2))
# DEF Round
self.DEF.do_attack(self.DEF, self.CAC_level) # DEF riposte
DEF_regiment.Attaque(DEF_regiment,self.CAC_level) # DEF riposte
if Loglevel:
txt += "\n{} round".format(self.DEF.name)
txt += "\n - Shots: {} SA + {} HA = {}".format(self.DEF.SoftAttack, self.DEF.HardAttack,
self.DEF.SoftAttack + self.DEF.HardAttack)
txt += "\n - Melee: {} SMA + {} HMA = {}".format(round(self.DEF.SoftMeleeAttack*self.CAC_level, 2),
round(self.DEF.HardMeleeAttack*self.CAC_level, 2),
round(self.DEF.SoftMeleeAttack*self.CAC_level, 2) + round(
self.DEF.SoftMeleeAttack*self.CAC_level, 2))
self.DEF.take_damage(self.ATK) # DEF prend les dommages
if Loglevel: txt+= "\n{} takes {} hits (-{} defenses)".format(self.DEF.name, self.ATK.nbr_attack, self.DEF.Defense)
self.ATK.take_damage(self.DEF) # ATK prend les dommages
if Loglevel: txt+= "\n{} takes {} hits (-{} breakthrought)".format(self.ATK.name, self.DEF.nbr_attack, self.ATK.Breakthrought)
txt += "\n{} round".format(DEF_regiment.Name)
txt += "\n - Shots: {} SA + {} HA = {}".format(DEF_regiment.SoftAttack, DEF_regiment.HardAttack,
DEF_regiment.SoftAttack + DEF_regiment.HardAttack)
txt += "\n - Melee: {} SMA + {} HMA = {}".format(round(DEF_regiment.SoftMeleeAttack*self.CAC_level, 2),
round(DEF_regiment.HardMeleeAttack*self.CAC_level, 2),
round(DEF_regiment.SoftMeleeAttack*self.CAC_level, 2) + round(
DEF_regiment.SoftMeleeAttack*self.CAC_level, 2))
DEF_regiment.Damage(ATK_regiment) # DEF prend les dommages
if Loglevel: txt+= "\n{} takes {} hits (-{} defenses)".format(DEF_regiment.Name,ATK_regiment.NbATK,DEF_regiment.Defense)
ATK_regiment.Damage(DEF_regiment) # ATK prend les dommages
if Loglevel: txt+= "\n{} takes {} hits (-{} breakthrought)".format(ATK_regiment.Name,DEF_regiment.NbATK,ATK_regiment.Breakthrought)
print(txt)
# Log de fin de round
self.roundCounter += 1
self.printLOG()
if PauseEachRound: AskUser("pausing ...","Click Enter")

def printLOG(self):
"""
log pour chaque heure de combats
"""
ATK_regiment = self.ATK["Regiment"]
DEF_regiment = self.DEF["Regiment"]
txt= """{}: {}/{} {}/{}
{}: {}/{} {}/{}
""".format(self.ATK.name, self.ATK.HP, self.ATK._Regiment__HP, self.ATK.org, self.ATK._Regiment__ORG,
self.DEF.name, self.DEF.HP, self.DEF._Regiment__HP, self.DEF.org, self.DEF._Regiment__ORG)
""".format(ATK_regiment.Name,ATK_regiment.HP,ATK_regiment._Regiment__HP,ATK_regiment.ORG,ATK_regiment._Regiment__ORG,
DEF_regiment.Name,DEF_regiment.HP,DEF_regiment._Regiment__HP,DEF_regiment.ORG,DEF_regiment._Regiment__ORG)
if self.isFinnish():
txt += """
----------- End of Battle -----------------
Expand Down
Loading

0 comments on commit 24f268b

Please sign in to comment.