Esempio n. 1
0
	def random(cls):
		global _character_id
		name = 'character%d' % _character_id
		_character_id += 1
		race_name = random.choice(races.keys())
		class_name = random.choice(classes.keys())
		rndstats = [random.choice(['dex', 'con', 'int', 'str']) for i in range(random.randrange(4, 6+1))]
		str = rndstats.count('str')
		dex = rndstats.count('dex')
		con = rndstats.count('con')
		int = rndstats.count('int')
		armor = random.choice(armors.values())#Armor.random()
		weapon = random.choice(weapons.values())#Weapon.random()
		return cls(name, race_name, class_name, str, dex, con, int, armor, weapon)
Esempio n. 2
0
	def __init__(self, screen):
		pygame.display.set_caption('Xadir')

		self.screen = screen
		self.width, self.height = self.screen.get_size()

		self.background = pygame.Surface((self.width, self.height))
		self.background.fill((127, 127, 127))

		self.fps = 30
		self.clock = pygame.time.Clock()

		self.res = Resources(None)

		self.sprites = pygame.sprite.LayeredDirty(_time_threshold = 1000.0)
		self.sprites.set_clip()

		grid = FakeGrid(GRID_SIZE)
		class_ = classes.keys()[0]

		races_ = races.keys()
		raceses = [races_[:len(races_)/2], races_[len(races_)/2:]]
		self.chars = []
		for r, races_ in enumerate(raceses):
			for x, hair in enumerate(hairs):
				for y, race in enumerate(races_):
					pos = (1 + r * (len(hairs) + 1) + x, 1 + y)
					armor = None
					char = CharacterSprite(None, Character(None, race, class_, 0, 0, 0, 0, armor, None, hair), pos, 270, grid, self.res)
					self.sprites.add(char)
					self.chars.append(char)

		for x, (hairname, hair) in enumerate(hairs.items()):
			ht = HairXY(hair, (int((x + 1.5) * GRID_SIZE[0]), 30))
			self.sprites.add(ht)

		for r, races_ in enumerate(raceses):
			for y, race in enumerate(races_):
				ht = HairL(races[race], ((r * (len(hairs) + 1) + 0.5) * GRID_SIZE[0], (y + 1.5) * GRID_SIZE[1]))
				self.sprites.add(ht)

		self.selected = None