浏览代码

Enable sanity checks for drop specs

This ensures that drop specs always drop at least one die and do not
drop all dice.
Ryan C. Thompson 7 年之前
父节点
当前提交
7d9c82f509
共有 1 个文件被更改,包括 8 次插入8 次删除
  1. 8 8
      roll.py

+ 8 - 8
roll.py

@@ -355,14 +355,14 @@ class DropSpec(object):
         if not isinstance(rolls, list):
             rolls = list(rolls)
         keeping = self.type in ('K', 'k')
-        # if keeping:
-        #     num_to_keep = self.count
-        # else:
-        #     num_to_keep = len(rolls) - self.count
-        # if num_to_keep == 0:
-        #     raise ValueError('Not enough rolls: would drop all rolls')
-        # elif num_to_keep == len(rolls):
-        #     raise ValueError('Keeping too many rolls: would not drop any rolls')
+        if keeping:
+            num_to_keep = self.count
+        else:
+            num_to_keep = len(rolls) - self.count
+        if num_to_keep == 0:
+            raise ValueError('Not enough rolls: would drop all rolls')
+        elif num_to_keep == len(rolls):
+            raise ValueError('Keeping too many rolls: would not drop any rolls')
         rolls.sort()
         if self.type in ('K', 'X', '-H'):
             rolls.reverse()