Esempio n. 1
0
 def testUpdate(self):
     self.units.units = {
         1: Character(1, 10, 10, 2000, UnitType.WORKER),
         2: Character(1, 10, 10, 2000, UnitType.CASTLE)
     }
     self.units.update()
     # for i in self.units.strengthMap:
     # for j in i:
     #         print j,
     #     print i
     # print self.units.unit
     self.assertEqual(len(self.units.unit[UnitType.CASTLE.value]), 1)
Esempio n. 2
0
 def get(self, character_id):
     _log.debug('Get character %s' % character_id)
     character = Character.get_by_id(int(character_id))
     if character is None:
         self.abort(404)
     else:
         self.write_json(character)
Esempio n. 3
0
 def get(self, character_id):
     _log.debug('Get character %s' % character_id)
     character = Character.get_by_id(int(character_id))
     if character is None:
         self.abort(404)
     else:
         self.write_json(character)
Esempio n. 4
0
def create_character(character_name, race, language, campaign, character_owner,
                     strength, dex, con, intel, wis, cha, speed):

    character_id = Character.query.filter_by().count() + 1

    if Language.query.filter_by(language=language).count() == 0:
        create_language(language)
    language_id = Language.query.filter_by(
        language=language).first().language_id
    character_language = CharacterLanguage(cl_language=language_id,
                                           cl_character=character_id)

    if Race.query.filter_by(race_name=race).count() == 0:
        race = create_race(race)
    race_id = Race.query.filter_by(race_name=race).first().race_id

    character = Character(character_name=character_name,
                          race=race_id,
                          campaign=campaign,
                          character_owner=character_owner,
                          strength=strength,
                          dex=dex,
                          con=con,
                          intel=intel,
                          wis=wis,
                          cha=cha,
                          speed=speed)

    db.session.add(character, character_language)
    db.session.commit()
Esempio n. 5
0
def generate(datadir, localedir, outdir):
    data = load_data(datadir, localedir)

    env = Environment(loader=FileSystemLoader(os.path.dirname(__file__)))
    env.filters['colorize'] = colorize
    template = env.get_template('template.txt')

    #weapon_data = {}
    #weapon_data['DataList'] = []
    #
    #def save_weapons_translation(weapon_data):
    #    f = open('Weapons.json', "w", encoding='utf8' )
    #    f.write(json.dumps(weapon_data, sort_keys=False, indent=4, ensure_ascii=False))
    #    f.close()
    #    return True

    for character in data.characters.values():
        if not character['IsPlayableCharacter'] or character[
                'ProductionStep'] != 'Release':
            continue

        try:
            character = Character.from_data(character['Id'], data)
        except Exception as err:
            print(f'Failed to parse for DevName {character["DevName"]}: {err}')
            traceback.print_exc()
            continue

        with open(os.path.join(outdir, f'{character.name_translated}.txt'),
                  'w',
                  encoding="utf8") as f:
            f.write(template.render(character=character))
Esempio n. 6
0
    def build_character_default(cls):
        assert type(cls) is type, "Must call as classmethod"
        """Construct a character to play with"""
        ########
        # BUILD HENRI (sort of)
        #######
        c = Character()
        c.base.str_score = 19
        c.base.dex_score = 12
        c.base.con_score = 13
        c.base.cha_score = 14

        c.BAB = 5

        greatsword = Weapon("Greatsword",
                      Attack(atk=+0, dmg_roll=DamageRoll.fromString("2d6"),
                             crit_range=[19,20], crit_mult=2, two_handed=True))
        #c.equipment.main_hand = greatsword

        # Add in dual-wield for testing
        tidewater_cutless = Weapon("Tidewater Cuttless +1",
                      Attack(atk=+1, dmg_roll=DamageRoll.fromString("1d6+1"),
                             crit_range=[18,19,20], crit_mult=2))
        c.equipment.main_hand = tidewater_cutless
        masterwork_handaxe = Weapon("Masterwork Handaxe",
                              Attack(atk=1, dmg_roll=DamageRoll.fromString("1d6"),
                                     crit_range=[20,], crit_mult=3))

        c.equipment.off_hand = masterwork_handaxe

        cls.c = c

        # Buffs
        cls.possible_buffs_list = \
            [Buff('Favored Enemy (Human)',4,4),
             Buff('Favored Enemy (Monstrous Humanoid)',2,2),
             Buff('Bless',atk_mod=1),
             Buff('Prayer',atk_mod=1,dmg_mod=1),
             Buff('Sickened',atk_mod=-2,dmg_mod=-2)]

        bulls_strength = Buff("Bull's Strength")
        bulls_strength.str_score = 4
        cls.possible_buffs_list.append(bulls_strength)

        # Update UIC Model
        cls.uic._model = cls.c
Esempio n. 7
0
def display_index():
    """Display index template."""

    characters = Character.all()
    series = Series.all()

    return render_template("index.html",
                            characters=characters,
                            series=series)
Esempio n. 8
0
def create_character(project_name, name, role, desc):
    """"Creates a Character"""

    project = get_project_by_name(project_name)
    character = Character(project_id=project.project_id,
                          role=role,
                          name=name,
                          desc=desc)

    db.session.add(character)
    db.session.commit()
Esempio n. 9
0
    def build_character(self):
        """Construct a character to play with"""
        ########
        # BUILD HENRI
        #######
        c = Character()
        c.base.str_score = 19
        c.base.dex_score = 12
        c.base.con_score = 13
        c.base.cha_score = 14

        c.BAB = 5

        greatsword = Weapon("Greatsword",
                      Attack(atk=+0, dmg_roll=DamageRoll.fromString("2d6"),
                             crit_range=[19,20], crit_mult=2, two_handed=True))
        c.equipment.main_hand = greatsword
        attacks = c.attacks

        self.c = c
def load_characters():
    """load characters into database."""
    print("Characters")

    Character.query.delete()

    for tag in characters_tags:
        character_index = characters_tags.index(tag) + 1
        add_character = Character(character_id=character_index, character=tag)

        db.session.add(add_character)

    db.session.commit()
Esempio n. 11
0
def load_characters():

    for line in open("csv/characters.csv"):
        line = line[:-1]
        name, group, actor, bio, image = line.split(',')

        character = Character(name=name,
                              group=group,
                              actor=actor,
                              bio=bio,
                              image=image)

        db.session.add(character)

    db.session.commit()
Esempio n. 12
0
    def post(self):
        if self.params.characters:
            party = Party.get_current()
            characters = []
            for character in self.params.characters:
                c_id = character.get('id')
                clean(character)
                db_char = c_id and Character.get(c_id) or Character(party=party)

                for k, v in character.iteritems():
                    setattr(db_char, k, extract(k, v))
                db_char.put()
                characters.append(db_char)
                
            self.write(json.dumps([c.to_dict() for c in characters]))
        else:
            self.write(json.dumps([]))
 def create(self):
     name = self.text_entry.text
     if len(name) > 0:
         today = date.today().isoformat()
         profile = Profile(name=name,
                           created_date=today,
                           modified_date=today)
         session = context['db_session']
         session.add(profile)
         # TODO: when supporting multiple characters per profile, move these
         character = Character(profile=profile,
                               name=name,
                               created_date=today,
                               modified_date=today,
                               gold=0,
                               enemies=0)
         session.add(character)
         session.commit()
         self.manager.set_screen('list_profiles')
Esempio n. 14
0
def generate(datadir, translationdir, outdir):
    data = load_data(datadir)
    tls = load_translations(translationdir)

    env = Environment(loader=FileSystemLoader(os.path.dirname(__file__)))
    env.filters['colorize'] = colorize
    template = env.get_template('template.txt')

    for character in data.characters.values():
        if not character['CollectionVisible']:
            continue

        try:
            character = Character.from_data(character['Id'], data, tls)
        except Exception as err:
            print(f'Failed to parse for DevName {character["DevName"]}: {err}')
            traceback.print_exc()
            continue

        with open(os.path.join(outdir, f'{character.name}.txt'), 'w') as f:
            f.write(template.render(character=character))
Esempio n. 15
0
def load_characters(file_name):
    """Loads characters from Characters.txt into database"""

    #Uses python csv.reader function to parse data from txt file
    with open(file_name) as csvfile:
        charreader = csv.reader(csvfile, delimiter=',', quotechar='~')
        for row in charreader:
            char_id = row[0]
            char_name = row[1]
            play_id = row[3]
            c_description = row[4]
            mono_count = row[5]

            #Connects data from Characters.txt to variables in the characters table
            character = Character(char_id=char_id,
                                  char_name=char_name,
                                  play_id=play_id,
                                  c_description=c_description,
                                  mono_count=mono_count)

            #Adds the character to the characters table in the database.
            db.session.add(character)
        db.session.commit()
Esempio n. 16
0
def get_data_for_d3():

    json = {"nodes":[], "links":[]}

    characters = Character.all()
    relationships = Relationship.query.all()

    characters = sorted(characters, key=lambda c:c.char_id)

    for c in characters:
        node = {}
        node["name"] = c.name
        node["group"] = c.group
        json["nodes"].append(node)

    for r in relationships:

        link = {}
        link["source"] = r.char1_id - 1
        link["target"] = r.char2_id - 1
        link["value"] = r.threshold
        json["links"].append(link)

    return jsonify(json)
Esempio n. 17
0
# Detect if we're already inside IBC and thus, all of this has been
#   provided for us
if 'Character' not in locals().keys():
    from model import (Character, RPGClass, Equipment, Weapon, Attack,
                       Buff, Feat, auditable)

class Ranger(RPGClass):
    def __init__(self):
        super(Ranger, self).__init__()
        self.hit_die = 10
        self.fort = 5       # TODO: Scale will level
        self.ref = 5
        self.will = 2

c = Character()
c.name = 'Clement'
c.lvl = 6
c.BAB = 6
c.rpg_class = Ranger()

# Ability Scores
c.base.str_score = 19
c.base.dex_score = 16
c.base.con_score = 14
# All the others are the default value of 10

# Armor
breastplate = Equipment("Mithral Chain Shirt +2")
breastplate.AC = 6
breastplate.ACP = 0
Esempio n. 18
0
 def post(self):
     if self.params.id:
         Character.get(self.params.id).delete()
Esempio n. 19
0
def turnInput(aBrain, t, s):
    aBrain.aStage.time = t
    aBrain.aStage.stageNum = s
    aBrain.aStage.turnNum = int(raw_input())
    aBrain.aStage.resourceNum = int(raw_input())
    N = int(raw_input())

    turnNum = aBrain.aStage.turnNum
    units = aBrain.aStage.supporter.units
    unitsId = []
    isSecond = False
    for i in xrange(N):
        cid, y, x, hp, utype = map(int, raw_input().split())
        if utype == UnitType.CASTLE.value:
            if y >= 60:
                isSecond = True

        if isSecond:
            y = MAPSIZE - y
            x = MAPSIZE - x

        unitsId.append(cid)
        if cid in units:
            c = units[cid]
            c.point = Point(x, y)
            c.turn = turnNum
        else:
            units[cid] = Character(cid, y, x, hp, UnitType(utype),
                                   ForceType.NEET, turnNum)

    # 永眠キャラを除去
    for key, unit in units.items():
        if key not in unitsId:
            units.pop(key)

    aBrain.aStage.enemies.units = {
        k: v
        for k, v in aBrain.aStage.enemies.units.items()
        if v.type not in FORGET_SET
    }
    enemies = aBrain.aStage.enemies.units

    M = int(raw_input())
    for i in xrange(M):
        cid, y, x, hp, utype = map(int, raw_input().split())

        if isSecond:
            y = MAPSIZE - y
            x = MAPSIZE - x

        if cid in enemies:
            c = enemies[cid]
            c.point = Point(x, y)
            c.turn = turnNum
        enemies[cid] = Character(cid, y, x, hp, UnitType(utype), turnNum)

    R = int(raw_input())
    for i in xrange(R):
        y, x = map(int, raw_input().split())
        if isSecond:
            y = MAPSIZE - y
            x = MAPSIZE - x
        aBrain.aStage.updateResource(Point(x, y))
    aBrain.startTurn()
    raw_input()  # end
    return isSecond
Esempio n. 20
0
 def get(self):
     allianceId = self.config.alliance_id
     characters = Character.query(
         Character.alliance_id == allianceId).order(
             Character.character_name)
     self.write_page(characters)
Esempio n. 21
0
class CharacterSheetController(object):
    file_name = "players_handbook" + ".json"
    file = open(file_name, "r")
    buffer = file.read()
    data = json.loads(buffer)
    file.close()

    RACE_DEFAULT = data.get('race_default')
    RACES = data.get("races")
    RACE_OPTIONS = [str(i) for i in RACES.keys()]
    RACE_OPTIONS.sort()
    RACE_OPTIONS = ["human"] + RACE_OPTIONS

    CLASSES = data.get("classes")
    CLASS_OPTIONS = [str(i) for i in CLASSES.keys()]
    CLASS_OPTIONS.sort()

    ABILITIES = data.get('abilities')

    WEAPON_DEFAULT = data.get("weapon_default")
    WEAPON_LIST = data.get("weapon_list")
    WEAPON_PROFICIENCIES = data.get('weapon_proficiencies')
    WEAPON_CATEGORIES = data.get('weapon_categories')
    WEAPONS = data.get("weapons")
    weapon_options = [" -none- "]

    ARMOUR_DEFAULT = data.get("armour_default")
    ARMOUR_LIST = data.get("armour_list")
    ARMOUR_CATEGORIES = data.get("armour_categories")
    ARMOUR = data.get("armour")
    armour_options = [" -none- "]

    SHIELD_DEFAULT = data.get("shield_default")
    SHIELD_LIST = data.get("shield_list")
    SHIELD_CATEGORIES = data.get("shield_categories")
    SHIELDS = data.get("shields")
    shield_options = [" -none- "]

    SKILLS_LIST = data.get("skills_list")
    SKILLS = data.get("skills")

    def __init__(self, root):
        self.phase = 1
        self.root = root
        self.character = Character()
        self.ability_rolls = self.character.roll_ability_scores()
        self.view = CharacterSheetView(root, self)
        self.validate_lvl_cmd = (root.register(self.validate_level), "%P",
                                 "%s", "%S", "%W")
        self.class_cmd = self.combine_funcs(
            self.update_class_level, self.update_ability_scores,
            self.update_saving_throws, self.update_base_attack_bonus,
            self.update_grapple, self.update_hp, self.update_armour_class,
            self.update_initiative, self.update_all_weapons,
            self.update_skills, self.update_all_skills)
        self.class_level_cmd = self.combine_funcs(
            self.update_class_level, self.update_saving_throws,
            self.update_base_attack_bonus, self.update_grapple,
            self.update_all_weapons, self.update_skills,
            self.update_all_skills)

        #class field
        self.view.race_class_level.class_var.set(self.CLASS_OPTIONS[0])
        self.view.race_class_level.class_var.trace("w", self.class_cmd)
        menu = self.view.race_class_level.class_choices['menu']
        menu.delete(0, 'end')
        for c in self.CLASS_OPTIONS:
            menu.add_command(label=c,
                             command=lambda c=c: self.view.race_class_level.
                             class_var.set(c))
        # class level field
        self.view.race_class_level.class_level.config(
            command=self.class_level_cmd,
            validatecommand=self.validate_lvl_cmd)
        self.view.race_class_level.class_level.bind("<Return>",
                                                    self.class_level_cmd)

        # race field
        self.view.race_class_level.race_var.set(self.RACE_OPTIONS[0])
        self.view.race_class_level.race_var.trace(
            "w",
            self.combine_funcs(self.update_race, self.update_size,
                               self.update_grapple, self.update_speed,
                               self.update_armour_class, self.update_skills,
                               self.update_armour, self.update_shield))
        menu = self.view.race_class_level.race_choices['menu']
        menu.delete(0, 'end')
        for race in self.RACE_OPTIONS:
            menu.add_command(label=race,
                             command=lambda r=race: self.view.race_class_level.
                             race_var.set(r))

        self.view.next_phase_btn.button.config(command=self.next_phase_button)

        self.view.ability_scores.btn1.config(
            command=self.switch_str_dex_scores)
        self.view.ability_scores.btn2.config(
            command=self.switch_dex_con_scores)
        self.view.ability_scores.btn3.config(
            command=self.switch_con_int_scores)
        self.view.ability_scores.btn4.config(
            command=self.switch_int_wis_scores)
        self.view.ability_scores.btn5.config(
            command=self.switch_wis_cha_scores)

        self.view.armour.armour_var.set(self.armour_options[0])
        self.view.armour.armour_var.trace(
            "w",
            self.combine_funcs(self.update_armour, self.update_armour_class))
        self.view.armour.armour_category_var.set(self.ARMOUR_CATEGORIES[0])
        self.view.armour.armour_category_var.trace("w",
                                                   self.update_armour_category)
        menu = self.view.armour.armour_categories['menu']
        menu.delete(0, 'end')
        for armour_category in self.ARMOUR_CATEGORIES:
            menu.add_command(label=armour_category,
                             command=lambda a=armour_category: self.view.armour
                             .armour_category_var.set(a))

        self.view.shield.shield_var.set(self.shield_options[0])
        self.view.shield.shield_var.trace(
            "w",
            self.combine_funcs(self.update_shield, self.update_armour_class))
        self.view.shield.shield_category_var.set(self.SHIELD_CATEGORIES[0])
        self.view.shield.shield_category_var.trace("w",
                                                   self.update_shield_category)
        menu = self.view.shield.shield_categories['menu']
        menu.delete(0, 'end')
        for shield_category in self.SHIELD_CATEGORIES:
            menu.add_command(label=shield_category,
                             command=lambda s=shield_category: self.view.shield
                             .shield_category_var.set(s))

        self.update_class_level()
        self.update_race()
        self.update_size()
        self.update_ability_scores()
        self.update_saving_throws()
        self.update_base_attack_bonus()
        self.update_grapple()
        self.update_hp()
        self.update_speed()
        self.update_armour_category()
        self.update_shield_category()
        self.update_armour_class()
        self.update_initiative()

        self.character.weapons_list = [{} for i in self.view.weapons_list]
        for weapon in self.view.weapons_list:
            weapon.weapon_var.set(self.weapon_options[0])
            weapon.weapon_var.trace(
                "w",
                lambda a, b, c, w=weapon: self.update_weapon(w, [a, b, c]))
            weapon.weapon_category_var.set("unarmed")
            weapon.weapon_category_var.trace(
                "w",
                lambda a, b, c, w=weapon: self.update_weapon_choices(
                    w, [a, b, c]))
            menu = weapon.weapon_proficiencies['menu']
            menu.delete(0, 'end')
            for proficiency in self.WEAPON_PROFICIENCIES:
                menu.add_command(label=proficiency,
                                 command=lambda p=proficiency, w=weapon: w.
                                 weapon_proficiency_var.set(p))
            weapon.weapon_proficiency_var.set(self.WEAPON_PROFICIENCIES[0])
            weapon.weapon_proficiency_var.trace(
                "w",
                lambda a, b, c, w=weapon: self.update_weapon_proficiency(
                    w, [a, b, c]))
            self.update_weapon_proficiency(weapon)

        self.character.skills = [{} for i in self.view.skills.skills_list]
        self.validate_skill_ranks_cmd = (root.register(
            self.validate_skill_ranks), "%P", "%s", "%S", "%W")
        for skill in self.view.skills.skills_list:
            skill.spend_ranks.config(
                command=lambda s=skill: self.combine_funcs(
                    self.update_skill(s), self.update_skills()),
                validatecommand=self.validate_skill_ranks_cmd)
            skill_data = self.SKILLS.get(skill.skill_name.get())
            skill_data['ranks'] = 0
            self.character.skills[self.view.skills.skills_list.index(
                skill)] = skill_data
            #self.update_skill(skill)
        self.update_skills()
        self.update_all_skills()

    def next_phase_button(self):
        if self.phase == 1:
            self.view.race_class_level.not_editable()
            self.view.ability_scores.remove_switches()
            self.character.hp = self.character.roll_hit_points()
            self.view.hit_points.render_hitpoints()
            self.update_hp()
            for i, skill in enumerate(self.view.skills.skills_list):
                skill.editable(i)
            self.view.skills.update()
            self.phase = 2
        elif self.phase == 2:
            for i, skill in enumerate(self.view.skills.skills_list):
                skill.not_editable(i)
            self.view.skills.update()
            self.view.next_phase_btn.button.grid_remove()

    def validate_level(self, user_input, current_base, new_base, widget_name):
        valid = new_base == "" or new_base.isdigit()
        if valid:
            minval = int(
                self.view.race_class_level.frame.nametowidget(
                    widget_name).config("from")[4])
            maxval = int(
                self.view.race_class_level.frame.nametowidget(
                    widget_name).config("to")[4] + 1)
            if user_input and int(user_input) not in range(minval, maxval):
                valid = False
        return valid

    def update_class_level(self, *args):
        class_data = self.view.race_class_level.class_var.get()
        if self.view.race_class_level.class_level.get() == "":
            self.view.race_class_level.class_level.insert(0, 1)
        class_data, level = (self.CLASSES.get(class_data),
                             int(self.view.race_class_level.class_level.get()))
        self.character.class_one_level = (class_data, level)

    def update_race(self, *args):
        race_data = self.view.race_class_level.race_var.get()
        if race_data == "human":
            self.character.race = self.RACE_DEFAULT.get(race_data)
        else:
            self.character.race = self.RACES.get(race_data)

    def update_size(self, *args):
        self.character.size = self.character.race.get("size")

    def update_saving_throws(self, *args):
        level_data = self.character.get_level_data()
        base_saving_throws = {
            "fortitude": level_data.get("fort_save"),
            "reflex": level_data.get("ref_save"),
            "will": level_data.get("will_save")
        }
        self.character.base_saving_throws = base_saving_throws
        self.view.saving_throws.fort_save_total_var.set(
            self.character.get_save_modifier("fortitude"))
        self.view.saving_throws.fort_save_base_var.set(
            base_saving_throws.get("fortitude"))
        self.view.saving_throws.ref_save_total_var.set(
            self.character.get_save_modifier("reflex"))
        self.view.saving_throws.ref_save_base_var.set(
            base_saving_throws.get("reflex"))
        self.view.saving_throws.will_save_total_var.set(
            self.character.get_save_modifier("will"))
        self.view.saving_throws.will_save_base_var.set(
            base_saving_throws.get("will"))

    def update_base_attack_bonus(self, *args):
        level_data = self.character.get_level_data()
        self.character.base_attack_bonus = level_data.get("base_attack_bonus")
        self.view.base_attack_bonus.base_attack_bonus_var.set(
            self.character.base_attack_bonus)

    def update_grapple(self, *args):
        self.view.grapple.grapple_total_var.set(
            self.character.get_grapple_modifier())
        self.view.grapple.grapple_base_attack_bonus_var.set(
            self.character.base_attack_bonus[0])
        self.view.grapple.grapple_size_mod_var.set(
            self.character.get_grapple_size_modifier())

    def update_hp(self, *args):
        self.view.hit_points.hitdice_var.set(
            self.character.get_class_data().get('hitdice'))
        self.view.hit_points.hp_total_var.set(self.character.hp)

    def update_speed(self, *args):
        self.view.speed.speed_var.set(
            str(self.character.race.get("land_speed")) + ' ft')

    def update_initiative(self, *args):
        self.view.initiative.initiative_var.set(
            self.character.get_initiative_modifier())

    def update_armour_class(self, *args):
        self.view.armour_class.ac_total_var.set(
            self.character.get_armour_class())
        self.view.armour_class.ac_armour_bonus_var.set(
            self.character.armour.get('ac_bonus', 0))
        self.view.armour_class.ac_shield_bonus_var.set(
            self.character.shield.get('ac_bonus', 0))
        self.view.armour_class.ac_dex_mod_var.set(
            self.character.get_armour_class_dex_mod())
        self.view.armour_class.ac_size_mod_var.set(
            self.character.get_size_modifier())
        self.view.armour_class.ac_natural_armour_var.set(0)
        self.view.armour_class.ac_deflection_mod_var.set(0)
        self.view.touch_armour_class.touch_ac_var.set(
            self.character.get_touch_armour_class())
        self.view.flatfooted_armour_class.flat_footed_ac_var.set(
            self.character.get_flatfoot_armour_class())

    def update_armour(self, *args):
        armour_data = self.view.armour.armour_var.get()
        if armour_data == " -none- ":
            armour_data = self.ARMOUR_DEFAULT.get(" -none- ")
        else:
            armour_data = self.ARMOUR.get(armour_data)
        self.character.armour = armour_data

        self.view.armour.armour_ac_bonus_var.set(
            self.character.armour.get('ac_bonus'))
        self.view.armour.armour_max_dex_var.set(
            str(self.character.armour.get('max_dex_bonus')).lower())
        self.view.armour.armour_check_penalty_var.set(
            self.character.armour.get('check_penalty'))
        self.view.armour.armour_spell_failure_var.set(
            str(self.character.armour.get('spell_failure')) + ' %')
        self.view.armour.armour_weight_var.set(str(self.character.get_protective_item_weight(self.character.armour))\
                                               .lower() + "%s" % (" lb." if self.character.armour.get('weight') else ""))

    def update_armour_category(self, *args):
        category = self.view.armour.armour_category_var.get()
        armour_options = [" -none- "]
        for a in self.ARMOUR_LIST:
            armour = self.ARMOUR.get(a)
            if armour.get('category') == category: armour_options.append(a)
        self.view.armour.armour_var.set(armour_options[0])
        menu = self.view.armour.armour_choices['menu']
        menu.delete(0, 'end')
        for armour in armour_options:
            menu.add_command(
                label=armour,
                command=lambda a=armour: self.view.armour.armour_var.set(a))

    def update_shield(self, *args):
        shield_data = self.view.shield.shield_var.get()
        if shield_data == " -none- ":
            shield_data = self.SHIELD_DEFAULT.get(" -none- ")
        else:
            shield_data = self.SHIELDS.get(shield_data)
        self.character.shield = shield_data

        self.view.shield.shield_ac_bonus_var.set(
            self.character.shield.get('ac_bonus'))
        self.view.shield.shield_max_dex_var.set(
            str(self.character.shield.get('max_dex_bonus')).lower())
        self.view.shield.shield_check_penalty_var.set(
            self.character.shield.get('check_penalty'))
        self.view.shield.shield_spell_failure_var.set(
            str(self.character.shield.get('spell_failure')) + ' %')
        self.view.shield.shield_weight_var.set(
            str(
                self.character.get_protective_item_weight(
                    self.character.shield)).lower() + "%s" %
            (" lb." if self.character.shield.get('weight') else ""))

    def update_shield_category(self, *args):
        category = self.view.shield.shield_category_var.get()
        shield_options = [" -none- "]
        for s in self.SHIELD_LIST:
            shield = self.SHIELDS.get(s)
            if shield.get('category') == category: shield_options.append(s)
            self.view.shield.shield_var.set(shield_options[0])
        menu = self.view.shield.shield_choices['menu']
        menu.delete(0, 'end')
        for shield in shield_options:
            menu.add_command(
                label=shield,
                command=lambda s=shield: self.view.shield.shield_var.set(s))

    def update_weapon(self, weapon, *args):
        weapon_data = weapon.weapon_var.get()
        if weapon_data in ["unarmed strike", " -none- "]:
            weapon_data = self.WEAPON_DEFAULT.get(weapon_data)
        else:
            weapon_data = self.WEAPONS.get(weapon_data)
        self.character.weapons_list[self.view.weapons_list.index(
            weapon)] = weapon_data
        model_weapon = self.character.weapons_list[
            self.view.weapons_list.index(weapon)]

        weapon.weapon_attack_bonus_var.set(
            self.character.get_attack_bonus(model_weapon))
        weapon.weapon_damage_var.set(model_weapon.get('dmg(m)'))
        weapon.weapon_critical_var.set(model_weapon.get('critical'))
        weapon.weapon_range_var.set(
            str(model_weapon.get('range')).lower() + "%s" %
            (" ft." if model_weapon.get('range') else ""))
        weapon.weapon_weight_var.set(
            str(model_weapon.get('weight')).lower() + "%s" %
            (" lb." if model_weapon.get('weight') else ""))

    def update_weapon_choices(self, weapon, *args):
        proficiency = weapon.weapon_proficiency_var.get()
        category = weapon.weapon_category_var.get()
        if proficiency == "simple" and category == "unarmed":
            weapon_options = ["unarmed strike"]
        else:
            weapon_options = [" -none- "]
        for i, w in enumerate(self.WEAPON_LIST):
            weapon_data = self.WEAPONS.get(w)
            if weapon_data.get(
                    'proficiency') == proficiency and weapon_data.get(
                        'category') == category:
                weapon_options.append(w)

        weapon.weapon_var.set(weapon_options[0])
        menu = weapon.weapon_choices['menu']
        menu.delete(0, 'end')
        for _weapon in weapon_options:
            weapon_data = self.WEAPONS.get(_weapon)
            weapon_title = _weapon
            if not _weapon in ['unarmed strike', ' -none- ']:
                if self.character.check_weapon_proficiency(weapon_data):
                    weapon_title += u' \u2022'
            menu.add_command(
                label=weapon_title,
                command=lambda w=_weapon: weapon.weapon_var.set(w))

    def update_weapon_proficiency(self, weapon, *args):
        proficiency = weapon.weapon_proficiency_var.get()
        category = weapon.weapon_category_var.get()

        if proficiency == "simple":
            category_options = ["unarmed"] + self.WEAPON_CATEGORIES
        else:
            category_options = self.WEAPON_CATEGORIES
            if category == "unarmed":
                weapon.weapon_category_var.set(category_options[0])
        menu = weapon.weapon_categories['menu']
        menu.delete(0, 'end')
        for category in category_options:
            menu.add_command(
                label=category,
                command=lambda c=category: weapon.weapon_category_var.set(c))
        self.update_weapon_choices(weapon)

    def update_all_weapons(self, *args):
        for weapon in self.view.weapons_list:
            self.update_weapon(weapon)
            current_weapon = weapon.weapon_var.get()
            self.update_weapon_choices(weapon)
            weapon.weapon_var.set(current_weapon)

    def update_skills(self, *args):
        self.view.skills.max_class_ranks_var.set(
            self.character.get_max_class_skill_ranks())
        self.view.skills.spent_ranks_var.set(
            self.character.get_spent_skill_ranks())

    def validate_skill_ranks(self, user_input, current_base, new_base,
                             widget_name):
        class_data, level = self.character.class_one_level
        spinbox = self.view.skills.frame.nametowidget(widget_name)
        spinbox.config(to=level + 3)

        valid = new_base == "" or new_base.isdigit()
        if valid:
            minval = int(spinbox.config("from")[4])
            maxval = int(spinbox.config("to")[4] + 1)
            if user_input and int(user_input) not in range(minval, maxval):
                valid = False

        return valid

    def update_skill(self, skill, *args):
        max_ranks = self.character.get_max_class_skill_ranks()
        spent_ranks = self.character.get_spent_skill_ranks()

        if spent_ranks >= max_ranks \
          and skill.spend_ranks.get() > skill.ranks_var.get():
            ranks = int(skill.spend_ranks.get()) - 1
            skill.spend_ranks.delete(0, "end")
            skill.spend_ranks.insert(0, ranks)

        ranks = int(skill.spend_ranks.get())
        self.character.skills[self.view.skills.skills_list.index(
            skill)]['ranks'] = ranks
        model_skill = self.character.skills[self.view.skills.skills_list.index(
            skill)]

        proficient = self.character.check_skill_profiency(
            model_skill.get('name'))
        ability = self.ABILITIES.get(skill.key_ability.get())

        if proficient:
            skill.skill_name.set(model_skill.get('name') + u' \u2022')
            total = self.character.get_ability_modifier(ability) + ranks
        else:
            skill.skill_name.set(model_skill.get('name'))
            total = self.character.get_ability_modifier(ability) + (ranks / 2)

        skill.skill_mod_var.set(total)
        skill.ability_mod_var.set(self.character.get_ability_modifier(ability))
        skill.ranks_var.set(ranks)

    def update_all_skills(self, *args):
        for skill in self.view.skills.skills_list:
            self.update_skill(skill)

    def update_strength(self, *args):
        self.view.ability_scores.str_score_var.set(
            self.character.ability_scores['strength'])
        self.view.ability_scores.str_mod_var.set(
            self.character.get_ability_modifier('strength'))

    def update_dexterity(self, *args):
        self.view.ability_scores.dex_score_var.set(
            self.character.ability_scores['dexterity'])
        self.view.ability_scores.dex_mod_var.set(
            self.character.get_ability_modifier('dexterity'))

    def update_constitution(self, *args):
        self.view.ability_scores.con_score_var.set(
            self.character.ability_scores['constitution'])
        self.view.ability_scores.con_mod_var.set(
            self.character.get_ability_modifier('constitution'))

    def update_intelligence(self, *args):
        self.view.ability_scores.int_score_var.set(
            self.character.ability_scores['intelligence'])
        self.view.ability_scores.int_mod_var.set(
            self.character.get_ability_modifier('intelligence'))

    def update_wisdom(self, *args):
        self.view.ability_scores.wis_score_var.set(
            self.character.ability_scores['wisdom'])
        self.view.ability_scores.wis_mod_var.set(
            self.character.get_ability_modifier('wisdom'))

    def update_charisma(self, *args):
        self.view.ability_scores.cha_score_var.set(
            self.character.ability_scores['charisma'])
        self.view.ability_scores.cha_mod_var.set(
            self.character.get_ability_modifier('charisma'))

    def update_ability_scores(self, *args):
        class_data = self.character.get_class_data()
        i = 0
        for ability in class_data.get('abilities'):
            if ability == "str":
                self.character.ability_scores['strength'] = self.ability_rolls[
                    i]
            elif ability == "dex":
                self.character.ability_scores[
                    'dexterity'] = self.ability_rolls[i]
            elif ability == "con":
                self.character.ability_scores[
                    'constitution'] = self.ability_rolls[i]
            elif ability == "int":
                self.character.ability_scores[
                    'intelligence'] = self.ability_rolls[i]
            elif ability == "wis":
                self.character.ability_scores['wisdom'] = self.ability_rolls[i]
            elif ability == "cha":
                self.character.ability_scores['charisma'] = self.ability_rolls[
                    i]
            i += 1
        self.update_strength()
        self.update_dexterity()
        self.update_constitution()
        self.update_intelligence()
        self.update_wisdom()
        self.update_charisma()

    def switch_str_dex_scores(self):
        str = self.character.ability_scores['strength']
        dex = self.character.ability_scores['dexterity']
        self.character.ability_scores['strength'] = dex
        self.character.ability_scores['dexterity'] = str
        self.update_strength()
        self.update_dexterity()
        self.update_saving_throws()
        self.update_grapple()
        self.update_armour_class()
        self.update_initiative()
        for weapon in self.view.weapons_list:
            self.update_weapon(weapon)
        self.update_all_skills()

    def switch_dex_con_scores(self):
        dex = self.character.ability_scores['dexterity']
        con = self.character.ability_scores['constitution']
        self.character.ability_scores['dexterity'] = con
        self.character.ability_scores['constitution'] = dex
        self.update_dexterity()
        self.update_constitution()
        self.update_saving_throws()
        self.update_armour_class()
        self.update_initiative()
        self.update_all_skills()

    def switch_con_int_scores(self):
        con = self.character.ability_scores['constitution']
        int = self.character.ability_scores['intelligence']
        self.character.ability_scores['constitution'] = int
        self.character.ability_scores['intelligence'] = con
        self.update_constitution()
        self.update_intelligence()
        self.update_saving_throws()
        self.update_skills()
        self.update_all_skills()

    def switch_int_wis_scores(self):
        int = self.character.ability_scores['intelligence']
        wis = self.character.ability_scores['wisdom']
        self.character.ability_scores['intelligence'] = wis
        self.character.ability_scores['wisdom'] = int
        self.update_intelligence()
        self.update_wisdom()
        self.update_saving_throws()
        self.update_skills()
        self.update_all_skills()

    def switch_wis_cha_scores(self):
        wis = self.character.ability_scores['wisdom']
        cha = self.character.ability_scores['charisma']
        self.character.ability_scores['wisdom'] = cha
        self.character.ability_scores['charisma'] = wis
        self.update_wisdom()
        self.update_charisma()
        self.update_saving_throws()
        self.update_all_skills()

    def combine_funcs(self, *funcs):
        def combined_func(*args, **kwargs):
            for f in funcs:
                f(*args, **kwargs)

        return combined_func
Esempio n. 22
0
                routes.PathPrefixRoute('/igb', [
                    webapp2.Route('/payments/pay/<payment_id>',
                                  handler=IGBPayHandler,
                                  name='igbpay'),
                    webapp2.Route('/payments',
                                  handler=IGBPaymentsHandler,
                                  name='igbpayments'),
                ]),
                webapp2.Route('/', handler=SrpHandler, name='srp'),
                webapp2.Route('',
                              handler=webapp2.RedirectHandler,
                              defaults={'_uri': '/ofsoundsrp/'}),
            ]),
        webapp2.Route('/ofsoundposes/', handler=PosmonHandler, name='posmon'),
        webapp2.Route('/ofsoundposes',
                      handler=webapp2.RedirectHandler,
                      defaults={'_uri': '/ofsoundposes/'}),
        webapp2.Route('/posmon/',
                      handler=webapp2.RedirectHandler,
                      defaults={'_uri': '/ofsoundposes/#/posmon'}),
        webapp2.Route('/posmon',
                      handler=webapp2.RedirectHandler,
                      defaults={'_uri': '/ofsoundposes/#/posmon'}),
    ],
    config=config,
    debug=True)

characters = []
Character.query().map(lambda c: characters.append(
    (c.character_name, c.character_id)))
Esempio n. 23
0
 def get(self, search_text):
     futures = []
     num = None
     if search_text.isdigit():
         num = int(search_text)
         _log.debug('Search by ids: %d' % num)
         futures.append(KillMail.get_by_id_async(num))
         futures.append(Character.get_by_id_async(num))
         futures.append(Payment.get_by_id_async(num))
         futures.append(Tower.get_by_id_async(num))
     if search_text.startswith('K') and search_text[1:].isdigit():
         _log.debug('Search kill by id: %s' % search_text[1:])
         futures.append(KillMail.get_by_id_async(int(search_text[1:])))
     if search_text.startswith('C') and search_text[1:].isdigit():
         _log.debug('Search character by id: %s' % search_text[1:])
         futures.append(Character.get_by_id_async(int(search_text[1:])))
     if search_text.startswith('P') and search_text[1:].isdigit():
         _log.debug('Search payment by id: %s' % search_text[1:])
         futures.append(Payment.get_by_id_async(int(search_text[1:])))
     if search_text.startswith('T') and search_text[1:].isdigit():
         _log.debug('Search tower by id: %s' % search_text[1:])
         futures.append(
             Tower.get_by_id_async(Tower.pos_id == int(search_text[1:])))
     results = []
     for name, id in characters:
         if search_text in name:
             _log.debug('Found matching character: %s' % name)
             futures.append(Character.get_by_id_async(id))
     for future in futures:
         try:
             result = future.get_result()
             if type(result) is KillMail:
                 results.append({
                     'type':
                     'kill',
                     'id':
                     result.kill_id,
                     'name':
                     "Kill %d: %s's %s" %
                     (result.kill_id, result.victim.character_name,
                      result.victim.ship_name),
                     'image':
                     'https://image.eveonline.com/Type/%d_32.png' %
                     result.victim.ship_type_id,
                     'value':
                     result
                 })
             elif type(result) is Character:
                 results.append({
                     'type':
                     'character',
                     'id':
                     result.character_id,
                     'name':
                     result.character_name,
                     'image':
                     'https://image.eveonline.com/Character/%d_32.jpg' %
                     result.character_id,
                     'value':
                     result
                 })
             elif type(result) is Payment:
                 results.append({
                     'type':
                     'payment',
                     'id':
                     result.payment_id,
                     'name':
                     'Payment %d: To %s' %
                     (result.payment_id, result.character_name),
                     'image':
                     'https://image.eveonline.com/Character/%d_32.jpg' %
                     result.character_id,
                     'value':
                     result
                 })
             if type(result) is Tower:
                 results.append({
                     'type':
                     'tower',
                     'id':
                     result.pos_id,
                     'name':
                     "Tower %s at %s P%d M%d" %
                     (result.pos_name, result.system_name, result.planet,
                      result.moon),
                     'image':
                     'https://image.eveonline.com/Type/%d_32.png' %
                     result.pos_type_id,
                     'value':
                     result
                 })
             elif result is not None:
                 _log.debug('Unknown result type: %s' % type(result))
         except:
             _log.debug('Error.')
     _log.debug('Search for %s found %d results.' %
                (search_text, len(results)))
     self.write_json(sorted(results))
Esempio n. 24
0
 def get(self, search_text):
     futures = []
     num = None
     if search_text.isdigit():
         num = int(search_text)
         _log.debug('Search by ids: %d' % num)
         futures.append(KillMail.get_by_id_async(num))
         futures.append(Character.get_by_id_async(num))
         futures.append(Payment.get_by_id_async(num))
         futures.append(Tower.get_by_id_async(num))
     if search_text.startswith('K') and search_text[1:].isdigit():
         _log.debug('Search kill by id: %s' % search_text[1:])
         futures.append(KillMail.get_by_id_async(int(search_text[1:])))
     if search_text.startswith('C') and search_text[1:].isdigit():
         _log.debug('Search character by id: %s' % search_text[1:])
         futures.append(Character.get_by_id_async(int(search_text[1:])))
     if search_text.startswith('P') and search_text[1:].isdigit():
         _log.debug('Search payment by id: %s' % search_text[1:])
         futures.append(Payment.get_by_id_async(int(search_text[1:])))
     if search_text.startswith('T') and search_text[1:].isdigit():
         _log.debug('Search tower by id: %s' % search_text[1:])
         futures.append(Tower.get_by_id_async(Tower.pos_id == int(search_text[1:])))
     results = []
     for name, id in characters:
         if search_text in name:
             _log.debug('Found matching character: %s' % name)
             futures.append(Character.get_by_id_async(id))
     for future in futures:
         try:
             result = future.get_result()
             if type(result) is KillMail:
                 results.append({
                     'type': 'kill',
                     'id': result.kill_id,
                     'name': "Kill %d: %s's %s" % (result.kill_id, result.victim.character_name, result.victim.ship_name),
                     'image': 'https://image.eveonline.com/Type/%d_32.png' % result.victim.ship_type_id,
                     'value': result
                 })
             elif type(result) is Character:
                 results.append({
                     'type': 'character',
                     'id': result.character_id,
                     'name': result.character_name,
                     'image': 'https://image.eveonline.com/Character/%d_32.jpg' % result.character_id,
                     'value': result
                 })
             elif type(result) is Payment:
                 results.append({
                     'type': 'payment',
                     'id': result.payment_id,
                     'name': 'Payment %d: To %s' % (result.payment_id, result.character_name),
                     'image': 'https://image.eveonline.com/Character/%d_32.jpg' % result.character_id,
                     'value': result
                 })
             if type(result) is Tower:
                 results.append({
                     'type': 'tower',
                     'id': result.pos_id,
                     'name': "Tower %s at %s P%d M%d" % (result.pos_name, result.system_name, result.planet, result.moon),
                     'image': 'https://image.eveonline.com/Type/%d_32.png' % result.pos_type_id,
                     'value': result
                 })
             elif result is not None:
                 _log.debug('Unknown result type: %s' % type(result))
         except:
             _log.debug('Error.')
     _log.debug('Search for %s found %d results.' % (search_text, len(results)))
     self.write_json(sorted(results))
Esempio n. 25
0
    def __init__(self, root):
        self.phase = 1
        self.root = root
        self.character = Character()
        self.ability_rolls = self.character.roll_ability_scores()
        self.view = CharacterSheetView(root, self)
        self.validate_lvl_cmd = (root.register(self.validate_level), "%P",
                                 "%s", "%S", "%W")
        self.class_cmd = self.combine_funcs(
            self.update_class_level, self.update_ability_scores,
            self.update_saving_throws, self.update_base_attack_bonus,
            self.update_grapple, self.update_hp, self.update_armour_class,
            self.update_initiative, self.update_all_weapons,
            self.update_skills, self.update_all_skills)
        self.class_level_cmd = self.combine_funcs(
            self.update_class_level, self.update_saving_throws,
            self.update_base_attack_bonus, self.update_grapple,
            self.update_all_weapons, self.update_skills,
            self.update_all_skills)

        #class field
        self.view.race_class_level.class_var.set(self.CLASS_OPTIONS[0])
        self.view.race_class_level.class_var.trace("w", self.class_cmd)
        menu = self.view.race_class_level.class_choices['menu']
        menu.delete(0, 'end')
        for c in self.CLASS_OPTIONS:
            menu.add_command(label=c,
                             command=lambda c=c: self.view.race_class_level.
                             class_var.set(c))
        # class level field
        self.view.race_class_level.class_level.config(
            command=self.class_level_cmd,
            validatecommand=self.validate_lvl_cmd)
        self.view.race_class_level.class_level.bind("<Return>",
                                                    self.class_level_cmd)

        # race field
        self.view.race_class_level.race_var.set(self.RACE_OPTIONS[0])
        self.view.race_class_level.race_var.trace(
            "w",
            self.combine_funcs(self.update_race, self.update_size,
                               self.update_grapple, self.update_speed,
                               self.update_armour_class, self.update_skills,
                               self.update_armour, self.update_shield))
        menu = self.view.race_class_level.race_choices['menu']
        menu.delete(0, 'end')
        for race in self.RACE_OPTIONS:
            menu.add_command(label=race,
                             command=lambda r=race: self.view.race_class_level.
                             race_var.set(r))

        self.view.next_phase_btn.button.config(command=self.next_phase_button)

        self.view.ability_scores.btn1.config(
            command=self.switch_str_dex_scores)
        self.view.ability_scores.btn2.config(
            command=self.switch_dex_con_scores)
        self.view.ability_scores.btn3.config(
            command=self.switch_con_int_scores)
        self.view.ability_scores.btn4.config(
            command=self.switch_int_wis_scores)
        self.view.ability_scores.btn5.config(
            command=self.switch_wis_cha_scores)

        self.view.armour.armour_var.set(self.armour_options[0])
        self.view.armour.armour_var.trace(
            "w",
            self.combine_funcs(self.update_armour, self.update_armour_class))
        self.view.armour.armour_category_var.set(self.ARMOUR_CATEGORIES[0])
        self.view.armour.armour_category_var.trace("w",
                                                   self.update_armour_category)
        menu = self.view.armour.armour_categories['menu']
        menu.delete(0, 'end')
        for armour_category in self.ARMOUR_CATEGORIES:
            menu.add_command(label=armour_category,
                             command=lambda a=armour_category: self.view.armour
                             .armour_category_var.set(a))

        self.view.shield.shield_var.set(self.shield_options[0])
        self.view.shield.shield_var.trace(
            "w",
            self.combine_funcs(self.update_shield, self.update_armour_class))
        self.view.shield.shield_category_var.set(self.SHIELD_CATEGORIES[0])
        self.view.shield.shield_category_var.trace("w",
                                                   self.update_shield_category)
        menu = self.view.shield.shield_categories['menu']
        menu.delete(0, 'end')
        for shield_category in self.SHIELD_CATEGORIES:
            menu.add_command(label=shield_category,
                             command=lambda s=shield_category: self.view.shield
                             .shield_category_var.set(s))

        self.update_class_level()
        self.update_race()
        self.update_size()
        self.update_ability_scores()
        self.update_saving_throws()
        self.update_base_attack_bonus()
        self.update_grapple()
        self.update_hp()
        self.update_speed()
        self.update_armour_category()
        self.update_shield_category()
        self.update_armour_class()
        self.update_initiative()

        self.character.weapons_list = [{} for i in self.view.weapons_list]
        for weapon in self.view.weapons_list:
            weapon.weapon_var.set(self.weapon_options[0])
            weapon.weapon_var.trace(
                "w",
                lambda a, b, c, w=weapon: self.update_weapon(w, [a, b, c]))
            weapon.weapon_category_var.set("unarmed")
            weapon.weapon_category_var.trace(
                "w",
                lambda a, b, c, w=weapon: self.update_weapon_choices(
                    w, [a, b, c]))
            menu = weapon.weapon_proficiencies['menu']
            menu.delete(0, 'end')
            for proficiency in self.WEAPON_PROFICIENCIES:
                menu.add_command(label=proficiency,
                                 command=lambda p=proficiency, w=weapon: w.
                                 weapon_proficiency_var.set(p))
            weapon.weapon_proficiency_var.set(self.WEAPON_PROFICIENCIES[0])
            weapon.weapon_proficiency_var.trace(
                "w",
                lambda a, b, c, w=weapon: self.update_weapon_proficiency(
                    w, [a, b, c]))
            self.update_weapon_proficiency(weapon)

        self.character.skills = [{} for i in self.view.skills.skills_list]
        self.validate_skill_ranks_cmd = (root.register(
            self.validate_skill_ranks), "%P", "%s", "%S", "%W")
        for skill in self.view.skills.skills_list:
            skill.spend_ranks.config(
                command=lambda s=skill: self.combine_funcs(
                    self.update_skill(s), self.update_skills()),
                validatecommand=self.validate_skill_ranks_cmd)
            skill_data = self.SKILLS.get(skill.skill_name.get())
            skill_data['ranks'] = 0
            self.character.skills[self.view.skills.skills_list.index(
                skill)] = skill_data
            #self.update_skill(skill)
        self.update_skills()
        self.update_all_skills()
Esempio n. 26
0
        webapp2.Route('/config', handler=ConfigHandler, name='jsonConfig'),
        webapp2.Route('/kills', handler=KillsHandler, name='jsonKills', methods=['GET','POST']),
        webapp2.Route('/kills/<kill_id>', handler=KillHandler, name='jsonKill'),
        webapp2.Route('/characters', handler=CharactersHandler, name='jsonCharacters'),
        webapp2.Route('/characters/<character_id>', handler=CharacterHandler, name='jsonCharacter'),
        webapp2.Route('/payments', handler=PaymentsHandler, name='jsonPayments'),
        webapp2.Route('/payments/<payment_id>', handler=PaymentHandler, name='jsonPayment'),
        webapp2.Route('/towers', handler=TowersHandler, name='towers'),
        webapp2.Route('/towers/<tower_id>', handler=TowerHandler, name='tower'),
        webapp2.Route('/search/<search_text>', handler=SearchHandler, name='jsonSearch'),
    ]),

    routes.PathPrefixRoute('/ofsoundsrp', [
        # Handlers for pages that need to work in the in game browser
        routes.PathPrefixRoute('/igb', [
            webapp2.Route('/payments/pay/<payment_id>', handler=IGBPayHandler, name='igbpay'),
            webapp2.Route('/payments', handler=IGBPaymentsHandler, name='igbpayments'),
        ]),
        webapp2.Route('/', handler=SrpHandler, name='srp'),
        webapp2.Route('', handler=webapp2.RedirectHandler, defaults={'_uri': '/ofsoundsrp/'}),
    ]),
    webapp2.Route('/ofsoundposes/', handler=PosmonHandler, name='posmon'),
    webapp2.Route('/ofsoundposes', handler=webapp2.RedirectHandler, defaults={'_uri': '/ofsoundposes/'}),
    webapp2.Route('/posmon/', handler=webapp2.RedirectHandler, defaults={'_uri': '/ofsoundposes/#/posmon'}),
    webapp2.Route('/posmon', handler=webapp2.RedirectHandler, defaults={'_uri': '/ofsoundposes/#/posmon'}),
], config=config, debug=True)

characters = []
Character.query().map(lambda c: characters.append((c.character_name, c.character_id)))

Esempio n. 27
0
 def get(self):
     allianceId = self.config.alliance_id
     characters = Character.query(Character.alliance_id == allianceId).order(Character.character_name)
     self.write_page(characters)
Esempio n. 28
0
# Detect if we're already inside IBC and thus, all of this has been
#   provided for us
if 'Character' not in locals().keys():
    from model import (Character, RPGClass, Equipment, Weapon, Attack,
                       Buff, Feat, auditable)

class Cavalier(RPGClass):
    def __init__(self):
        super(Cavalier, self).__init__()
        self.hit_die = 10
        self.fort = 7      # TODO: Scale will level
        self.ref = 3
        self.will = 3

c = Character()
c.name = 'Henri (Level 11)'
c.lvl = 11
c.BAB = 11
c.rpg_class = Cavalier()

# Ability Scores
c.base.str_score = 20
c.base.dex_score = 12
c.base.con_score = 13
c.base.cha_score = 16
# All the others are the default value of 10

# Armor
breastplate = Equipment("Mytheral Breastplate of Speed")
breastplate.AC = 10