def test_items(self): character = extsea.Character('null') item = rpgdb.createl('money', 20) character.add(item) item = rpgdb.createl('money', 54) character.add(item) self.assertEqual(character.attrib['money'].rlevel, 74)
def receive(name, amount): item = rpgdb.createl(name, amount) text = 'Zdobyłeś '+item.title if amount > 1: text += ' (' + str(amount) + ')' dialog(text) character.add(item)
def to_extsea(self): '''Convert into extsea class''' attribute = rpgdb.createl(self.name, self.level) attribute.id = self.id attribute.rlevel = attribute.level attribute.exp = self.exp return attribute
def register(request): context = {} if ('user' in request.session): return HttpResponseRedirect('/') if request.POST: pattern = re.compile('^[A-z0-9_]+$') if not(pattern.match(request.POST['name'])): context['error'] = 'Nieprawidłowe znaki w nazwie użytkownika.' is_exists = Character.objects.filter(name=request.POST['name']) context['name'] = request.POST['name'] if is_exists.count() > 0: context['error'] = 'Użytkownik istnieje.' if len(request.POST['pass']) < 4: context['error'] = 'Za krótkie hasło.' if request.POST['pass'] != request.POST['pass2']: context['error'] = 'Hasła nie zgadzają się.' if not('error' in context): new_char = extsea.Character(request.POST['name']) new_char.add(rpgdb.create('human')) new_char.add(rpgdb.createl("strength", 1)) new_char.add(rpgdb.createl("speed", 1)) new_char.add(rpgdb.createl("life", 1)) new_char.add(rpgdb.createl("magic", 1)) for i in range(1, 4): rand = randint(0, 3) traits = ['strength', 'speed', 'life', 'magic'] new_char.add(rpgdb.createl('trait_' + traits[rand] + str(random()), 1)) new_char.add(rpgdb.createl("hit", 1)) if (request.POST['gender'] == 'male'): new_char.add(rpgdb.create('male')) else: new_char.add(rpgdb.create('female')) new_user = Character.from_extsea(new_char) new_user.password = hashlib.sha224(request.POST['pass']).hexdigest() new_user.place = Place.objects.all()[0] new_user.save() return HttpResponseRedirect('/welcome/' + new_char.name) context.update(csrf(request)) return render_to_response('register.html', context)
import extsea import rpgdb c = extsea.Character("elo") print(c.name) c.add(rpgdb.createl("sword", 4)) c.add(rpgdb.create("male")) c.add(rpgdb.createl("strength", 3)) c.add(rpgdb.create("human")) #rpgdb.viewc(c) w = rpgdb.create_monster("wolf") m = rpgdb.create_monster("mushroom") w.team = 2 b = extsea.Battle([w, m]) b.run()