############################################################################# ## This file is part of the Ostendo Resource Manager. ## ##-------------------------------------------------------------------------## ## Copyright 2007-2008 Bryce Schroeder ## ## bryce.schroeder@gmail.com ## ## http://www.ferazelhosting.net/~bryce/ ## ##-------------------------------------------------------------------------## ## 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 3 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, see . ## ############################################################################# from random import * class D: def __init__(self, n, d, bonus=0): self.n = n self.d = d self.bonus = bonus def roll(self): return dice(self.n,self.d) + self.bonus def dice(n, d): i = 0 t = 0 while i < n: i += 1 t += randint(1,d) return t RIGHT={'north': 'east', 'east': 'south', 'south': 'west', 'west': 'north'} LEFT={'north': 'west', 'west': 'south', 'south': 'east', 'east': 'north'} def turn_left(d): return LEFT[d] def turn_right(d): return RIGHT[d] def turn_around(d): return LEFT[LEFT[d]]