An opposed pool roll system with modifiers help #241
-
Hi there, I'm wondering if I could get some eyes on/suggestions/help for an opposed roll mechanic I am working on modeling with Icepool. I think I have something working here that covers the basics. Its just a modification of an earlier mechanic I was working on, so I'm not sure if this is the best way to go about it. The attacking player rolls a pool with size from 2d6-12d6, and counts one success for each die that scores 4 or greater. The number of dice rolled in the pool can be increased or decreased by a modifier (mod, e.g. +2). The opposing player rolls a pool with size equal to their cohesion (co) ranging from 3-6d6. The number of dice rolled in this pool can be increased by a modifier for cover (cov, e.g. +1 through +5). If the number of successes in the attacking players roll is greater than the number of successes in the opposing player's roll, this is considered a hit. I'd like to be able to examine the range of different rolls and the degrees of success of the attacker versus the opposing player's roll. You can see I have the modifiers and cover integrated in the first output line. One of the issues I'm seeing is that I can't use a negative modifier like -2 in the code below, it throws an error. Anyway, still learning the Icepool package and surely there is a better way to do this. I'd be grateful to see any recommendations. Cheers, from icepool import d6, map_function
tn = 4 # target number
co = 4 # cohesion
mod = 2 # modifier (+/-)
cov = 2 # cover (+)
@map_function
def btc(pool, target):
return sum(x >= target for x in pool)
output(btc(d6.pool(1 + mod), tn) - (co + cov) @ (d6 >= tn), "1D6")# Pool of 1
output(btc(d6.pool(2), tn) - co @ (d6 >= tn), "2D6")# Pool of 2
output(btc(d6.pool(3), tn) - co @ (d6 >= tn), "3D6")# Pool of 3
output(btc(d6.pool(4), tn) - co @ (d6 >= tn), "4D6")# Pool of 4
output(btc(d6.pool(5), tn) - co @ (d6 >= tn), "5D6")# Pool of 5
output(btc(d6.pool(6), tn) - co @ (d6 >= tn), "6D6")# Pool of 6
output(btc(d6.pool(9), tn) - co @ (d6 >= tn), "9D6")# Pool of 9
output(btc(d6.pool(12), tn) - co @ (d6 >= tn), "12D6")# Pool of 12 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
In this case it's easiest to use the from icepool import d6, map_function
tn = 4 # target number
atk = 4 # base attacker dice
co = 4 # cohesion
mod = 2 # modifier (+/-)
cov = 2 # cover (+)
output((atk + mod) @ (d6 >= tn) - (co + cov) @ (d6 >= tn)) You do have to define what happens with zero or negative pool size. |
Beta Was this translation helpful? Give feedback.
In this case it's easiest to use the
@
operator for the attacker as well, e.g.You do have to define what happens with zero or negative pool size.
@
treats a negative left operand as negating the result, whereas I did not define the result of a negativepool
size.