Esempio n. 1
0
		self.critical_multiplier = critical_multiplier or {'light': 1.5, 'medium': 2.0, 'heavy': 3.0}[size]
		self.critical_chance = critical_chance or {'light': 15, 'medium': 10, 'heavy': 5}[size]
		self.price = price

	@classmethod
	def random(cls):
		global _weapon_id
		name = u'weapon%d' % _weapon_id
		_weapon_id += 1
		size = random.choice(cls.sizes)
		type = random.choice(cls.types)
		class_ = random.choice(cls.classes)
		damage = Dice(random.randrange(1, 4), random.randrange(4, 11, 2))
		damage_type = set([random.choice(cls.damage_types)])
		magic_enchantment = random.randrange(11)
		return cls(name, size, type, class_, damage, damage_type, magic_enchantment, price = 10)

	def __repr__(self):
		return 'Weapon(%r, %r, %r, %r, %r, %r, %r)' % (self.name, self.size, self.type, self.class_, self.damage, self.damage_type, self.magic_enchantment)

	def __str__(self):
		return '%s (%s %s %s %s+%d %s)' % (self.name or 'Weapon', self.size, self.type, self.class_, self.damage, self.magic_enchantment, '/'.join(self.damage_type))

weapons = {}
for name, type, size, dmg_type, dmg_roll, crit_mult, crit_chance, min_range, max_range, price in weapon_data:
	dmg_roll = Dice(*map(int, dmg_roll.split('d')))
	weapons[name] = Weapon(name, size, type, None, dmg_roll, set(dmg_type), 0, crit_mult, crit_chance, price)

default = Weapon('fist', 'light', 'melee', None, Dice(0, 0), set(['bludgeoning']), 0, 1, 0, 0)