示例#1
0
def run(args):

    logging.debug('INSIDE RUN')

    gurkis = Character("Gurkis")
    rayjk = Character("Rayjk")
    target = Target()
    # simulation = sim.Simulation(20000, target, [gurkis, rayjk])
    # simulation = sim.Simulation(10000, target, [rayjk])
    simulation = sim.Simulation(20000, target, [gurkis])
    simulation.run()

    return 0
示例#2
0
def get_generate(a_class: ClassName, name: str, best_roll_ability: Ability = 'CHA', as_pdf: bool = False):

    char_class, ancestry = factory.get_class(a_class)
    c = Character(char_class, ancestry)
    c.ancestry.set_best_ability(best_roll_ability)
    c.generate(name=name)
    if as_pdf:
        output = create_pdf(c)
        headers = {
            'Content-Disposition': f'attachment; filename=FTD_sheet_{name}.pdf'
        }
        return Response(output.getvalue(), headers=headers)
    return c
示例#3
0
    def get(self):
        user = users.get_current_user()
        
        if user:
            user_name = user.nickname()

            try:
                id = self.request.GET['story_id']
            except:
                id = None

            if not id:
                self.redirect("/error?msg=Key missing for management.")
                return

            story = ndb.Key(urlsafe=id).get()
            characters = Character.query(Character.story == story.key.id()).order(Character.name)
            access_link = users.create_logout_url("/")

            template_values = {
                "info": AppInfo,
                "user_name": user_name,
                "access_link": access_link,
                "story": story,
                "characters": characters
            }

            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(jinja.render_template("characters.html", **template_values))
        else:
            self.redirect("/")
            return
示例#4
0
    async def inint_monsters(cls):

        if not cls.country:
            raise Exception('WorldCache.init_monsters: Run configure before init_monsters.')

        path = f'monsters/{cls.country}/{cls.state}/{cls.county}'
        monsters_directory = os.path.join(cls.directory, path)

        template = cls.jinja_monsters.get_template(f'{cls.country}/{cls.state}/{cls.county}/{cls.shard}.toml')
        template_data = loads(template.render())
        for m in template_data['monsters']:
            character = Character(m['monster'])
            character.shard = cls.shard
            character.monster_id = str(uuid4())
            await character.save()
            await character.set_location(
                character.location.coordinates[0],
                character.location.coordinates[1]
            )
            cls.monsters[character.id] = True
            cls.output.info(f'{Fore.MAGENTA}Created {character.id}{Style.RESET_ALL}')
示例#5
0
文件: add.py 项目: Baltasarq/el-boli
    def get(self):
        try:
            story_id = self.request.GET['story_id']
        except:
            self.redirect("/error?msg=missing key")
            return

        user = users.get_current_user()

        if user:
            try:
                story = ndb.Key(urlsafe=story_id).get()
            except:
                self.redirect("/error?msg=key was not found")
                return

            num_characters = len(Character.query().fetch(keys_only=True)) + 1
            character = Character()
            character.story = story.key.id()
            character.name = "John Doe " + str(num_characters)
            character.summary = "An awesome character."
            key = model.character.update(character)
            self.redirect("/characters/modify?character_id=" + key.urlsafe())
        else:
            self.redirect("/")

        return
示例#6
0
    def __init__(self):
        """Class constructor"""

        self.lab = Labyrinth('resource/map.txt')
        macgyver = Character('M', 1, 3)
        guardian = Character('G', 13, 13)
        self.lab.set_character_position(macgyver)
        self.lab.set_character_position(guardian)
        self.lab.set_tool_positions(constants.TOOLS)

        view = self.initialize_view()

        view.display_lab(self.lab.lablist)

        game_loop = True
        while game_loop:
            direction = view.get_direction()

            if direction is None:  # exit key pressed
                exit()

            for d in direction:
                move = self.lab.move_macgyver(macgyver,
                                              guardian,
                                              d)
                if move in ['CONTINUE', 'ADD_TOOL']:
                    view.display_lab(self.lab.lablist)
                elif move == 'NO_MOVE':
                    continue
                elif move == 'WIN':
                    view.win()
                    game_loop = False
                    exit()
                elif move == 'LOSE':
                    view.lose()
                    game_loop = False
                    exit()
示例#7
0
def get_player(player):
    conn = psycopg2.connect(database_url, sslmode='require')
    cur = conn.cursor()

    cur.execute("SELECT * FROM character WHERE player = '{0}'".format(player))

    row = cur.fetchone()

    cur.close()
    conn.close()

    if row != None:
        player_character = Character(row[1], row[2], row[3], row[4])
        return player_character

    return None
示例#8
0
def get_shortcut_player_guild(shortcut, player, guild_id):
    conn = psycopg2.connect(database_url, sslmode='require')
    cur = conn.cursor()

    cur.execute("SELECT * FROM character WHERE shortcut = '{0}' AND player = '{1}' AND guild_id = '{2}'".format(shortcut, player, guild_id))

    row = cur.fetchone()

    cur.close()
    conn.close()

    if row != None:
        player_character = Character(row[1], row[2], row[3], row[4])
        return player_character

    return None
示例#9
0
    def post(self):
        try:
            character_id = self.request.GET['character_id']
        except:
            self.redirect("/error?msg=missing id for modification")
            return

        user = users.get_current_user()

        if user:
            # Get story by key
            try:
                character = ndb.Key(urlsafe=character_id).get()
                story = Story.get_by_id(character.story)
            except:
                self.redirect("/error?msg=key does not exist")
                return

            character.name = self.request.get("name", "").strip()
            character.summary = self.request.get("summary", "").strip()

            # Chk
            if len(character.name) < 1:
                self.redirect("/error?msg=Aborted modification: missing name")
                return

            # Chk title
            existing_characters = Character.query(
                Character.name == character.name)
            if (existing_characters and existing_characters.count() > 0
                    and existing_characters.get() != character):
                self.redirect("/error?msg=Character with name \"" +
                              character.title.encode("ascii", "replace") +
                              "\" already exists.")
                return

            # Save
            character.put()
            self.redirect("/info?msg=Character modified: \"" +
                          character.name.encode("ascii", "replace") + "@" +
                          story.title.encode("ascii", "replace") +
                          "\"&url=/manage_characters?story_id=" +
                          story.key.urlsafe())
        else:
            self.redirect("/")
 def getCharacter(self):
     name = str(self.ui.editChar.text())
     player = str(self.ui.editPlayer.text())
     classe = str(self.ui.cboxClass.currentText())
     
     char = Character(name, player, classe)
     
     char.hp = self.ui.spinHp.value()
     char.ca = self.ui.spinCa.value()
     char.hs = self.ui.spinHs.value()
     char.currHp = self.ui.spinHp.value()
     char.currHs = self.ui.spinHs.value()
     
     return char
示例#11
0
    async def refresh(cls, attributes, token):

        token_data = token.get('data')
        token_id = token_data.get('id')
        token_groups = token_data.get('groups')
        token_scope = token_data.get('scope')

        if not await Profile.exists(token_id):
            raise Exception('Profile not found for token ID.')

        token = {
            #'exp': datetime.utcnow() + timedelta(minutes=5),
            'nbf': datetime.utcnow(),
            'iat': datetime.utcnow(),
            'data': {
                'id': token_id,
                'groups': token_groups,
                'scope': token_scope,
            }
        }

        if attributes and attributes.get('character'):

            characters = [
                character
                async for character in Character.find({'profile': profile.id})
            ]

            character = attributes.get('character')

            if character and isinstance(character, dict):
                id = character.get('id')
                if not id in list(map(lambda c: c.id, characters)):
                    raise Exception('Invalid request.')
                if id:
                    token['data']['attributes'] = {'character': {'id': id}}
                else:
                    raise Exception('Invalid request.')
            else:
                raise Exception('Invalid request.')

        return token
示例#12
0
def get_all_player(player, guild_id):
    conn = psycopg2.connect(database_url, sslmode='require')
    cur = conn.cursor()

    cur.execute("SELECT * FROM character WHERE player = '{0}' AND guild_id = '{1}'".format(player, guild_id))

    row = cur.fetchone()

    player_characters = []

    while row != None:
        player_character = Character(row[1], row[2], row[3], row[4])
        player_characters.append(player_character)
        
        row = cur.fetchone()

    cur.close()
    conn.close()

    return player_characters
示例#13
0
    def get(self):
        try:
            section_id = self.request.GET['section_id']
        except:
            self.redirect("/error?msg=missing key for modification")
            return

        user = users.get_current_user()

        if user:
            user_name = user.nickname()
            access_link = users.create_logout_url("/")

            try:
                section = ndb.Key(urlsafe=section_id).get()
                chapter = Chapter.get_by_id(section.chapter)
                story = Story.get_by_id(chapter.story)
                characters = Character.query(Character.story == story.key.id())
            except:
                self.redirect("/error?msg=key does not exist")
                return

            template_values = {
                "info": AppInfo,
                "user_name": user_name,
                "access_link": access_link,
                "story": story,
                "characters": characters,
                "chapter": chapter,
                "section": section
            }

            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(
                jinja.render_template("modify_section.html",
                                      **template_values))
        else:
            self.redirect("/")
示例#14
0
def remove_all_characters_of(story_key):
    characters_keys = Character.query(Character.story == story_key.id()).fetch(
        keys_only=True)
    ndb.delete_multi(characters_keys)
示例#15
0
from controller.core import JikanGatewaysAPI, ImageViewer
from model.character import Character
from model.manga import Manga
from model.anime import Anime
import requests

s = JikanGatewaysAPI(requests)

all_char = list()
for character in s.search_character('shouta aizawa').json().get('results'):
    all_char.append(Character(character))

all_anime = list()
for anime in s.search_anime('Boku No Hero').json().get('results'):
    all_anime.append(Anime(anime))

all_manga = list()
for manga in s.search_manga('Boku No Hero').json().get('results'):
    all_manga.append(Manga(manga))

all_anime_of_season = list()
for anime in s.list_animes_from_season(2018, 'winter').json().get('anime'):
    all_anime_of_season.append(Anime(anime))

works = s.search_person_works("junichi")
print(works)
print(all_char[0].image_url)
img = ImageViewer(all_char[0].image_url, requests)
print(all_anime[0].title)
print(all_manga[0].title)
print(all_anime_of_season[0].title)
示例#16
0
async def create(request, token):

    if not token:
        error = Error(title='Create Character Error',
                      detail='You are not logged in.',
                      status=403)
        return jsonapi({"errors": [error.serialize()]}, status=403)

    token = Document(token)

    data = request.json.get('data')
    attributes = data.get('attributes')

    character = await Character.find_one({'profile': token.data.id})

    if character:
        error = Error(title='Create Character Error',
                      detail='You already have a character.',
                      status=403)
        return jsonapi({"errors": [error.serialize()]}, status=403)

    try:
        character = Character(attributes)
    except:
        error = Error(title='Create Character Error',
                      detail='Invalid attributes.',
                      status=403)
        return jsonapi({"errors": [error.serialize()]}, status=403)

    character.profile = token.data.id

    if not character.race in WorldCache.races:
        error = Error(title='Create Character Error',
                      detail='Invalid race.',
                      status=403)
        return jsonapi({"errors": [error.serialize()]}, status=403)

    if not len(character.name.first) > 5:
        error = Error(title='Create Character Error',
                      detail='Invalid first name.',
                      status=403)
        return jsonapi({"errors": [error.serialize()]}, status=403)

    character.level = {'current': 1, 'experience': 0, 'next': 1000}
    character.attributes = WorldCache.races[character.race]['attributes']
    character.health = 0
    character.state = {
        'target': None,
        'hostile': False,
        'retaliate': False,
        'dead': False,
        'casting': False
    }

    await character.save()

    return jsonapi({
        'data': {
            'attributes': {
                'message': 'Character created.',
                'url': f'/v1/characters/{character.id}'
            }
        }
    })
示例#17
0
 def __init__(self, *args, **kwargs):
     super(TestActionStatus, self).__init__(*args, **kwargs)
     self.character = Character("Gurkis")
示例#18
0
from api import server
from authentication import Authentication
from model.character import Character
from model.profile import Profile

server.blueprint(Authentication.resource(url_prefix='v1'))

server.blueprint(Profile.resource(url_prefix='v1'))
server.blueprint(Character.resource(url_prefix='v1'))