战锤40k统计工具
warhammer-stats的Python项目详细描述
战锤属性
这是一个Python库,提供了为warhammer40000生成pmf的组件。这段代码是从https://www.warhammer-stats-engine.com/的后端提取的,并拆分成自己的包,以便其他开发人员更容易使用。在
使用
您可以使用pip获取库的最新版本。https://pypi.org/project/warhammer-stats/
pipenv install warhammer-stats
示例用法
fromwarhammer_statsimportAttack,Weapon,Target,PMFCollectionfromwarhammer_stats.modifiersimportModifierCollection,ReRollOnes# Define a re-roll ones weapon modifierweapon_mods=ModifierCollection(hit_mods=[ReRollOnes()])# Define the weapon. In this case it is a clasic boltgun hitting on a 4+weapon=Weapon(bs=4,shots=PMFCollection.static(10),strength=4,ap=0,damage=PMFCollection.static(1),modifiers=weapon_mods)# Define the target. In this case it is a space marinetarget=Target(toughness=4,save=3,invuln=7,fnp=7,wounds=1)# Create an attackattack=Attack(weapon,target)# Run the calculationresult=attack.run()# print the mean of the damage distributionprint(f'Average wounds: {result.damage_dist.mean()}')
- 项目
标签: