## a vs die roller as used by Exalted #!/usr/bin/env python # Copyright (C) 2000-2001 The OpenRPG Project # # openrpg-dev@lists.sourceforge.net # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -- # # File: exalted.py # Author: Dashiel Nemeth # Maintainer: # Version: # $Id: exalted.py,v Traipse 'Ornery-Orc' prof.ebral Exp $ # # Description: Exalted die roller __version__ = "$Id: exalted.py,v Traipse 'Ornery-Orc' prof.ebral Exp $" from std import std from orpg.dieroller.base import * class exalted(std): name = "exalted" regExpression = "[\(0-9\*\-\+\)]+[a-zA-Z]+[0-9]+" def __init__(self,source=[],target=-1): std.__init__(self,source) self.target = target def vs(self,target): self.target = target return self def sum(self): rolls = [] successes = 0 botch = 0 for a in self.data: rolls.extend(a.gethistory()) for r in rolls: if r == 10: successes += 2 elif r >= 7: successes += 1 elif r == 1: botch = 1 if botch == 1 and successes == 0: successes = -1 return successes def dam(self): rolls = [] successes = 0 for a in self.data: rolls.extend(a.gethistory()) for r in rolls: if r >= 7: successes += 1 return successes def __str__(self): if len(self.data) > 0: myStr = "[" + str(self.data[0]) for a in self.data[1:]: myStr += "," myStr += str(a) if self.target == -1: if self.sum() < 0: myStr += "] => Botch!" elif self.sum() == 0: myStr += "] => Failure!" elif self.sum() == 1: myStr += "] => Standard Success. (1 Success, 1 Damage)" elif self.sum() == 2: myStr += "] => Difficult Success. (2 Successes, " + str(self.dam()) + " Damage)" elif self.sum() == 3: myStr += "] => Challenging Success! (3 Successes, " + str(self.dam()) + " Damage)" elif self.sum() == 4: myStr += "] => Nearly Impossible Success! (4 Successes, " + str(self.dam()) + " Damage)" else: myStr += "] => Legendary Success! (" + str(self.sum()) + " Successes, " + str(self.dam()) + " Damage)" else: if self.target < 0: self.target=0 threshold = self.sum() - self.target if self.sum() < 0: myStr += "] => Botch!" elif self.sum() <= self.target: myStr += "] => Failure!" elif threshold == 1 and self.sum() == 1: myStr += "] => Adiquate Success. (1 Success, 1 Extra)" elif threshold == 1: myStr += "] => Adequate Success. (" + str(self.sum()) + " Successes, 1 Extra)" elif threshold == 2: myStr += "] => Competent Success. (" + str(self.sum()) + " Successes, 2 Extra)" elif threshold == 3: myStr += "] => Superior Success! (" + str(self.sum()) + " Successes, 3 Extra)" elif threshold == 4: myStr += "] => Astonishing Success! (" + str(self.sum()) + " Successes, 4 Extra)" else: myStr += "] => Phenomenal Success! (" + str(self.sum()) + " Successes, " + str(threshold) + " Extra)" return myStr def non_stdDie(self, match): command = match.group(0) args = command.split('v') if len(args) > 1: dice = args[0] target = args[1] command = '(' + dice.strip() + "**die_rollers['exalted'](10)).vs(" + target + ')' return str(eval(command)) die_rollers.register(exalted)