예제 #1
0
    def deal_damage(self, effect, critical=False, multi=1.0):
        dmgs = []

        if effect.type == ability.EffectType.damage_health:
            if effect.element is None:
                weapon = self.eq_weapon

                for dmg in weapon.damages:
                    total = dice.roll(dmg[0], dmg[1], critical)
                    total *= self.get_element_scaling(Elements(dmg[2]))
                    total = round(total * multi)

                    if critical:
                        total += weapon.crit_damage

                    dmgs.append((total, Elements(dmg[2])))
            elif type(effect) == ability.Effect:
                total = dice.roll(dice.count(self.level), effect.dice_value,
                                  critical)
                total *= self.get_element_scaling(effect.element)
                total = round(total)
                dmgs.append((total, effect.element))
        else:
            raise Exception(
                f'{self.name} called character deal damage with invalid effect type {type(effect)}'
            )

        return dmgs
예제 #2
0
 def generateBin(self):
     if random.uniform(0, 1) > 0.5:
         orientation = 'R'
         o = Elements().putBin(self.currentBounds[1], self.currentBounds[3],
                               orientation)
     else:
         orientation = 'L'
         o = Elements().putBin(self.currentBounds[0], self.currentBounds[2],
                               orientation)
     self.generatedList.append(o)
예제 #3
0
 def generateProjectorPanel(self):
     if random.uniform(0, 1) > 0.5:
         orientation = 'R'
         o = Elements().putProjectorPanel(self.currentBounds[1],
                                          self.currentBounds[3],
                                          self.officeSize[2], orientation)
     else:
         orientation = 'L'
         o = Elements().putProjectorPanel(self.currentBounds[0],
                                          self.currentBounds[2],
                                          self.officeSize[2], orientation)
     self.generatedList.append(o)
예제 #4
0
 def _initialize(self, atoms):
     """ Initialization of hotbit. """
     if not self.init:
         self.set_text(self.txt)
         self.timer = Timer('Hotbit', txt=self.get_output())
         self.start_timing('initialization')
         self.el = Elements(self, atoms)
         self.ia = Interactions(self)
         self.st = States(self)
         self.rep = Repulsion(self)
         self.pp = PairPotential(self)
         if self.get('vdw'):
             if self.get('vdw_parameters') is not None:
                 self.el.update_vdw(self.get('vdw_parameters'))
             setup_vdw(self)
         self.env = Environment(self)
         pbc = atoms.get_pbc()
         # FIXME: gamma_cut -stuff
         #if self.get('SCC') and np.any(pbc) and self.get('gamma_cut')==None:
         #    raise NotImplementedError('SCC not implemented for periodic systems yet (see parameter gamma_cut).')
         if np.any(pbc) and abs(
                 self.get('charge')) > 0.0 and self.get('SCC'):
             raise AssertionError('Charged system cannot be periodic.')
         self.flush()
         self.flags = {}
         self.flags['Mulliken'] = False
         self.flags['DOS'] = False
         self.flags['bonds'] = False
         self.flags['grid'] = False
         self.stop_timing('initialization')
     self.el.set_atoms(atoms)
     if not self.init:
         self.init = True
         self.greetings()
예제 #5
0
    def deal_damage(self, crit: bool, fight, out: str, targets, user):
        for target in targets:
            for effect in self.effects:
                if effect.type == EffectType.damage_health:
                    dmgs = target.take_damage(
                        user.deal_damage(effect, critical=crit), user.ele_pens)
                    shock = False
                    confusion = False

                    for dmg in dmgs:
                        ele = Elements(dmg[1])
                        out += f'\n{target.name} suffered {dmg[0]} {Elements(dmg[1]).name} damage.'
                        shock = True if ele == Elements.electricity else False
                        confusion = True if ele == Elements.water else False

                    if shock:
                        target.shock += 1
                    if confusion:
                        target.confusion += 1
                elif effect.type == EffectType.burn:
                    if target.apply_burn(effect.effect_turns, effect.dot_value,
                                         user.dot_effect, user.dot_duration):
                        out += f'\n{target.name} is burning.'
                    else:
                        out += f'\n{target.name} is already seriously burning.'
                elif effect.type == EffectType.bleed:
                    if target.apply_bleed(effect.effect_turns,
                                          effect.dot_value, user.dot_effect,
                                          user.dot_duration):
                        out += f'\n{target.name} is bleeding.'
                    else:
                        out += f'\n{target.name} is bleeding more severely.'
        out += self.handle_elements(fight)
        return out
예제 #6
0
def test_creation():
    mytable = Elements()
    myseries = mytable._table[mytable._table.columns[0]].tolist()
    assert myseries == [
        1, 1.008, -252.9, -423.2, 0.0, 0.0, 'Cavendish', 1, -259.0, -434.2,
        'H', 'Nonmetal', '1766'
    ]
예제 #7
0
def project(slug, trial='trial1'):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    set_project_menu(cfg, slug, trial)
    data['slug'] = slug
    data['trial'] = trial
    data['pub_home'] = os.environ['POLO_PUB']
    data['page_title'] = '{}, {}'.format(slug, trial)
    data['ini'] = cfg.ini['DEFAULT']  # Really?
    data['trials'] = cfg.get_trial_names()
    data['groups'] = cfg.get_group_fields()
    data['src_ord_col'] = cfg.ini['DEFAULT']['src_ord_col']
    data['doc_count'] = els.get_doc_count()
    data['topic_count'] = els.get_topic_count()
    data['topics'] = els.get_topics()
    data['bigrams'] = els.get_top_bigrams()
    data['phrases'] = els.get_all_topic_phrases()
    #data['ngm'] = els.get_ngram_group_matrix(degree=2)
    src_ord_col = cfg.ini['DEFAULT']['src_ord_col']
    print(src_ord_col)
    data['dtm'] = els.get_topicdoc_group_matrix(group_field=src_ord_col)
    data['doc_ord_counts'] = els.get_topicdocgrooup_counts(
        'topic{}_matrix_counts'.format(src_ord_col))
    data['dtm_sums'] = els.get_topicdoc_sum_matrix(data['dtm'],
                                                   data['doc_ord_counts'])
    return render_template("project.html", **data)
예제 #8
0
    def generateDeskType2(self):
        self.currentBounds[2][1] += (self.currentBounds[0][1] -
                                     self.currentBounds[2][1]) * 0.25
        self.currentBounds[3][1] += (self.currentBounds[1][1] -
                                     self.currentBounds[3][1]) * 0.25
        data = Elements().putDeskType2(self.currentBounds)
        self.lastDesk = data[:]

        self.currentBounds[0] = [
            self.lastDesk[1] - (self.lastDesk[5] / 2),
            self.lastDesk[2] + (self.lastDesk[3] / 2)
        ]
        self.currentBounds[1] = [
            self.lastDesk[1] + (self.lastDesk[5] / 2),
            self.lastDesk[2] + (self.lastDesk[3] / 2)
        ]
        self.currentBounds[2] = [
            self.lastDesk[1] - (self.lastDesk[5] / 2),
            self.lastDesk[2] - (self.lastDesk[3] / 2)
        ]
        self.currentBounds[3] = [
            self.lastDesk[1] + (self.lastDesk[5] / 2),
            self.lastDesk[2] - (self.lastDesk[3] / 2)
        ]

        o = data[-1]
        self.generatedList.append(o)
예제 #9
0
def topic_comp_net(slug, trial):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    data['slug'] = slug
    data['trial'] = trial
    data['page_title'] = 'Topic Component Net'
    data['nodes'], data['edges'] = els.get_topic_comp_net()
    return render_template('topic_comp_net.html', **data)
예제 #10
0
 def generateMonitor(self):
     o = Elements().putMonitor(self.currentBounds, self.lastDesk[6],
                               self.lastDesk[4])
     if self.lastDesk[4] == 90:
         self.currentBounds[0][1] -= (2.6 * 0.35)
         self.currentBounds[1][1] = self.currentBounds[0][1]
     if self.lastDesk[4] == 270:
         self.currentBounds[2][1] += (2.6 * 0.35)
         self.currentBounds[3][1] = self.currentBounds[2][1]
     self.generatedList.append(o)
예제 #11
0
def topicdoc_label_heatmap(slug, trial='trial1'):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    data['ini'] = cfg.ini['DEFAULT']
    data['trials'] = cfg.get_trial_names()
    data['slug'] = slug
    data['trial'] = trial
    data['page_title'] = '{}, {}: Topic-Label Heatmap'.format(slug, trial)
    data['dtm'] = els.get_topicdoclabel_matrix()
    return render_template("topic_label_heatmap.html", **data)
예제 #12
0
def w2v_page(slug, trial='trial1', join='inner'):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    data['slug'] = slug
    data['trial'] = trial
    data['page_title'] = 'Word Embeddings'
    data['join'] = join
    data['topics'] = els.get_topics()
    data['coords'] = els.get_tsne_coords(join=join)
    return render_template('w2v.html', **data)
예제 #13
0
def groups(slug, trial, group):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    data['slug'] = slug
    data['trial'] = trial
    data['group_field'] = group
    data['page_title'] = '{}, {}: Groups'.format(slug, trial)
    data['group_matrix'] = els.get_group_matrix(group)
    data['group_pairs'] = els.get_group_pairs(group)
    data['group_counts'] = els.get_group_counts(group)
    return render_template('group.html', **data)
예제 #14
0
def ngram_item(slug, trial, ngram):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    data['slug'] = slug
    data['trial'] = trial
    data['ngram'] = ngram
    data['degree'] = len(ngram.split('_'))
    data['page_title'] = '{}, {}: NGram: "{}"'.format(slug, trial,
                                                      ngram.replace('_', ' '))
    data['docs'] = els.get_docs_for_ngram(ngram, data['degree'])
    data['groups'] = els.get_ngrams_per_group(ngram, data['degree'])
    return render_template('ngram_item.html', **data)
예제 #15
0
def doc_list(slug, trial='trial1'):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    set_project_menu(cfg, slug, trial)
    data['slug'] = slug
    data['trial'] = trial
    data['page_title'] = '{}, {}'.format(slug, trial)
    data['doc_entropy'] = els.get_doc_entropy()
    data['doc_entropy_avg'] = els.get_doc_entropy_avg()
    data['topic_entropy'] = data['doc_entropy_avg']
    data['docs'] = els.get_docs_for_topic_entropy(data['doc_entropy_avg'])
    return render_template('doc_list.html', **data)
예제 #16
0
 def generateReadingLamp(self):
     l = Elements().putReadingLamp(self.currentBounds, self.lastDesk[6],
                                   self.lastDesk[4])
     div = l[0]
     if div > 0.5:
         self.currentBounds[1][0] -= (4 * 0.35)
         self.currentBounds[3][0] -= (4 * 0.35)
     else:
         self.currentBounds[0][0] += (4 * 0.35)
         self.currentBounds[2][0] += (4 * 0.35)
     o = l[1]
     self.generatedList.append(o)
예제 #17
0
def topicdoc_heatmap(slug, trial='trial1', group_field='label'):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    set_project_menu(cfg, slug, trial)
    data['ini'] = cfg.ini['DEFAULT']
    data['trials'] = cfg.get_trial_names()
    data['slug'] = slug
    data['trial'] = trial
    data['page_title'] = '{}, {}: Topic-{} Heatmap'.format(
        slug, trial, group_field)
    data['dtm'] = els.get_topicdoc_group_matrix(group_field=group_field,
                                                use_glass_label=True)
    return render_template("topic_label_heatmap.html", **data)
예제 #18
0
def group_item(slug, trial, group, item):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    data['slug'] = slug
    data['trial'] = trial
    data['group_field'] = group
    data['page_title'] = '{}, {}: {} = {}'.format(slug, trial, group, item)
    data['item'] = item
    data['topics'] = els.get_group_topics(group, item)
    data['comps'] = els.get_group_comps(group, item)
    data['docs'] = els.get_docs_for_group(item, group)
    data['max_tw'] = els.get_max_topic_weight()
    return render_template('group_item.html', **data)
예제 #19
0
def topic(slug, topic_id, trial='trial1'):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    data['topic_id'] = topic_id
    data['slug'] = slug
    data['trial'] = trial
    data['page_title'] = '{}, {}: Topic {}'.format(slug, trial, topic_id)
    data['topics'] = els.get_topics()
    data['topic'] = els.get_topic(topic_id)
    data['trend'] = els.get_topicdoc_ord_for_topic(topic_id)
    data['rels'] = els.get_topics_related(topic_id)
    data['docs'] = els.get_docs_for_topic(topic_id)
    return render_template('topic.html', **data)
예제 #20
0
def doc_item(slug, src_doc_id, trial='trial1'):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    set_project_menu(cfg, slug, trial)
    data['slug'] = slug
    data['trial'] = trial
    data['page_title'] = '{}, {} src_doc_id = {}'.format(
        slug, trial, src_doc_id)
    data['doc'] = els.get_doc(src_doc_id)
    data['doc_id'] = els.get_doc_id_for_src_doc_id(src_doc_id)
    data['doctopics'] = els.get_topics_for_doc_id(data['doc_id'])
    data['topics'] = els.get_topics()
    return render_template('doc_item.html', **data)
예제 #21
0
def topic_pair_net(slug, trial='trial1', thresh=0.05):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    set_project_menu(cfg, slug, trial)
    data['ini'] = cfg.ini['DEFAULT']
    data['trials'] = cfg.get_trial_names()
    data['slug'] = slug
    data['trial'] = trial
    data['thresh'] = thresh
    data['page_title'] = '{}, {}: Topic Pair Network I(a;b) >= {}'.format(
        slug, trial, thresh)
    data['nodes'], data['edges'] = els.get_topicpair_net(thresh)
    return render_template("topic_pair_net.html", **data)
예제 #22
0
def topic_pair_heatmap(slug, trial='trial1', sim=None):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    set_project_menu(cfg, slug, trial)
    data['ini'] = cfg.ini['DEFAULT']
    data['trials'] = cfg.get_trial_names()
    data['slug'] = slug
    data['trial'] = trial
    data['sim'] = sim
    data['page_title'] = '{}, {}: Topic Pair Heatmap by {}'.format(
        slug, trial, sim)
    data['tpm'] = els.get_topicpair_matrix()
    return render_template("topic_pair_heatmap.html", **data)
예제 #23
0
def pca_page(slug, trial='trial1'):
    cfg = get_project_config(slug)
    els = Elements(cfg, trial)
    data['slug'] = slug
    data['trial'] = trial
    data['page_title'] = 'PCA'
    data['pca_docs'] = els.get_pca_docs()
    print(data['pca_docs'].head())
    data['pca_terms'] = els.get_pca_terms()
    data['pca_items'] = els.get_pca_items()
    data['max_variance'] = data['pca_items']['explained_variance'].max()
    data['topics'] = els.get_topics()
    return render_template('pca.html', **data)
예제 #24
0
 def generateMeetingDesk(self):
     print(self.currentBounds)
     print(self.previousBounds)
     if self.previousBounds[0][0] == self.currentBounds[0][0]:
         self.currentBounds[0] = self.previousBounds[1]
         self.currentBounds[2] = self.previousBounds[3]
     else:
         self.currentBounds[1] = self.previousBounds[0]
         self.currentBounds[3] = self.previousBounds[2]
     data = Elements().putMeetingDesk(self.currentBounds)
     self.lastDesk = data[:]
     o = data[-1]
     self.generatedList.append(o)
예제 #25
0
def test_matrix_one_element():
    myelements = 'Hydrogen'
    mytable = Elements()
    mymatrix = mytable.matrix(myelements)
    assert mymatrix == [['Element', 'Hydrogen'], ['Atomic Number', 1],
                        ['Atomic Weight', 1.008],
                        ['Boiling Point (C)', -252.9],
                        ['Boiling Point (F)', -423.2],
                        ['Density (g/cm^(3))', 0.0],
                        ['Density (lb/in^(3))', 0.0],
                        ['Discoverer', 'Cavendish'], ['Group', 1],
                        ['Melting Point (C)', -259.0],
                        ['Melting Point (F)', -434.2], ['Symbol', 'H'],
                        ['Type', 'Nonmetal'], ['Year of Discovery', '1766']]
예제 #26
0
 def __init__(self, name, code, code3, composition):
     #: Full name of the AA
     self.name = name
     #: One letter code
     self.code = code
     #: Three letter code
     self.code3 = code3
     #: Elemental composition
     self.composition = {}
     self.composition = composition
     #: Library of elements
     self.elementsLib = Elements()
     self.deltaMass = Formulas.mass(
         self.composition,
         elementsLib=self.elementsLib)  #self.calDeltaMass()
예제 #27
0
 def generateShelving(self):
     if random.uniform(0, 1) > 0.5:
         self.currentBounds[1][0] -= (self.currentBounds[1][0] -
                                      self.currentBounds[0][0]) * 0.75
         self.currentBounds[3][0] -= (self.currentBounds[1][0] -
                                      self.currentBounds[0][0]) * 0.75
         orientation = 'L'
     else:
         self.currentBounds[0][0] += (self.currentBounds[1][0] -
                                      self.currentBounds[0][0]) * 0.75
         self.currentBounds[2][0] += (self.currentBounds[3][0] -
                                      self.currentBounds[2][0]) * 0.75
         orientation = 'R'
     o = Elements().putShelving(self.currentBounds, orientation)
     self.generatedList.append(o)
예제 #28
0
def main():
    assert len(sys.argv) > 1

    filename = sys.argv[1]
    if filename == "elements.txt":
        data = Elements()
    else:
        data = Numbers()

    with open(filename, "r") as fh:
        lines = data.import_lines(fh)

    random.shuffle(lines)

    while lines:
        os.system("clear")
        lines = check_all(data, lines)
예제 #29
0
def test_matrix():
    myelements = ['Hydrogen', 'Boron']
    mytable = Elements()
    mymatrix = mytable.matrix(myelements)
    assert mymatrix == [['Element', 'Hydrogen', 'Boron'],
                        ['Atomic Number', 1, 5],
                        ['Atomic Weight', 1.008, 10.811],
                        ['Boiling Point (C)', -252.9, 3926.8],
                        ['Boiling Point (F)', -423.2, 7100.3],
                        ['Density (g/cm^(3))', 0.0, 2.34],
                        ['Density (lb/in^(3))', 0.0, 0.085],
                        ['Discoverer', 'Cavendish', 'Gay-Lussac'],
                        ['Group', 1,
                         13], ['Melting Point (C)', -259.0, 2300.0],
                        ['Melting Point (F)', -434.2, 4172.0],
                        ['Symbol', 'H', 'B'],
                        ['Type', 'Nonmetal', 'Metalloid'],
                        ['Year of Discovery', '1766', '1808']]
예제 #30
0
def test_markdown_one_element():
    myelements = 'Hydrogen'
    mytable = Elements()
    mymarkdown = mytable.markdown(myelements)
    assert mymarkdown == ('|Element|Hydrogen|'
                          '\n|:--|--:|'
                          '\n|**Atomic Number**|1|'
                          '\n|**Atomic Weight**|1.008|'
                          '\n|**Boiling Point (C)**|-252.9|'
                          '\n|**Boiling Point (F)**|-423.2|'
                          '\n|**Density (g/cm^(3))**|0.0|'
                          '\n|**Density (lb/in^(3))**|0.0|'
                          '\n|**Discoverer**|Cavendish|'
                          '\n|**Group**|1|'
                          '\n|**Melting Point (C)**|-259.0|'
                          '\n|**Melting Point (F)**|-434.2|'
                          '\n|**Symbol**|H|'
                          '\n|**Type**|Nonmetal|'
                          '\n|**Year of Discovery**|1766|')