repo_id stringlengths 6 101 | file_path stringlengths 2 269 | content stringlengths 367 5.14M | size int64 367 5.14M | filename stringlengths 1 248 | ext stringlengths 0 87 | lang stringclasses 88 values | program_lang stringclasses 232 values | doc_type stringclasses 5 values | quality_signal stringlengths 2 1.9k | effective stringclasses 2 values | hit_map stringlengths 2 1.4k |
|---|---|---|---|---|---|---|---|---|---|---|---|
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/SnipersMark.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.SpiritBow;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
import com.watabou.noosa.Image;
import com.watabou.utils.Bundle;
public class SnipersMark extends FlavourBuff implements ActionIndicator.Action {
public int object = 0;
private static final String OBJECT = "object";
@Override
public boolean attachTo(Char target) {
ActionIndicator.setAction(this);
return super.attachTo(target);
}
@Override
public void detach() {
super.detach();
ActionIndicator.clearAction(this);
}
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( OBJECT, object );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
object = bundle.getInt( OBJECT );
}
@Override
public int icon() {
return BuffIndicator.MARK;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc");
}
@Override
public Image getIcon() {
return new ItemSprite(ItemSpriteSheet.SPIRIT_BOW, null);
}
@Override
public void doAction() {
Hero hero = Dungeon.hero;
if (hero == null) return;
SpiritBow bow = hero.belongings.getItem(SpiritBow.class);
if (bow == null) return;
SpiritBow.SpiritArrow arrow = bow.knockArrow();
if (arrow == null) return;
Char ch = (Char) Actor.findById(object);
if (ch == null) return;
int cell = QuickSlotButton.autoAim(ch, arrow);
if (cell == -1) return;
bow.sniperSpecial = true;
arrow.cast(hero, cell);
detach();
}
}
| 3,106 | SnipersMark | java | en | java | code | {"qsc_code_num_words": 366, "qsc_code_num_chars": 3106.0, "qsc_code_mean_word_length": 6.37704918, "qsc_code_frac_words_unique": 0.42622951, "qsc_code_frac_chars_top_2grams": 0.05012853, "qsc_code_frac_chars_top_3grams": 0.19537275, "qsc_code_frac_chars_top_4grams": 0.20736932, "qsc_code_frac_chars_dupe_5grams": 0.20222793, "qsc_code_frac_chars_dupe_6grams": 0.02399314, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00722708, "qsc_code_frac_chars_whitespace": 0.15357373, "qsc_code_size_file_byte": 3106.0, "qsc_code_num_lines": 112.0, "qsc_code_num_chars_line_max": 81.0, "qsc_code_num_chars_line_mean": 27.73214286, "qsc_code_frac_chars_alphabet": 0.88056295, "qsc_code_frac_chars_comments": 0.25144881, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.12857143, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00602151, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.12857143, "qsc_codejava_score_lines_no_logic": 0.32857143, "qsc_codejava_frac_words_no_modifier": 0.9, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Haste.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class Haste extends FlavourBuff {
{
type = buffType.POSITIVE;
}
public static final float DURATION = 20f;
@Override
public int icon() {
return BuffIndicator.MOMENTUM;
}
@Override
public void tintIcon(Image icon) {
icon.tint(1, 1, 0, 0.5f);
if (cooldown() < 5f) greyIcon(icon, 5f, cooldown());
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,588 | Haste | java | en | java | code | {"qsc_code_num_words": 211, "qsc_code_num_chars": 1588.0, "qsc_code_mean_word_length": 5.55450237, "qsc_code_frac_words_unique": 0.57819905, "qsc_code_frac_chars_top_2grams": 0.05802048, "qsc_code_frac_chars_top_3grams": 0.12969283, "qsc_code_frac_chars_top_4grams": 0.04863481, "qsc_code_frac_chars_dupe_5grams": 0.15358362, "qsc_code_frac_chars_dupe_6grams": 0.04778157, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01977186, "qsc_code_frac_chars_whitespace": 0.17191436, "qsc_code_size_file_byte": 1588.0, "qsc_code_num_lines": 58.0, "qsc_code_num_chars_line_max": 74.0, "qsc_code_num_chars_line_mean": 27.37931034, "qsc_code_frac_chars_alphabet": 0.87148289, "qsc_code_frac_chars_comments": 0.49118388, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.14285714, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00990099, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.14285714, "qsc_codejava_score_lines_no_logic": 0.32142857, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/AdrenalineSurge.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Bundle;
public class AdrenalineSurge extends Buff {
{
type = buffType.POSITIVE;
}
private int boost;
private float interval;
public void reset(int boost, float interval){
this.boost = boost;
this.interval = interval;
spend(interval - cooldown());
}
public int boost(){
return boost;
}
@Override
public boolean act() {
boost --;
if (boost > 0){
spend( interval );
} else {
detach();
}
return true;
}
@Override
public int icon() {
return BuffIndicator.FURY;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", boost, dispTurns(cooldown()+1));
}
private static final String BOOST = "boost";
private static final String INTERVAL = "interval";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( BOOST, boost );
bundle.put( INTERVAL, interval );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
boost = bundle.getInt( BOOST );
//pre-0.7.1
if (bundle.contains(INTERVAL)) {
interval = bundle.getFloat(INTERVAL);
} else {
interval = 800f;
}
}
}
| 2,307 | AdrenalineSurge | java | en | java | code | {"qsc_code_num_words": 286, "qsc_code_num_chars": 2307.0, "qsc_code_mean_word_length": 5.74125874, "qsc_code_frac_words_unique": 0.47552448, "qsc_code_frac_chars_top_2grams": 0.05115713, "qsc_code_frac_chars_top_3grams": 0.09257004, "qsc_code_frac_chars_top_4grams": 0.03471376, "qsc_code_frac_chars_dupe_5grams": 0.15103532, "qsc_code_frac_chars_dupe_6grams": 0.03410475, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01336898, "qsc_code_frac_chars_whitespace": 0.18942349, "qsc_code_size_file_byte": 2307.0, "qsc_code_num_lines": 95.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 24.28421053, "qsc_code_frac_chars_alphabet": 0.86470588, "qsc_code_frac_chars_comments": 0.34286953, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13333333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01385224, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.13333333, "qsc_codejava_score_lines_no_logic": 0.28333333, "qsc_codejava_frac_words_no_modifier": 0.88888889, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/FireImbue.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class FireImbue extends Buff {
{
type = buffType.POSITIVE;
announced = true;
}
public static final float DURATION = 50f;
protected float left;
private static final String LEFT = "left";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( LEFT, left );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
left = bundle.getFloat( LEFT );
}
public void set( float duration ) {
this.left = duration;
}
@Override
public boolean act() {
if (Dungeon.level.map[target.pos] == Terrain.GRASS) {
Dungeon.level.set(target.pos, Terrain.EMBERS);
GameScene.updateMap(target.pos);
}
spend(TICK);
left -= TICK;
if (left <= 0){
detach();
} else if (left < 5){
BuffIndicator.refreshHero();
}
return true;
}
public void proc(Char enemy){
if (Random.Int(2) == 0)
Buff.affect( enemy, Burning.class ).reignite( enemy );
enemy.sprite.emitter().burst( FlameParticle.FACTORY, 2 );
}
@Override
public int icon() {
return BuffIndicator.FIRE;
}
@Override
public void tintIcon(Image icon) {
FlavourBuff.greyIcon(icon, 5f, left);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns(left));
}
{
immunities.add( Burning.class );
}
}
| 2,816 | FireImbue | java | en | java | code | {"qsc_code_num_words": 348, "qsc_code_num_chars": 2816.0, "qsc_code_mean_word_length": 5.93103448, "qsc_code_frac_words_unique": 0.48563218, "qsc_code_frac_chars_top_2grams": 0.04360465, "qsc_code_frac_chars_top_3grams": 0.14728682, "qsc_code_frac_chars_top_4grams": 0.14922481, "qsc_code_frac_chars_dupe_5grams": 0.06492248, "qsc_code_frac_chars_dupe_6grams": 0.02713178, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01062022, "qsc_code_frac_chars_whitespace": 0.1640625, "qsc_code_size_file_byte": 2816.0, "qsc_code_num_lines": 112.0, "qsc_code_num_chars_line_max": 81.0, "qsc_code_num_chars_line_mean": 25.14285714, "qsc_code_frac_chars_alphabet": 0.86618522, "qsc_code_frac_chars_comments": 0.27734375, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09722222, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00589681, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.125, "qsc_codejava_score_lines_no_logic": 0.30555556, "qsc_codejava_frac_words_no_modifier": 0.9, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/curses/Multiplicity.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.curses;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PinCushion;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Bundle;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
import com.watabou.utils.Reflection;
import java.util.ArrayList;
public class Multiplicity extends Armor.Glyph {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
if (Random.Int(20) == 0){
ArrayList<Integer> spawnPoints = new ArrayList<>();
for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
int p = defender.pos + PathFinder.NEIGHBOURS8[i];
if (Actor.findChar( p ) == null && (Dungeon.level.passable[p] || Dungeon.level.avoid[p])) {
spawnPoints.add( p );
}
}
if (spawnPoints.size() > 0) {
Mob m = null;
if (Random.Int(2) == 0 && defender instanceof Hero){
m = new MirrorImage();
((MirrorImage)m).duplicate( (Hero)defender );
} else {
//FIXME should probably have a mob property for this
if (attacker.properties().contains(Char.Property.BOSS) || attacker.properties().contains(Char.Property.MINIBOSS)
|| attacker instanceof Mimic || attacker instanceof Statue){
m = Dungeon.level.createMob();
} else {
Actor.fixTime();
m = (Mob)Reflection.newInstance(attacker.getClass());
if (m != null) {
Bundle store = new Bundle();
attacker.storeInBundle(store);
m.restoreFromBundle(store);
m.pos = 0;
m.HP = m.HT;
if (m.buff(PinCushion.class) != null) {
m.remove(m.buff(PinCushion.class));
}
//If a thief has stolen an item, that item is not duplicated.
if (m instanceof Thief) {
((Thief) m).item = null;
}
}
}
}
if (m != null) {
GameScene.add(m);
ScrollOfTeleportation.appear(m, Random.element(spawnPoints));
}
}
}
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
@Override
public boolean curse() {
return true;
}
}
| 3,843 | Multiplicity | java | en | java | code | {"qsc_code_num_words": 458, "qsc_code_num_chars": 3843.0, "qsc_code_mean_word_length": 5.99344978, "qsc_code_frac_words_unique": 0.3930131, "qsc_code_frac_chars_top_2grams": 0.05901639, "qsc_code_frac_chars_top_3grams": 0.20765027, "qsc_code_frac_chars_top_4grams": 0.22440801, "qsc_code_frac_chars_dupe_5grams": 0.28378871, "qsc_code_frac_chars_dupe_6grams": 0.11876138, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01077313, "qsc_code_frac_chars_whitespace": 0.17876659, "qsc_code_size_file_byte": 3843.0, "qsc_code_num_lines": 117.0, "qsc_code_num_chars_line_max": 118.0, "qsc_code_num_chars_line_mean": 32.84615385, "qsc_code_frac_chars_alphabet": 0.85899873, "qsc_code_frac_chars_comments": 0.23263076, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09210526, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00271278, "qsc_code_frac_lines_prompt_comments": 0.00854701, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.02631579, "qsc_codejava_score_lines_no_logic": 0.32894737, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/curses/Overgrowth.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.LeafParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.plants.BlandfruitBush;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.shatteredpixel.shatteredpixeldungeon.plants.Starflower;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Overgrowth extends Armor.Glyph {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
if ( Random.Int( 20 ) == 0) {
Plant.Seed s;
do{
s = (Plant.Seed) Generator.random(Generator.Category.SEED);
} while (s instanceof BlandfruitBush.Seed || s instanceof Starflower.Seed);
Plant p = s.couch(defender.pos, null);
//momentarily revoke warden benefits, otherwise this curse would be incredibly powerful
if (defender instanceof Hero && ((Hero) defender).subClass == HeroSubClass.WARDEN){
((Hero) defender).subClass = HeroSubClass.NONE;
p.activate( defender );
((Hero) defender).subClass = HeroSubClass.WARDEN;
} else {
p.activate( defender );
}
CellEmitter.get( defender.pos ).burst( LeafParticle.LEVEL_SPECIFIC, 10 );
}
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
@Override
public boolean curse() {
return true;
}
}
| 2,709 | Overgrowth | java | en | java | code | {"qsc_code_num_words": 324, "qsc_code_num_chars": 2709.0, "qsc_code_mean_word_length": 6.35185185, "qsc_code_frac_words_unique": 0.47222222, "qsc_code_frac_chars_top_2grams": 0.09912536, "qsc_code_frac_chars_top_3grams": 0.22157434, "qsc_code_frac_chars_top_4grams": 0.23517979, "qsc_code_frac_chars_dupe_5grams": 0.34936832, "qsc_code_frac_chars_dupe_6grams": 0.07968902, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01261418, "qsc_code_frac_chars_whitespace": 0.15134736, "qsc_code_size_file_byte": 2709.0, "qsc_code_num_lines": 79.0, "qsc_code_num_chars_line_max": 91.0, "qsc_code_num_chars_line_mean": 34.29113924, "qsc_code_frac_chars_alphabet": 0.88255763, "qsc_code_frac_chars_comments": 0.3200443, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.11627907, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00434311, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.04651163, "qsc_codejava_score_lines_no_logic": 0.41860465, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/curses/Bulk.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
public class Bulk extends Armor.Glyph {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
//no proc effect, see armor.speedfactor
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
@Override
public boolean curse() {
return true;
}
}
| 1,452 | Bulk | java | en | java | code | {"qsc_code_num_words": 195, "qsc_code_num_chars": 1452.0, "qsc_code_mean_word_length": 5.63076923, "qsc_code_frac_words_unique": 0.57948718, "qsc_code_frac_chars_top_2grams": 0.06193078, "qsc_code_frac_chars_top_3grams": 0.13843352, "qsc_code_frac_chars_top_4grams": 0.05191257, "qsc_code_frac_chars_dupe_5grams": 0.16211293, "qsc_code_frac_chars_dupe_6grams": 0.05100182, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01991701, "qsc_code_frac_chars_whitespace": 0.17011019, "qsc_code_size_file_byte": 1452.0, "qsc_code_num_lines": 48.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 30.25, "qsc_code_frac_chars_alphabet": 0.89128631, "qsc_code_frac_chars_comments": 0.56404959, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.15789474, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.01263823, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.10526316, "qsc_codejava_score_lines_no_logic": 0.47368421, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/curses/Displacement.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.curses;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Displacement extends Armor.Glyph {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage ) {
if (defender == Dungeon.hero && Random.Int(20) == 0){
ScrollOfTeleportation.teleportHero(Dungeon.hero);
return 0;
}
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return BLACK;
}
@Override
public boolean curse() {
return true;
}
}
| 1,715 | Displacement | java | en | java | code | {"qsc_code_num_words": 220, "qsc_code_num_chars": 1715.0, "qsc_code_mean_word_length": 5.97272727, "qsc_code_frac_words_unique": 0.54090909, "qsc_code_frac_chars_top_2grams": 0.07762557, "qsc_code_frac_chars_top_3grams": 0.17351598, "qsc_code_frac_chars_top_4grams": 0.1674277, "qsc_code_frac_chars_dupe_5grams": 0.17732116, "qsc_code_frac_chars_dupe_6grams": 0.04261796, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01929704, "qsc_code_frac_chars_whitespace": 0.15393586, "qsc_code_size_file_byte": 1715.0, "qsc_code_num_lines": 54.0, "qsc_code_num_chars_line_max": 85.0, "qsc_code_num_chars_line_mean": 31.75925926, "qsc_code_frac_chars_alphabet": 0.88628532, "qsc_code_frac_chars_comments": 0.45539359, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.11538462, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00856531, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.07692308, "qsc_codejava_score_lines_no_logic": 0.5, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/curses/Metabolism.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.curses;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor.Glyph;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Random;
public class Metabolism extends Glyph {
private static ItemSprite.Glowing BLACK = new ItemSprite.Glowing( 0x000000 );
@Override
public int proc( Armor armor, Char attacker, Char defender, int damage) {
if (Random.Int( 6 ) == 0 && defender instanceof Hero) {
//assumes using up 10% of starving, and healing of 1 hp per 10 turns;
int healing = Math.min((int)Hunger.STARVING/100, defender.HT - defender.HP);
if (healing > 0) {
Hunger hunger = Buff.affect(defender, Hunger.class);
if (hunger != null && !hunger.isStarving()) {
hunger.reduceHunger( healing * -10 );
BuffIndicator.refreshHero();
defender.HP += healing;
defender.sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 );
defender.sprite.showStatus( CharSprite.POSITIVE, Integer.toString( healing ) );
}
}
}
return damage;
}
@Override
public Glowing glowing() {
return BLACK;
}
@Override
public boolean curse() {
return true;
}
}
| 2,625 | Metabolism | java | en | java | code | {"qsc_code_num_words": 321, "qsc_code_num_chars": 2625.0, "qsc_code_mean_word_length": 6.15576324, "qsc_code_frac_words_unique": 0.47352025, "qsc_code_frac_chars_top_2grams": 0.10323887, "qsc_code_frac_chars_top_3grams": 0.23076923, "qsc_code_frac_chars_top_4grams": 0.24493927, "qsc_code_frac_chars_dupe_5grams": 0.31933198, "qsc_code_frac_chars_dupe_6grams": 0.20546559, "qsc_code_frac_chars_dupe_7grams": 0.0597166, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01714028, "qsc_code_frac_chars_whitespace": 0.15542857, "qsc_code_size_file_byte": 2625.0, "qsc_code_num_lines": 77.0, "qsc_code_num_chars_line_max": 85.0, "qsc_code_num_chars_line_mean": 34.09090909, "qsc_code_frac_chars_alphabet": 0.87415426, "qsc_code_frac_chars_comments": 0.32380952, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.07317073, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00450704, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.07317073, "qsc_codejava_score_lines_no_logic": 0.46341463, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00JCIV00/cova | examples/covademo.zig | //! Example usage of Cova.
//! Comptime Setup, Runtime Use.
const std = @import("std");
const builtin = @import("builtin");
const fmt = std.fmt;
const fs = std.fs;
const io = std.io;
const log = std.log;
const mem = std.mem;
const meta = std.meta;
const proc = std.process;
const ComptimeStringMap = std.ComptimeStringMap;
const StringHashMap = std.StringHashMap;
const testing = std.testing;
const zon = std.zon;
const Io = std.Io;
const cova = @import("cova");
const Command = cova.Command;
const Option = cova.Option;
const Value = cova.Value;
const utils = cova.utils;
const MultiSliceF = utils.MultiSliceFormatter;
const ex_structs = @import("example_structs.zig");
const conf_optimized = Command.Config.optimized(.{});
pub const CommandT = Command.Custom(.{
.global_help_prefix = "CovaDemo",
.global_vals_mandatory = false,
.help_category_order = &.{ .Prefix, .Header, .Aliases, .Values, .Options, .Commands },
.allow_abbreviated_cmds = true,
//.allow_arg_indices = false,
.global_usage_fn = struct{
fn usage(self: anytype, writer: anytype, _: ?mem.Allocator) !void {
const CmdT = @TypeOf(self.*);
const OptT = CmdT.OptionT;
const indent_fmt = CmdT.indent_fmt;
var no_args = true;
var pre_sep: []const u8 = "";
try writer.print("USAGE\n", .{});
if (self.opts) |opts| {
no_args = false;
try writer.print("{s}{s} [", .{
indent_fmt,
self.name,
});
for (opts) |opt| {
try writer.print("{s} {s}{s} ", .{
pre_sep,
OptT.long_prefix orelse opt.short_prefix,
opt.long_name orelse &.{ opt.short_name orelse 0 },
});
pre_sep = "| ";
}
try writer.print("]\n", .{});
}
if (self.sub_cmds) |cmds| {
no_args = false;
try writer.print("{s}{s} [", .{
indent_fmt,
self.name,
});
pre_sep = "";
for (cmds) |cmd| {
try writer.print("{s} {s} ", .{
pre_sep,
cmd.name,
});
pre_sep = "| ";
}
try writer.print("]\n", .{});
}
if (no_args) try writer.print("{s}{s}{s}", .{
indent_fmt,
indent_fmt,
self.name,
});
}
}.usage,
//.help_header_fmt =
// \\HELP
// \\{s}COMMAND: {s}
// \\
// \\{s}DESCRIPTION: {s}
// \\
// \\
//,
//.global_help_fn = struct{
// fn help(self: anytype, writer: anytype, _: mem.Allocator) !void {
// const CmdT = @TypeOf(self.*);
// const OptT = CmdT.OptionT;
// const indent_fmt = CmdT.indent_fmt;
//
// try writer.print("{s}\n", .{ self.help_prefix });
// try self.usage(writer);
// try writer.print("\n", .{});
// try writer.print(CmdT.help_header_fmt, .{
// indent_fmt, self.name,
// indent_fmt, self.description
// });
// if (self.sub_cmds) |cmds| {
// try writer.print("SUBCOMMANDS\n", .{});
// for (cmds) |cmd| {
// try writer.print("{s}{s}: {s}\n", .{
// indent_fmt,
// cmd.name,
// cmd.description,
// });
// }
// try writer.print("\n", .{});
// }
// if (self.opts) |opts| {
// try writer.print("OPTIONS\n", .{});
// for (opts) |opt| {
// try writer.print(
// \\{s}{s}{s} "{s} ({s})"
// \\{s}{s}{s}
// \\
// \\
// , .{
// indent_fmt,
// OptT.long_prefix orelse OptT.short_prefix, opt.long_name orelse "",
// opt.val.name(), opt.val.childType(),
// indent_fmt, indent_fmt,
// opt.description,
// }
// );
// }
// }
// if (self.vals) |vals| {
// try writer.print("VALUES\n", .{});
// for (vals) |val| {
// try writer.print("{s}", .{ indent_fmt });
// try val.usage(writer);
// try writer.print("\n", .{});
// }
// try writer.print("\n", .{});
// }
// }
//}.help,
//.global_case_sensitive = false,
.opt_config = .{
//.usage_fmt = "{u}{?u}{s} {s}{?s} <{s} ({s})>",
//.allow_arg_indices = false,
//.global_case_sensitive = false,
//.usage_fn = struct{
// fn usage(self: anytype, writer: anytype, _: ?mem.Allocator) !void {
// const short_prefix = @TypeOf(self.*).short_prefix;
// const long_prefix = @TypeOf(self.*).long_prefix;
// try writer.print("{?u}{?u}, {?s}{?s}", .{
// short_prefix,
// self.short_name,
// long_prefix,
// self.long_name,
// }
// );
// }
//}.usage,
.global_help_fn = struct{
fn help(self: anytype, writer: anytype, _: ?mem.Allocator) !void {
const indent_fmt = @TypeOf(self.*).indent_fmt;
try self.usage(writer);
try writer.print("\n{?s}{?s}{?s}{s}", .{ indent_fmt, indent_fmt, indent_fmt, self.description });
}
}.help
},
.val_config = .{
//.allow_arg_indices = false,
//.custom_types = &.{ DemoStruct.InnerEnum },
//.custom_types = &.{ SimpleEnum },
.child_type_parse_fns = &.{
//.{
// .ChildT = bool,
// .parse_fn = Value.ParsingFns.Builder.altBool(
// &.{ "true", "t", "yes", "y", "1", "ok" },
// &.{ "false", "f", "no", "n", "0" },
// .Error
// )
//},
//.{
// .ChildT = u1024,
// .parse_fn = struct{ fn testFn(arg: []const u8, alloc: mem.Allocator) !u1024 { _ = arg; _ = alloc; return 69696969696969; } }.testFn,
//},
},
.child_type_aliases = &.{
.{
.ChildT = []const u8,
.alias = "text",
},
.{
.ChildT = bool,
.alias = "toggle",
},
.{
.ChildT = [6]u8,
.alias = "byte_array",
},
},
},
//.global_usage_fn = struct{
// fn usage(_: anytype, writer: anytype, _: ?mem.Allocator) !void {
// // In a real implementation checks should be done to ensure `self` is a suitable Command Type and extract its sub Argument Types.
// try writer.print("This is an overriding usage message!\n\n", .{});
// }
//}.usage,
});
pub const ValueT = CommandT.ValueT;
//pub const log_level: log.Level = .err;
pub const SimpleEnum = enum{
a,
b,
};
pub const DemoStruct = struct{
pub const InnerStruct = struct{
in_bool: bool = false,
in_float: f32 = 0,
h_string: []const u8 = "Just a test for fields starting with 'h'",
};
pub const InnerEnum = enum(u2){
red,
blue,
green,
};
// Command
inner_cmd: InnerStruct = .{
.in_bool = true,
.in_float = 0,
},
// Options
int: ?i32 = 26,
str: ?[]const u8 = "Demo Opt string.",
str2: ?[]const u8 = "Demo Opt string 2.",
flt: ?f16 = 0,
int2: ?u16 = 0,
multi_int: [3]?u8,
multi_str: [5]?[]const u8,
rgb_enum: ?InnerEnum = .blue,
// Values
struct_bool: bool = true,
struct_str: []const u8 = "Demo Struct string.",
struct_int: i64 = 8967,
multi_int_val: [2]u16,
_ignored_int: i8 = 15,
// Cova Argument Types
//cova_val_int: ValueT = ValueT.ofType(i8, .{
// .name = "cova_val_int",
// .description = "A test cova Value within a struct.",
// .default_val = 50,
//}),
};
pub const DemoUnion = union(enum) {
// Options
int: ?i32,
str: ?[]const u8,
// Values
union_uint: u8,
union_str: []const u8,
};
pub fn demoFn(int: i32, string: []const u8, array: [6]u8) void {
log.info("Demo function result:\n - Int: {d}\n - String: {s}\n - Array: {s}", .{ int, string, array[0..] });
}
// Comptime Setup Command
pub const setup_cmd: CommandT = .{
.name = "covademo",
.description = "A demo of the Cova command line argument parser.",
.examples = &.{
"covademo -b --string \"Optional String\"",
"covademo -i 0 -i=1 -i2 -i=3,4,5 -i6,7 --int 8 --int=9",
"covademo --file \"/some/file\"",
},
.cmd_groups = &.{ "RAW", "STRUCT-BASED", "FN-BASED" },
.opt_groups = &.{ "INT", "BOOL", "STRING" },
.val_groups = &.{ "INT", "BOOL", "STRING" },
.sub_cmds_mandatory = false,
//.mandatory_opt_groups = &.{ "BOOL" },
.sub_cmds = &.{
.{
.name = "sub-cmd",
.alias_names = &.{ "alias-cmd", "test-alias" },
.description = "A demo sub command.",
.examples = &.{
"covademo sub-cmd 3.14",
},
.cmd_group = "RAW",
.opts = &.{
.{
.name = "nested_int_opt",
.short_name = 'i',
//.long_name = "nested_int",
.val = ValueT.ofType(u8, .{
.name = "nested_int_val",
.description = "A nested integer value.",
.default_val = 203,
}),
.description = "A nested integer option.",
},
.{
.name = "nested_str_opt",
.short_name = 's',
.long_name = "nested_str",
.val = ValueT.ofType([]const u8, .{
.name = "nested_str_val",
.description = "A nested string value.",
.default_val = "A nested string value.",
}),
.description = "A nested string option.",
},
},
.vals = &.{
ValueT.ofType([]const u8, .{
.name = "nested_str_val",
.description = "A nested string value.",
.max_entries = 10,
.set_behavior = .Multi,
}),
ValueT.ofType(f32, .{
.name = "nested_float_val",
.description = "A nested float value.",
.default_val = 0,
}),
}
},
.{
.name = "basic",
.alias_names = &.{ "basic-cmd" },
.description = "The most basic Command.",
.cmd_group = "RAW",
},
.{
.name = "nest-1",
.description = "Nested Level 1.",
.sub_cmds = &.{
.{
.name = "nest-2",
.description = "Nested Level 2.",
.sub_cmds = &.{
.{
.name = "nest-3",
.description = "Nested Level 3.",
.sub_cmds = &.{
.{
.name = "nest-4",
.description = "Nested Level 4.",
}
},
.opts = &.{
.{
.name = "inheritable",
.description = "Inheritable Option",
.inheritable = true,
.short_name = 'i',
.long_name = "inheritable",
}
}
}
}
}
}
},
CommandT.from(DemoStruct, .{
.cmd_name = "struct-cmd",
.cmd_description = "A demo sub command made from a struct.",
.attempt_short_opts = true,
//.cmd_hidden = true,
.cmd_group = "STRUCT-BASED",
.sub_cmds_mandatory = false,
.default_val_opts = true,
.sub_descriptions = &.{
.{ "inner_cmd", "An inner/nested command for struct-cmd" },
.{ "int", "The first Integer Value for the struct-cmd." },
},
}),
CommandT.from(DemoUnion, .{
.cmd_name = "union-cmd",
.cmd_description = "A demo sub command made from a union.",
.cmd_group = "STRUCT-BASED",
.sub_descriptions = &.{
.{ "int", "The first Integer Value for the union-cmd." },
.{ "str", "The first String Value for the union-cmd." },
},
}),
CommandT.from(@TypeOf(demoFn), .{
.cmd_name = "fn-cmd",
.cmd_description = "A demo sub command made from a function.",
.cmd_group = "FN-BASED",
.sub_descriptions = &.{
.{ "int", "The first Integer Value for the fn-cmd." },
.{ "string", "The first String Value for the fn-cmd." },
.{ "byte_array", "A 6-Byte Array for fn-cmd" },
},
.ignore_incompatible = false,
}),
CommandT.from(ex_structs.add_user, .{
.cmd_name = "add-user",
.cmd_group = "STRUCT-BASED",
.cmd_description = "A demo sub command for adding a user.",
}),
},
.opts = &.{
.{
.name = "string_opt",
.description = "A string option. (Can be given up to 4 times.)",
//.hidden = true,
.inheritable = true,
.opt_group = "STRING",
.short_name = 's',
.long_name = "string",
.alias_long_names = &.{ "text" },
.allow_empty = true,
.val = ValueT.ofType([]const u8, .{
.name = "string_val",
.description = "A string value.",
.default_val = "Default string value.",
.alias_child_type = "string",
.set_behavior = .Multi,
.max_entries = 4,
.parse_fn = Value.ParsingFns.toUpper,
}),
},
.{
.name = "int_opt",
.description = "An integer option. (Can be given up to 10 times.)",
.opt_group = "INT",
.short_name = 'i',
.long_name = "int",
.val = ValueT.ofType(i16, .{
.name = "int_val",
.description = "An integer value.",
.valid_fn = struct{ fn valFn(int: i16, alloc: mem.Allocator) bool { _ = alloc; return int < 666; } }.valFn,
.set_behavior = .Multi,
.max_entries = 10,
}),
},
//.{
// .name = "uint_opt",
// .description = "An unsigned integer option. (Can be given up to 10 times.)",
// .opt_group = "INT",
// .short_name = 'U',
// .long_name = "uint",
// .val = ValueT.ofType(u1024, .{
// .name = "uint_val",
// .description = "An unsigned integer value.",
// .set_behavior = .Multi,
// .max_entries = 10,
// }),
//},
.{
.name = "float_opt",
.description = "An float option. (Can be given up to 10 times.)",
//.opt_group = "INT",
.short_name = 'f',
.long_name = "float",
.val = ValueT.ofType(f16, .{
.name = "float_val",
.description = "A float value.",
.valid_fn = Value.ValidationFns.Builder.inRange(f16, 0.0, 36_000.0, true),
.set_behavior = .Multi,
.max_entries = 10,
}),
},
.{
.name = "file_opt",
.description = "A filepath option.",
.opt_group = "STRING",
.short_name = 'F',
.long_name = "file",
.val = ValueT.ofType([]const u8, .{
.name = "filepath",
.description = "A filepath value.",
.alias_child_type = "filepath",
.valid_fn = Value.ValidationFns.validFilepath,
}),
},
.{
.name = "ordinal_opt",
.description = "An ordinal number option.",
.opt_group = "STRING",
.short_name = 'o',
.long_name = "ordinal",
.val = ValueT.ofType([]const u8, .{
.name = "ordinal_val",
.description = "An ordinal number value.",
.valid_fn = Value.ValidationFns.ordinalNum,
}),
},
.{
.name = "cardinal_opt",
.description = "A cardinal number option.",
.opt_group = "INT",
.short_name = 'c',
.long_name = "cardinal",
.val = ValueT.ofType(u8, .{
.name = "cardinal_val",
.description = "A cardinal number value.",
.parse_fn = Value.ParsingFns.Builder.asEnumType(enum(u8) { zero, one, two }),
.set_behavior = .Multi,
.max_entries = 3,
}),
},
.{
.name = "toggle_opt",
.description = "A toggle/boolean option.",
.opt_group = "BOOL",
.short_name = 't',
.long_name = "toggle",
.alias_long_names = &.{ "switch" },
.val = ValueT.ofType(bool, .{
.name = "toggle_val",
.description = "A toggle/boolean value.",
}),
},
.{
.name = "bool_opt",
.description = "A toggle/boolean option.",
.opt_group = "BOOL",
.short_name = 'b',
.long_name = "bool",
//.mandatory = true,
.val = ValueT.ofType(bool, .{
.name = "bool_val",
.description = "A toggle/boolean value.",
//.parse_fn = Value.ParsingFns.Builder.altBool(&.{ "true", "t", "yes", "y", "1" }, &.{}, .False),
}),
},
.{
.name = "verbosity_opt",
.description = "Set the CovaDemo verbosity level. (WIP)",
.inheritable = true,
.short_name = 'v',
.long_name = "verbosity",
.val = ValueT.ofType(u4, .{
.name = "verbosity_level",
.description = "The verbosity level from 0 (err) to 3 (debug).",
.default_val = 3,
.valid_fn = struct{ fn valFn(val: u4, _: mem.Allocator) bool { return val >= 0 and val <= 3; } }.valFn,
}),
},
},
.vals = &.{
ValueT.ofType([]const u8, .{
.name = "cmd_str",
.val_group = "STRING",
.description = "A string value for the command.",
.max_entries = 10,
.set_behavior = .Multi,
.parse_fn = Value.ParsingFns.trimWhitespace,
}),
ValueT.ofType(bool, .{
.name = "cmd_bool",
.description = "A boolean value for the command.",
.set_behavior = .Multi,
.max_entries = 10,
.parse_fn = Value.ParsingFns.Builder.altBool(&.{ "true", "t", "yes", "y", "1" }, &.{ "false", "f", "no", "n", "0" }, .Error),
}),
ValueT.ofType(u64, .{
.name = "cmd_u64",
.description = "A u64 value for the command.",
.default_val = 654321,
.set_behavior = .Multi,
.max_entries = 3,
.parse_fn = struct{ fn parseFn(arg: []const u8, alloc: mem.Allocator) !u64 { _ = alloc; return (try fmt.parseInt(u64, arg, 0)) * 100; } }.parseFn,
.valid_fn = Value.ValidationFns.Builder.inRange(u64, 123456, 9999999999, true),
}),
}
};
pub fn main() !void {
// Setup
//var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
//var alloc_buf: [100 << 10]u8 = undefined;
//var fba = std.heap.FixedBufferAllocator.init(alloc_buf[0..]);
//var arena = std.heap.ArenaAllocator.init(fba.allocator());
//defer arena.deinit();
//const alloc = arena.allocator();
var gpa: std.heap.GeneralPurposeAllocator(.{ .verbose_log = builtin.mode == .Debug }) = .{};
const alloc = gpa.allocator();
defer {
if (gpa.deinit() != .ok) {
if (builtin.mode == .Debug and gpa.detectLeaks()) log.err("Memory leak detected!", .{});
}
else log.debug("Memory freed. No leaks detected.", .{});
}
var stdout_file = fs.File.stdout();
var stdout_buf: [4096]u8 = undefined;
var stdout_writer = stdout_file.writer(stdout_buf[0..]);
const stdout = &stdout_writer.interface;
defer stdout.flush() catch {};
var main_cmd = try setup_cmd.init(alloc, .{});
defer main_cmd.deinit();
var args_iter = try cova.ArgIteratorGeneric.init(alloc);
defer args_iter.deinit();
// Parsing
cova.parseArgs(
&args_iter,
CommandT,
main_cmd,
stdout, .{
//.auto_handle_usage_help = false,
},
) catch |err| switch (err) {
error.UsageHelpCalled => {},
else => return err,
};
try stdout.flush();
// Analysis
// - Debug Output of Commands after Parsing.
try stdout.print("\nCova Demo Argument Results:\n", .{});
try cova.utils.displayCmdInfo(CommandT, main_cmd, alloc, stdout, true);
try stdout.flush();
// - Individual Command Analysis (this is how analysis would look in a normal program)
log.debug("Main Cmd", .{});
// -- Get Values
const val_map = try main_cmd.getVals(.{ .arg_group = "STRING" });
var val_iter = val_map.valueIterator();
log.debug("Get String Values:", .{});
while (val_iter.next()) |str_val| log.debug("- {s}", .{ str_val.getAs([]const u8) catch "[value not set]" });
// -- Check Options
const opts_check_names: []const []const u8 = &.{ "int_opt", "string_opt", "float_opt", "bool_opt" };
const and_opts_check = main_cmd.checkOpts(opts_check_names, .{ .logic = .AND });
const or_opts_check = main_cmd.checkOpts(opts_check_names, .{ .logic = .OR });
const xor_opts_check = main_cmd.checkOpts(opts_check_names, .{ .logic = .XOR });
log.debug(
\\ Check Options: {f}
\\ - AND: {}
\\ - OR: {}
\\ - XOR: {}
\\
, .{
MultiSliceF{ .slices = opts_check_names },
and_opts_check,
or_opts_check,
xor_opts_check,
}
);
var main_opts = try main_cmd.getOpts(.{});
if (main_opts.get("string_opt")) |str_opt| strOpt: {
if (str_opt.val.isEmpty() and str_opt.val.isSet()) {
log.debug("This Option was set, but intentionally left empty.", .{});
break :strOpt;
}
const opt_strs = try str_opt.val.getAllAs([]const u8);
log.debug("Option Strings (--string): {d}", .{ opt_strs.len });
for (opt_strs, 0..) |str, idx| log.debug(" {d}. {s}", .{ idx, str });
}
//if (main_cmd.opts) |main_opts| {
// for (main_opts) |opt| log.debug("-> Opt: {s}, Idx: {d}", .{ opt.name, opt.arg_idx orelse continue });
//}
if (main_cmd.checkSubCmd("sub-cmd"))
log.debug("-> Sub Cmd", .{});
if (main_cmd.matchSubCmd("add-user")) |add_user_cmd|
log.debug("-> Add User Cmd\nTo Struct:\n{any}\n\n", .{ try add_user_cmd.to(ex_structs.add_user, .{}) });
if (main_cmd.matchSubCmd("struct-cmd")) |struct_cmd| structCmd: {
log.debug("Parent Cmd (struct-cmd): {s}", .{ struct_cmd.parent_cmd.?.name });
log.debug("Parent Cmd (int-opt / int-val): {s} / {s}", optPar: {
const struct_cmd_opts = struct_cmd.getOpts(.{}) catch break: optPar .{ "[no opts]", "" };
const int_opt = struct_cmd_opts.get("int") orelse break: optPar .{ "[no int opt]", "" };
break :optPar .{ if (int_opt.parent_cmd) |p_cmd| p_cmd.name else "[no parent?]", if (int_opt.val.parent_cmd) |p_cmd| p_cmd.name else "[no parent?]" };
});
const demo_struct = try struct_cmd.to(DemoStruct, .{ .default_val_opts = true });
var out_buf: [4096]u8 = undefined;
//var out_stream: io.FixedBufferStream([]u8) = .{ .buffer = out_buf[0..], .pos = 0 };
var out_writer: Io.Writer = .fixed(out_buf[0..]);
try zon.stringify.serializeMaxDepth(
demo_struct,
.{},
&out_writer,
10,
);
//log.debug("-> Struct Cmd\n{any}", .{ demo_struct });
log.debug("-> Struct Cmd\n{s}", .{ out_buf[0..] });
if (struct_cmd.matchSubCmd("inner-cmd")) |inner_cmd| {
const inner_struct = try inner_cmd.to(DemoStruct.InnerStruct, .{});
@memset(out_buf[0..], 0);
//out_stream.pos = 0;
try zon.stringify.serializeMaxDepth(
inner_struct,
.{},
&out_writer,
10,
);
log.debug("->-> Inner Cmd\n{s}", .{ out_buf[0..] });
}
//for (struct_cmd.opts orelse break :structCmd) |opt| log.debug("->-> Opt: {s}, Idx: {d}", .{ opt.name, opt.arg_idx orelse continue });
break :structCmd;
}
if (main_cmd.checkSubCmd("union-cmd"))
log.debug("-> Union Cmd\nTo Union:\n{any}\n\n", .{ meta.activeTag(try main_cmd.sub_cmd.?.to(DemoUnion, .{})) });
if (main_cmd.matchSubCmd("fn-cmd")) |fn_cmd| {
log.debug("-> Fn Cmd", .{});
try fn_cmd.callAs(demoFn, null, void);
}
// Tokenization Example
const arg_str = "cova struct-cmd --multi-str \"demo str\" -m 'a \"quoted string\"' -m \"A string using an 'apostrophe'\" -m (quick parans test) 50";
const args = try cova.tokenizeArgs(arg_str, alloc, .{ .groupers_open = "\"'(", .groupers_close = "\"')" });
defer alloc.free(args);
log.debug("Tokenized Args:\n{f}", .{ MultiSliceF{ .slices = args } });
// Optimized Config
//log.debug("Optimized Config:\n{any}", .{ conf_optimized });
}
| 27,128 | covademo | zig | en | zig | code | {"qsc_code_num_words": 2682, "qsc_code_num_chars": 27128.0, "qsc_code_mean_word_length": 4.46718867, "qsc_code_frac_words_unique": 0.14765101, "qsc_code_frac_chars_top_2grams": 0.02704282, "qsc_code_frac_chars_top_3grams": 0.02687589, "qsc_code_frac_chars_top_4grams": 0.01126784, "qsc_code_frac_chars_dupe_5grams": 0.31074201, "qsc_code_frac_chars_dupe_6grams": 0.2473917, "qsc_code_frac_chars_dupe_7grams": 0.17043652, "qsc_code_frac_chars_dupe_8grams": 0.14706619, "qsc_code_frac_chars_dupe_9grams": 0.13938736, "qsc_code_frac_chars_dupe_10grams": 0.11718554, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01501502, "qsc_code_frac_chars_whitespace": 0.386243, "qsc_code_size_file_byte": 27128.0, "qsc_code_num_lines": 716.0, "qsc_code_num_chars_line_max": 163.0, "qsc_code_num_chars_line_mean": 37.88826816, "qsc_code_frac_chars_alphabet": 0.70456456, "qsc_code_frac_chars_comments": 0.20628133, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.2867784, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.00372439, "qsc_code_frac_chars_string_length": 0.14666543, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
0-1-0/lightblue-0.4 | src/mac/LightAquaBlue/OBEXFileTransferDictionary.plist | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>0001 - ServiceClassIDList</key>
<array>
<data>
EQY=
</data>
</array>
<key>0004 - ProtocolDescriptorList</key>
<array>
<array>
<data>
AQA=
</data>
</array>
<array>
<data>
AAM=
</data>
<dict>
<key>DataElementSize</key>
<integer>1</integer>
<key>DataElementType</key>
<integer>1</integer>
<key>DataElementValue</key>
<integer>3</integer>
</dict>
</array>
<array>
<data>
AAg=
</data>
</array>
</array>
<key>0005 - BrowseGroupList*</key>
<array>
<data>
EAI=
</data>
</array>
<key>0006 - LanguageBaseAttributeIDList*</key>
<array>
<dict>
<key>DataElementSize</key>
<integer>2</integer>
<key>DataElementType</key>
<integer>1</integer>
<key>DataElementValue</key>
<integer>25966</integer>
</dict>
<dict>
<key>DataElementSize</key>
<integer>2</integer>
<key>DataElementType</key>
<integer>1</integer>
<key>DataElementValue</key>
<integer>106</integer>
</dict>
<dict>
<key>DataElementSize</key>
<integer>2</integer>
<key>DataElementType</key>
<integer>1</integer>
<key>DataElementValue</key>
<integer>256</integer>
</dict>
</array>
<key>0009 - BluetoothProfileDescriptorList</key>
<array>
<array>
<data>
EQY=
</data>
<dict>
<key>DataElementSize</key>
<integer>2</integer>
<key>DataElementType</key>
<integer>1</integer>
<key>DataElementValue</key>
<integer>256</integer>
</dict>
</array>
</array>
<key>0303 - Supported Formats List</key>
<array>
<dict>
<key>DataElementType</key>
<integer>1</integer>
<key>DataElementValue</key>
<data>
/w==
</data>
</dict>
</array>
</dict>
</plist>
| 1,888 | OBEXFileTransferDictionary | plist | en | openstep property list | data | {"qsc_code_num_words": 211, "qsc_code_num_chars": 1888.0, "qsc_code_mean_word_length": 5.48815166, "qsc_code_frac_words_unique": 0.2464455, "qsc_code_frac_chars_top_2grams": 0.13816926, "qsc_code_frac_chars_top_3grams": 0.06649396, "qsc_code_frac_chars_top_4grams": 0.10880829, "qsc_code_frac_chars_dupe_5grams": 0.56217617, "qsc_code_frac_chars_dupe_6grams": 0.56131261, "qsc_code_frac_chars_dupe_7grams": 0.52677029, "qsc_code_frac_chars_dupe_8grams": 0.52677029, "qsc_code_frac_chars_dupe_9grams": 0.52677029, "qsc_code_frac_chars_dupe_10grams": 0.47668394, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.03841146, "qsc_code_frac_chars_whitespace": 0.18644068, "qsc_code_size_file_byte": 1888.0, "qsc_code_num_lines": 98.0, "qsc_code_num_chars_line_max": 112.0, "qsc_code_num_chars_line_mean": 19.26530612, "qsc_code_frac_chars_alphabet": 0.71549479, "qsc_code_frac_chars_comments": 0.0, "qsc_code_cate_xml_start": 1.0, "qsc_code_frac_lines_dupe_lines": 0.81632653, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.04925847, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_words_unique": 1, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 1, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 1, "qsc_code_cate_autogen": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0} |
00JCIV00/cova | examples/logger.zig | const std = @import("std");
const log = std.log;
const cova = @import("cova");
// We need to add any Enums we're using to our Value Config.
pub const CommandT = cova.Command.Custom(.{
.val_config = .{
.custom_types = &.{ log.Level },
},
});
pub const setup_cmd = CommandT{
.name = "logger",
.description = "A small demo of using the Log Level Enum as an Option.",
.opts = &.{
.{
.name = "log_level",
.description = "An Option using the `log.Level` Enum.",
.long_name = "log-level",
.mandatory = true,
.val = CommandT.ValueT.ofType(log.Level, .{
.name = "log_level_val",
.description = " This Value will handle then Enum."
})
}
},
};
pub fn main() !void {
var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{};
const alloc = gpa.allocator();
defer if (gpa.deinit() != .ok and gpa.detectLeaks()) log.err("Memory leak detected!", .{});
var stdout_file = std.fs.File.stdout();
var stdout_buf: [4096]u8 = undefined;
var stdout_writer = stdout_file.writer(stdout_buf[0..]);
const stdout = &stdout_writer.interface;
defer stdout.flush() catch {};
var main_cmd = try setup_cmd.init(alloc, .{});
defer main_cmd.deinit();
var args_iter = try cova.ArgIteratorGeneric.init(alloc);
defer args_iter.deinit();
cova.parseArgs(&args_iter, CommandT, main_cmd, stdout, .{}) catch |err| switch (err) {
error.UsageHelpCalled => return,
else => return err,
};
const main_opts = try main_cmd.getOpts(.{});
const log_lvl_opt = main_opts.get("log_level").?;
const log_lvl = log_lvl_opt.val.getAs(log.Level) catch {
log.err("The provided Log Level was invalid.", .{});
return;
};
log.info("Provided Log Level: {s}", .{ @tagName(log_lvl) });
}
| 1,881 | logger | zig | en | zig | code | {"qsc_code_num_words": 236, "qsc_code_num_chars": 1881.0, "qsc_code_mean_word_length": 4.58050847, "qsc_code_frac_words_unique": 0.42372881, "qsc_code_frac_chars_top_2grams": 0.08140611, "qsc_code_frac_chars_top_3grams": 0.0333025, "qsc_code_frac_chars_top_4grams": 0.02960222, "qsc_code_frac_chars_dupe_5grams": 0.03700278, "qsc_code_frac_chars_dupe_6grams": 0.0, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0042796, "qsc_code_frac_chars_whitespace": 0.25465178, "qsc_code_size_file_byte": 1881.0, "qsc_code_num_lines": 55.0, "qsc_code_num_chars_line_max": 96.0, "qsc_code_num_chars_line_mean": 34.2, "qsc_code_frac_chars_alphabet": 0.76676177, "qsc_code_frac_chars_comments": 0.03242956, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.06122449, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.14120879, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/FlavourBuff.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.watabou.noosa.Image;
//buff whose only internal logic is to wait and detach after a time.
public class FlavourBuff extends Buff {
@Override
public boolean act() {
detach();
return true;
}
public static void greyIcon(Image icon, float startGrey, float remaining){
if (remaining >= startGrey){
icon.resetColor();
} else {
icon.tint(0xb3b3b3, 0.6f + 0.3f*(startGrey - remaining)/startGrey);
}
}
//flavour buffs can all just rely on cooldown()
protected String dispTurns() {
//add one turn as buffs act last, we want them to end at 1 visually, even if they end at 0 internally.
return dispTurns(cooldown()+1f);
}
}
| 1,502 | FlavourBuff | java | en | java | code | {"qsc_code_num_words": 220, "qsc_code_num_chars": 1502.0, "qsc_code_mean_word_length": 4.96818182, "qsc_code_frac_words_unique": 0.64545455, "qsc_code_frac_chars_top_2grams": 0.03019213, "qsc_code_frac_chars_top_3grams": 0.03568161, "qsc_code_frac_chars_top_4grams": 0.05215005, "qsc_code_frac_chars_dupe_5grams": 0.07502287, "qsc_code_frac_chars_dupe_6grams": 0.05123513, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02302632, "qsc_code_frac_chars_whitespace": 0.19041278, "qsc_code_size_file_byte": 1502.0, "qsc_code_num_lines": 47.0, "qsc_code_num_chars_line_max": 105.0, "qsc_code_num_chars_line_mean": 31.95744681, "qsc_code_frac_chars_alphabet": 0.87582237, "qsc_code_frac_chars_comments": 0.6644474, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.01587302, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.21052632, "qsc_codejava_score_lines_no_logic": 0.36842105, "qsc_codejava_frac_words_no_modifier": 0.6, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 1, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Fury.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
public class Fury extends Buff {
public static float LEVEL = 0.5f;
{
type = buffType.POSITIVE;
announced = true;
}
@Override
public boolean act() {
if (target.HP > target.HT * LEVEL) {
detach();
}
spend( TICK );
return true;
}
@Override
public int icon() {
return BuffIndicator.FURY;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String heroMessage() {
return Messages.get(this, "heromsg");
}
@Override
public String desc() {
return Messages.get(this, "desc");
}
}
| 1,550 | Fury | java | en | java | code | {"qsc_code_num_words": 204, "qsc_code_num_chars": 1550.0, "qsc_code_mean_word_length": 5.45098039, "qsc_code_frac_words_unique": 0.59313725, "qsc_code_frac_chars_top_2grams": 0.06294964, "qsc_code_frac_chars_top_3grams": 0.03507194, "qsc_code_frac_chars_top_4grams": 0.05125899, "qsc_code_frac_chars_dupe_5grams": 0.07374101, "qsc_code_frac_chars_dupe_6grams": 0.05035971, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01517572, "qsc_code_frac_chars_whitespace": 0.19225806, "qsc_code_size_file_byte": 1550.0, "qsc_code_num_lines": 65.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 23.84615385, "qsc_code_frac_chars_alphabet": 0.87300319, "qsc_code_frac_chars_comments": 0.50387097, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.14705882, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01950585, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.14705882, "qsc_codejava_score_lines_no_logic": 0.26470588, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Bless.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class Bless extends FlavourBuff {
public static final float DURATION = 30f;
{
type = buffType.POSITIVE;
announced = true;
}
@Override
public int icon() {
return BuffIndicator.BLESS;
}
@Override
public void tintIcon(Image icon) {
greyIcon(icon, 5f, cooldown());
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,477 | Bless | java | en | java | code | {"qsc_code_num_words": 196, "qsc_code_num_chars": 1477.0, "qsc_code_mean_word_length": 5.56122449, "qsc_code_frac_words_unique": 0.6122449, "qsc_code_frac_chars_top_2grams": 0.05137615, "qsc_code_frac_chars_top_3grams": 0.03577982, "qsc_code_frac_chars_top_4grams": 0.05229358, "qsc_code_frac_chars_dupe_5grams": 0.07522936, "qsc_code_frac_chars_dupe_6grams": 0.05137615, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01644737, "qsc_code_frac_chars_whitespace": 0.17670955, "qsc_code_size_file_byte": 1477.0, "qsc_code_num_lines": 55.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 26.85454545, "qsc_code_frac_chars_alphabet": 0.87993421, "qsc_code_frac_chars_comments": 0.52877454, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.14814815, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01149425, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.14814815, "qsc_codejava_score_lines_no_logic": 0.2962963, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/ToxicImbue.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
import com.watabou.utils.Bundle;
public class ToxicImbue extends Buff {
{
type = buffType.POSITIVE;
announced = true;
}
public static final float DURATION = 50f;
protected float left;
private static final String LEFT = "left";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( LEFT, left );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
left = bundle.getFloat( LEFT );
}
public void set( float duration ) {
this.left = duration;
}
@Override
public boolean act() {
GameScene.add(Blob.seed(target.pos, 50, ToxicGas.class));
spend(TICK);
left -= TICK;
if (left <= 0){
detach();
} else if (left < 5){
BuffIndicator.refreshHero();
}
return true;
}
@Override
public int icon() {
return BuffIndicator.IMMUNITY;
}
@Override
public void tintIcon(Image icon) {
FlavourBuff.greyIcon(icon, 5f, left);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns(left));
}
{
immunities.add( ToxicGas.class );
immunities.add( Poison.class );
}
}
| 2,432 | ToxicImbue | java | en | java | code | {"qsc_code_num_words": 303, "qsc_code_num_chars": 2432.0, "qsc_code_mean_word_length": 5.86138614, "qsc_code_frac_words_unique": 0.5049505, "qsc_code_frac_chars_top_2grams": 0.03547297, "qsc_code_frac_chars_top_3grams": 0.12837838, "qsc_code_frac_chars_top_4grams": 0.12387387, "qsc_code_frac_chars_dupe_5grams": 0.13738739, "qsc_code_frac_chars_dupe_6grams": 0.09346847, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01191067, "qsc_code_frac_chars_whitespace": 0.17146382, "qsc_code_size_file_byte": 2432.0, "qsc_code_num_lines": 100.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 24.32, "qsc_code_frac_chars_alphabet": 0.86947891, "qsc_code_frac_chars_comments": 0.32113487, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.11290323, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00726832, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.12903226, "qsc_codejava_score_lines_no_logic": 0.29032258, "qsc_codejava_frac_words_no_modifier": 0.88888889, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Recharging.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class Recharging extends FlavourBuff {
{
type = buffType.POSITIVE;
}
@Override
public int icon() {
return BuffIndicator.RECHARGING;
}
@Override
public void tintIcon(Image icon) {
FlavourBuff.greyIcon(icon, 5f, cooldown());
}
@Override
public String toString() {
return Messages.get(this, "name");
}
//want to process partial turns for this buff, and not count it when it's expiring.
//firstly, if this buff has half a turn left, should give out half the benefit.
//secondly, recall that buffs execute in random order, so this can cause a problem where we can't simply check
//if this buff is still attached, must instead directly check its remaining time, and act accordingly.
//otherwise this causes inconsistent behaviour where this may detach before, or after, a wand charger acts.
public float remainder() {
return Math.min(1f, this.cooldown());
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,998 | Recharging | java | en | java | code | {"qsc_code_num_words": 281, "qsc_code_num_chars": 1998.0, "qsc_code_mean_word_length": 5.30960854, "qsc_code_frac_words_unique": 0.60498221, "qsc_code_frac_chars_top_2grams": 0.03753351, "qsc_code_frac_chars_top_3grams": 0.02613941, "qsc_code_frac_chars_top_4grams": 0.03820375, "qsc_code_frac_chars_dupe_5grams": 0.05495979, "qsc_code_frac_chars_dupe_6grams": 0.03753351, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01150121, "qsc_code_frac_chars_whitespace": 0.17317317, "qsc_code_size_file_byte": 1998.0, "qsc_code_num_lines": 61.0, "qsc_code_num_chars_line_max": 112.0, "qsc_code_num_chars_line_mean": 32.75409836, "qsc_code_frac_chars_alphabet": 0.89164649, "qsc_code_frac_chars_comments": 0.63163163, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.14285714, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01086957, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.17857143, "qsc_codejava_score_lines_no_logic": 0.32142857, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/ShieldBuff.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.watabou.utils.Bundle;
public abstract class ShieldBuff extends Buff {
private int shielding;
@Override
public boolean attachTo(Char target) {
if (super.attachTo(target)) {
target.needsShieldUpdate = true;
return true;
} else {
return false;
}
}
@Override
public void detach() {
target.needsShieldUpdate = true;
super.detach();
}
public int shielding(){
return shielding;
}
public void setShield( int shield ) {
this.shielding = shield;
target.needsShieldUpdate = true;
}
public void incShield(){
incShield(1);
}
public void incShield( int amt ){
shielding += amt;
target.needsShieldUpdate = true;
}
public void decShield(){
decShield(1);
}
public void decShield( int amt ){
shielding -= amt;
target.needsShieldUpdate = true;
}
//returns the amount of damage leftover
public int absorbDamage( int dmg ){
if (shielding >= dmg){
shielding -= dmg;
dmg = 0;
} else {
dmg -= shielding;
shielding = 0;
}
if (shielding == 0){
detach();
}
target.needsShieldUpdate = true;
return dmg;
}
private static final String SHIELDING = "shielding";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( SHIELDING, shielding);
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
shielding = bundle.getInt( SHIELDING );
}
}
| 2,408 | ShieldBuff | java | en | java | code | {"qsc_code_num_words": 291, "qsc_code_num_chars": 2408.0, "qsc_code_mean_word_length": 5.86941581, "qsc_code_frac_words_unique": 0.44329897, "qsc_code_frac_chars_top_2grams": 0.04683841, "qsc_code_frac_chars_top_3grams": 0.09484778, "qsc_code_frac_chars_top_4grams": 0.03337237, "qsc_code_frac_chars_dupe_5grams": 0.26053864, "qsc_code_frac_chars_dupe_6grams": 0.08548009, "qsc_code_frac_chars_dupe_7grams": 0.05269321, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01139896, "qsc_code_frac_chars_whitespace": 0.19850498, "qsc_code_size_file_byte": 2408.0, "qsc_code_num_lines": 105.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 22.93333333, "qsc_code_frac_chars_alphabet": 0.87357513, "qsc_code_frac_chars_comments": 0.34011628, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.17910448, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00566394, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.1641791, "qsc_codejava_score_lines_no_logic": 0.29850746, "qsc_codejava_frac_words_no_modifier": 0.91666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Levitation.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class Levitation extends FlavourBuff {
{
type = buffType.POSITIVE;
}
public static final float DURATION = 20f;
@Override
public boolean attachTo( Char target ) {
if (super.attachTo( target )) {
target.flying = true;
Roots.detach( target, Roots.class );
return true;
} else {
return false;
}
}
@Override
public void detach() {
target.flying = false;
Dungeon.level.occupyCell(target );
super.detach();
}
@Override
public int icon() {
return BuffIndicator.LEVITATION;
}
@Override
public void tintIcon(Image icon) {
greyIcon(icon, 5f, cooldown());
}
@Override
public void fx(boolean on) {
if (on) target.sprite.add(CharSprite.State.LEVITATING);
else target.sprite.remove(CharSprite.State.LEVITATING);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 2,140 | Levitation | java | en | java | code | {"qsc_code_num_words": 268, "qsc_code_num_chars": 2140.0, "qsc_code_mean_word_length": 5.89925373, "qsc_code_frac_words_unique": 0.52238806, "qsc_code_frac_chars_top_2grams": 0.06198608, "qsc_code_frac_chars_top_3grams": 0.14421252, "qsc_code_frac_chars_top_4grams": 0.13915244, "qsc_code_frac_chars_dupe_5grams": 0.05186591, "qsc_code_frac_chars_dupe_6grams": 0.03542062, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01122334, "qsc_code_frac_chars_whitespace": 0.16728972, "qsc_code_size_file_byte": 2140.0, "qsc_code_num_lines": 81.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 26.41975309, "qsc_code_frac_chars_alphabet": 0.87598204, "qsc_code_frac_chars_comments": 0.36495327, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.14, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00588668, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.14, "qsc_codejava_score_lines_no_logic": 0.32, "qsc_codejava_frac_words_no_modifier": 0.875, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Swiftthistle;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class Invisibility extends FlavourBuff {
public static final float DURATION = 20f;
{
type = buffType.POSITIVE;
announced = true;
}
@Override
public boolean attachTo( Char target ) {
if (super.attachTo( target )) {
target.invisible++;
if (target instanceof Hero && ((Hero) target).subClass == HeroSubClass.ASSASSIN){
Buff.affect(target, Preparation.class);
}
return true;
} else {
return false;
}
}
@Override
public void detach() {
if (target.invisible > 0)
target.invisible--;
super.detach();
}
@Override
public int icon() {
return BuffIndicator.INVISIBLE;
}
@Override
public void tintIcon(Image icon) {
greyIcon(icon, 5f, cooldown());
}
@Override
public void fx(boolean on) {
if (on) target.sprite.add( CharSprite.State.INVISIBLE );
else if (target.invisible == 0) target.sprite.remove( CharSprite.State.INVISIBLE );
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
public static void dispel() {
Invisibility buff = Dungeon.hero.buff( Invisibility.class );
if (buff != null) {
buff.detach();
}
CloakOfShadows.cloakStealth cloakBuff = Dungeon.hero.buff( CloakOfShadows.cloakStealth.class );
if (cloakBuff != null) {
cloakBuff.dispel();
}
//these aren't forms of invisibilty, but do dispel at the same time as it.
TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff( TimekeepersHourglass.timeFreeze.class );
if (timeFreeze != null) {
timeFreeze.detach();
}
Preparation prep = Dungeon.hero.buff( Preparation.class );
if (prep != null){
prep.detach();
}
Swiftthistle.TimeBubble bubble = Dungeon.hero.buff( Swiftthistle.TimeBubble.class );
if (bubble != null){
bubble.detach();
}
}
}
| 3,426 | Invisibility | java | en | java | code | {"qsc_code_num_words": 400, "qsc_code_num_chars": 3426.0, "qsc_code_mean_word_length": 6.345, "qsc_code_frac_words_unique": 0.42, "qsc_code_frac_chars_top_2grams": 0.07368006, "qsc_code_frac_chars_top_3grams": 0.16469661, "qsc_code_frac_chars_top_4grams": 0.17336485, "qsc_code_frac_chars_dupe_5grams": 0.15918046, "qsc_code_frac_chars_dupe_6grams": 0.11032309, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00761246, "qsc_code_frac_chars_whitespace": 0.15645067, "qsc_code_size_file_byte": 3426.0, "qsc_code_num_lines": 116.0, "qsc_code_num_chars_line_max": 107.0, "qsc_code_num_chars_line_mean": 29.53448276, "qsc_code_frac_chars_alphabet": 0.87058824, "qsc_code_frac_chars_comments": 0.24956217, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0875, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00311163, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.1, "qsc_codejava_score_lines_no_logic": 0.275, "qsc_codejava_frac_words_no_modifier": 0.88888889, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/ArtifactRecharge.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
import com.watabou.utils.Bundle;
//TODO this may be very powerful, consider balancing
public class ArtifactRecharge extends Buff {
{
type = buffType.POSITIVE;
}
private int left;
@Override
public boolean act() {
if (target instanceof Hero){
Belongings b = ((Hero) target).belongings;
if (b.misc1 instanceof Artifact){
((Artifact)b.misc1).charge((Hero)target);
}
if (b.misc2 instanceof Artifact){
((Artifact)b.misc2).charge((Hero)target);
}
}
left--;
if (left <= 0){
detach();
} else {
spend(TICK);
}
return true;
}
public void set( int amount ){
left = amount;
}
public void prolong( int amount ){
left += amount;
}
@Override
public int icon() {
return BuffIndicator.RECHARGING;
}
@Override
public void tintIcon(Image icon) {
icon.hardlight(0, 1f, 0);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns(left+1));
}
private static final String LEFT = "left";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put( LEFT, left );
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
left = bundle.getInt(LEFT);
}
}
| 2,614 | ArtifactRecharge | java | en | java | code | {"qsc_code_num_words": 326, "qsc_code_num_chars": 2614.0, "qsc_code_mean_word_length": 5.8006135, "qsc_code_frac_words_unique": 0.46932515, "qsc_code_frac_chars_top_2grams": 0.03807509, "qsc_code_frac_chars_top_3grams": 0.14066631, "qsc_code_frac_chars_top_4grams": 0.13960867, "qsc_code_frac_chars_dupe_5grams": 0.18297197, "qsc_code_frac_chars_dupe_6grams": 0.0867266, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01205937, "qsc_code_frac_chars_whitespace": 0.17521041, "qsc_code_size_file_byte": 2614.0, "qsc_code_num_lines": 107.0, "qsc_code_num_chars_line_max": 74.0, "qsc_code_num_chars_line_mean": 24.42990654, "qsc_code_frac_chars_alphabet": 0.86502783, "qsc_code_frac_chars_comments": 0.31828615, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.10447761, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00673401, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.00934579, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.13432836, "qsc_codejava_score_lines_no_logic": 0.29850746, "qsc_codejava_frac_words_no_modifier": 0.9, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Drowsy.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Random;
public class Drowsy extends Buff {
{
type = buffType.NEUTRAL;
announced = true;
}
@Override
public int icon() {
return BuffIndicator.DROWSY;
}
public boolean attachTo( Char target ) {
if (!target.isImmune(Sleep.class) && super.attachTo(target)) {
if (cooldown() == 0)
spend(Random.Int(3, 6));
return true;
}
return false;
}
@Override
public boolean act(){
Buff.affect(target, MagicalSleep.class);
detach();
return true;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns(cooldown()+1));
}
}
| 1,722 | Drowsy | java | en | java | code | {"qsc_code_num_words": 225, "qsc_code_num_chars": 1722.0, "qsc_code_mean_word_length": 5.57777778, "qsc_code_frac_words_unique": 0.56444444, "qsc_code_frac_chars_top_2grams": 0.05418327, "qsc_code_frac_chars_top_3grams": 0.12111554, "qsc_code_frac_chars_top_4grams": 0.04541833, "qsc_code_frac_chars_dupe_5grams": 0.06533865, "qsc_code_frac_chars_dupe_6grams": 0.04462151, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01475755, "qsc_code_frac_chars_whitespace": 0.17363531, "qsc_code_size_file_byte": 1722.0, "qsc_code_num_lines": 66.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 26.09090909, "qsc_code_frac_chars_alphabet": 0.86718201, "qsc_code_frac_chars_comments": 0.45354239, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.16216216, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00850159, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.13513514, "qsc_codejava_score_lines_no_logic": 0.35135135, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Ooze.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Ooze extends Buff {
{
type = buffType.NEGATIVE;
announced = true;
}
private float left;
private static final String LEFT = "left";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( LEFT, left );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle(bundle);
//pre-0.7.0
if (bundle.contains( LEFT )) {
left = bundle.getFloat(LEFT);
} else {
left = 20;
}
}
@Override
public int icon() {
return BuffIndicator.OOZE;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String heroMessage() {
return Messages.get(this, "heromsg");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns(left));
}
public void set(float left){
this.left = left;
}
@Override
public boolean act() {
if (target.isAlive()) {
if (Dungeon.depth > 4)
target.damage( Dungeon.depth/5, this );
else if (Random.Int(2) == 0)
target.damage( 1, this );
if (!target.isAlive() && target == Dungeon.hero) {
Dungeon.fail( getClass() );
GLog.n( Messages.get(this, "ondeath") );
}
spend( TICK );
left -= TICK;
if (left <= 0){
detach();
}
} else {
detach();
}
if (Dungeon.level.water[target.pos]) {
detach();
}
return true;
}
}
| 2,541 | Ooze | java | en | java | code | {"qsc_code_num_words": 321, "qsc_code_num_chars": 2541.0, "qsc_code_mean_word_length": 5.4953271, "qsc_code_frac_words_unique": 0.47663551, "qsc_code_frac_chars_top_2grams": 0.05555556, "qsc_code_frac_chars_top_3grams": 0.10770975, "qsc_code_frac_chars_top_4grams": 0.09977324, "qsc_code_frac_chars_dupe_5grams": 0.07596372, "qsc_code_frac_chars_dupe_6grams": 0.03174603, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01363194, "qsc_code_frac_chars_whitespace": 0.19165683, "qsc_code_size_file_byte": 2541.0, "qsc_code_num_lines": 105.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 24.2, "qsc_code_frac_chars_alphabet": 0.84518014, "qsc_code_frac_chars_comments": 0.31168831, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.16666667, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01486564, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.11111111, "qsc_codejava_score_lines_no_logic": 0.23611111, "qsc_codejava_frac_words_no_modifier": 0.88888889, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Weakness.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
public class Weakness extends FlavourBuff {
public static final float DURATION = 40f;
{
type = buffType.NEGATIVE;
announced = true;
}
@Override
public int icon() {
return BuffIndicator.WEAKNESS;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String heroMessage() {
return Messages.get(this, "heromsg");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,450 | Weakness | java | en | java | code | {"qsc_code_num_words": 190, "qsc_code_num_chars": 1450.0, "qsc_code_mean_word_length": 5.64210526, "qsc_code_frac_words_unique": 0.6, "qsc_code_frac_chars_top_2grams": 0.05223881, "qsc_code_frac_chars_top_3grams": 0.0363806, "qsc_code_frac_chars_top_4grams": 0.05317164, "qsc_code_frac_chars_dupe_5grams": 0.07649254, "qsc_code_frac_chars_dupe_6grams": 0.05223881, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0159129, "qsc_code_frac_chars_whitespace": 0.17655172, "qsc_code_size_file_byte": 1450.0, "qsc_code_num_lines": 54.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 26.85185185, "qsc_code_frac_chars_alphabet": 0.88190955, "qsc_code_frac_chars_comments": 0.53862069, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.15384615, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.02242152, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.15384615, "qsc_codejava_score_lines_no_logic": 0.26923077, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Adrenaline.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class Adrenaline extends FlavourBuff {
{
type = buffType.POSITIVE;
announced = true;
}
public static final float DURATION = 10f;
@Override
public int icon() {
return BuffIndicator.AMOK;
}
@Override
public void tintIcon(Image icon) {
greyIcon(icon, 5f, cooldown());
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,563 | Adrenaline | java | en | java | code | {"qsc_code_num_words": 203, "qsc_code_num_chars": 1563.0, "qsc_code_mean_word_length": 5.71428571, "qsc_code_frac_words_unique": 0.59605911, "qsc_code_frac_chars_top_2grams": 0.05862069, "qsc_code_frac_chars_top_3grams": 0.13103448, "qsc_code_frac_chars_top_4grams": 0.04913793, "qsc_code_frac_chars_dupe_5grams": 0.15517241, "qsc_code_frac_chars_dupe_6grams": 0.04827586, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01547988, "qsc_code_frac_chars_whitespace": 0.17338452, "qsc_code_size_file_byte": 1563.0, "qsc_code_num_lines": 59.0, "qsc_code_num_chars_line_max": 74.0, "qsc_code_num_chars_line_mean": 26.49152542, "qsc_code_frac_chars_alphabet": 0.88235294, "qsc_code_frac_chars_comments": 0.49904031, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.14285714, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01021711, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.14285714, "qsc_codejava_score_lines_no_logic": 0.32142857, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Awareness.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
public class Awareness extends FlavourBuff {
{
type = buffType.POSITIVE;
}
public static final float DURATION = 2f;
@Override
public void detach() {
super.detach();
Dungeon.observe();
GameScene.updateFog();
}
}
| 1,199 | Awareness | java | en | java | code | {"qsc_code_num_words": 162, "qsc_code_num_chars": 1199.0, "qsc_code_mean_word_length": 5.54938272, "qsc_code_frac_words_unique": 0.64814815, "qsc_code_frac_chars_top_2grams": 0.03670745, "qsc_code_frac_chars_top_3grams": 0.04338154, "qsc_code_frac_chars_top_4grams": 0.06340378, "qsc_code_frac_chars_dupe_5grams": 0.09121246, "qsc_code_frac_chars_dupe_6grams": 0.06229143, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0182002, "qsc_code_frac_chars_whitespace": 0.17514595, "qsc_code_size_file_byte": 1199.0, "qsc_code_num_lines": 40.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 29.975, "qsc_code_frac_chars_alphabet": 0.89079879, "qsc_code_frac_chars_comments": 0.65137615, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.26666667, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/PrismaticGuard.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.PrismaticImage;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
import com.watabou.utils.Bundle;
import com.watabou.utils.PathFinder;
public class PrismaticGuard extends Buff {
{
type = buffType.POSITIVE;
}
private float HP;
@Override
public boolean act() {
Hero hero = (Hero)target;
Mob closest = null;
int v = hero.visibleEnemies();
for (int i=0; i < v; i++) {
Mob mob = hero.visibleEnemy( i );
if ( mob.isAlive() && mob.state != mob.PASSIVE && mob.state != mob.WANDERING && mob.state != mob.SLEEPING && !hero.mindVisionEnemies.contains(mob)
&& (closest == null || Dungeon.level.distance(hero.pos, mob.pos) < Dungeon.level.distance(hero.pos, closest.pos))) {
closest = mob;
}
}
if (closest != null && Dungeon.level.distance(hero.pos, closest.pos) < 5){
//spawn guardian
int bestPos = -1;
for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
int p = hero.pos + PathFinder.NEIGHBOURS8[i];
if (Actor.findChar( p ) == null && Dungeon.level.passable[p]) {
if (bestPos == -1 || Dungeon.level.trueDistance(p, closest.pos) < Dungeon.level.trueDistance(bestPos, closest.pos)){
bestPos = p;
}
}
}
if (bestPos != -1) {
PrismaticImage pris = new PrismaticImage();
pris.duplicate(hero, (int)Math.floor(HP) );
pris.state = pris.HUNTING;
GameScene.add(pris, 1);
ScrollOfTeleportation.appear(pris, bestPos);
detach();
} else {
spend( TICK );
}
} else {
spend(TICK);
}
LockedFloor lock = target.buff(LockedFloor.class);
if (HP < maxHP() && (lock == null || lock.regenOn())){
HP += 0.1f;
}
return true;
}
public void set( int HP ){
this.HP = HP;
}
public int maxHP(){
return maxHP((Hero)target);
}
public static int maxHP( Hero hero ){
return 8 + (int)Math.floor(hero.lvl * 2.5f);
}
@Override
public int icon() {
return BuffIndicator.ARMOR;
}
@Override
public void tintIcon(Image icon) {
icon.tint(0.5f, 0.5f, 1, 0.5f);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", (int)HP, maxHP());
}
private static final String HEALTH = "hp";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(HEALTH, HP);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
HP = bundle.getFloat(HEALTH);
}
}
| 3,912 | PrismaticGuard | java | en | java | code | {"qsc_code_num_words": 489, "qsc_code_num_chars": 3912.0, "qsc_code_mean_word_length": 5.57464213, "qsc_code_frac_words_unique": 0.38854806, "qsc_code_frac_chars_top_2grams": 0.03961849, "qsc_code_frac_chars_top_3grams": 0.13939839, "qsc_code_frac_chars_top_4grams": 0.14526779, "qsc_code_frac_chars_dupe_5grams": 0.17718269, "qsc_code_frac_chars_dupe_6grams": 0.10528247, "qsc_code_frac_chars_dupe_7grams": 0.04512106, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01184539, "qsc_code_frac_chars_whitespace": 0.1799591, "qsc_code_size_file_byte": 3912.0, "qsc_code_num_lines": 141.0, "qsc_code_num_chars_line_max": 150.0, "qsc_code_num_chars_line_mean": 27.74468085, "qsc_code_frac_chars_alphabet": 0.83790524, "qsc_code_frac_chars_comments": 0.20347648, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.11458333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00320924, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.11458333, "qsc_codejava_score_lines_no_logic": 0.27083333, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MindVision.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class MindVision extends FlavourBuff {
public static final float DURATION = 20f;
public int distance = 2;
{
type = buffType.POSITIVE;
announced = true;
}
@Override
public int icon() {
return BuffIndicator.MIND_VISION;
}
@Override
public void tintIcon(Image icon) {
greyIcon(icon, 5f, cooldown());
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public void detach() {
super.detach();
Dungeon.observe();
GameScene.updateFog();
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,742 | MindVision | java | en | java | code | {"qsc_code_num_words": 222, "qsc_code_num_chars": 1742.0, "qsc_code_mean_word_length": 5.83333333, "qsc_code_frac_words_unique": 0.58558559, "qsc_code_frac_chars_top_2grams": 0.06563707, "qsc_code_frac_chars_top_3grams": 0.14671815, "qsc_code_frac_chars_top_4grams": 0.13590734, "qsc_code_frac_chars_dupe_5grams": 0.06332046, "qsc_code_frac_chars_dupe_6grams": 0.04324324, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01448276, "qsc_code_frac_chars_whitespace": 0.16762342, "qsc_code_size_file_byte": 1742.0, "qsc_code_num_lines": 66.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 26.39393939, "qsc_code_frac_chars_alphabet": 0.87862069, "qsc_code_frac_chars_comments": 0.44833525, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13888889, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00832466, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.13888889, "qsc_codejava_score_lines_no_logic": 0.30555556, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/ArcaneArmor.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
import com.watabou.utils.Bundle;
//A magical version of barkskin, essentially
public class ArcaneArmor extends Buff {
{
type = buffType.POSITIVE;
}
private int level = 0;
private int interval = 1;
@Override
public boolean act() {
if (target.isAlive()) {
spend( interval );
if (--level <= 0) {
detach();
}
} else {
detach();
}
return true;
}
public int level() {
return level;
}
public void set( int value, int time ) {
//decide whether to override, preferring high value + low interval
if (Math.sqrt(interval)*level < Math.sqrt(time)*value) {
level = value;
interval = time;
spend(time - cooldown() - 1);
}
}
@Override
public int icon() {
return BuffIndicator.ARMOR;
}
@Override
public void tintIcon(Image icon) {
icon.tint(0.5f, 0, 1, 0.5f);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", level, dispTurns(cooldown()+1));
}
private static final String LEVEL = "level";
private static final String INTERVAL = "interval";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( INTERVAL, interval );
bundle.put( LEVEL, level );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
interval = bundle.getInt( INTERVAL );
level = bundle.getInt( LEVEL );
}
}
| 2,491 | ArcaneArmor | java | en | java | code | {"qsc_code_num_words": 315, "qsc_code_num_chars": 2491.0, "qsc_code_mean_word_length": 5.4952381, "qsc_code_frac_words_unique": 0.47619048, "qsc_code_frac_chars_top_2grams": 0.05661467, "qsc_code_frac_chars_top_3grams": 0.02253033, "qsc_code_frac_chars_top_4grams": 0.03292894, "qsc_code_frac_chars_dupe_5grams": 0.04737146, "qsc_code_frac_chars_dupe_6grams": 0.03235124, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01409869, "qsc_code_frac_chars_whitespace": 0.20272983, "qsc_code_size_file_byte": 2491.0, "qsc_code_num_lines": 106.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 23.5, "qsc_code_frac_chars_alphabet": 0.85750252, "qsc_code_frac_chars_comments": 0.35728623, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.140625, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0131168, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.140625, "qsc_codejava_score_lines_no_logic": 0.25, "qsc_codejava_frac_words_no_modifier": 0.9, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Frost.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.food.FrozenCarpaccio;
import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Random;
import java.util.ArrayList;
public class Frost extends FlavourBuff {
private static final float DURATION = 5f;
{
type = buffType.NEGATIVE;
announced = true;
}
@Override
public boolean attachTo( Char target ) {
if (super.attachTo( target )) {
target.paralysed++;
Buff.detach( target, Burning.class );
Buff.detach( target, Chill.class );
if (target instanceof Hero) {
Hero hero = (Hero)target;
ArrayList<Item> freezable = new ArrayList<>();
//does not reach inside of containers
for (Item i : hero.belongings.backpack.items){
if ((i instanceof Potion && !(i instanceof PotionOfStrength))
|| i instanceof MysteryMeat){
freezable.add(i);
}
}
if (!freezable.isEmpty()){
Item toFreeze = Random.element(freezable).detach( hero.belongings.backpack );
GLog.w( Messages.get(this, "freezes", toFreeze.toString()) );
if (toFreeze instanceof Potion){
((Potion) toFreeze).shatter(hero.pos);
} else if (toFreeze instanceof MysteryMeat){
FrozenCarpaccio carpaccio = new FrozenCarpaccio();
if (!carpaccio.collect( hero.belongings.backpack )) {
Dungeon.level.drop( carpaccio, target.pos ).sprite.drop();
}
}
}
} else if (target instanceof Thief) {
Item item = ((Thief) target).item;
if (item instanceof Potion && !(item instanceof PotionOfStrength)) {
((Potion) ((Thief) target).item).shatter(target.pos);
((Thief) target).item = null;
} else if (item instanceof MysteryMeat){
((Thief) target).item = new FrozenCarpaccio();
}
}
return true;
} else {
return false;
}
}
@Override
public void detach() {
super.detach();
if (target.paralysed > 0)
target.paralysed--;
if (Dungeon.level.water[target.pos])
Buff.prolong(target, Chill.class, 4f);
}
@Override
public int icon() {
return BuffIndicator.FROST;
}
@Override
public void fx(boolean on) {
if (on) target.sprite.add(CharSprite.State.FROZEN);
else target.sprite.remove(CharSprite.State.FROZEN);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
public static float duration( Char ch ) {
return DURATION;
}
}
| 4,125 | Frost | java | en | java | code | {"qsc_code_num_words": 477, "qsc_code_num_chars": 4125.0, "qsc_code_mean_word_length": 6.28092243, "qsc_code_frac_words_unique": 0.38155136, "qsc_code_frac_chars_top_2grams": 0.08511348, "qsc_code_frac_chars_top_3grams": 0.19025367, "qsc_code_frac_chars_top_4grams": 0.20560748, "qsc_code_frac_chars_dupe_5grams": 0.18291055, "qsc_code_frac_chars_dupe_6grams": 0.09145527, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00581564, "qsc_code_frac_chars_whitespace": 0.16630303, "qsc_code_size_file_byte": 4125.0, "qsc_code_num_lines": 135.0, "qsc_code_num_chars_line_max": 83.0, "qsc_code_num_chars_line_mean": 30.55555556, "qsc_code_frac_chars_alphabet": 0.86536784, "qsc_code_frac_chars_comments": 0.19830303, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.06451613, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00453583, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.07526882, "qsc_codejava_score_lines_no_logic": 0.29032258, "qsc_codejava_frac_words_no_modifier": 0.875, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Foresight.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
public class Foresight extends FlavourBuff {
{
type = buffType.POSITIVE;
announced = true;
}
@Override
public int icon() {
return BuffIndicator.FORESIGHT;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,399 | Foresight | java | en | java | code | {"qsc_code_num_words": 182, "qsc_code_num_chars": 1399.0, "qsc_code_mean_word_length": 5.75824176, "qsc_code_frac_words_unique": 0.58791209, "qsc_code_frac_chars_top_2grams": 0.0648855, "qsc_code_frac_chars_top_3grams": 0.14503817, "qsc_code_frac_chars_top_4grams": 0.05438931, "qsc_code_frac_chars_dupe_5grams": 0.17175573, "qsc_code_frac_chars_dupe_6grams": 0.05343511, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01462995, "qsc_code_frac_chars_whitespace": 0.16940672, "qsc_code_size_file_byte": 1399.0, "qsc_code_num_lines": 49.0, "qsc_code_num_chars_line_max": 74.0, "qsc_code_num_chars_line_mean": 28.55102041, "qsc_code_frac_chars_alphabet": 0.88726334, "qsc_code_frac_chars_comments": 0.5575411, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13636364, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01292407, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.13636364, "qsc_codejava_score_lines_no_logic": 0.31818182, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/BlobImmunity.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blizzard;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ConfusionGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.CorrosiveGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Electricity;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Freezing;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Inferno;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ParalyticGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.SmokeScreen;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.StenchGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.StormCloud;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Web;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class BlobImmunity extends FlavourBuff {
{
type = buffType.POSITIVE;
}
public static final float DURATION = 20f;
@Override
public int icon() {
return BuffIndicator.IMMUNITY;
}
@Override
public void tintIcon(Image icon) {
greyIcon(icon, 5f, cooldown());
}
@Override
public String toString() {
return Messages.get(this, "name");
}
{
//all harmful blobs
immunities.add( Blizzard.class );
immunities.add( ConfusionGas.class );
immunities.add( CorrosiveGas.class );
immunities.add( Electricity.class );
immunities.add( Fire.class );
immunities.add( Freezing.class );
immunities.add( Inferno.class );
immunities.add( ParalyticGas.class );
immunities.add( Regrowth.class );
immunities.add( SmokeScreen.class );
immunities.add( StenchGas.class );
immunities.add( StormCloud.class );
immunities.add( ToxicGas.class );
immunities.add( Web.class );
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 3,018 | BlobImmunity | java | en | java | code | {"qsc_code_num_words": 351, "qsc_code_num_chars": 3018.0, "qsc_code_mean_word_length": 6.75213675, "qsc_code_frac_words_unique": 0.39316239, "qsc_code_frac_chars_top_2grams": 0.12194093, "qsc_code_frac_chars_top_3grams": 0.27257384, "qsc_code_frac_chars_top_4grams": 0.29704641, "qsc_code_frac_chars_dupe_5grams": 0.35949367, "qsc_code_frac_chars_dupe_6grams": 0.34852321, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00754148, "qsc_code_frac_chars_whitespace": 0.12127237, "qsc_code_size_file_byte": 3018.0, "qsc_code_num_lines": 86.0, "qsc_code_num_chars_line_max": 75.0, "qsc_code_num_chars_line_mean": 35.09302326, "qsc_code_frac_chars_alphabet": 0.88612368, "qsc_code_frac_chars_comments": 0.26507621, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.07142857, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00360685, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.07142857, "qsc_codejava_score_lines_no_logic": 0.39285714, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Paralysis.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Paralysis extends FlavourBuff {
public static final float DURATION = 10f;
{
type = buffType.NEGATIVE;
announced = true;
}
@Override
public boolean attachTo( Char target ) {
if (super.attachTo( target )) {
target.paralysed++;
return true;
} else {
return false;
}
}
public void processDamage( int damage ){
if (target == null) return;
ParalysisResist resist = target.buff(ParalysisResist.class);
if (resist == null){
resist = Buff.affect(target, ParalysisResist.class);
}
resist.damage += damage;
if (Random.NormalIntRange(0, resist.damage) >= Random.NormalIntRange(0, target.HP)){
if (Dungeon.level.heroFOV[target.pos]) {
target.sprite.showStatus(CharSprite.NEUTRAL, Messages.get(this, "out"));
}
detach();
}
}
@Override
public void detach() {
super.detach();
if (target.paralysed > 0)
target.paralysed--;
}
@Override
public int icon() {
return BuffIndicator.PARALYSIS;
}
@Override
public void fx(boolean on) {
if (on) target.sprite.add(CharSprite.State.PARALYSED);
else target.sprite.remove(CharSprite.State.PARALYSED);
}
@Override
public String heroMessage() {
return Messages.get(this, "heromsg");
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
public static float duration( Char ch ) {
return DURATION;
}
public static class ParalysisResist extends Buff {
{
type = buffType.POSITIVE;
}
private int damage;
@Override
public boolean act() {
if (target.buff(Paralysis.class) == null) {
damage -= Math.ceil(damage / 10f);
if (damage >= 0) detach();
}
spend(TICK);
return true;
}
private static final String DAMAGE = "damage";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
damage = bundle.getInt(DAMAGE);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
bundle.put( DAMAGE, damage );
}
}
}
| 3,321 | Paralysis | java | en | java | code | {"qsc_code_num_words": 396, "qsc_code_num_chars": 3321.0, "qsc_code_mean_word_length": 5.97979798, "qsc_code_frac_words_unique": 0.41414141, "qsc_code_frac_chars_top_2grams": 0.05912162, "qsc_code_frac_chars_top_3grams": 0.09628378, "qsc_code_frac_chars_top_4grams": 0.09290541, "qsc_code_frac_chars_dupe_5grams": 0.03462838, "qsc_code_frac_chars_dupe_6grams": 0.02364865, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0091878, "qsc_code_frac_chars_whitespace": 0.18066847, "qsc_code_size_file_byte": 3321.0, "qsc_code_num_lines": 134.0, "qsc_code_num_chars_line_max": 87.0, "qsc_code_num_chars_line_mean": 24.78358209, "qsc_code_frac_chars_alphabet": 0.86108049, "qsc_code_frac_chars_comments": 0.23517013, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.12765957, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00944882, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.12765957, "qsc_codejava_score_lines_no_logic": 0.26595745, "qsc_codejava_frac_words_no_modifier": 0.92307692, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Buff.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
import com.watabou.utils.Reflection;
import java.text.DecimalFormat;
import java.util.HashSet;
public class Buff extends Actor {
public Char target;
{
actPriority = BUFF_PRIO; //low priority, towards the end of a turn
}
//determines how the buff is announced when it is shown.
public enum buffType {POSITIVE, NEGATIVE, NEUTRAL}
public buffType type = buffType.NEUTRAL;
//whether or not the buff announces its name
public boolean announced = false;
protected HashSet<Class> resistances = new HashSet<>();
public HashSet<Class> resistances() {
return new HashSet<>(resistances);
}
protected HashSet<Class> immunities = new HashSet<>();
public HashSet<Class> immunities() {
return new HashSet<>(immunities);
}
public boolean attachTo( Char target ) {
if (target.isImmune( getClass() )) {
return false;
}
this.target = target;
target.add( this );
if (target.buffs().contains(this)){
if (target.sprite != null) fx( true );
return true;
} else {
this.target = null;
return false;
}
}
public void detach() {
if (target.sprite != null) fx( false );
target.remove( this );
}
@Override
public boolean act() {
diactivate();
return true;
}
public int icon() {
return BuffIndicator.NONE;
}
public void tintIcon( Image icon ){
//do nothing by default
}
public void fx(boolean on) {
//do nothing by default
}
public String heroMessage(){
return null;
}
public String desc(){
return "";
}
//to handle the common case of showing how many turns are remaining in a buff description.
protected String dispTurns(float input){
return new DecimalFormat("#.##").format(input);
}
//creates a fresh instance of the buff and attaches that, this allows duplication.
public static<T extends Buff> T append( Char target, Class<T> buffClass ) {
T buff = Reflection.newInstance(buffClass);
buff.attachTo( target );
return buff;
}
public static<T extends FlavourBuff> T append( Char target, Class<T> buffClass, float duration ) {
T buff = append( target, buffClass );
buff.spend( duration * target.resist(buffClass) );
return buff;
}
//same as append, but prevents duplication.
public static<T extends Buff> T affect( Char target, Class<T> buffClass ) {
T buff = target.buff( buffClass );
if (buff != null) {
return buff;
} else {
return append( target, buffClass );
}
}
public static<T extends FlavourBuff> T affect( Char target, Class<T> buffClass, float duration ) {
T buff = affect( target, buffClass );
buff.spend( duration * target.resist(buffClass) );
return buff;
}
//postpones an already active buff, or creates & attaches a new buff and delays that.
public static<T extends FlavourBuff> T prolong( Char target, Class<T> buffClass, float duration ) {
T buff = affect( target, buffClass );
buff.postpone( duration * target.resist(buffClass) );
return buff;
}
public static void detach( Buff buff ) {
if (buff != null) {
buff.detach();
}
}
public static void detach( Char target, Class<? extends Buff> cl ) {
detach( target.buff( cl ) );
}
}
| 4,181 | Buff | java | en | java | code | {"qsc_code_num_words": 545, "qsc_code_num_chars": 4181.0, "qsc_code_mean_word_length": 5.42568807, "qsc_code_frac_words_unique": 0.36513761, "qsc_code_frac_chars_top_2grams": 0.02705445, "qsc_code_frac_chars_top_3grams": 0.03043625, "qsc_code_frac_chars_top_4grams": 0.03381806, "qsc_code_frac_chars_dupe_5grams": 0.30537707, "qsc_code_frac_chars_dupe_6grams": 0.21406831, "qsc_code_frac_chars_dupe_7grams": 0.15015218, "qsc_code_frac_chars_dupe_8grams": 0.09671965, "qsc_code_frac_chars_dupe_9grams": 0.09671965, "qsc_code_frac_chars_dupe_10grams": 0.08217788, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00502513, "qsc_code_frac_chars_whitespace": 0.19086343, "qsc_code_size_file_byte": 4181.0, "qsc_code_num_lines": 158.0, "qsc_code_num_chars_line_max": 101.0, "qsc_code_num_chars_line_mean": 26.46202532, "qsc_code_frac_chars_alphabet": 0.86905114, "qsc_code_frac_chars_comments": 0.30327673, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.17, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00137315, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.12, "qsc_codejava_score_lines_no_logic": 0.32, "qsc_codejava_frac_words_no_modifier": 0.84615385, "qsc_codejava_frac_words_legal_var_name": 0.44444444, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Blindness.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
public class Blindness extends FlavourBuff {
{
type = buffType.NEGATIVE;
announced = true;
}
@Override
public void detach() {
super.detach();
Dungeon.observe();
}
@Override
public int icon() {
return BuffIndicator.BLINDNESS;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String heroMessage() {
return Messages.get(this, "heromsg");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,545 | Blindness | java | en | java | code | {"qsc_code_num_words": 197, "qsc_code_num_chars": 1545.0, "qsc_code_mean_word_length": 5.79187817, "qsc_code_frac_words_unique": 0.57360406, "qsc_code_frac_chars_top_2grams": 0.06134969, "qsc_code_frac_chars_top_3grams": 0.13321648, "qsc_code_frac_chars_top_4grams": 0.04995618, "qsc_code_frac_chars_dupe_5grams": 0.07186678, "qsc_code_frac_chars_dupe_6grams": 0.04907975, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01330203, "qsc_code_frac_chars_whitespace": 0.17281553, "qsc_code_size_file_byte": 1545.0, "qsc_code_num_lines": 59.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 26.18644068, "qsc_code_frac_chars_alphabet": 0.87949922, "qsc_code_frac_chars_comments": 0.50550162, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.16129032, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01963351, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.16129032, "qsc_codejava_score_lines_no_logic": 0.29032258, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Healing.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Bundle;
import com.watabou.utils.GameMath;
public class Healing extends Buff {
private int healingLeft;
private float percentHealPerTick;
private int flatHealPerTick;
{
//unlike other buffs, this one acts after the hero and takes priority against other effects
//healing is much more useful if you get some of it off before taking damage
actPriority = HERO_PRIO - 1;
type = buffType.POSITIVE;
}
@Override
public boolean act(){
target.HP = Math.min(target.HT, target.HP + healingThisTick());
healingLeft -= healingThisTick();
if (healingLeft <= 0){
detach();
}
spend( TICK );
return true;
}
private int healingThisTick(){
return (int)GameMath.gate(1,
Math.round(healingLeft * percentHealPerTick) + flatHealPerTick,
healingLeft);
}
public void setHeal(int amount, float percentPerTick, int flatPerTick){
healingLeft = amount;
percentHealPerTick = percentPerTick;
flatHealPerTick = flatPerTick;
}
public void increaseHeal( int amount ){
healingLeft += amount;
}
@Override
public void fx(boolean on) {
if (on) target.sprite.add( CharSprite.State.HEALING );
else target.sprite.remove( CharSprite.State.HEALING );
}
private static final String LEFT = "left";
private static final String PERCENT = "percent";
private static final String FLAT = "flat";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(LEFT, healingLeft);
bundle.put(PERCENT, percentHealPerTick);
bundle.put(FLAT, flatHealPerTick);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
healingLeft = bundle.getInt(LEFT);
percentHealPerTick = bundle.getFloat(PERCENT);
flatHealPerTick = bundle.getInt(FLAT);
}
@Override
public int icon() {
return BuffIndicator.HEALING;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", healingThisTick(), healingLeft);
}
}
| 3,113 | Healing | java | en | java | code | {"qsc_code_num_words": 373, "qsc_code_num_chars": 3113.0, "qsc_code_mean_word_length": 6.14209115, "qsc_code_frac_words_unique": 0.46380697, "qsc_code_frac_chars_top_2grams": 0.04277608, "qsc_code_frac_chars_top_3grams": 0.06634657, "qsc_code_frac_chars_top_4grams": 0.02487997, "qsc_code_frac_chars_dupe_5grams": 0.03579223, "qsc_code_frac_chars_dupe_6grams": 0.02444347, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00776699, "qsc_code_frac_chars_whitespace": 0.17282364, "qsc_code_size_file_byte": 3113.0, "qsc_code_num_lines": 117.0, "qsc_code_num_chars_line_max": 94.0, "qsc_code_num_chars_line_mean": 26.60683761, "qsc_code_frac_chars_alphabet": 0.88194175, "qsc_code_frac_chars_comments": 0.30452939, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09722222, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01062356, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.13888889, "qsc_codejava_score_lines_no_logic": 0.27777778, "qsc_codejava_frac_words_no_modifier": 0.90909091, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/FrostImbue.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SnowParticle;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class FrostImbue extends FlavourBuff {
{
type = buffType.POSITIVE;
announced = true;
}
public static final float DURATION = 50f;
public void proc(Char enemy){
Buff.affect(enemy, Chill.class, 2f);
enemy.sprite.emitter().burst( SnowParticle.FACTORY, 2 );
}
@Override
public int icon() {
return BuffIndicator.FROST;
}
@Override
public void tintIcon(Image icon) {
greyIcon(icon, 5f, cooldown());
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
{
immunities.add( Frost.class );
immunities.add( Chill.class );
}
}
| 2,111 | FrostImbue | java | en | java | code | {"qsc_code_num_words": 263, "qsc_code_num_chars": 2111.0, "qsc_code_mean_word_length": 6.1026616, "qsc_code_frac_words_unique": 0.52471483, "qsc_code_frac_chars_top_2grams": 0.0953271, "qsc_code_frac_chars_top_3grams": 0.21308411, "qsc_code_frac_chars_top_4grams": 0.21931464, "qsc_code_frac_chars_dupe_5grams": 0.24984424, "qsc_code_frac_chars_dupe_6grams": 0.17196262, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01222902, "qsc_code_frac_chars_whitespace": 0.14779725, "qsc_code_size_file_byte": 2111.0, "qsc_code_num_lines": 72.0, "qsc_code_num_chars_line_max": 80.0, "qsc_code_num_chars_line_mean": 29.31944444, "qsc_code_frac_chars_alphabet": 0.8799333, "qsc_code_frac_chars_comments": 0.36949313, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09756098, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00601052, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.12195122, "qsc_codejava_score_lines_no_logic": 0.36585366, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MagicalSight.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class MagicalSight extends FlavourBuff {
public static final float DURATION = 50f;
public int distance = 8;
{
type = buffType.POSITIVE;
announced = true;
}
@Override
public int icon() {
return BuffIndicator.MIND_VISION;
}
@Override
public void tintIcon(Image icon) {
greyIcon(icon, 5f, cooldown());
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public void detach() {
super.detach();
Dungeon.observe();
GameScene.updateFog();
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,824 | MagicalSight | java | en | java | code | {"qsc_code_num_words": 229, "qsc_code_num_chars": 1824.0, "qsc_code_mean_word_length": 5.95196507, "qsc_code_frac_words_unique": 0.56768559, "qsc_code_frac_chars_top_2grams": 0.07483492, "qsc_code_frac_chars_top_3grams": 0.16727806, "qsc_code_frac_chars_top_4grams": 0.16140866, "qsc_code_frac_chars_dupe_5grams": 0.13206163, "qsc_code_frac_chars_dupe_6grams": 0.04108584, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01377953, "qsc_code_frac_chars_whitespace": 0.16447368, "qsc_code_size_file_byte": 1824.0, "qsc_code_num_lines": 69.0, "qsc_code_num_chars_line_max": 74.0, "qsc_code_num_chars_line_mean": 26.43478261, "qsc_code_frac_chars_alphabet": 0.88057743, "qsc_code_frac_chars_comments": 0.42763158, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13513514, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00766284, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.13513514, "qsc_codejava_score_lines_no_logic": 0.32432432, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Barkskin.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Bundle;
public class Barkskin extends Buff {
{
type = buffType.POSITIVE;
}
private int level = 0;
private int interval = 1;
@Override
public boolean act() {
if (target.isAlive()) {
spend( interval );
if (--level <= 0) {
detach();
}
} else {
detach();
}
return true;
}
public int level() {
return level;
}
public void set( int value, int time ) {
//decide whether to override, preferring high value + low interval
if (Math.sqrt(interval)*level < Math.sqrt(time)*value) {
level = value;
interval = time;
spend(time - cooldown() - 1);
}
}
@Override
public int icon() {
return BuffIndicator.BARKSKIN;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", level, dispTurns(cooldown()+1));
}
private static final String LEVEL = "level";
private static final String INTERVAL = "interval";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( INTERVAL, interval );
bundle.put( LEVEL, level );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
interval = bundle.getInt( INTERVAL );
level = bundle.getInt( LEVEL );
}
}
| 2,326 | Barkskin | java | en | java | code | {"qsc_code_num_words": 290, "qsc_code_num_chars": 2326.0, "qsc_code_mean_word_length": 5.57931034, "qsc_code_frac_words_unique": 0.4862069, "qsc_code_frac_chars_top_2grams": 0.05191595, "qsc_code_frac_chars_top_3grams": 0.02410383, "qsc_code_frac_chars_top_4grams": 0.03522868, "qsc_code_frac_chars_dupe_5grams": 0.05067985, "qsc_code_frac_chars_dupe_6grams": 0.03461063, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01187905, "qsc_code_frac_chars_whitespace": 0.20378332, "qsc_code_size_file_byte": 2326.0, "qsc_code_num_lines": 98.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 23.73469388, "qsc_code_frac_chars_alphabet": 0.86177106, "qsc_code_frac_chars_comments": 0.36414445, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13559322, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01419878, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.13559322, "qsc_codejava_score_lines_no_logic": 0.23728814, "qsc_codejava_frac_words_no_modifier": 0.88888889, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Combo.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing;
import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.Callback;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
public class Combo extends Buff implements ActionIndicator.Action {
private int count = 0;
private float comboTime = 0f;
private int misses = 0;
@Override
public int icon() {
return BuffIndicator.COMBO;
}
@Override
public void tintIcon(Image icon) {
if (comboTime >= 3f){
icon.resetColor();
} else {
icon.tint(0xb3b3b3, 0.5f + 0.5f*(3f + 1 - comboTime)/3f);
}
}
@Override
public String toString() {
return Messages.get(this, "name");
}
public void hit( Char enemy ) {
count++;
comboTime = 4f;
misses = 0;
BuffIndicator.refreshHero();
if (count >= 2) {
ActionIndicator.setAction( this );
Badges.validateMasteryCombo( count );
GLog.p( Messages.get(this, "combo", count) );
}
}
public void miss( Char enemy ){
misses++;
comboTime = 4f;
if (misses >= 2){
detach();
}
}
@Override
public void detach() {
super.detach();
ActionIndicator.clearAction(this);
}
@Override
public boolean act() {
comboTime-=TICK;
spend(TICK);
BuffIndicator.refreshHero();
if (comboTime <= 0) {
detach();
}
return true;
}
@Override
public String desc() {
String desc = Messages.get(this, "desc");
if (count >= 10) desc += "\n\n" + Messages.get(this, "fury_desc");
else if (count >= 8)desc += "\n\n" + Messages.get(this, "crush_desc");
else if (count >= 6)desc += "\n\n" + Messages.get(this, "slam_desc");
else if (count >= 4)desc += "\n\n" + Messages.get(this, "cleave_desc");
else if (count >= 2)desc += "\n\n" + Messages.get(this, "clobber_desc");
return desc;
}
private static final String COUNT = "count";
private static final String TIME = "combotime";
private static final String MISSES= "misses";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(COUNT, count);
bundle.put(TIME, comboTime);
bundle.put(MISSES, misses);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
count = bundle.getInt( COUNT );
if (count >= 2) ActionIndicator.setAction(this);
comboTime = bundle.getFloat( TIME );
misses = bundle.getInt( MISSES );
}
@Override
public Image getIcon() {
Image icon;
if (((Hero)target).belongings.weapon != null){
icon = new ItemSprite(((Hero)target).belongings.weapon.image, null);
} else {
icon = new ItemSprite(new Item(){ {image = ItemSpriteSheet.WEAPON_HOLDER; }});
}
if (count >= 10) icon.tint(0xFFFF0000);
else if (count >= 8)icon.tint(0xFFFFCC00);
else if (count >= 6)icon.tint(0xFFFFFF00);
else if (count >= 4)icon.tint(0xFFCCFF00);
else icon.tint(0xFF00FF00);
return icon;
}
@Override
public void doAction() {
GameScene.selectCell(finisher);
}
private enum finisherType{
CLOBBER, CLEAVE, SLAM, CRUSH, FURY
}
private CellSelector.Listener finisher = new CellSelector.Listener() {
private finisherType type;
@Override
public void onSelect(Integer cell) {
if (cell == null) return;
final Char enemy = Actor.findChar( cell );
if (enemy == null
|| !Dungeon.level.heroFOV[cell]
|| !((Hero)target).canAttack(enemy)
|| target.isCharmedBy( enemy )){
GLog.w( Messages.get(Combo.class, "bad_target") );
} else {
target.sprite.attack(cell, new Callback() {
@Override
public void call() {
if (count >= 10) type = finisherType.FURY;
else if (count >= 8)type = finisherType.CRUSH;
else if (count >= 6)type = finisherType.SLAM;
else if (count >= 4)type = finisherType.CLEAVE;
else type = finisherType.CLOBBER;
doAttack(enemy);
}
});
}
}
private void doAttack(final Char enemy){
AttackIndicator.target(enemy);
int dmg = target.damageRoll();
//variance in damage dealt
switch(type){
case CLOBBER:
dmg = Math.round(dmg*0.6f);
break;
case CLEAVE:
dmg = Math.round(dmg*1.5f);
break;
case SLAM:
dmg += target.drRoll();
break;
case CRUSH:
//rolls 4 times, takes the highest roll
for (int i = 1; i < 4; i++) {
int dmgReroll = target.damageRoll();
if (dmgReroll > dmg) dmg = dmgReroll;
}
dmg = Math.round(dmg*2.5f);
break;
case FURY:
dmg = Math.round(dmg*0.6f);
break;
}
dmg = enemy.defenseProc(target, dmg);
dmg -= enemy.drRoll();
dmg = target.attackProc(enemy, dmg);
enemy.damage( dmg, this );
//special effects
switch (type){
case CLOBBER:
if (enemy.isAlive()){
if (!enemy.properties().contains(Char.Property.IMMOVABLE)){
for (int i = 0; i < PathFinder.NEIGHBOURS8.length; i++) {
int ofs = PathFinder.NEIGHBOURS8[i];
if (enemy.pos - target.pos == ofs) {
int newPos = enemy.pos + ofs;
if ((Dungeon.level.passable[newPos] || Dungeon.level.avoid[newPos])
&& Actor.findChar( newPos ) == null) {
Actor.addDelayed( new Pushing( enemy, enemy.pos, newPos ), -1 );
enemy.pos = newPos;
Dungeon.level.occupyCell(enemy );
}
break;
}
}
}
Buff.prolong(enemy, Vertigo.class, Random.NormalIntRange(1, 4));
}
break;
case SLAM:
BrokenSeal.WarriorShield shield = Buff.affect(target, BrokenSeal.WarriorShield.class);
if (shield != null) {
shield.supercharge(dmg / 2);
}
break;
default:
//nothing
break;
}
if (target.buff(FireImbue.class) != null)
target.buff(FireImbue.class).proc(enemy);
if (target.buff(EarthImbue.class) != null)
target.buff(EarthImbue.class).proc(enemy);
if (target.buff(FrostImbue.class) != null)
target.buff(FrostImbue.class).proc(enemy);
Sample.INSTANCE.play( Assets.SND_HIT, 1, 1, Random.Float( 0.8f, 1.25f ) );
enemy.sprite.bloodBurstA( target.sprite.center(), dmg );
enemy.sprite.flash();
if (!enemy.isAlive()){
GLog.i( Messages.capitalize(Messages.get(Char.class, "defeat", enemy.name)) );
}
Hero hero = (Hero)target;
//Post-attack behaviour
switch(type){
case CLEAVE:
if (!enemy.isAlive()) {
//combo isn't reset, but rather increments with a cleave kill, and grants more time.
hit( enemy );
comboTime = 12f;
} else {
detach();
ActionIndicator.clearAction(Combo.this);
}
hero.spendAndNext(hero.attackDelay());
break;
case FURY:
count--;
//fury attacks as many times as you have combo count
if (count > 0 && enemy.isAlive()){
target.sprite.attack(enemy.pos, new Callback() {
@Override
public void call() {
doAttack(enemy);
}
});
} else {
detach();
ActionIndicator.clearAction(Combo.this);
hero.spendAndNext(hero.attackDelay());
}
break;
default:
detach();
ActionIndicator.clearAction(Combo.this);
hero.spendAndNext(hero.attackDelay());
break;
}
}
@Override
public String prompt() {
if (count >= 10) return Messages.get(Combo.class, "fury_prompt");
else if (count >= 8)return Messages.get(Combo.class, "crush_prompt");
else if (count >= 6)return Messages.get(Combo.class, "slam_prompt");
else if (count >= 4)return Messages.get(Combo.class, "cleave_prompt");
else return Messages.get(Combo.class, "clobber_prompt");
}
};
}
| 9,566 | Combo | java | en | java | code | {"qsc_code_num_words": 1126, "qsc_code_num_chars": 9566.0, "qsc_code_mean_word_length": 5.64831261, "qsc_code_frac_words_unique": 0.25754885, "qsc_code_frac_chars_top_2grams": 0.03396226, "qsc_code_frac_chars_top_3grams": 0.11352201, "qsc_code_frac_chars_top_4grams": 0.1245283, "qsc_code_frac_chars_dupe_5grams": 0.22720126, "qsc_code_frac_chars_dupe_6grams": 0.1, "qsc_code_frac_chars_dupe_7grams": 0.04481132, "qsc_code_frac_chars_dupe_8grams": 0.03757862, "qsc_code_frac_chars_dupe_9grams": 0.03757862, "qsc_code_frac_chars_dupe_10grams": 0.03757862, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01406414, "qsc_code_frac_chars_whitespace": 0.20468325, "qsc_code_size_file_byte": 9566.0, "qsc_code_num_lines": 342.0, "qsc_code_num_chars_line_max": 92.0, "qsc_code_num_chars_line_mean": 27.97076023, "qsc_code_frac_chars_alphabet": 0.821898, "qsc_code_frac_chars_comments": 0.10777755, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.25842697, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0212068, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00679555, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06367041, "qsc_codejava_score_lines_no_logic": 0.17228464, "qsc_codejava_frac_words_no_modifier": 0.94444444, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MagicImmune.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class MagicImmune extends FlavourBuff {
{
type = buffType.POSITIVE;
announced = true;
}
{
immunities.addAll(AntiMagic.RESISTS);
}
//FIXME what about active buffs/debuffs?, what about rings? what about artifacts?
@Override
public int icon() {
return BuffIndicator.COMBO;
}
@Override
public void tintIcon(Image icon) {
icon.hardlight(0, 1, 0);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,721 | MagicImmune | java | en | java | code | {"qsc_code_num_words": 222, "qsc_code_num_chars": 1721.0, "qsc_code_mean_word_length": 5.8018018, "qsc_code_frac_words_unique": 0.58558559, "qsc_code_frac_chars_top_2grams": 0.06599379, "qsc_code_frac_chars_top_3grams": 0.14751553, "qsc_code_frac_chars_top_4grams": 0.13664596, "qsc_code_frac_chars_dupe_5grams": 0.13975155, "qsc_code_frac_chars_dupe_6grams": 0.04347826, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01390821, "qsc_code_frac_chars_whitespace": 0.16443928, "qsc_code_size_file_byte": 1721.0, "qsc_code_num_lines": 63.0, "qsc_code_num_chars_line_max": 83.0, "qsc_code_num_chars_line_mean": 27.31746032, "qsc_code_frac_chars_alphabet": 0.88178025, "qsc_code_frac_chars_comments": 0.50029053, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.12903226, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00930233, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.01587302, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.12903226, "qsc_codejava_score_lines_no_logic": 0.32258065, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 1, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Corrosion.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.Image;
import com.watabou.utils.Bundle;
public class Corrosion extends Buff implements Hero.Doom {
private float damage = 1;
protected float left;
private static final String DAMAGE = "damage";
private static final String LEFT = "left";
{
type = buffType.NEGATIVE;
announced = true;
}
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( DAMAGE, damage );
bundle.put( LEFT, left );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
damage = bundle.getFloat( DAMAGE );
left = bundle.getFloat( LEFT );
}
public void set(float duration, int damage) {
this.left = Math.max(duration, left);
if (this.damage < damage) this.damage = damage;
}
@Override
public int icon() {
return BuffIndicator.POISON;
}
@Override
public void tintIcon(Image icon) {
icon.hardlight(1f, 0.5f, 0f);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String heroMessage() {
return Messages.get(this, "heromsg");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns(left), (int)damage);
}
@Override
public boolean act() {
if (target.isAlive()) {
target.damage((int)damage, this);
if (damage < (Dungeon.depth/2)+2) {
damage++;
} else {
damage += 0.5f;
}
spend( TICK );
if ((left -= TICK) <= 0) {
detach();
}
} else {
detach();
}
return true;
}
@Override
public void onDeath() {
Dungeon.fail( getClass() );
GLog.n(Messages.get(this, "ondeath"));
}
}
| 2,802 | Corrosion | java | en | java | code | {"qsc_code_num_words": 350, "qsc_code_num_chars": 2802.0, "qsc_code_mean_word_length": 5.66571429, "qsc_code_frac_words_unique": 0.44857143, "qsc_code_frac_chars_top_2grams": 0.06354009, "qsc_code_frac_chars_top_3grams": 0.11497731, "qsc_code_frac_chars_top_4grams": 0.11094302, "qsc_code_frac_chars_dupe_5grams": 0.04135149, "qsc_code_frac_chars_dupe_6grams": 0.02824004, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01178525, "qsc_code_frac_chars_whitespace": 0.18236974, "qsc_code_size_file_byte": 2802.0, "qsc_code_num_lines": 115.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 24.36521739, "qsc_code_frac_chars_alphabet": 0.85377564, "qsc_code_frac_chars_comments": 0.27872948, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.16883117, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01583375, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.12987013, "qsc_codejava_score_lines_no_logic": 0.25974026, "qsc_codejava_frac_words_no_modifier": 0.90909091, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Barrier.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class Barrier extends ShieldBuff {
{
type = buffType.POSITIVE;
}
@Override
public boolean act() {
absorbDamage(1);
if (shielding() <= 0){
detach();
}
spend( TICK );
return true;
}
@Override
public void fx(boolean on) {
if (on) target.sprite.add(CharSprite.State.SHIELDED);
else target.sprite.remove(CharSprite.State.SHIELDED);
}
@Override
public int icon() {
return BuffIndicator.ARMOR;
}
@Override
public void tintIcon(Image icon) {
icon.tint(0, 0.5f, 1, 0.5f);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", shielding());
}
}
| 1,784 | Barrier | java | en | java | code | {"qsc_code_num_words": 233, "qsc_code_num_chars": 1784.0, "qsc_code_mean_word_length": 5.53648069, "qsc_code_frac_words_unique": 0.57081545, "qsc_code_frac_chars_top_2grams": 0.06511628, "qsc_code_frac_chars_top_3grams": 0.11782946, "qsc_code_frac_chars_top_4grams": 0.04418605, "qsc_code_frac_chars_dupe_5grams": 0.06356589, "qsc_code_frac_chars_dupe_6grams": 0.04341085, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01708817, "qsc_code_frac_chars_whitespace": 0.17993274, "qsc_code_size_file_byte": 1784.0, "qsc_code_num_lines": 74.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 24.10810811, "qsc_code_frac_chars_alphabet": 0.86466165, "qsc_code_frac_chars_comments": 0.43721973, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.15, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00796813, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.15, "qsc_codejava_score_lines_no_logic": 0.3, "qsc_codejava_frac_words_no_modifier": 0.85714286, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Stamina.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class Stamina extends FlavourBuff {
{
type = buffType.POSITIVE;
}
@Override
public int icon() {
return BuffIndicator.MOMENTUM;
}
@Override
public void tintIcon(Image icon) {
icon.tint(1, 1, 0, 0.5f);
if (cooldown() < 5f) greyIcon(icon, 5f, cooldown());
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,545 | Stamina | java | en | java | code | {"qsc_code_num_words": 205, "qsc_code_num_chars": 1545.0, "qsc_code_mean_word_length": 5.56585366, "qsc_code_frac_words_unique": 0.57073171, "qsc_code_frac_chars_top_2grams": 0.05959684, "qsc_code_frac_chars_top_3grams": 0.13321648, "qsc_code_frac_chars_top_4grams": 0.04995618, "qsc_code_frac_chars_dupe_5grams": 0.15775635, "qsc_code_frac_chars_dupe_6grams": 0.04907975, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01872075, "qsc_code_frac_chars_whitespace": 0.17022654, "qsc_code_size_file_byte": 1545.0, "qsc_code_num_lines": 56.0, "qsc_code_num_chars_line_max": 74.0, "qsc_code_num_chars_line_mean": 27.58928571, "qsc_code_frac_chars_alphabet": 0.87129485, "qsc_code_frac_chars_comments": 0.50485437, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.14814815, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01045752, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.14814815, "qsc_codejava_score_lines_no_logic": 0.33333333, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Freezing.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SnowParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.utils.Random;
public class Freezing extends Blob {
@Override
protected void evolve() {
int cell;
Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class );
for (int i = area.left-1; i <= area.right; i++) {
for (int j = area.top-1; j <= area.bottom; j++) {
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0) {
if (fire != null && fire.volume > 0 && fire.cur[cell] > 0){
fire.clear(cell);
off[cell] = cur[cell] = 0;
continue;
}
Freezing.freeze(cell);
off[cell] = cur[cell] - 1;
volume += off[cell];
} else {
off[cell] = 0;
}
}
}
}
public static void freeze( int cell ){
Char ch = Actor.findChar( cell );
if (ch != null && !ch.isImmune(Freezing.class)) {
if (ch.buff(Frost.class) != null){
Buff.affect(ch, Frost.class, 2f);
} else {
Buff.affect(ch, Chill.class, Dungeon.level.water[cell] ? 5f : 3f);
Chill chill = ch.buff(Chill.class);
if (chill != null && chill.cooldown() >= 10f){
Buff.affect(ch, Frost.class, 5f);
}
}
}
Heap heap = Dungeon.level.heaps.get( cell );
if (heap != null) heap.freeze();
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.start( SnowParticle.FACTORY, 0.05f, 0 );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
//legacy functionality from before this was a proper blob. Returns true if this cell is visible
public static boolean affect( int cell, Fire fire ) {
Char ch = Actor.findChar( cell );
if (ch != null) {
if (Dungeon.level.water[ch.pos]){
Buff.prolong(ch, Frost.class, Frost.duration(ch) * Random.Float(5f, 7.5f));
} else {
Buff.prolong(ch, Frost.class, Frost.duration(ch) * Random.Float(1.0f, 1.5f));
}
}
if (fire != null) {
fire.clear( cell );
}
Heap heap = Dungeon.level.heaps.get( cell );
if (heap != null) {
heap.freeze();
}
if (Dungeon.level.heroFOV[cell]) {
CellEmitter.get( cell ).start( SnowParticle.FACTORY, 0.2f, 6 );
return true;
} else {
return false;
}
}
}
| 3,710 | Freezing | java | en | java | code | {"qsc_code_num_words": 485, "qsc_code_num_chars": 3710.0, "qsc_code_mean_word_length": 5.22474227, "qsc_code_frac_words_unique": 0.35876289, "qsc_code_frac_chars_top_2grams": 0.08050513, "qsc_code_frac_chars_top_3grams": 0.17995264, "qsc_code_frac_chars_top_4grams": 0.19100237, "qsc_code_frac_chars_dupe_5grams": 0.33307024, "qsc_code_frac_chars_dupe_6grams": 0.191397, "qsc_code_frac_chars_dupe_7grams": 0.10418311, "qsc_code_frac_chars_dupe_8grams": 0.10418311, "qsc_code_frac_chars_dupe_9grams": 0.07971586, "qsc_code_frac_chars_dupe_10grams": 0.07971586, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.015005, "qsc_code_frac_chars_whitespace": 0.1916442, "qsc_code_size_file_byte": 3710.0, "qsc_code_num_lines": 124.0, "qsc_code_num_chars_line_max": 97.0, "qsc_code_num_chars_line_mean": 29.91935484, "qsc_code_frac_chars_alphabet": 0.82994331, "qsc_code_frac_chars_comments": 0.2361186, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.15294118, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00141143, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.05882353, "qsc_codejava_score_lines_no_logic": 0.24705882, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/SmokeScreen.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
public class SmokeScreen extends Blob {
@Override
protected void evolve() {
super.evolve();
int cell;
Level l = Dungeon.level;
for (int i = area.left; i < area.right; i++){
for (int j = area.top; j < area.bottom; j++){
cell = i + j*l.width();
l.losBlocking[cell] = off[cell] > 0 || (Terrain.flags[l.map[cell]] & Terrain.LOS_BLOCKING) != 0;
}
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour( Speck.factory( Speck.SMOKE ), 0.1f );
}
@Override
public void clear(int cell) {
super.clear(cell);
Level l = Dungeon.level;
l.losBlocking[cell] = cur[cell] > 0 || (Terrain.flags[l.map[cell]] & Terrain.LOS_BLOCKING) != 0;
}
@Override
public void fullyClear() {
super.fullyClear();
Dungeon.level.buildFlagMaps();
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 2,191 | SmokeScreen | java | en | java | code | {"qsc_code_num_words": 287, "qsc_code_num_chars": 2191.0, "qsc_code_mean_word_length": 5.54355401, "qsc_code_frac_words_unique": 0.46689895, "qsc_code_frac_chars_top_2grams": 0.08548083, "qsc_code_frac_chars_top_3grams": 0.1910748, "qsc_code_frac_chars_top_4grams": 0.19358894, "qsc_code_frac_chars_dupe_5grams": 0.34569453, "qsc_code_frac_chars_dupe_6grams": 0.11313639, "qsc_code_frac_chars_dupe_7grams": 0.0779384, "qsc_code_frac_chars_dupe_8grams": 0.0779384, "qsc_code_frac_chars_dupe_9grams": 0.0779384, "qsc_code_frac_chars_dupe_10grams": 0.0779384, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01256831, "qsc_code_frac_chars_whitespace": 0.16476495, "qsc_code_size_file_byte": 2191.0, "qsc_code_num_lines": 73.0, "qsc_code_num_chars_line_max": 101.0, "qsc_code_num_chars_line_mean": 30.01369863, "qsc_code_frac_chars_alphabet": 0.8568306, "qsc_code_frac_chars_comments": 0.35600183, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.16666667, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00283487, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.11904762, "qsc_codejava_score_lines_no_logic": 0.33333333, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/StenchGas.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
public class StenchGas extends Blob {
@Override
protected void evolve() {
super.evolve();
Char ch;
int cell;
for (int i = area.left; i < area.right; i++){
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0 && (ch = Actor.findChar( cell )) != null) {
if (!ch.isImmune(this.getClass()))
Buff.prolong( ch, Paralysis.class, Paralysis.DURATION/5 );
}
}
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour( Speck.factory(Speck.STENCH), 0.4f );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 2,028 | StenchGas | java | en | java | code | {"qsc_code_num_words": 263, "qsc_code_num_chars": 2028.0, "qsc_code_mean_word_length": 5.68821293, "qsc_code_frac_words_unique": 0.51330798, "qsc_code_frac_chars_top_2grams": 0.10227273, "qsc_code_frac_chars_top_3grams": 0.22860963, "qsc_code_frac_chars_top_4grams": 0.23529412, "qsc_code_frac_chars_dupe_5grams": 0.26336898, "qsc_code_frac_chars_dupe_6grams": 0.11096257, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01233118, "qsc_code_frac_chars_whitespace": 0.16025641, "qsc_code_size_file_byte": 2028.0, "qsc_code_num_lines": 63.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 32.19047619, "qsc_code_frac_chars_alphabet": 0.86611861, "qsc_code_frac_chars_comments": 0.38510848, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.08571429, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0032077, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.08571429, "qsc_codejava_score_lines_no_logic": 0.4, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Electricity.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SparkParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
public class Electricity extends Blob {
{
//acts after mobs, to give them a chance to resist paralysis
actPriority = MOB_PRIO - 1;
}
private boolean[] water;
@Override
protected void evolve() {
water = Dungeon.level.water;
int cell;
//spread first..
for (int i = area.left-1; i <= area.right; i++) {
for (int j = area.top-1; j <= area.bottom; j++) {
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0) {
spreadFromCell(cell, cur[cell]);
}
}
}
//..then decrement/shock
for (int i = area.left-1; i <= area.right; i++) {
for (int j = area.top-1; j <= area.bottom; j++) {
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0) {
Char ch = Actor.findChar( cell );
if (ch != null && !ch.isImmune(this.getClass())) {
Buff.prolong( ch, Paralysis.class, 1f);
if (cur[cell] % 2 == 1) {
ch.damage(Math.round(Random.Float(2 + Dungeon.depth / 5f)), this);
if (!ch.isAlive() && ch == Dungeon.hero){
Dungeon.fail( getClass() );
GLog.n( Messages.get(this, "ondeath") );
}
}
}
Heap h = Dungeon.level.heaps.get( cell );
if (h != null){
Item toShock = h.peek();
if (toShock instanceof Wand){
((Wand) toShock).gainCharge(0.333f);
} else if (toShock instanceof MagesStaff){
((MagesStaff) toShock).gainCharge(0.333f);
}
}
off[cell] = cur[cell] - 1;
volume += off[cell];
} else {
off[cell] = 0;
}
}
}
}
private void spreadFromCell( int cell, int power ){
if (cur[cell] == 0) {
area.union(cell % Dungeon.level.width(), cell / Dungeon.level.width());
}
cur[cell] = Math.max(cur[cell], power);
for (int c : PathFinder.NEIGHBOURS4){
if (water[cell + c] && cur[cell + c] < power){
spreadFromCell(cell + c, power);
}
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.start( SparkParticle.FACTORY, 0.05f, 0 );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 3,867 | Electricity | java | en | java | code | {"qsc_code_num_words": 486, "qsc_code_num_chars": 3867.0, "qsc_code_mean_word_length": 5.39300412, "qsc_code_frac_words_unique": 0.39917695, "qsc_code_frac_chars_top_2grams": 0.05150706, "qsc_code_frac_chars_top_3grams": 0.20297596, "qsc_code_frac_chars_top_4grams": 0.21823731, "qsc_code_frac_chars_dupe_5grams": 0.2914918, "qsc_code_frac_chars_dupe_6grams": 0.12972148, "qsc_code_frac_chars_dupe_7grams": 0.06638688, "qsc_code_frac_chars_dupe_8grams": 0.06638688, "qsc_code_frac_chars_dupe_9grams": 0.06638688, "qsc_code_frac_chars_dupe_10grams": 0.06638688, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0144648, "qsc_code_frac_chars_whitespace": 0.19550039, "qsc_code_size_file_byte": 3867.0, "qsc_code_num_lines": 127.0, "qsc_code_num_chars_line_max": 81.0, "qsc_code_num_chars_line_mean": 30.4488189, "qsc_code_frac_chars_alphabet": 0.82802957, "qsc_code_frac_chars_comments": 0.22782519, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.12790698, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00368386, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.04651163, "qsc_codejava_score_lines_no_logic": 0.24418605, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Blob.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.watabou.utils.Bundle;
import com.watabou.utils.Rect;
import com.watabou.utils.Reflection;
public class Blob extends Actor {
{
actPriority = BLOB_PRIO;
}
public int volume = 0;
public int[] cur;
protected int[] off;
public BlobEmitter emitter;
public Rect area = new Rect();
public boolean alwaysVisible = false;
private static final String CUR = "cur";
private static final String START = "start";
private static final String LENGTH = "length";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
if (volume > 0) {
int start;
for (start=0; start < Dungeon.level.length(); start++) {
if (cur[start] > 0) {
break;
}
}
int end;
for (end=Dungeon.level.length()-1; end > start; end--) {
if (cur[end] > 0) {
break;
}
}
bundle.put( START, start );
bundle.put( LENGTH, cur.length );
bundle.put( CUR, trim( start, end + 1 ) );
}
}
private int[] trim( int start, int end ) {
int len = end - start;
int[] copy = new int[len];
System.arraycopy( cur, start, copy, 0, len );
return copy;
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
if (bundle.contains( CUR )) {
cur = new int[bundle.getInt(LENGTH)];
off = new int[cur.length];
int[] data = bundle.getIntArray(CUR);
int start = bundle.getInt(START);
for (int i = 0; i < data.length; i++) {
cur[i + start] = data[i];
volume += data[i];
}
}
}
@Override
public boolean act() {
spend( TICK );
if (volume > 0) {
if (area.isEmpty())
setupArea();
volume = 0;
evolve();
int[] tmp = off;
off = cur;
cur = tmp;
} else {
if (!area.isEmpty()) {
area.setEmpty();
//clear any values remaining in off
System.arraycopy(cur, 0, off, 0, cur.length);
}
}
return true;
}
public void setupArea(){
for (int cell=0; cell < cur.length; cell++) {
if (cur[cell] != 0){
area.union(cell%Dungeon.level.width(), cell/Dungeon.level.width());
}
}
}
public void use( BlobEmitter emitter ) {
this.emitter = emitter;
}
protected void evolve() {
boolean[] blocking = Dungeon.level.solid;
int cell;
for (int i=area.top-1; i <= area.bottom; i++) {
for (int j = area.left-1; j <= area.right; j++) {
cell = j + i*Dungeon.level.width();
if (Dungeon.level.insideMap(cell)) {
if (!blocking[cell]) {
int count = 1;
int sum = cur[cell];
if (j > area.left && !blocking[cell-1]) {
sum += cur[cell-1];
count++;
}
if (j < area.right && !blocking[cell+1]) {
sum += cur[cell+1];
count++;
}
if (i > area.top && !blocking[cell-Dungeon.level.width()]) {
sum += cur[cell-Dungeon.level.width()];
count++;
}
if (i < area.bottom && !blocking[cell+Dungeon.level.width()]) {
sum += cur[cell+Dungeon.level.width()];
count++;
}
int value = sum >= count ? (sum / count) - 1 : 0;
off[cell] = value;
if (value > 0){
if (i < area.top)
area.top = i;
else if (i >= area.bottom)
area.bottom = i+1;
if (j < area.left)
area.left = j;
else if (j >= area.right)
area.right = j+1;
}
volume += value;
} else {
off[cell] = 0;
}
}
}
}
}
public void seed( Level level, int cell, int amount ) {
if (cur == null) cur = new int[level.length()];
if (off == null) off = new int[cur.length];
cur[cell] += amount;
volume += amount;
area.union(cell%level.width(), cell/level.width());
}
public void clear( int cell ) {
if (volume == 0) return;
volume -= cur[cell];
cur[cell] = 0;
}
public void fullyClear(){
volume = 0;
area.setEmpty();
cur = new int[Dungeon.level.length()];
off = new int[Dungeon.level.length()];
}
public String tileDesc() {
return null;
}
public static<T extends Blob> T seed( int cell, int amount, Class<T> type ) {
return seed(cell, amount, type, Dungeon.level);
}
@SuppressWarnings("unchecked")
public static<T extends Blob> T seed( int cell, int amount, Class<T> type, Level level ) {
T gas = (T)level.blobs.get( type );
if (gas == null) {
gas = Reflection.newInstance(type);
level.blobs.put( type, gas );
}
if (gas != null) {
level.blobs.put(type, gas);
gas.seed(level, cell, amount);
}
return gas;
}
public static int volumeAt( int cell, Class<? extends Blob> type){
Blob gas = Dungeon.level.blobs.get( type );
if (gas == null || gas.volume == 0) {
return 0;
} else {
return gas.cur[cell];
}
}
}
| 5,841 | Blob | java | en | java | code | {"qsc_code_num_words": 771, "qsc_code_num_chars": 5841.0, "qsc_code_mean_word_length": 4.63424125, "qsc_code_frac_words_unique": 0.23605707, "qsc_code_frac_chars_top_2grams": 0.05037783, "qsc_code_frac_chars_top_3grams": 0.03330535, "qsc_code_frac_chars_top_4grams": 0.03526448, "qsc_code_frac_chars_dupe_5grams": 0.15617128, "qsc_code_frac_chars_dupe_6grams": 0.11418976, "qsc_code_frac_chars_dupe_7grams": 0.09851665, "qsc_code_frac_chars_dupe_8grams": 0.09851665, "qsc_code_frac_chars_dupe_9grams": 0.0822838, "qsc_code_frac_chars_dupe_10grams": 0.06493143, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01134559, "qsc_code_frac_chars_whitespace": 0.24550591, "qsc_code_size_file_byte": 5841.0, "qsc_code_num_lines": 255.0, "qsc_code_num_chars_line_max": 92.0, "qsc_code_num_chars_line_mean": 22.90588235, "qsc_code_frac_chars_alphabet": 0.79941003, "qsc_code_frac_chars_comments": 0.13970211, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.10869565, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00457711, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06521739, "qsc_codejava_score_lines_no_logic": 0.16304348, "qsc_codejava_frac_words_no_modifier": 0.84615385, "qsc_codejava_frac_words_legal_var_name": 0.94117647, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Regrowth.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.LeafParticle;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
public class Regrowth extends Blob {
@Override
protected void evolve() {
super.evolve();
if (volume > 0) {
int cell;
for (int i = area.left; i < area.right; i++) {
for (int j = area.top; j < area.bottom; j++) {
cell = i + j*Dungeon.level.width();
if (off[cell] > 0) {
int c = Dungeon.level.map[cell];
int c1 = c;
if (c == Terrain.EMPTY || c == Terrain.EMBERS || c == Terrain.EMPTY_DECO) {
c1 = (cur[cell] > 9 && Actor.findChar( cell ) == null)
? Terrain.HIGH_GRASS : Terrain.GRASS;
} else if ((c == Terrain.GRASS || c == Terrain.FURROWED_GRASS)
&& cur[cell] > 9 && Dungeon.level.plants.get(cell) == null && Actor.findChar( cell ) == null ) {
c1 = Terrain.HIGH_GRASS;
}
if (c1 != c) {
Level.set( cell, c1 );
GameScene.updateMap( cell );
}
Char ch = Actor.findChar( cell );
if (ch != null
&& !ch.isImmune(this.getClass())
&& off[cell] > 1) {
Buff.prolong( ch, Roots.class, TICK );
}
}
}
}
Dungeon.observe();
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.start( LeafParticle.LEVEL_SPECIFIC, 0.2f, 0 );
}
}
| 2,736 | Regrowth | java | en | java | code | {"qsc_code_num_words": 342, "qsc_code_num_chars": 2736.0, "qsc_code_mean_word_length": 5.47660819, "qsc_code_frac_words_unique": 0.43859649, "qsc_code_frac_chars_top_2grams": 0.09983983, "qsc_code_frac_chars_top_3grams": 0.22317138, "qsc_code_frac_chars_top_4grams": 0.23491725, "qsc_code_frac_chars_dupe_5grams": 0.263748, "qsc_code_frac_chars_dupe_6grams": 0.08862787, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01369863, "qsc_code_frac_chars_whitespace": 0.1995614, "qsc_code_size_file_byte": 2736.0, "qsc_code_num_lines": 80.0, "qsc_code_num_chars_line_max": 105.0, "qsc_code_num_chars_line_mean": 34.2, "qsc_code_frac_chars_alphabet": 0.84155251, "qsc_code_frac_chars_comments": 0.28545322, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.03846154, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.03846154, "qsc_codejava_score_lines_no_logic": 0.26923077, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/StormCloud.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
public class StormCloud extends Blob {
@Override
protected void evolve() {
super.evolve();
int cell;
for (int i = area.left; i < area.right; i++){
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
if (off[cell] > 0) {
int terr = Dungeon.level.map[cell];
if (terr == Terrain.EMPTY || terr == Terrain.GRASS ||
terr == Terrain.EMBERS || terr == Terrain.EMPTY_SP ||
terr == Terrain.HIGH_GRASS || terr == Terrain.FURROWED_GRASS
|| terr == Terrain.EMPTY_DECO) {
Level.set(cell, Terrain.WATER);
GameScene.updateMap(cell);
} else if (terr == Terrain.SECRET_TRAP || terr == Terrain.TRAP || terr == Terrain.INACTIVE_TRAP) {
Level.set(cell, Terrain.WATER);
Dungeon.level.traps.remove(cell);
GameScene.updateMap(cell);
}
}
}
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour( Speck.factory( Speck.STORM ), 0.4f );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 2,440 | StormCloud | java | en | java | code | {"qsc_code_num_words": 308, "qsc_code_num_chars": 2440.0, "qsc_code_mean_word_length": 5.6461039, "qsc_code_frac_words_unique": 0.46753247, "qsc_code_frac_chars_top_2grams": 0.06325474, "qsc_code_frac_chars_top_3grams": 0.19666475, "qsc_code_frac_chars_top_4grams": 0.20241518, "qsc_code_frac_chars_dupe_5grams": 0.24726855, "qsc_code_frac_chars_dupe_6grams": 0.03220242, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00996016, "qsc_code_frac_chars_whitespace": 0.17704918, "qsc_code_size_file_byte": 2440.0, "qsc_code_num_lines": 73.0, "qsc_code_num_chars_line_max": 104.0, "qsc_code_num_chars_line_mean": 33.42465753, "qsc_code_frac_chars_alphabet": 0.8560757, "qsc_code_frac_chars_comments": 0.31967213, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.15909091, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00240964, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06818182, "qsc_codejava_score_lines_no_logic": 0.29545455, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/GooWarn.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.GooSprite;
public class GooWarn extends Blob {
//cosmetic blob, used to warn noobs that goo's pump up should, infact, be avoided.
{
//this one needs to act after the Goo
actPriority = MOB_PRIO - 1;
}
protected int pos;
@Override
protected void evolve() {
int cell;
for (int i = area.left; i < area.right; i++){
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
off[cell] = cur[cell] > 0 ? cur[cell] - 1 : 0;
if (off[cell] > 0) {
volume += off[cell];
}
}
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour(GooSprite.GooParticle.FACTORY, 0.03f );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 1,859 | GooWarn | java | en | java | code | {"qsc_code_num_words": 256, "qsc_code_num_chars": 1859.0, "qsc_code_mean_word_length": 5.16796875, "qsc_code_frac_words_unique": 0.56640625, "qsc_code_frac_chars_top_2grams": 0.06424792, "qsc_code_frac_chars_top_3grams": 0.143613, "qsc_code_frac_chars_top_4grams": 0.13303099, "qsc_code_frac_chars_dupe_5grams": 0.06198035, "qsc_code_frac_chars_dupe_6grams": 0.04232804, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01660027, "qsc_code_frac_chars_whitespace": 0.18988704, "qsc_code_size_file_byte": 1859.0, "qsc_code_num_lines": 70.0, "qsc_code_num_chars_line_max": 84.0, "qsc_code_num_chars_line_mean": 26.55714286, "qsc_code_frac_chars_alphabet": 0.86188579, "qsc_code_frac_chars_comments": 0.48413125, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09090909, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00417537, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.09090909, "qsc_codejava_score_lines_no_logic": 0.3030303, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/ParalyticGas.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
public class ParalyticGas extends Blob {
{
//acts after mobs, to give them a chance to resist paralysis
actPriority = MOB_PRIO - 1;
}
@Override
protected void evolve() {
super.evolve();
Char ch;
int cell;
for (int i = area.left; i < area.right; i++) {
for (int j = area.top; j < area.bottom; j++) {
cell = i + j * Dungeon.level.width();
if (cur[cell] > 0 && (ch = Actor.findChar(cell)) != null) {
if (!ch.isImmune(this.getClass()))
Buff.prolong(ch, Paralysis.class, Paralysis.DURATION);
}
}
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour( Speck.factory( Speck.PARALYSIS ), 0.4f );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 2,142 | ParalyticGas | java | en | java | code | {"qsc_code_num_words": 277, "qsc_code_num_chars": 2142.0, "qsc_code_mean_word_length": 5.65703971, "qsc_code_frac_words_unique": 0.5234657, "qsc_code_frac_chars_top_2grams": 0.0976388, "qsc_code_frac_chars_top_3grams": 0.21825144, "qsc_code_frac_chars_top_4grams": 0.22463306, "qsc_code_frac_chars_dupe_5grams": 0.25143586, "qsc_code_frac_chars_dupe_6grams": 0.10593491, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01178451, "qsc_code_frac_chars_whitespace": 0.16806723, "qsc_code_size_file_byte": 2142.0, "qsc_code_num_lines": 68.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 31.5, "qsc_code_frac_chars_alphabet": 0.86756453, "qsc_code_frac_chars_comments": 0.39262372, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.07894737, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00307456, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.07894737, "qsc_codejava_score_lines_no_logic": 0.36842105, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfHealth.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.DewVial;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes.Landmark;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample;
public class WaterOfHealth extends WellWater {
@Override
protected boolean affectHero( Hero hero ) {
if (!hero.isAlive()) return false;
Sample.INSTANCE.play( Assets.SND_DRINK );
hero.HP = hero.HT;
hero.sprite.emitter().start( Speck.factory( Speck.HEALING ), 0.4f, 4 );
PotionOfHealing.cure( hero );
hero.belongings.uncurseEquipped();
hero.buff( Hunger.class ).satisfy( Hunger.STARVING );
CellEmitter.get( hero.pos ).start( ShaftParticle.FACTORY, 0.2f, 3 );
Dungeon.hero.interrupt();
GLog.p( Messages.get(this, "procced") );
return true;
}
@Override
protected Item affectItem( Item item, int pos ) {
if (item instanceof DewVial && !((DewVial)item).isFull()) {
((DewVial)item).fill();
return item;
}
return null;
}
@Override
protected Landmark record() {
return Landmark.WELL_OF_HEALTH;
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.start( Speck.factory( Speck.HEALING ), 0.5f, 0 );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 2,900 | WaterOfHealth | java | en | java | code | {"qsc_code_num_words": 349, "qsc_code_num_chars": 2900.0, "qsc_code_mean_word_length": 6.35243553, "qsc_code_frac_words_unique": 0.46991404, "qsc_code_frac_chars_top_2grams": 0.1150203, "qsc_code_frac_chars_top_3grams": 0.25710419, "qsc_code_frac_chars_top_4grams": 0.27785295, "qsc_code_frac_chars_dupe_5grams": 0.27379341, "qsc_code_frac_chars_dupe_6grams": 0.0586378, "qsc_code_frac_chars_dupe_7grams": 0.03337844, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01037096, "qsc_code_frac_chars_whitespace": 0.13551724, "qsc_code_size_file_byte": 2900.0, "qsc_code_num_lines": 89.0, "qsc_code_num_chars_line_max": 81.0, "qsc_code_num_chars_line_mean": 32.58426966, "qsc_code_frac_chars_alphabet": 0.87395293, "qsc_code_frac_chars_comments": 0.26931034, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09433962, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00519113, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.09433962, "qsc_codejava_score_lines_no_logic": 0.45283019, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
01bps/WiFi-Auto-Auth | static/dashboard.css | /* WiFi Auto Auth Dashboard - Custom Styles */
:root {
--primary-color: #667eea;
--secondary-color: #764ba2;
--success-color: #28a745;
--danger-color: #dc3545;
--warning-color: #ffc107;
--info-color: #17a2b8;
--light-color: #f8f9fa;
--dark-color: #343a40;
--gradient-primary: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
--gradient-success: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
--gradient-danger: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
--gradient-info: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
--border-radius: 10px;
--box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
--transition: all 0.3s ease;
}
/* Global Styles */
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
line-height: 1.6;
}
/* Navigation Enhancements */
.navbar-brand {
font-weight: 700;
font-size: 1.5rem;
}
.navbar-brand i {
margin-right: 0.5rem;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
/* Card Enhancements */
.card {
border: none;
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
transition: var(--transition);
overflow: hidden;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}
.card-header {
background: var(--gradient-primary);
color: white;
border-bottom: none;
padding: 1rem 1.5rem;
}
.card-header h5 {
margin: 0;
font-weight: 600;
}
.card-body {
padding: 1.5rem;
}
/* Statistics Cards */
.card.bg-primary {
background: var(--gradient-primary) !important;
border: none;
}
.card.bg-success {
background: var(--gradient-success) !important;
border: none;
}
.card.bg-danger {
background: var(--gradient-danger) !important;
border: none;
}
.card.bg-info {
background: var(--gradient-info) !important;
border: none;
}
.card .fs-1 {
opacity: 0.8;
transition: var(--transition);
}
.card:hover .fs-1 {
opacity: 1;
transform: scale(1.1);
}
/* Form Enhancements */
.form-control, .form-select {
border-radius: var(--border-radius);
border: 2px solid #e9ecef;
transition: var(--transition);
padding: 0.75rem 1rem;
}
.form-control:focus, .form-select:focus {
border-color: var(--primary-color);
box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}
.form-label {
font-weight: 600;
color: var(--dark-color);
margin-bottom: 0.5rem;
}
/* Button Enhancements */
.btn {
border-radius: var(--border-radius);
font-weight: 600;
padding: 0.5rem 1.5rem;
transition: var(--transition);
border: none;
}
.btn-primary {
background: var(--gradient-primary);
border: none;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}
.btn-secondary:hover {
transform: translateY(-2px);
}
.btn-outline-light:hover {
transform: translateY(-2px);
}
/* Table Enhancements */
.table {
border-radius: var(--border-radius);
overflow: hidden;
margin-bottom: 0;
}
.table thead th {
border-bottom: none;
font-weight: 700;
text-transform: uppercase;
font-size: 0.85rem;
letter-spacing: 0.5px;
}
.table-striped tbody tr:nth-of-type(odd) {
background-color: rgba(0, 0, 0, 0.02);
}
.table-hover tbody tr:hover {
background-color: rgba(102, 126, 234, 0.05);
transform: scale(1.002);
}
/* Badge Enhancements */
.badge {
border-radius: 20px;
padding: 0.5em 0.8em;
font-weight: 600;
font-size: 0.75rem;
}
.badge.bg-success {
background: var(--gradient-success) !important;
}
.badge.bg-danger {
background: var(--gradient-danger) !important;
}
.badge.bg-primary {
background: var(--gradient-primary) !important;
}
/* Alert Enhancements */
.alert {
border: none;
border-radius: var(--border-radius);
padding: 1rem 1.5rem;
}
.alert-info {
background: linear-gradient(135deg, rgba(23, 162, 184, 0.1) 0%, rgba(23, 162, 184, 0.05) 100%);
color: #0c5460;
border-left: 4px solid var(--info-color);
}
/* Chart Container Enhancements */
canvas {
max-height: 400px !important;
}
.card .card-body canvas {
background: rgba(255, 255, 255, 0.8);
border-radius: var(--border-radius);
padding: 1rem;
}
/* Code Styling */
code {
background: rgba(102, 126, 234, 0.1);
color: var(--primary-color);
padding: 0.2em 0.4em;
border-radius: 4px;
font-size: 0.85em;
font-weight: 600;
}
/* Responsive Enhancements */
@media (max-width: 768px) {
.card-body {
padding: 1rem;
}
.table-responsive {
border-radius: var(--border-radius);
}
.row.g-3 > * {
margin-bottom: 1rem;
}
.btn {
width: 100%;
margin-bottom: 0.5rem;
}
.d-flex.justify-content-between {
flex-direction: column;
align-items: flex-start !important;
}
.navbar-nav.ms-auto {
margin-top: 1rem;
}
}
/* Loading Animation */
.loading {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: #fff;
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Utility Classes */
.text-gradient {
background: var(--gradient-primary);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
font-weight: 700;
}
.glass-effect {
backdrop-filter: blur(10px);
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.shadow-custom {
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
/* Dark Theme Support (Optional) */
@media (prefers-color-scheme: dark) {
:root {
--light-color: #1a1a1a;
--dark-color: #f8f9fa;
}
body {
background-color: #1a1a1a;
color: #f8f9fa;
}
.card {
background-color: #2d2d2d;
color: #f8f9fa;
}
.table-striped tbody tr:nth-of-type(odd) {
background-color: rgba(255, 255, 255, 0.05);
}
.form-control, .form-select {
background-color: #2d2d2d;
border-color: #404040;
color: #f8f9fa;
}
.form-control:focus, .form-select:focus {
background-color: #2d2d2d;
color: #f8f9fa;
}
} | 6,594 | dashboard | css | en | css | data | {"qsc_code_num_words": 810, "qsc_code_num_chars": 6594.0, "qsc_code_mean_word_length": 4.90246914, "qsc_code_frac_words_unique": 0.27530864, "qsc_code_frac_chars_top_2grams": 0.05439436, "qsc_code_frac_chars_top_3grams": 0.00755477, "qsc_code_frac_chars_top_4grams": 0.03701838, "qsc_code_frac_chars_dupe_5grams": 0.25585495, "qsc_code_frac_chars_dupe_6grams": 0.16645681, "qsc_code_frac_chars_dupe_7grams": 0.12465374, "qsc_code_frac_chars_dupe_8grams": 0.02518257, "qsc_code_frac_chars_dupe_9grams": 0.02518257, "qsc_code_frac_chars_dupe_10grams": 0.02518257, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.08241325, "qsc_code_frac_chars_whitespace": 0.23081589, "qsc_code_size_file_byte": 6594.0, "qsc_code_num_lines": 325.0, "qsc_code_num_chars_line_max": 109.0, "qsc_code_num_chars_line_mean": 20.28923077, "qsc_code_frac_chars_alphabet": 0.70051262, "qsc_code_frac_chars_comments": 0.0, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.26765799, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00333586, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 1, "qsc_code_mean_word_length": 0, "qsc_code_frac_words_unique": 1, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/ConfusionGas.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
public class ConfusionGas extends Blob {
@Override
protected void evolve() {
super.evolve();
Char ch;
int cell;
for (int i = area.left; i < area.right; i++){
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0 && (ch = Actor.findChar( cell )) != null) {
if (!ch.isImmune(this.getClass())) {
Buff.prolong(ch, Vertigo.class, 2);
}
}
}
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour( Speck.factory( Speck.CONFUSION, true ), 0.4f );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
} | 2,025 | ConfusionGas | java | en | java | code | {"qsc_code_num_words": 262, "qsc_code_num_chars": 2025.0, "qsc_code_mean_word_length": 5.66793893, "qsc_code_frac_words_unique": 0.51526718, "qsc_code_frac_chars_top_2grams": 0.1030303, "qsc_code_frac_chars_top_3grams": 0.23030303, "qsc_code_frac_chars_top_4grams": 0.23703704, "qsc_code_frac_chars_dupe_5grams": 0.26531987, "qsc_code_frac_chars_dupe_6grams": 0.11178451, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01240402, "qsc_code_frac_chars_whitespace": 0.16395062, "qsc_code_size_file_byte": 2025.0, "qsc_code_num_lines": 64.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 31.640625, "qsc_code_frac_chars_alphabet": 0.86473715, "qsc_code_frac_chars_comments": 0.38567901, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.08333333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00321285, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.08333333, "qsc_codejava_score_lines_no_logic": 0.38888889, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Foliage.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Shadows;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle;
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
public class Foliage extends Blob {
@Override
protected void evolve() {
int[] map = Dungeon.level.map;
boolean visible = false;
int cell;
for (int i = area.left; i < area.right; i++) {
for (int j = area.top; j < area.bottom; j++) {
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0) {
off[cell] = cur[cell];
volume += off[cell];
if (map[cell] == Terrain.EMBERS) {
map[cell] = Terrain.GRASS;
GameScene.updateMap(cell);
}
visible = visible || Dungeon.level.heroFOV[cell];
} else {
off[cell] = 0;
}
}
}
Hero hero = Dungeon.hero;
if (hero.isAlive() && hero.visibleEnemies() == 0 && cur[hero.pos] > 0) {
Buff.affect( hero, Shadows.class ).prolong();
}
if (visible) {
Notes.add( Notes.Landmark.GARDEN );
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.start( ShaftParticle.FACTORY, 0.9f, 0 );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 2,547 | Foliage | java | en | java | code | {"qsc_code_num_words": 318, "qsc_code_num_chars": 2547.0, "qsc_code_mean_word_length": 5.75471698, "qsc_code_frac_words_unique": 0.47484277, "qsc_code_frac_chars_top_2grams": 0.10218579, "qsc_code_frac_chars_top_3grams": 0.2284153, "qsc_code_frac_chars_top_4grams": 0.24043716, "qsc_code_frac_chars_dupe_5grams": 0.18797814, "qsc_code_frac_chars_dupe_6grams": 0.09071038, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0113906, "qsc_code_frac_chars_whitespace": 0.17275226, "qsc_code_size_file_byte": 2547.0, "qsc_code_num_lines": 85.0, "qsc_code_num_chars_line_max": 81.0, "qsc_code_num_chars_line_mean": 29.96470588, "qsc_code_frac_chars_alphabet": 0.85714286, "qsc_code_frac_chars_comments": 0.30663526, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.05882353, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00226501, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.05882353, "qsc_codejava_score_lines_no_logic": 0.29411765, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfAwareness.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Identification;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes.Landmark;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample;
public class WaterOfAwareness extends WellWater {
@Override
protected boolean affectHero( Hero hero ) {
Sample.INSTANCE.play( Assets.SND_DRINK );
emitter.parent.add( new Identification( hero.sprite.center() ) );
hero.belongings.observe();
for (int i=0; i < Dungeon.level.length(); i++) {
int terr = Dungeon.level.map[i];
if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
Dungeon.level.discover( i );
if (Dungeon.level.heroFOV[i]) {
GameScene.discoverTile( i, terr );
}
}
}
Buff.affect( hero, Awareness.class, Awareness.DURATION );
Dungeon.observe();
Dungeon.hero.interrupt();
GLog.p( Messages.get(this, "procced") );
return true;
}
@Override
protected Item affectItem( Item item, int pos ) {
if (item.isIdentified()) {
return null;
} else {
item.identify();
Badges.validateItemLevelAquired( item );
emitter.parent.add( new Identification( DungeonTilemap.tileCenterToWorld( pos ) ) );
return item;
}
}
@Override
protected Landmark record() {
return Landmark.WELL_OF_AWARENESS;
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour( Speck.factory( Speck.QUESTION ), 0.3f );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 3,247 | WaterOfAwareness | java | en | java | code | {"qsc_code_num_words": 377, "qsc_code_num_chars": 3247.0, "qsc_code_mean_word_length": 6.49602122, "qsc_code_frac_words_unique": 0.45888594, "qsc_code_frac_chars_top_2grams": 0.11800735, "qsc_code_frac_chars_top_3grams": 0.26378114, "qsc_code_frac_chars_top_4grams": 0.28746427, "qsc_code_frac_chars_dupe_5grams": 0.1882401, "qsc_code_frac_chars_dupe_6grams": 0.06778277, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0075703, "qsc_code_frac_chars_whitespace": 0.14567293, "qsc_code_size_file_byte": 3247.0, "qsc_code_num_lines": 103.0, "qsc_code_num_chars_line_max": 88.0, "qsc_code_num_chars_line_mean": 31.52427184, "qsc_code_frac_chars_alphabet": 0.87527037, "qsc_code_frac_chars_comments": 0.24052972, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.078125, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00446067, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.078125, "qsc_codejava_score_lines_no_logic": 0.40625, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfTransmutation.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator.Category;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes.Landmark;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.watabou.utils.Random;
import com.watabou.utils.Reflection;
public class WaterOfTransmutation extends WellWater {
@Override
protected Item affectItem( Item item, int pos ) {
if (item instanceof MagesStaff) {
item = changeStaff( (MagesStaff)item );
} else if (item instanceof MeleeWeapon) {
item = changeWeapon( (MeleeWeapon)item );
} else if (item instanceof Scroll) {
item = changeScroll( (Scroll)item );
} else if (item instanceof Potion) {
item = changePotion( (Potion)item );
} else if (item instanceof Ring) {
item = changeRing( (Ring)item );
} else if (item instanceof Wand) {
item = changeWand( (Wand)item );
} else if (item instanceof Plant.Seed) {
item = changeSeed( (Plant.Seed)item );
} else if (item instanceof Artifact) {
item = changeArtifact( (Artifact)item );
} else {
item = null;
}
//incase a never-seen item pops out
if (item != null&& item.isIdentified()){
Catalog.setSeen(item.getClass());
}
return item;
}
@Override
protected boolean affectHero(Hero hero) {
return false;
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.start( Speck.factory( Speck.CHANGE ), 0.2f, 0 );
}
@Override
protected Landmark record() {
return Landmark.WELL_OF_TRANSMUTATION;
}
private MagesStaff changeStaff( MagesStaff staff ){
Class<?extends Wand> wandClass = staff.wandClass();
if (wandClass == null){
return null;
} else {
Wand n;
do {
n = (Wand)Generator.random(Category.WAND);
} while (Challenges.isItemBlocked(n) || n.getClass() == wandClass);
n.level(0);
n.identify();
staff.imbueWand(n, null);
}
return staff;
}
private Weapon changeWeapon( MeleeWeapon w ) {
Weapon n;
Category c = Generator.wepTiers[w.tier-1];
do {
n = (MeleeWeapon)Reflection.newInstance(c.classes[Random.chances(c.probs)]);
} while (Challenges.isItemBlocked(n) || n.getClass() == w.getClass());
int level = w.level();
if (w.curseInfusionBonus) level--;
if (level > 0) {
n.upgrade( level );
} else if (level < 0) {
n.degrade( -level );
}
n.enchantment = w.enchantment;
n.curseInfusionBonus = w.curseInfusionBonus;
n.levelKnown = w.levelKnown;
n.cursedKnown = w.cursedKnown;
n.cursed = w.cursed;
n.augment = w.augment;
return n;
}
private Ring changeRing( Ring r ) {
Ring n;
do {
n = (Ring)Generator.random( Category.RING );
} while (Challenges.isItemBlocked(n) || n.getClass() == r.getClass());
n.level(0);
int level = r.level();
if (level > 0) {
n.upgrade( level );
} else if (level < 0) {
n.degrade( -level );
}
n.levelKnown = r.levelKnown;
n.cursedKnown = r.cursedKnown;
n.cursed = r.cursed;
return n;
}
private Artifact changeArtifact( Artifact a ) {
Artifact n = Generator.randomArtifact();
if (n != null && !Challenges.isItemBlocked(n)){
n.cursedKnown = a.cursedKnown;
n.cursed = a.cursed;
n.levelKnown = a.levelKnown;
n.transferUpgrade(a.visiblyUpgraded());
return n;
}
return null;
}
private Wand changeWand( Wand w ) {
Wand n;
do {
n = (Wand)Generator.random( Category.WAND );
} while ( Challenges.isItemBlocked(n) || n.getClass() == w.getClass());
n.level( 0 );
int level = w.level();
if (w.curseInfusionBonus) level--;
n.upgrade( level );
n.levelKnown = w.levelKnown;
n.cursedKnown = w.cursedKnown;
n.cursed = w.cursed;
n.curseInfusionBonus = w.curseInfusionBonus;
return n;
}
private Plant.Seed changeSeed( Plant.Seed s ) {
Plant.Seed n;
do {
n = (Plant.Seed)Generator.random( Category.SEED );
} while (n.getClass() == s.getClass());
return n;
}
private Scroll changeScroll( Scroll s ) {
if (s instanceof ScrollOfUpgrade) {
return null;
} else {
Scroll n;
do {
n = (Scroll)Generator.random( Category.SCROLL );
} while (n.getClass() == s.getClass());
return n;
}
}
private Potion changePotion( Potion p ) {
if (p instanceof PotionOfStrength) {
return null;
} else {
Potion n;
do {
n = (Potion)Generator.random( Category.POTION );
} while (n.getClass() == p.getClass());
return n;
}
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 6,614 | WaterOfTransmutation | java | en | java | code | {"qsc_code_num_words": 778, "qsc_code_num_chars": 6614.0, "qsc_code_mean_word_length": 6.00771208, "qsc_code_frac_words_unique": 0.2596401, "qsc_code_frac_chars_top_2grams": 0.04428755, "qsc_code_frac_chars_top_3grams": 0.17886179, "qsc_code_frac_chars_top_4grams": 0.19768935, "qsc_code_frac_chars_dupe_5grams": 0.38896021, "qsc_code_frac_chars_dupe_6grams": 0.2618742, "qsc_code_frac_chars_dupe_7grams": 0.1508344, "qsc_code_frac_chars_dupe_8grams": 0.12516046, "qsc_code_frac_chars_dupe_9grams": 0.08130081, "qsc_code_frac_chars_dupe_10grams": 0.08130081, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00513102, "qsc_code_frac_chars_whitespace": 0.17493196, "qsc_code_size_file_byte": 6614.0, "qsc_code_num_lines": 244.0, "qsc_code_num_chars_line_max": 80.0, "qsc_code_num_chars_line_mean": 27.10655738, "qsc_code_frac_chars_alphabet": 0.85138354, "qsc_code_frac_chars_comments": 0.12337466, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.33333333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00068989, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.06779661, "qsc_codejava_score_lines_no_logic": 0.31638418, "qsc_codejava_frac_words_no_modifier": 0.92307692, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WellWater.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
public abstract class WellWater extends Blob {
@Override
protected void evolve() {
int cell;
boolean seen = false;
for (int i=area.top-1; i <= area.bottom; i++) {
for (int j = area.left-1; j <= area.right; j++) {
cell = j + i* Dungeon.level.width();
if (Dungeon.level.insideMap(cell)) {
off[cell] = cur[cell];
volume += off[cell];
if (off[cell] > 0 && Dungeon.level.visited[cell]) {
seen = true;
}
}
}
}
if (seen){
Notes.add(record());
} else {
Notes.remove(record());
}
}
protected boolean affect( int pos ) {
Heap heap;
if (pos == Dungeon.hero.pos && affectHero( Dungeon.hero )) {
cur[pos] = 0;
return true;
} else if ((heap = Dungeon.level.heaps.get( pos )) != null) {
Item oldItem = heap.peek();
Item newItem = affectItem( oldItem, pos );
if (newItem != null) {
if (newItem == oldItem) {
} else if (oldItem.quantity() > 1) {
oldItem.quantity( oldItem.quantity() - 1 );
heap.drop( newItem );
} else {
heap.replace( oldItem, newItem );
}
heap.sprite.link();
cur[pos] = 0;
return true;
} else {
int newPlace;
do {
newPlace = pos + PathFinder.NEIGHBOURS8[Random.Int( 8 )];
} while (!Dungeon.level.passable[newPlace] && !Dungeon.level.avoid[newPlace]);
Dungeon.level.drop( heap.pickUp(), newPlace ).sprite.drop( pos );
return false;
}
} else {
return false;
}
}
protected abstract boolean affectHero( Hero hero );
protected abstract Item affectItem( Item item, int pos );
protected abstract Notes.Landmark record();
public static void affectCell( int cell ) {
Class<?>[] waters = {WaterOfHealth.class, WaterOfAwareness.class, WaterOfTransmutation.class};
for (Class<?>waterClass : waters) {
WellWater water = (WellWater)Dungeon.level.blobs.get( waterClass );
if (water != null &&
water.volume > 0 &&
water.cur[cell] > 0 &&
water.affect( cell )) {
Level.set( cell, Terrain.EMPTY_WELL );
GameScene.updateMap( cell );
return;
}
}
}
}
| 3,564 | WellWater | java | en | java | code | {"qsc_code_num_words": 429, "qsc_code_num_chars": 3564.0, "qsc_code_mean_word_length": 5.53846154, "qsc_code_frac_words_unique": 0.3986014, "qsc_code_frac_chars_top_2grams": 0.03787879, "qsc_code_frac_chars_top_3grams": 0.14393939, "qsc_code_frac_chars_top_4grams": 0.14814815, "qsc_code_frac_chars_dupe_5grams": 0.13552189, "qsc_code_frac_chars_dupe_6grams": 0.04124579, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01000715, "qsc_code_frac_chars_whitespace": 0.21492705, "qsc_code_size_file_byte": 3564.0, "qsc_code_num_lines": 134.0, "qsc_code_num_chars_line_max": 97.0, "qsc_code_num_chars_line_mean": 26.59701493, "qsc_code_frac_chars_alphabet": 0.83917084, "qsc_code_frac_chars_comments": 0.2191358, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.12048193, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.03614458, "qsc_codejava_score_lines_no_logic": 0.26506024, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Alchemy.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
import com.shatteredpixel.shatteredpixeldungeon.scenes.AlchemyScene;
public class Alchemy extends Blob implements AlchemyScene.AlchemyProvider {
protected int pos;
@Override
protected void evolve() {
int cell;
for (int i=area.top-1; i <= area.bottom; i++) {
for (int j = area.left-1; j <= area.right; j++) {
cell = j + i* Dungeon.level.width();
if (Dungeon.level.insideMap(cell)) {
off[cell] = cur[cell];
volume += off[cell];
if (off[cell] > 0 && Dungeon.level.heroFOV[cell]){
Notes.add( Notes.Landmark.ALCHEMY );
}
}
}
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.start( Speck.factory( Speck.BUBBLE ), 0.33f, 0 );
}
public static int alchPos;
//1 volume is kept in reserve
@Override
public int getEnergy() {
return Math.max(0, cur[alchPos] - 1);
}
@Override
public void spendEnergy(int reduction) {
cur[alchPos] = Math.max(1, cur[alchPos] - reduction);
}
}
| 2,083 | Alchemy | java | en | java | code | {"qsc_code_num_words": 277, "qsc_code_num_chars": 2083.0, "qsc_code_mean_word_length": 5.3898917, "qsc_code_frac_words_unique": 0.50541516, "qsc_code_frac_chars_top_2grams": 0.06831882, "qsc_code_frac_chars_top_3grams": 0.15271266, "qsc_code_frac_chars_top_4grams": 0.14735432, "qsc_code_frac_chars_dupe_5grams": 0.1232418, "qsc_code_frac_chars_dupe_6grams": 0.03750837, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01639344, "qsc_code_frac_chars_whitespace": 0.1800288, "qsc_code_size_file_byte": 2083.0, "qsc_code_num_lines": 69.0, "qsc_code_num_chars_line_max": 76.0, "qsc_code_num_chars_line_mean": 30.1884058, "qsc_code_frac_chars_alphabet": 0.85772834, "qsc_code_frac_chars_comments": 0.38886222, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.1025641, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.1025641, "qsc_codejava_score_lines_no_logic": 0.33333333, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Bundle;
public class Hunger extends Buff implements Hero.Doom {
private static final float STEP = 10f;
public static final float HUNGRY = 300f;
public static final float STARVING = 450f;
private float level;
private float partialDamage;
private static final String LEVEL = "level";
private static final String PARTIALDAMAGE = "partialDamage";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle(bundle);
bundle.put( LEVEL, level );
bundle.put( PARTIALDAMAGE, partialDamage );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
level = bundle.getFloat( LEVEL );
partialDamage = bundle.getFloat(PARTIALDAMAGE);
}
@Override
public boolean act() {
if (Dungeon.level.locked || target.buff(WellFed.class) != null){
spend(STEP);
return true;
}
if (target.isAlive() && target instanceof Hero) {
Hero hero = (Hero)target;
if (isStarving()) {
partialDamage += STEP * target.HT/1000f;
if (partialDamage > 1){
target.damage( (int)partialDamage, this);
partialDamage -= (int)partialDamage;
}
} else {
float newLevel = level + STEP;
boolean statusUpdated = false;
if (newLevel >= STARVING) {
GLog.n( Messages.get(this, "onstarving") );
hero.resting = false;
hero.damage( 1, this );
statusUpdated = true;
hero.interrupt();
} else if (newLevel >= HUNGRY && level < HUNGRY) {
GLog.w( Messages.get(this, "onhungry") );
statusUpdated = true;
}
level = newLevel;
if (statusUpdated) {
BuffIndicator.refreshHero();
}
}
spend( target.buff( Shadows.class ) == null ? STEP : STEP * 1.5f );
} else {
diactivate();
}
return true;
}
public void satisfy( float energy ) {
Artifact.ArtifactBuff buff = target.buff( HornOfPlenty.hornRecharge.class );
if (buff != null && buff.isCursed()){
energy *= 0.67f;
GLog.n( Messages.get(this, "cursedhorn") );
}
reduceHunger( energy );
}
//directly interacts with hunger, no checks.
public void reduceHunger( float energy ) {
level -= energy;
if (level < 0) {
level = 0;
} else if (level > STARVING) {
float excess = level - STARVING;
level = STARVING;
partialDamage += excess * (target.HT/1000f);
}
BuffIndicator.refreshHero();
}
public boolean isStarving() {
return level >= STARVING;
}
public int hunger() {
return (int)Math.ceil(level);
}
@Override
public int icon() {
if (level < HUNGRY) {
return BuffIndicator.NONE;
} else if (level < STARVING) {
return BuffIndicator.HUNGER;
} else {
return BuffIndicator.STARVATION;
}
}
@Override
public String toString() {
if (level < STARVING) {
return Messages.get(this, "hungry");
} else {
return Messages.get(this, "starving");
}
}
@Override
public String desc() {
String result;
if (level < STARVING) {
result = Messages.get(this, "desc_intro_hungry");
} else {
result = Messages.get(this, "desc_intro_starving");
}
result += Messages.get(this, "desc");
return result;
}
@Override
public void onDeath() {
Badges.validateDeathFromHunger();
Dungeon.fail( getClass() );
GLog.n( Messages.get(this, "ondeath") );
}
}
| 4,657 | Hunger | java | en | java | code | {"qsc_code_num_words": 529, "qsc_code_num_chars": 4657.0, "qsc_code_mean_word_length": 6.10018904, "qsc_code_frac_words_unique": 0.34593573, "qsc_code_frac_chars_top_2grams": 0.04741246, "qsc_code_frac_chars_top_3grams": 0.10598079, "qsc_code_frac_chars_top_4grams": 0.10907964, "qsc_code_frac_chars_dupe_5grams": 0.13851875, "qsc_code_frac_chars_dupe_6grams": 0.0845987, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0112, "qsc_code_frac_chars_whitespace": 0.19476058, "qsc_code_size_file_byte": 4657.0, "qsc_code_num_lines": 195.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 23.88205128, "qsc_code_frac_chars_alphabet": 0.84933333, "qsc_code_frac_chars_comments": 0.17715267, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.15503876, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.02792276, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.08527132, "qsc_codejava_score_lines_no_logic": 0.20930233, "qsc_codejava_frac_words_no_modifier": 0.91666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Light.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
public class Light extends FlavourBuff {
{
type = buffType.POSITIVE;
}
public static final float DURATION = 300f;
public static final int DISTANCE = 6;
@Override
public boolean attachTo( Char target ) {
if (super.attachTo( target )) {
if (Dungeon.level != null) {
target.viewDistance = Math.max( Dungeon.level.viewDistance, DISTANCE );
Dungeon.observe();
}
return true;
} else {
return false;
}
}
@Override
public void detach() {
target.viewDistance = Dungeon.level.viewDistance;
Dungeon.observe();
super.detach();
}
@Override
public int icon() {
return BuffIndicator.LIGHT;
}
@Override
public void tintIcon(Image icon) {
greyIcon(icon, 20f, cooldown());
}
@Override
public void fx(boolean on) {
if (on) target.sprite.add(CharSprite.State.ILLUMINATED);
else target.sprite.remove(CharSprite.State.ILLUMINATED);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 2,254 | Light | java | en | java | code | {"qsc_code_num_words": 280, "qsc_code_num_chars": 2254.0, "qsc_code_mean_word_length": 5.93214286, "qsc_code_frac_words_unique": 0.51428571, "qsc_code_frac_chars_top_2grams": 0.0590006, "qsc_code_frac_chars_top_3grams": 0.13726671, "qsc_code_frac_chars_top_4grams": 0.13245033, "qsc_code_frac_chars_dupe_5grams": 0.04936785, "qsc_code_frac_chars_dupe_6grams": 0.03371463, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01226013, "qsc_code_frac_chars_whitespace": 0.16770186, "qsc_code_size_file_byte": 2254.0, "qsc_code_num_lines": 84.0, "qsc_code_num_chars_line_max": 76.0, "qsc_code_num_chars_line_mean": 26.83333333, "qsc_code_frac_chars_alphabet": 0.87313433, "qsc_code_frac_chars_comments": 0.34649512, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.16981132, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00543109, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.13207547, "qsc_codejava_score_lines_no_logic": 0.30188679, "qsc_codejava_frac_words_no_modifier": 0.875, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Berserk.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite;
import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal.WarriorShield;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.GameMath;
public class Berserk extends Buff {
private enum State{
NORMAL, BERSERK, RECOVERING
}
private State state = State.NORMAL;
private static final float LEVEL_RECOVER_START = 2f;
private float levelRecovery;
private float power = 0;
private static final String STATE = "state";
private static final String LEVEL_RECOVERY = "levelrecovery";
private static final String POWER = "power";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(STATE, state);
bundle.put(POWER, power);
if (state == State.RECOVERING) bundle.put(LEVEL_RECOVERY, levelRecovery);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
//pre-0.6.5 saves
if (bundle.contains("exhaustion")){
state = State.RECOVERING;
} else {
state = bundle.getEnum(STATE, State.class);
}
if (bundle.contains(POWER)){
power = bundle.getFloat(POWER);
} else {
power = 1f;
}
if (state == State.RECOVERING) levelRecovery = bundle.getFloat(LEVEL_RECOVERY);
}
@Override
public boolean act() {
if (berserking()){
ShieldBuff buff = target.buff(WarriorShield.class);
if (target.HP <= 0) {
if (buff != null && buff.shielding() > 0) {
buff.absorbDamage(1 + (int)Math.ceil(target.shielding() * 0.1f));
} else {
//if there is no shield buff, or it is empty, then try to remove from other shielding buffs
buff = target.buff(ShieldBuff.class);
if (buff != null) buff.absorbDamage(1 + (int)Math.ceil(target.shielding() * 0.1f));
}
if (target.shielding() <= 0) {
target.die(this);
if (!target.isAlive()) Dungeon.fail(this.getClass());
}
} else {
state = State.RECOVERING;
levelRecovery = LEVEL_RECOVER_START;
BuffIndicator.refreshHero();
if (buff != null) buff.absorbDamage(buff.shielding());
power = 0f;
}
} else if (state == State.NORMAL) {
power -= GameMath.gate(0.1f, power, 1f) * 0.067f * Math.pow((target.HP/(float)target.HT), 2);
if (power <= 0){
detach();
}
BuffIndicator.refreshHero();
}
spend(TICK);
return true;
}
public int damageFactor(int dmg){
float bonus = Math.min(1.5f, 1f + (power / 2f));
return Math.round(dmg * bonus);
}
public boolean berserking(){
if (target.HP == 0 && state == State.NORMAL && power >= 1f){
WarriorShield shield = target.buff(WarriorShield.class);
if (shield != null){
state = State.BERSERK;
BuffIndicator.refreshHero();
shield.supercharge(shield.maxShield() * 10);
SpellSprite.show(target, SpellSprite.BERSERK);
Sample.INSTANCE.play( Assets.SND_CHALLENGE );
GameScene.flash(0xFF0000);
}
}
return state == State.BERSERK && target.shielding() > 0;
}
public void damage(int damage){
if (state == State.RECOVERING) return;
power = Math.min(1.1f, power + (damage/(float)target.HT)/3f );
BuffIndicator.refreshHero();
}
public void recover(float percent){
if (levelRecovery > 0){
levelRecovery -= percent;
BuffIndicator.refreshHero();
if (levelRecovery <= 0) {
state = State.NORMAL;
levelRecovery = 0;
}
}
}
@Override
public int icon() {
return BuffIndicator.BERSERK;
}
@Override
public void tintIcon(Image icon) {
switch (state){
case NORMAL: default:
if (power < 0.5f) icon.hardlight(1f, 1f, 1f - 2*(power));
else if (power < 1f) icon.hardlight(1f, 1.5f - power, 0f);
else icon.hardlight(1f, 0f, 0f);
break;
case BERSERK:
icon.hardlight(1f, 0f, 0f);
break;
case RECOVERING:
icon.hardlight(1f - (levelRecovery*0.5f), 1f - (levelRecovery*0.3f), 1f);
break;
}
}
@Override
public String toString() {
switch (state){
case NORMAL: default:
return Messages.get(this, "angered");
case BERSERK:
return Messages.get(this, "berserk");
case RECOVERING:
return Messages.get(this, "recovering");
}
}
@Override
public String desc() {
float dispDamage = (damageFactor(10000) / 100f) - 100f;
switch (state){
case NORMAL: default:
return Messages.get(this, "angered_desc", Math.floor(power * 100f), dispDamage);
case BERSERK:
return Messages.get(this, "berserk_desc");
case RECOVERING:
return Messages.get(this, "recovering_desc", levelRecovery);
}
}
}
| 5,746 | Berserk | java | en | java | code | {"qsc_code_num_words": 701, "qsc_code_num_chars": 5746.0, "qsc_code_mean_word_length": 5.64621969, "qsc_code_frac_words_unique": 0.30527817, "qsc_code_frac_chars_top_2grams": 0.03789793, "qsc_code_frac_chars_top_3grams": 0.07680647, "qsc_code_frac_chars_top_4grams": 0.07781708, "qsc_code_frac_chars_dupe_5grams": 0.16018191, "qsc_code_frac_chars_dupe_6grams": 0.12228398, "qsc_code_frac_chars_dupe_7grams": 0.10813542, "qsc_code_frac_chars_dupe_8grams": 0.05154118, "qsc_code_frac_chars_dupe_9grams": 0.05154118, "qsc_code_frac_chars_dupe_10grams": 0.05154118, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02137666, "qsc_code_frac_chars_whitespace": 0.18586843, "qsc_code_size_file_byte": 5746.0, "qsc_code_num_lines": 199.0, "qsc_code_num_chars_line_max": 97.0, "qsc_code_num_chars_line_mean": 28.87437186, "qsc_code_frac_chars_alphabet": 0.82471142, "qsc_code_frac_chars_comments": 0.15471632, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.21428571, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01976529, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00164711, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.07142857, "qsc_codejava_score_lines_no_logic": 0.16233766, "qsc_codejava_frac_words_no_modifier": 0.91666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Preparation.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Rat;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Effects;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.PathFinder;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class Preparation extends Buff implements ActionIndicator.Action {
{
//always acts after other buffs, so invisibility effects can process first
actPriority = BUFF_PRIO - 1;
}
public enum AttackLevel{
LVL_1( 1, 0.1f, 0.0f, 1, 0),
LVL_2( 3, 0.2f, 0.0f, 1, 1),
LVL_3( 6, 0.3f, 0.0f, 2, 3),
LVL_4( 11, 0.4f, 0.6f, 2, 5),
LVL_5( 16, 0.5f, 1.0f, 3, 7);
final int turnsReq;
final float baseDmgBonus, missingHPBonus;
final int damageRolls, blinkDistance;
AttackLevel( int turns, float base, float missing, int rolls, int dist){
turnsReq = turns;
baseDmgBonus = base; missingHPBonus = missing;
damageRolls =rolls; blinkDistance = dist;
}
public boolean canInstakill(Char defender){
return this == LVL_5
&& !defender.properties().contains(Char.Property.MINIBOSS)
&& !defender.properties().contains(Char.Property.BOSS);
}
public int damageRoll( Char attacker, Char defender){
int dmg = attacker.damageRoll();
for( int i = 1; i < damageRolls; i++){
int newDmg = attacker.damageRoll();
if (newDmg > dmg) dmg = newDmg;
}
float defenderHPPercent = 1f - (defender.HP / (float)defender.HT);
return Math.round(dmg * (1f + baseDmgBonus + (missingHPBonus * defenderHPPercent)));
}
public static AttackLevel getLvl(int turnsInvis){
List<AttackLevel> values = Arrays.asList(values());
Collections.reverse(values);
for ( AttackLevel lvl : values ){
if (turnsInvis >= lvl.turnsReq){
return lvl;
}
}
return LVL_1;
}
}
private int turnsInvis = 0;
@Override
public boolean act() {
if (target.invisible > 0){
turnsInvis++;
if (AttackLevel.getLvl(turnsInvis).blinkDistance > 0 && target == Dungeon.hero){
ActionIndicator.setAction(this);
}
BuffIndicator.refreshHero();
spend(TICK);
} else {
detach();
}
return true;
}
@Override
public void detach() {
super.detach();
ActionIndicator.clearAction(this);
}
public int damageRoll(Char attacker, Char defender ){
AttackLevel lvl = AttackLevel.getLvl(turnsInvis);
if (lvl.canInstakill(defender)){
int dmg = lvl.damageRoll(attacker, defender);
defender.damage( Math.max(defender.HT, dmg), attacker );
//even though the defender is dead, other effects should still proc (enchants, etc.)
return Math.max( defender.HT, dmg);
} else {
return lvl.damageRoll(attacker, defender);
}
}
@Override
public int icon() {
return BuffIndicator.PREPARATION;
}
@Override
public void tintIcon(Image icon) {
switch (AttackLevel.getLvl(turnsInvis)){
case LVL_1:
icon.hardlight(1f, 1f, 1f);
break;
case LVL_2:
icon.hardlight(0f, 1f, 0f);
break;
case LVL_3:
icon.hardlight(1f, 1f, 0f);
break;
case LVL_4:
icon.hardlight(1f, 0.6f, 0f);
break;
case LVL_5:
icon.hardlight(1f, 0f, 0f);
break;
}
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
String desc = Messages.get(this, "desc");
AttackLevel lvl = AttackLevel.getLvl(turnsInvis);
if (lvl.canInstakill(new Rat())){
desc += "\n\n" + Messages.get(this, "desc_dmg_instakill",
(int)(lvl.baseDmgBonus*100),
(int)(lvl.baseDmgBonus*100 + lvl.missingHPBonus*100));
} else if (lvl.missingHPBonus > 0){
desc += "\n\n" + Messages.get(this, "desc_dmg_scale",
(int)(lvl.baseDmgBonus*100),
(int)(lvl.baseDmgBonus*100 + lvl.missingHPBonus*100));
} else {
desc += "\n\n" + Messages.get(this, "desc_dmg", (int)(lvl.baseDmgBonus*100));
}
if (lvl.damageRolls > 1){
desc += " " + Messages.get(this, "desc_dmg_likely");
}
if (lvl.blinkDistance > 0){
desc += "\n\n" + Messages.get(this, "desc_blink", lvl.blinkDistance);
}
desc += "\n\n" + Messages.get(this, "desc_invis_time", turnsInvis);
if (lvl.ordinal() != AttackLevel.values().length-1){
AttackLevel next = AttackLevel.values()[lvl.ordinal()+1];
desc += "\n" + Messages.get(this, "desc_invis_next", next.turnsReq);
}
return desc;
}
private static final String TURNS = "turnsInvis";
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
turnsInvis = bundle.getInt(TURNS);
if (AttackLevel.getLvl(turnsInvis).blinkDistance > 0){
ActionIndicator.setAction(this);
}
}
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(TURNS, turnsInvis);
}
@Override
public Image getIcon() {
Image actionIco = Effects.get(Effects.Type.WOUND);
tintIcon(actionIco);
return actionIco;
}
@Override
public void doAction() {
GameScene.selectCell(attack);
}
private CellSelector.Listener attack = new CellSelector.Listener() {
@Override
public void onSelect(Integer cell) {
if (cell == null) return;
final Char enemy = Actor.findChar( cell );
if (enemy == null || Dungeon.hero.isCharmedBy(enemy) || enemy instanceof NPC){
GLog.w(Messages.get(Preparation.class, "no_target"));
} else {
//just attack them then!
if (Dungeon.hero.canAttack(enemy)){
if (Dungeon.hero.handle( cell )) {
Dungeon.hero.next();
}
return;
}
AttackLevel lvl = AttackLevel.getLvl(turnsInvis);
boolean[] passable = Dungeon.level.passable.clone();
//need to consider enemy cell as passable in case they are on a trap or chasm
passable[cell] = true;
PathFinder.buildDistanceMap(Dungeon.hero.pos, passable, lvl.blinkDistance+1);
if (PathFinder.distance[cell] == Integer.MAX_VALUE){
GLog.w(Messages.get(Preparation.class, "out_of_reach"));
return;
}
//we can move through enemies when determining blink distance,
// but not when actually jumping to a location
for (Char ch : Actor.chars()){
if (ch != Dungeon.hero) passable[ch.pos] = false;
}
PathFinder.Path path = PathFinder.find(Dungeon.hero.pos, cell, passable);
int attackPos = path == null ? -1 : path.get(path.size()-2);
if (attackPos == -1 ||
Dungeon.level.distance(attackPos, Dungeon.hero.pos) > lvl.blinkDistance){
GLog.w(Messages.get(Preparation.class, "out_of_reach"));
return;
}
Dungeon.hero.pos = attackPos;
Dungeon.level.occupyCell(Dungeon.hero);
//prevents the hero from being interrupted by seeing new enemies
Dungeon.observe();
Dungeon.hero.checkVisibleMobs();
Dungeon.hero.sprite.place( Dungeon.hero.pos );
Dungeon.hero.sprite.turnTo( Dungeon.hero.pos, cell);
CellEmitter.get( Dungeon.hero.pos ).burst( Speck.factory( Speck.WOOL ), 6 );
Sample.INSTANCE.play( Assets.SND_PUFF );
if (Dungeon.hero.handle( cell )) {
Dungeon.hero.next();
}
}
}
@Override
public String prompt() {
return Messages.get(Preparation.class, "prompt", AttackLevel.getLvl(turnsInvis).blinkDistance);
}
};
}
| 8,930 | Preparation | java | en | java | code | {"qsc_code_num_words": 1083, "qsc_code_num_chars": 8930.0, "qsc_code_mean_word_length": 5.71283472, "qsc_code_frac_words_unique": 0.29085873, "qsc_code_frac_chars_top_2grams": 0.0276386, "qsc_code_frac_chars_top_3grams": 0.09827057, "qsc_code_frac_chars_top_4grams": 0.10667529, "qsc_code_frac_chars_dupe_5grams": 0.2687894, "qsc_code_frac_chars_dupe_6grams": 0.15419428, "qsc_code_frac_chars_dupe_7grams": 0.10376596, "qsc_code_frac_chars_dupe_8grams": 0.08582512, "qsc_code_frac_chars_dupe_9grams": 0.03685146, "qsc_code_frac_chars_dupe_10grams": 0.03685146, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01650525, "qsc_code_frac_chars_whitespace": 0.17905935, "qsc_code_size_file_byte": 8930.0, "qsc_code_num_lines": 297.0, "qsc_code_num_chars_line_max": 99.0, "qsc_code_num_chars_line_mean": 30.06734007, "qsc_code_frac_chars_alphabet": 0.8274451, "qsc_code_frac_chars_comments": 0.13572228, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.18061674, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.02267427, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.07048458, "qsc_codejava_score_lines_no_logic": 0.21145374, "qsc_codejava_frac_words_no_modifier": 0.94117647, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MagicalSleep.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class MagicalSleep extends Buff {
private static final float STEP = 1f;
@Override
public boolean attachTo( Char target ) {
if (!target.isImmune(Sleep.class) && super.attachTo( target )) {
target.paralysed++;
if (target.alignment == Char.Alignment.ALLY) {
if (target.HP == target.HT) {
if (target instanceof Hero) GLog.i(Messages.get(this, "toohealthy"));
detach();
} else {
if (target instanceof Hero) GLog.i(Messages.get(this, "fallasleep"));
}
}
if (target instanceof Mob) {
((Mob) target).state = ((Mob) target).SLEEPING;
}
return true;
} else {
return false;
}
}
@Override
public boolean act(){
if (target instanceof Mob && ((Mob) target).state != ((Mob) target).SLEEPING){
detach();
return true;
}
if (target.alignment == Char.Alignment.ALLY) {
target.HP = Math.min(target.HP+1, target.HT);
if (target instanceof Hero) ((Hero) target).resting = true;
if (target.HP == target.HT) {
if (target instanceof Hero) GLog.p(Messages.get(this, "wakeup"));
detach();
}
}
spend( STEP );
return true;
}
@Override
public void detach() {
if (target.paralysed > 0)
target.paralysed--;
if (target instanceof Hero)
((Hero) target).resting = false;
super.detach();
}
@Override
public int icon() {
return BuffIndicator.MAGIC_SLEEP;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc");
}
} | 2,758 | MagicalSleep | java | en | java | code | {"qsc_code_num_words": 346, "qsc_code_num_chars": 2758.0, "qsc_code_mean_word_length": 5.58959538, "qsc_code_frac_words_unique": 0.41907514, "qsc_code_frac_chars_top_2grams": 0.05377456, "qsc_code_frac_chars_top_3grams": 0.13753878, "qsc_code_frac_chars_top_4grams": 0.13650465, "qsc_code_frac_chars_dupe_5grams": 0.32885212, "qsc_code_frac_chars_dupe_6grams": 0.23784902, "qsc_code_frac_chars_dupe_7grams": 0.16959669, "qsc_code_frac_chars_dupe_8grams": 0.12926577, "qsc_code_frac_chars_dupe_9grams": 0.12926577, "qsc_code_frac_chars_dupe_10grams": 0.09927611, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00887311, "qsc_code_frac_chars_whitespace": 0.18274112, "qsc_code_size_file_byte": 2758.0, "qsc_code_num_lines": 100.0, "qsc_code_num_chars_line_max": 81.0, "qsc_code_num_chars_line_mean": 27.58, "qsc_code_frac_chars_alphabet": 0.84915705, "qsc_code_frac_chars_comments": 0.28317621, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.26865672, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01718908, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.08955224, "qsc_codejava_score_lines_no_logic": 0.25373134, "qsc_codejava_frac_words_no_modifier": 0.85714286, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Amok.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
public class Amok extends FlavourBuff {
{
type = buffType.NEGATIVE;
announced = true;
}
@Override
public int icon() {
return BuffIndicator.AMOK;
}
@Override
public void detach() {
super.detach();
if (target instanceof Mob)
((Mob)target).aggro( null );
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,495 | Amok | java | en | java | code | {"qsc_code_num_words": 196, "qsc_code_num_chars": 1495.0, "qsc_code_mean_word_length": 5.62755102, "qsc_code_frac_words_unique": 0.59183673, "qsc_code_frac_chars_top_2grams": 0.06165005, "qsc_code_frac_chars_top_3grams": 0.13780598, "qsc_code_frac_chars_top_4grams": 0.05167724, "qsc_code_frac_chars_dupe_5grams": 0.0743427, "qsc_code_frac_chars_dupe_6grams": 0.05077063, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01375405, "qsc_code_frac_chars_whitespace": 0.17324415, "qsc_code_size_file_byte": 1495.0, "qsc_code_num_lines": 55.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 27.18181818, "qsc_code_frac_chars_alphabet": 0.87864078, "qsc_code_frac_chars_comments": 0.52240803, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.14285714, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01120448, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.14285714, "qsc_codejava_score_lines_no_logic": 0.28571429, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Charm.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Bundle;
public class Charm extends FlavourBuff {
public int object = 0;
private static final String OBJECT = "object";
{
type = buffType.NEGATIVE;
announced = true;
}
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( OBJECT, object );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
object = bundle.getInt( OBJECT );
}
@Override
public int icon() {
return BuffIndicator.HEART;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String heroMessage() {
return Messages.get(this, "heromsg");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
public void recover() {
spend(-5f);
if (cooldown() <= 0){
detach();
}
}
}
| 1,996 | Charm | java | en | java | code | {"qsc_code_num_words": 247, "qsc_code_num_chars": 1996.0, "qsc_code_mean_word_length": 5.91902834, "qsc_code_frac_words_unique": 0.53846154, "qsc_code_frac_chars_top_2grams": 0.05745554, "qsc_code_frac_chars_top_3grams": 0.12995896, "qsc_code_frac_chars_top_4grams": 0.12038304, "qsc_code_frac_chars_dupe_5grams": 0.05608755, "qsc_code_frac_chars_dupe_6grams": 0.03830369, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01212121, "qsc_code_frac_chars_whitespace": 0.17334669, "qsc_code_size_file_byte": 1996.0, "qsc_code_num_lines": 78.0, "qsc_code_num_chars_line_max": 76.0, "qsc_code_num_chars_line_mean": 25.58974359, "qsc_code_frac_chars_alphabet": 0.87393939, "qsc_code_frac_chars_comments": 0.39128257, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13043478, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01728395, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.15217391, "qsc_codejava_score_lines_no_logic": 0.2826087, "qsc_codejava_frac_words_no_modifier": 0.875, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
01bps/WiFi-Auto-Auth | templates/dashboard.html | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WiFi Auto Auth Dashboard</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
<!-- Chart.js -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<!-- Custom CSS -->
<link href="/static/dashboard.css" rel="stylesheet">
</head>
<body class="bg-light">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container-fluid">
<a class="navbar-brand" href="/">
<i class="bi bi-wifi"></i> WiFi Auto Auth Dashboard
</a>
<div class="navbar-nav ms-auto">
<span class="navbar-text me-3">
<i class="bi bi-person-circle"></i> Welcome, {{ username }}
</span>
<button class="btn btn-outline-light btn-sm" onclick="refreshData()">
<i class="bi bi-arrow-clockwise"></i> Refresh
</button>
</div>
</div>
</nav>
<div class="container-fluid mt-4">
<!-- Statistics Cards -->
<div class="row mb-4">
<div class="col-md-3 mb-3">
<div class="card bg-primary text-white">
<div class="card-body">
<div class="d-flex justify-content-between">
<div>
<h4 class="card-title">{{ stats.total_attempts }}</h4>
<p class="card-text">Total Attempts</p>
</div>
<div class="align-self-center">
<i class="bi bi-bar-chart-fill fs-1"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="card bg-success text-white">
<div class="card-body">
<div class="d-flex justify-content-between">
<div>
<h4 class="card-title">{{ stats.successful_attempts }}</h4>
<p class="card-text">Successful</p>
</div>
<div class="align-self-center">
<i class="bi bi-check-circle-fill fs-1"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="card bg-danger text-white">
<div class="card-body">
<div class="d-flex justify-content-between">
<div>
<h4 class="card-title">{{ stats.failed_attempts }}</h4>
<p class="card-text">Failed</p>
</div>
<div class="align-self-center">
<i class="bi bi-x-circle-fill fs-1"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="card bg-info text-white">
<div class="card-body">
<div class="d-flex justify-content-between">
<div>
<h4 class="card-title">{{ stats.success_rate|round(1) }}%</h4>
<p class="card-text">Success Rate</p>
</div>
<div class="align-self-center">
<i class="bi bi-percent fs-1"></i>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<!-- Filters Panel -->
<div class="col-md-12 mb-4">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">
<i class="bi bi-funnel"></i> Filters
</h5>
</div>
<div class="card-body">
<form id="filterForm" class="row g-3">
<div class="col-md-3">
<label for="startDate" class="form-label">Start Date</label>
<input type="datetime-local" class="form-control" id="startDate" name="start_date">
</div>
<div class="col-md-3">
<label for="endDate" class="form-label">End Date</label>
<input type="datetime-local" class="form-control" id="endDate" name="end_date">
</div>
<div class="col-md-3">
<label for="statusFilter" class="form-label">Status</label>
<select class="form-select" id="statusFilter" name="status_filter">
<option value="">All</option>
<option value="success">Success Only</option>
<option value="failed">Failed Only</option>
</select>
</div>
<div class="col-md-3">
<label for="limitResults" class="form-label">Limit</label>
<select class="form-select" id="limitResults" name="limit">
<option value="25">25 results</option>
<option value="50" selected>50 results</option>
<option value="100">100 results</option>
<option value="200">200 results</option>
</select>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">
<i class="bi bi-search"></i> Apply Filters
</button>
<button type="button" class="btn btn-secondary" onclick="clearFilters()">
<i class="bi bi-x-lg"></i> Clear
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<!-- Charts Section -->
<div class="col-md-8 mb-4">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">
<i class="bi bi-graph-up"></i> Login Attempts Over Time
</h5>
</div>
<div class="card-body">
<canvas id="attemptsChart" width="400" height="200"></canvas>
</div>
</div>
</div>
<!-- Success Rate Pie Chart -->
<div class="col-md-4 mb-4">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">
<i class="bi bi-pie-chart"></i> Success Rate Distribution
</h5>
</div>
<div class="card-body">
<canvas id="successChart" width="200" height="200"></canvas>
</div>
</div>
</div>
</div>
<!-- Recent Login Attempts Table -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="card-title mb-0">
<i class="bi bi-table"></i> Recent Login Attempts
</h5>
<div class="badge bg-primary" id="attemptCount">{{ recent_attempts|length }} results</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-hover" id="attemptsTable">
<thead class="table-dark">
<tr>
<th scope="col">Timestamp</th>
<th scope="col">Username</th>
<th scope="col">Session ID</th>
<th scope="col">Status</th>
<th scope="col">Message</th>
</tr>
</thead>
<tbody id="attemptsTableBody">
{% for attempt in recent_attempts %}
<tr>
<td>
<span class="text-muted small">{{ attempt.timestamp }}</span>
</td>
<td>
<i class="bi bi-person"></i> {{ attempt.username }}
</td>
<td>
<code class="small">{{ attempt.a }}</code>
</td>
<td>
{% if attempt.response_status == "200" %}
<span class="badge bg-success">
<i class="bi bi-check-circle"></i> {{ attempt.response_status }}
</span>
{% else %}
<span class="badge bg-danger">
<i class="bi bi-x-circle"></i> {{ attempt.response_status }}
</span>
{% endif %}
</td>
<td class="text-truncate" style="max-width: 300px;" title="{{ attempt.response_message }}">
{{ attempt.response_message }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% if stats.last_attempt %}
<div class="row mt-3">
<div class="col-12">
<div class="alert alert-info">
<i class="bi bi-info-circle"></i>
<strong>Last Activity:</strong> {{ stats.last_attempt }}
</div>
</div>
</div>
{% endif %}
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom JavaScript -->
<script>
// Global variables
let attemptsChart = null;
let successChart = null;
// Initialize dashboard
document.addEventListener('DOMContentLoaded', function() {
initializeCharts();
loadChartData();
loadSuccessChartData();
setupEventListeners();
});
// Setup event listeners
function setupEventListeners() {
document.getElementById('filterForm').addEventListener('submit', function(e) {
e.preventDefault();
applyFilters();
});
}
// Initialize charts
function initializeCharts() {
// Login attempts over time chart
const attemptsCtx = document.getElementById('attemptsChart').getContext('2d');
attemptsChart = new Chart(attemptsCtx, {
type: 'line',
data: {
labels: [],
datasets: [{
label: 'Successful',
data: [],
borderColor: 'rgb(75, 192, 192)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
tension: 0.1
}, {
label: 'Failed',
data: [],
borderColor: 'rgb(255, 99, 132)',
backgroundColor: 'rgba(255, 99, 132, 0.2)',
tension: 0.1
}]
},
options: {
responsive: true,
plugins: {
title: {
display: true,
text: 'Login Attempts (Last 7 Days)'
}
},
scales: {
y: {
beginAtZero: true
}
}
}
});
// Success rate pie chart
const successCtx = document.getElementById('successChart').getContext('2d');
successChart = new Chart(successCtx, {
type: 'doughnut',
data: {
labels: ['Successful', 'Failed'],
datasets: [{
data: [0, 0], // Will be loaded via AJAX
backgroundColor: [
'rgba(75, 192, 192, 0.8)',
'rgba(255, 99, 132, 0.8)'
],
borderColor: [
'rgb(75, 192, 192)',
'rgb(255, 99, 132)'
],
borderWidth: 2
}]
},
options: {
responsive: true,
plugins: {
title: {
display: true,
text: 'Success vs Failure Rate'
}
}
}
});
}
// Load chart data from API
async function loadChartData() {
try {
const response = await fetch('/api/hourly-stats?days=7');
const data = await response.json();
const labels = data.hourly_stats.map(item => {
const date = new Date(item.hour + ':00:00');
return date.toLocaleDateString() + ' ' + date.getHours() + ':00';
});
const successData = data.hourly_stats.map(item => item.successful_attempts);
const failedData = data.hourly_stats.map(item => item.failed_attempts);
attemptsChart.data.labels = labels;
attemptsChart.data.datasets[0].data = successData;
attemptsChart.data.datasets[1].data = failedData;
attemptsChart.update();
} catch (error) {
console.error('Error loading chart data:', error);
}
}
// Load success chart data from API
async function loadSuccessChartData() {
try {
const response = await fetch('/api/stats');
const data = await response.json();
successChart.data.datasets[0].data = [data.successful_attempts, data.failed_attempts];
successChart.update();
} catch (error) {
console.error('Error loading success chart data:', error);
}
}
// Apply filters
async function applyFilters() {
const formData = new FormData(document.getElementById('filterForm'));
const params = new URLSearchParams();
for (const [key, value] of formData.entries()) {
if (value) {
params.append(key, value);
}
}
try {
const response = await fetch('/api/attempts?' + params.toString());
const data = await response.json();
updateAttemptsTable(data.attempts);
document.getElementById('attemptCount').textContent = data.attempts.length + ' results';
} catch (error) {
console.error('Error applying filters:', error);
alert('Error applying filters. Please try again.');
}
}
// Update attempts table
function updateAttemptsTable(attempts) {
const tbody = document.getElementById('attemptsTableBody');
tbody.innerHTML = '';
attempts.forEach(attempt => {
const row = document.createElement('tr');
const statusBadge = attempt.response_status == '200'
? `<span class="badge bg-success"><i class="bi bi-check-circle"></i> ${attempt.response_status}</span>`
: `<span class="badge bg-danger"><i class="bi bi-x-circle"></i> ${attempt.response_status}</span>`;
row.innerHTML = `
<td><span class="text-muted small">${attempt.timestamp}</span></td>
<td><i class="bi bi-person"></i> ${attempt.username}</td>
<td><code class="small">${attempt.a}</code></td>
<td>${statusBadge}</td>
<td class="text-truncate" style="max-width: 300px;" title="${attempt.response_message}">
${attempt.response_message}
</td>
`;
tbody.appendChild(row);
});
}
// Clear filters
function clearFilters() {
document.getElementById('filterForm').reset();
location.reload();
}
// Refresh data
function refreshData() {
location.reload();
}
// Auto-refresh every 30 seconds
setInterval(function() {
loadChartData();
loadSuccessChartData();
// Optionally refresh table data as well
applyFilters();
}, 30000);
</script>
</body>
</html> | 19,573 | dashboard | html | en | html | code | {"qsc_code_num_words": 1560, "qsc_code_num_chars": 19573.0, "qsc_code_mean_word_length": 4.80961538, "qsc_code_frac_words_unique": 0.20897436, "qsc_code_frac_chars_top_2grams": 0.05651073, "qsc_code_frac_chars_top_3grams": 0.03358657, "qsc_code_frac_chars_top_4grams": 0.026656, "qsc_code_frac_chars_dupe_5grams": 0.42303079, "qsc_code_frac_chars_dupe_6grams": 0.38251366, "qsc_code_frac_chars_dupe_7grams": 0.30894309, "qsc_code_frac_chars_dupe_8grams": 0.28681861, "qsc_code_frac_chars_dupe_9grams": 0.250833, "qsc_code_frac_chars_dupe_10grams": 0.2401706, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02125945, "qsc_code_frac_chars_whitespace": 0.49292393, "qsc_code_size_file_byte": 19573.0, "qsc_code_num_lines": 453.0, "qsc_code_num_chars_line_max": 132.0, "qsc_code_num_chars_line_mean": 43.20750552, "qsc_code_frac_chars_alphabet": 0.73471033, "qsc_code_frac_chars_comments": 0.03371992, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.44387755, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.00765306, "qsc_code_frac_chars_string_length": 0.15491171, "qsc_code_frac_chars_long_word_length": 0.01115576, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codehtml_cate_ast": 1.0, "qsc_codehtml_frac_words_text": 0.1009554, "qsc_codehtml_num_chars_text": 1976.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_codehtml_cate_ast": 0, "qsc_codehtml_frac_words_text": 1, "qsc_codehtml_num_chars_text": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/CorrosiveGas.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Corrosion;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.utils.Bundle;
public class CorrosiveGas extends Blob {
//FIXME should have strength per-cell
private int strength = 0;
@Override
protected void evolve() {
super.evolve();
if (volume == 0){
strength = 0;
} else {
Char ch;
int cell;
for (int i = area.left; i < area.right; i++){
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0 && (ch = Actor.findChar( cell )) != null) {
if (!ch.isImmune(this.getClass()))
Buff.affect(ch, Corrosion.class).set(2f, strength);
}
}
}
}
}
public CorrosiveGas setStrength(int str){
if (str > strength) {
strength = str;
}
return this;
}
private static final String STRENGTH = "strength";
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
strength = bundle.getInt( STRENGTH );
}
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put( STRENGTH, strength );
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour( Speck.factory(Speck.CORROSION), 0.4f );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 2,616 | CorrosiveGas | java | en | java | code | {"qsc_code_num_words": 328, "qsc_code_num_chars": 2616.0, "qsc_code_mean_word_length": 5.78658537, "qsc_code_frac_words_unique": 0.46036585, "qsc_code_frac_chars_top_2grams": 0.08061117, "qsc_code_frac_chars_top_3grams": 0.18018967, "qsc_code_frac_chars_top_4grams": 0.18545838, "qsc_code_frac_chars_dupe_5grams": 0.24341412, "qsc_code_frac_chars_dupe_6grams": 0.08746048, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01106501, "qsc_code_frac_chars_whitespace": 0.17087156, "qsc_code_size_file_byte": 2616.0, "qsc_code_num_lines": 92.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 28.43478261, "qsc_code_frac_chars_alphabet": 0.86399262, "qsc_code_frac_chars_comments": 0.31269113, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0862069, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00667408, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.01086957, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.10344828, "qsc_codejava_score_lines_no_logic": 0.32758621, "qsc_codejava_frac_words_no_modifier": 0.85714286, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 1, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/ToxicGas.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class ToxicGas extends Blob implements Hero.Doom {
@Override
protected void evolve() {
super.evolve();
int damage = 1 + Dungeon.depth/5;
Char ch;
int cell;
for (int i = area.left; i < area.right; i++){
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0 && (ch = Actor.findChar( cell )) != null) {
if (!ch.isImmune(this.getClass())) {
ch.damage(damage, this);
}
}
}
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour( Speck.factory( Speck.TOXIC ), 0.4f );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
@Override
public void onDeath() {
Badges.validateDeathFromGas();
Dungeon.fail( getClass() );
GLog.n( Messages.get(this, "ondeath") );
}
}
| 2,260 | ToxicGas | java | en | java | code | {"qsc_code_num_words": 287, "qsc_code_num_chars": 2260.0, "qsc_code_mean_word_length": 5.72473868, "qsc_code_frac_words_unique": 0.49825784, "qsc_code_frac_chars_top_2grams": 0.10346926, "qsc_code_frac_chars_top_3grams": 0.23128424, "qsc_code_frac_chars_top_4grams": 0.24102252, "qsc_code_frac_chars_dupe_5grams": 0.20328667, "qsc_code_frac_chars_dupe_6grams": 0.03408399, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01168969, "qsc_code_frac_chars_whitespace": 0.16725664, "qsc_code_size_file_byte": 2260.0, "qsc_code_num_lines": 77.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 29.35064935, "qsc_code_frac_chars_alphabet": 0.86131775, "qsc_code_frac_chars_comments": 0.34557522, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09090909, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00743746, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.09090909, "qsc_codejava_score_lines_no_logic": 0.36363636, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Web.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.WebParticle;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
public class Web extends Blob {
@Override
protected void evolve() {
int cell;
for (int i = area.left; i < area.right; i++){
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
off[cell] = cur[cell] > 0 ? cur[cell] - 1 : 0;
if (off[cell] > 0) {
volume += off[cell];
Char ch = Actor.findChar( cell );
if (ch != null && !ch.isImmune(this.getClass())) {
Buff.prolong( ch, Roots.class, TICK );
}
}
}
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour( WebParticle.FACTORY, 0.4f );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 2,083 | Web | java | en | java | code | {"qsc_code_num_words": 270, "qsc_code_num_chars": 2083.0, "qsc_code_mean_word_length": 5.57037037, "qsc_code_frac_words_unique": 0.50740741, "qsc_code_frac_chars_top_2grams": 0.10172872, "qsc_code_frac_chars_top_3grams": 0.22739362, "qsc_code_frac_chars_top_4grams": 0.23404255, "qsc_code_frac_chars_dupe_5grams": 0.26196809, "qsc_code_frac_chars_dupe_6grams": 0.11037234, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01337209, "qsc_code_frac_chars_whitespace": 0.17426788, "qsc_code_size_file_byte": 2083.0, "qsc_code_num_lines": 68.0, "qsc_code_num_chars_line_max": 79.0, "qsc_code_num_chars_line_mean": 30.63235294, "qsc_code_frac_chars_alphabet": 0.86104651, "qsc_code_frac_chars_comments": 0.37493999, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.08108108, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0030722, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.08108108, "qsc_codejava_score_lines_no_logic": 0.35135135, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Fire.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
public class Fire extends Blob {
@Override
protected void evolve() {
boolean[] flamable = Dungeon.level.flamable;
int cell;
int fire;
Freezing freeze = (Freezing)Dungeon.level.blobs.get( Freezing.class );
boolean observe = false;
for (int i = area.left-1; i <= area.right; i++) {
for (int j = area.top-1; j <= area.bottom; j++) {
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0) {
if (freeze != null && freeze.volume > 0 && freeze.cur[cell] > 0){
freeze.clear(cell);
off[cell] = cur[cell] = 0;
continue;
}
burn( cell );
fire = cur[cell] - 1;
if (fire <= 0 && flamable[cell]) {
Dungeon.level.destroy( cell );
observe = true;
GameScene.updateMap( cell );
}
} else if (freeze == null || freeze.volume <= 0 || freeze.cur[cell] <= 0) {
if (flamable[cell]
&& (cur[cell-1] > 0
|| cur[cell+1] > 0
|| cur[cell-Dungeon.level.width()] > 0
|| cur[cell+Dungeon.level.width()] > 0)) {
fire = 4;
burn( cell );
area.union(i, j);
} else {
fire = 0;
}
} else {
fire = 0;
}
volume += (off[cell] = fire);
}
}
if (observe) {
Dungeon.observe();
}
}
public static void burn( int pos ) {
Char ch = Actor.findChar( pos );
if (ch != null && !ch.isImmune(Fire.class)) {
Buff.affect( ch, Burning.class ).reignite( ch );
}
Heap heap = Dungeon.level.heaps.get( pos );
if (heap != null) {
heap.burn();
}
Plant plant = Dungeon.level.plants.get( pos );
if (plant != null){
plant.wither();
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour( FlameParticle.FACTORY, 0.03f );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 3,398 | Fire | java | en | java | code | {"qsc_code_num_words": 423, "qsc_code_num_chars": 3398.0, "qsc_code_mean_word_length": 5.37352246, "qsc_code_frac_words_unique": 0.38061466, "qsc_code_frac_chars_top_2grams": 0.08974923, "qsc_code_frac_chars_top_3grams": 0.20061593, "qsc_code_frac_chars_top_4grams": 0.21293445, "qsc_code_frac_chars_dupe_5grams": 0.23757149, "qsc_code_frac_chars_dupe_6grams": 0.13726353, "qsc_code_frac_chars_dupe_7grams": 0.05675319, "qsc_code_frac_chars_dupe_8grams": 0.03431588, "qsc_code_frac_chars_dupe_9grams": 0.03431588, "qsc_code_frac_chars_dupe_10grams": 0.03431588, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01446051, "qsc_code_frac_chars_whitespace": 0.20629782, "qsc_code_size_file_byte": 3398.0, "qsc_code_num_lines": 125.0, "qsc_code_num_chars_line_max": 81.0, "qsc_code_num_chars_line_mean": 27.184, "qsc_code_frac_chars_alphabet": 0.82832777, "qsc_code_frac_chars_comments": 0.22984108, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.1097561, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00152847, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.04878049, "qsc_codejava_score_lines_no_logic": 0.2195122, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
01bps/WiFi-Auto-Auth | templates/login.html | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WiFi Auto Auth Dashboard - Login</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
<style>
body {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
}
.login-card {
backdrop-filter: blur(10px);
background: rgba(255, 255, 255, 0.95);
border: none;
border-radius: 15px;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}
.login-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-radius: 15px 15px 0 0;
padding: 2rem;
text-align: center;
}
.login-form {
padding: 2rem;
}
.form-control {
border-radius: 10px;
padding: 0.75rem 1rem;
border: 2px solid #e9ecef;
transition: all 0.3s ease;
}
.form-control:focus {
border-color: #667eea;
box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}
.btn-login {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
border-radius: 10px;
padding: 0.75rem 2rem;
font-weight: 600;
transition: all 0.3s ease;
}
.btn-login:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}
.wifi-icon {
font-size: 3rem;
margin-bottom: 1rem;
}
.alert {
border-radius: 10px;
border: none;
}
</style>
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6 col-lg-5">
<div class="card login-card">
<div class="login-header">
<i class="bi bi-wifi wifi-icon"></i>
<h2 class="mb-0">WiFi Auto Auth</h2>
<p class="mb-0">Dashboard Login</p>
</div>
<div class="login-form">
<div class="alert alert-info" role="alert">
<i class="bi bi-info-circle"></i>
This dashboard is protected with HTTP Basic Authentication.
Your browser will prompt for credentials.
</div>
<div class="text-center">
<a href="/" class="btn btn-login btn-primary btn-lg">
<i class="bi bi-box-arrow-in-right"></i>
Access Dashboard
</a>
</div>
<hr class="my-4">
<div class="row text-center">
<div class="col-6">
<div class="p-3">
<i class="bi bi-shield-check text-success fs-3"></i>
<h6 class="mt-2">Secure Access</h6>
<small class="text-muted">Protected with authentication</small>
</div>
</div>
<div class="col-6">
<div class="p-3">
<i class="bi bi-graph-up text-primary fs-3"></i>
<h6 class="mt-2">Real-time Monitoring</h6>
<small class="text-muted">Live statistics and charts</small>
</div>
</div>
</div>
<div class="text-center mt-4">
<small class="text-muted">
<i class="bi bi-info-circle"></i>
Default credentials: admin / admin123
</small>
</div>
</div>
</div>
<div class="text-center mt-4">
<small class="text-white-50">
WiFi Auto Auth Dashboard v1.0.0
</small>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html> | 5,230 | login | html | en | shell | code | {"qsc_code_num_words": 504, "qsc_code_num_chars": 5230.0, "qsc_code_mean_word_length": 4.1984127, "qsc_code_frac_words_unique": 0.34722222, "qsc_code_frac_chars_top_2grams": 0.05671078, "qsc_code_frac_chars_top_3grams": 0.02977316, "qsc_code_frac_chars_top_4grams": 0.02835539, "qsc_code_frac_chars_dupe_5grams": 0.33034026, "qsc_code_frac_chars_dupe_6grams": 0.26039698, "qsc_code_frac_chars_dupe_7grams": 0.23298677, "qsc_code_frac_chars_dupe_8grams": 0.19990548, "qsc_code_frac_chars_dupe_9grams": 0.11247637, "qsc_code_frac_chars_dupe_10grams": 0.11247637, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.06647294, "qsc_code_frac_chars_whitespace": 0.47361377, "qsc_code_size_file_byte": 5230.0, "qsc_code_num_lines": 143.0, "qsc_code_num_chars_line_max": 112.0, "qsc_code_num_chars_line_mean": 36.57342657, "qsc_code_frac_chars_alphabet": 0.70214312, "qsc_code_frac_chars_comments": 0.01892925, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.26666667, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.025, "qsc_code_frac_chars_string_length": 0.14049104, "qsc_code_frac_chars_long_word_length": 0.0083788, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0} |
01bps/WiFi-Auto-Auth | config/logging_config.py | """
Professional logging configuration for WiFi Auto Auth application.
Provides structured, configurable logging with multiple output handlers and log rotation.
"""
import os
import sys
import logging
import logging.handlers
from pathlib import Path
from typing import Optional
class LoggerFactory:
"""Factory class for creating and managing loggers."""
_loggers = {}
_configured = False
@classmethod
def get_logger(cls, name: str) -> logging.Logger:
"""
Get or create a logger with the specified name.
Args:
name: Logger name (typically __name__ of the calling module)
Returns:
Configured logger instance
"""
if not cls._configured:
cls._setup_logging()
if name not in cls._loggers:
cls._loggers[name] = logging.getLogger(name)
return cls._loggers[name]
@classmethod
def _setup_logging(cls) -> None:
"""Set up the global logging configuration."""
if cls._configured:
return
# Create formatters
simple_formatter = logging.Formatter(
fmt='%(asctime)s [%(levelname)s] %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
detailed_formatter = logging.Formatter(
fmt='%(asctime)s [%(levelname)s] [%(name)s:%(funcName)s:%(lineno)d] %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
# Set up root logger
root_logger = logging.getLogger()
root_logger.setLevel(cls._get_log_level())
# Clear existing handlers to avoid duplicates
root_logger.handlers.clear()
# Console handler
if cls._is_console_logging_enabled():
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setLevel(cls._get_console_log_level())
console_handler.setFormatter(simple_formatter)
root_logger.addHandler(console_handler)
# File handler with rotation
if cls._is_file_logging_enabled():
file_handler = cls._create_file_handler(detailed_formatter)
file_handler.setLevel(logging.DEBUG) # Always capture all levels in file
root_logger.addHandler(file_handler)
cls._configured = True
@classmethod
def _get_log_level(cls) -> int:
"""Get the overall log level from environment variables."""
level_str = os.getenv('LOG_LEVEL', 'INFO').upper()
return getattr(logging, level_str, logging.INFO)
@classmethod
def _get_console_log_level(cls) -> int:
"""Get the console log level from environment variables."""
level_str = os.getenv('CONSOLE_LOG_LEVEL', os.getenv('LOG_LEVEL', 'INFO')).upper()
return getattr(logging, level_str, logging.INFO)
@classmethod
def _is_console_logging_enabled(cls) -> bool:
"""Check if console logging is enabled."""
return os.getenv('CONSOLE_LOGGING_ENABLED', 'true').lower() == 'true'
@classmethod
def _is_file_logging_enabled(cls) -> bool:
"""Check if file logging is enabled."""
return os.getenv('LOG_FILE_ENABLED', 'true').lower() == 'true'
@classmethod
def _create_file_handler(cls, formatter: logging.Formatter) -> logging.Handler:
"""Create a rotating file handler."""
log_dir = Path(os.getenv('LOG_DIR', './logs'))
log_dir.mkdir(exist_ok=True)
log_file = log_dir / 'wifi_auto_auth.log'
# Get rotation settings from environment
max_bytes = int(os.getenv('LOG_MAX_BYTES', '10485760')) # 10MB default
backup_count = int(os.getenv('LOG_BACKUP_COUNT', '5'))
# Use RotatingFileHandler for size-based rotation
handler = logging.handlers.RotatingFileHandler(
log_file,
maxBytes=max_bytes,
backupCount=backup_count,
encoding='utf-8'
)
handler.setFormatter(formatter)
return handler
@classmethod
def configure_from_args(cls, args) -> None:
"""
Configure logging based on command line arguments.
Args:
args: Parsed command line arguments with logging options
"""
if hasattr(args, 'log_level'):
os.environ['LOG_LEVEL'] = args.log_level
if hasattr(args, 'log_file'):
os.environ['LOG_FILE_ENABLED'] = 'true' if args.log_file else 'false'
if hasattr(args, 'log_dir'):
os.environ['LOG_DIR'] = args.log_dir
if hasattr(args, 'console_logging'):
os.environ['CONSOLE_LOGGING_ENABLED'] = 'true' if args.console_logging else 'false'
# Reconfigure logging with new settings
cls._configured = False
cls._setup_logging()
def get_logger(name: str) -> logging.Logger:
"""
Convenience function to get a logger.
Args:
name: Logger name (typically __name__ of the calling module)
Returns:
Configured logger instance
"""
return LoggerFactory.get_logger(name)
def setup_logging_from_env() -> None:
"""Set up logging configuration from environment variables."""
LoggerFactory._setup_logging()
# Convenience functions for common logging patterns
def log_function_entry(logger: logging.Logger, func_name: str, *args, **kwargs) -> None:
"""Log function entry with parameters."""
params = []
if args:
params.append(f"args={args}")
if kwargs:
params.append(f"kwargs={kwargs}")
param_str = ", ".join(params) if params else "no parameters"
logger.debug(f"Entering {func_name}({param_str})")
def log_function_exit(logger: logging.Logger, func_name: str, return_value=None) -> None:
"""Log function exit with return value."""
if return_value is not None:
logger.debug(f"Exiting {func_name} with return value: {return_value}")
else:
logger.debug(f"Exiting {func_name}")
def log_exception(logger: logging.Logger, exc: Exception, message: str = "Exception occurred") -> None:
"""Log an exception with full traceback."""
logger.exception(f"{message}: {exc}") | 6,106 | logging_config | py | en | python | code | {"qsc_code_num_words": 723, "qsc_code_num_chars": 6106.0, "qsc_code_mean_word_length": 5.22959889, "qsc_code_frac_words_unique": 0.24204703, "qsc_code_frac_chars_top_2grams": 0.02539011, "qsc_code_frac_chars_top_3grams": 0.0174557, "qsc_code_frac_chars_top_4grams": 0.01269505, "qsc_code_frac_chars_dupe_5grams": 0.23168474, "qsc_code_frac_chars_dupe_6grams": 0.23168474, "qsc_code_frac_chars_dupe_7grams": 0.1422904, "qsc_code_frac_chars_dupe_8grams": 0.1422904, "qsc_code_frac_chars_dupe_9grams": 0.11795821, "qsc_code_frac_chars_dupe_10grams": 0.08357577, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00261552, "qsc_code_frac_chars_whitespace": 0.24860793, "qsc_code_size_file_byte": 6106.0, "qsc_code_num_lines": 186.0, "qsc_code_num_chars_line_max": 104.0, "qsc_code_num_chars_line_mean": 32.82795699, "qsc_code_frac_chars_alphabet": 0.82149085, "qsc_code_frac_chars_comments": 0.22977399, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13861386, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.00990099, "qsc_code_frac_chars_string_length": 0.13559698, "qsc_code_frac_chars_long_word_length": 0.02308034, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codepython_cate_ast": 1.0, "qsc_codepython_frac_lines_func_ratio": 0.12871287, "qsc_codepython_cate_var_zero": false, "qsc_codepython_frac_lines_pass": 0.0, "qsc_codepython_frac_lines_import": 0.05940594, "qsc_codepython_frac_lines_simplefunc": 0.0, "qsc_codepython_score_lines_no_logic": 0.2970297, "qsc_codepython_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codepython_cate_ast": 0, "qsc_codepython_frac_lines_func_ratio": 0, "qsc_codepython_cate_var_zero": 0, "qsc_codepython_frac_lines_pass": 0, "qsc_codepython_frac_lines_import": 0, "qsc_codepython_frac_lines_simplefunc": 0, "qsc_codepython_score_lines_no_logic": 0, "qsc_codepython_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Inferno.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
public class Inferno extends Blob {
@Override
protected void evolve() {
super.evolve();
int cell;
boolean observe = false;
Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class );
Freezing freeze = (Freezing)Dungeon.level.blobs.get( Freezing.class );
Blizzard bliz = (Blizzard)Dungeon.level.blobs.get( Blizzard.class );
for (int i = area.left-1; i <= area.right; i++) {
for (int j = area.top-1; j <= area.bottom; j++) {
cell = i + j * Dungeon.level.width();
if (cur[cell] > 0) {
if (fire != null) fire.clear(cell);
if (freeze != null) freeze.clear(cell);
if (bliz != null && bliz.volume > 0 && bliz.cur[cell] > 0){
bliz.clear(cell);
off[cell] = cur[cell] = 0;
continue;
}
Fire.burn(cell);
} else if (Dungeon.level.flamable[cell]
&& (cur[cell-1] > 0
|| cur[cell+1] > 0
|| cur[cell-Dungeon.level.width()] > 0
|| cur[cell+Dungeon.level.width()] > 0)) {
Fire.burn(cell);
Dungeon.level.destroy( cell );
observe = true;
GameScene.updateMap( cell );
}
}
}
if (observe) {
Dungeon.observe();
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.pour( Speck.factory( Speck.INFERNO, true ), 0.4f );
}
@Override
public String tileDesc() {
return Messages.get(this, "desc");
}
}
| 2,572 | Inferno | java | en | java | code | {"qsc_code_num_words": 332, "qsc_code_num_chars": 2572.0, "qsc_code_mean_word_length": 5.1746988, "qsc_code_frac_words_unique": 0.43072289, "qsc_code_frac_chars_top_2grams": 0.05587893, "qsc_code_frac_chars_top_3grams": 0.13271246, "qsc_code_frac_chars_top_4grams": 0.12805588, "qsc_code_frac_chars_dupe_5grams": 0.14668219, "qsc_code_frac_chars_dupe_6grams": 0.07217695, "qsc_code_frac_chars_dupe_7grams": 0.02968568, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01527846, "qsc_code_frac_chars_whitespace": 0.21111975, "qsc_code_size_file_byte": 2572.0, "qsc_code_num_lines": 91.0, "qsc_code_num_chars_line_max": 73.0, "qsc_code_num_chars_line_mean": 28.26373626, "qsc_code_frac_chars_alphabet": 0.83144406, "qsc_code_frac_chars_comments": 0.30326594, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09433962, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00223214, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.05660377, "qsc_codejava_score_lines_no_logic": 0.18867925, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Corruption.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
public class Corruption extends Buff {
{
type = buffType.NEGATIVE;
announced = true;
}
private float buildToDamage = 0f;
@Override
public boolean attachTo(Char target) {
if (super.attachTo(target)){
target.alignment = Char.Alignment.ALLY;
return true;
} else {
return false;
}
}
@Override
public boolean act() {
buildToDamage += target.HT/200f;
int damage = (int)buildToDamage;
buildToDamage -= damage;
if (damage > 0)
target.damage(damage, this);
spend(TICK);
return true;
}
@Override
public void fx(boolean on) {
if (on) target.sprite.add( CharSprite.State.DARKENED );
else if (target.invisible == 0) target.sprite.remove( CharSprite.State.DARKENED );
}
@Override
public int icon() {
return BuffIndicator.CORRUPT;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc");
}
}
| 2,117 | Corruption | java | en | java | code | {"qsc_code_num_words": 267, "qsc_code_num_chars": 2117.0, "qsc_code_mean_word_length": 5.83520599, "qsc_code_frac_words_unique": 0.52434457, "qsc_code_frac_chars_top_2grams": 0.06546855, "qsc_code_frac_chars_top_3grams": 0.14634146, "qsc_code_frac_chars_top_4grams": 0.14120668, "qsc_code_frac_chars_dupe_5grams": 0.11681643, "qsc_code_frac_chars_dupe_6grams": 0.03594352, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0130905, "qsc_code_frac_chars_whitespace": 0.17005196, "qsc_code_size_file_byte": 2117.0, "qsc_code_num_lines": 83.0, "qsc_code_num_chars_line_max": 85.0, "qsc_code_num_chars_line_mean": 25.5060241, "qsc_code_frac_chars_alphabet": 0.87364826, "qsc_code_frac_chars_comments": 0.36891828, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.16326531, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00598802, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.12244898, "qsc_codejava_score_lines_no_logic": 0.30612245, "qsc_codejava_frac_words_no_modifier": 0.85714286, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/SoulMark.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
public class SoulMark extends FlavourBuff {
public static final float DURATION = 10f;
{
type = buffType.NEGATIVE;
announced = true;
}
@Override
public int icon() {
return BuffIndicator.CORRUPT;
}
@Override
public void fx(boolean on) {
if (on) target.sprite.add(CharSprite.State.MARKED);
else target.sprite.remove(CharSprite.State.MARKED);
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
}
| 1,583 | SoulMark | java | en | java | code | {"qsc_code_num_words": 208, "qsc_code_num_chars": 1583.0, "qsc_code_mean_word_length": 5.69711538, "qsc_code_frac_words_unique": 0.60576923, "qsc_code_frac_chars_top_2grams": 0.05738397, "qsc_code_frac_chars_top_3grams": 0.12827004, "qsc_code_frac_chars_top_4grams": 0.04810127, "qsc_code_frac_chars_dupe_5grams": 0.06919831, "qsc_code_frac_chars_dupe_6grams": 0.04725738, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01438304, "qsc_code_frac_chars_whitespace": 0.16550853, "qsc_code_size_file_byte": 1583.0, "qsc_code_num_lines": 56.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 28.26785714, "qsc_code_frac_chars_alphabet": 0.88266465, "qsc_code_frac_chars_comments": 0.49336702, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.14285714, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00997506, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.14285714, "qsc_codejava_score_lines_no_logic": 0.28571429, "qsc_codejava_frac_words_no_modifier": 0.8, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Terror.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Bundle;
public class Terror extends FlavourBuff {
public int object = 0;
private static final String OBJECT = "object";
{
type = buffType.NEGATIVE;
announced = true;
}
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle(bundle);
bundle.put(OBJECT, object);
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
object = bundle.getInt( OBJECT );
}
@Override
public int icon() {
return BuffIndicator.TERROR;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns());
}
public void recover() {
spend(-5f);
if (cooldown() <= 0){
detach();
}
}
}
| 1,769 | Terror | java | en | java | code | {"qsc_code_num_words": 225, "qsc_code_num_chars": 1769.0, "qsc_code_mean_word_length": 5.70222222, "qsc_code_frac_words_unique": 0.56, "qsc_code_frac_chars_top_2grams": 0.05455963, "qsc_code_frac_chars_top_3grams": 0.03039751, "qsc_code_frac_chars_top_4grams": 0.04442712, "qsc_code_frac_chars_dupe_5grams": 0.0639127, "qsc_code_frac_chars_dupe_6grams": 0.0436477, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01381215, "qsc_code_frac_chars_whitespace": 0.18145845, "qsc_code_size_file_byte": 1769.0, "qsc_code_num_lines": 71.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 24.91549296, "qsc_code_frac_chars_alphabet": 0.87223757, "qsc_code_frac_chars_comments": 0.44149237, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.125, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01417004, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.15, "qsc_codejava_score_lines_no_logic": 0.25, "qsc_codejava_frac_words_no_modifier": 0.85714286, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Regeneration.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.ChaliceOfBlood;
public class Regeneration extends Buff {
{
//unlike other buffs, this one acts after the hero and takes priority against other effects
//healing is much more useful if you get some of it off before taking damage
actPriority = HERO_PRIO - 1;
}
private static final float REGENERATION_DELAY = 10;
@Override
public boolean act() {
if (target.isAlive()) {
if (target.HP < regencap() && !((Hero)target).isStarving()) {
LockedFloor lock = target.buff(LockedFloor.class);
if (target.HP > 0 && (lock == null || lock.regenOn())) {
target.HP += 1;
if (target.HP == regencap()) {
((Hero) target).resting = false;
}
}
}
ChaliceOfBlood.chaliceRegen regenBuff = Dungeon.hero.buff( ChaliceOfBlood.chaliceRegen.class);
if (regenBuff != null)
if (regenBuff.isCursed())
spend( REGENERATION_DELAY * 1.5f );
else
spend( REGENERATION_DELAY - regenBuff.itemLevel()*0.9f );
else
spend( REGENERATION_DELAY );
} else {
diactivate();
}
return true;
}
public int regencap(){
return target.HT;
}
}
| 2,143 | Regeneration | java | en | java | code | {"qsc_code_num_words": 273, "qsc_code_num_chars": 2143.0, "qsc_code_mean_word_length": 5.52380952, "qsc_code_frac_words_unique": 0.53846154, "qsc_code_frac_chars_top_2grams": 0.04509284, "qsc_code_frac_chars_top_3grams": 0.10079576, "qsc_code_frac_chars_top_4grams": 0.03779841, "qsc_code_frac_chars_dupe_5grams": 0.09151194, "qsc_code_frac_chars_dupe_6grams": 0.07427056, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01513388, "qsc_code_frac_chars_whitespace": 0.19832011, "qsc_code_size_file_byte": 2143.0, "qsc_code_num_lines": 73.0, "qsc_code_num_chars_line_max": 98.0, "qsc_code_num_chars_line_mean": 29.35616438, "qsc_code_frac_chars_alphabet": 0.86263097, "qsc_code_frac_chars_comments": 0.44237051, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.05263158, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.05263158, "qsc_codejava_score_lines_no_logic": 0.18421053, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/WellFed.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Bundle;
public class WellFed extends Buff {
{
type = buffType.POSITIVE;
announced = true;
}
int left;
@Override
public boolean act() {
left --;
if (left < 0){
detach();
return true;
} else if (left % 18 == 0){
target.HP = Math.min(target.HT, target.HP + 1);
}
spend(TICK);
return true;
}
public void reset(){
//heals one HP every 18 turns for 450 turns
//25 HP healed in total
left = (int)Hunger.STARVING;
}
@Override
public int icon() {
return BuffIndicator.WELL_FED;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", left + 1);
}
private static final String LEFT = "left";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(LEFT, left);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
left = bundle.getInt(LEFT);
}
}
| 2,131 | WellFed | java | en | java | code | {"qsc_code_num_words": 280, "qsc_code_num_chars": 2131.0, "qsc_code_mean_word_length": 5.475, "qsc_code_frac_words_unique": 0.52142857, "qsc_code_frac_chars_top_2grams": 0.05479452, "qsc_code_frac_chars_top_3grams": 0.12393999, "qsc_code_frac_chars_top_4grams": 0.11480757, "qsc_code_frac_chars_dupe_5grams": 0.19112851, "qsc_code_frac_chars_dupe_6grams": 0.10828441, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01723148, "qsc_code_frac_chars_whitespace": 0.18301267, "qsc_code_size_file_byte": 2131.0, "qsc_code_num_lines": 87.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 24.49425287, "qsc_code_frac_chars_alphabet": 0.86329696, "qsc_code_frac_chars_comments": 0.39699672, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.15686275, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00933852, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.1372549, "qsc_codejava_score_lines_no_logic": 0.31372549, "qsc_codejava_frac_words_no_modifier": 0.875, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
0015/ThatProject | README.md | # [That Project](https://youtube.com/@ThatProject)
Welcome to my project repository.
The source code for each project can be downloaded here, and please refer to the below video for the project tutorial.
Thank you.
## ESP32/ESP32-S3 Projects
<p align="left">
<a href="https://youtu.be/4GVH3JicaPo">
<img src="https://github.com/0015/ThatProject/blob/master/ESP32-LoRa/misc/Chat_APP_SX1262.jpg"/>
</a>
</p>
[[USB-Serial] Android Phone + ESP32-LoRa Module + Chat App = Text Transceiver!]
[[Video]](https://youtu.be/4GVH3JicaPo)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32-LoRa/Chat_APP_SX1262)
#
<p align="left">
<a href="https://youtu.be/qq2FRv0lCPw">
<img src="https://github.com/0015/ThatProject/blob/master/ESP32_MICROPHONE/Broadcasting_Your_Voice/thumbnail/project_thumbnail.jpg"/>
</a>
</p>
[Broadcasting Your Voice with ESP32-S3 & INMP441]
[[Video]](https://youtu.be/qq2FRv0lCPw)[[Source Code]](https://github.com/0015/ThatProject/blob/master/ESP32_MICROPHONE/Broadcasting_Your_Voice)
#
<p align="left">
<a href="https://youtu.be/QDrJKkUJmFE">
<img src="https://github.com/0015/ThatProject/blob/master/ESP32_LVGL/LVGL8_SquareLine/04_Turntable_MP3_Player/demo/demo.gif"/>
</a>
</p>
[Creating Stunning Animations in MCU Using LVGL and SquareLine Studio with ESP32-S3]
[[Video]](https://youtu.be/QDrJKkUJmFE)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/LVGL8_SquareLine/04_Turntable_MP3_Player)
#
<p align="left">
<a href="https://youtu.be/kOYJ-4oZ8Ws">
<img src="https://github.com/0015/ThatProject/blob/master/Cellular/T-SIMCAM/demo/T_SIMCAM.jpg"/>
</a>
</p>
[T-SIMCAM, ESP32-S3 + Camera Module(OV2640) + LTE Modem(SIM7600G-H) + Google Fi SIM]
[[Video]](https://youtu.be/kOYJ-4oZ8Ws)[[Source Code]](https://github.com/0015/ThatProject/tree/master/Cellular/T-SIMCAM/01_T-SIMCAM_ImageUploader)
#
<p align="left">
<a href="https://youtu.be/J0AYSS8xxOY">
<img src="https://github.com/0015/ThatProject/blob/master/ESP32_LVGL/LVGL8_SquareLine/03_Let's_build_a_GPS_Speedometer/demo/part_1_demo.gif"/>
</a>
<a href="https://youtu.be/b_4m1A3A2yw">
<img src="https://github.com/0015/ThatProject/blob/master/ESP32_LVGL/LVGL8_SquareLine/03_Let's_build_a_GPS_Speedometer/demo/part_2_demo.gif"/>
</a>
</p>
[Developing Embedded GUI with SquareLine Studio [2/2]]
[[Video]](https://youtu.be/b_4m1A3A2yw)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/LVGL8_SquareLine/03_Let's_build_a_GPS_Speedometer)
[Let's build a GPS Speedometer with ESP32-S3 and BN-880Q(GPS, Compass) [1/2]]
[[Video]](https://youtu.be/J0AYSS8xxOY)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/LVGL8_SquareLine/03_Let's_build_a_GPS_Speedometer)
#
<p align="left">
<a href="https://youtu.be/2TOVohmUqOE">
<img src="https://github.com/0015/ThatProject/blob/master/ESP32_VideoPlayer/MiniLegoTV/demo/demo.gif"/>
</a>
</p>
[Mini Lego TV based on ESP32]
[[Video]](https://youtu.be/2TOVohmUqOE)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_VideoPlayer/MiniLegoTV)
#
<p align="left">
<a href="https://youtu.be/gliwNg25fLE">
<img src="https://github.com/0015/ThatProject/blob/master/ESP32_LVGL/LVGL8/5_System_Monitor/demo/demo.gif"/>
</a>
</p>
[Make your own System Monitor with ESP32 + LVGL 8]
[[Video]](https://youtu.be/gliwNg25fLE)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/LVGL8/5_System_Monitor)
#
<p align="left">
<a href="https://youtu.be/zJvDw4UVDLc">
<img src="https://i.ytimg.com/vi/zJvDw4UVDLc/hqdefault.jpg"/>
</a>
</p>
[LoRa, GPS Data showing on the Map]
[[Video]](https://youtu.be/zJvDw4UVDLc)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32-LoRa/LoRa_GPS_Data_Viewer)[[Try here]](https://0015.github.io/LoRa_GPS_Viewer)
#
<p align="left">
<a href="https://youtu.be/vaYJydZcObU">
<img src="https://i.ytimg.com/vi/vaYJydZcObU/hqdefault.jpg"/>
</a>
</p>
[My ESP32 Tag App for my own ESP32Tag Device!]
[[Video]](https://youtu.be/vaYJydZcObU)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_UWB/2_My-ESP32Tag-App)[[Google Play]](https://play.google.com/store/apps/details?id=com.thatproject.my_esp32tag)
#
* [QR Code Maker (ESP32+LVGL8)][[Video]](https://youtu.be/Ss3zBO-V9kI)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/LVGL8/4_QR_Code_Maker)
* [Part.2: Creating Tesla's Website in SquareLine Studio (ESP32+LVGL)][[Video]](https://youtu.be/7PXBPRm_8_Y)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/LVGL8_SquareLine/02_Tesla_Multi_Pages)
* [Creating Tesla's Website in SquareLine Studio (ESP32+LVGL)][[Video]](https://youtu.be/LrvqSjLzo44)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/LVGL8_SquareLine/01_Tesla_Single_Page)
* [ESP32 + UWB | Warning sounds depending on the distance][[Video]](https://youtu.be/xrDvu8QT1Qs)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_UWB/1_My_Anchor_With_Audio)
* [Not AirTag, But ESP32Tag][[Video]](https://youtu.be/_Bu3lw49m5s)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_UWB/0_ESP32TAG)
* [ESP32 | LVGL8 | Ep 3. Base Project for WiFi Settings][[Video]](https://youtu.be/r62vfOhWXeo)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/LVGL8/3_BaseProject_Network_Selector)
* [Auto Focus with OV5640 on ESP32 AI-Thinker Board][[Video]](https://youtu.be/922BWy3OOoQ)
* [OV5640 for ESP32 Camera (Compared to OV2640)][[Video]](https://youtu.be/BCvOBMQSliY)
* [ESP32CAM | Sending images via UDP?][[Video]](https://youtu.be/1kHxd5FOUEU)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_UDP)
* [Tic Tac Camera Using ESP32CAM And Wireless Charging][[Video]](https://youtu.be/hteut2R8eQ0)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/TicTacCamera)
* [ESP32 | LVGL8 | Ep 2. Shortcuts for Pull Stack Developer][[Video]](https://youtu.be/i4qrWbHXH3U)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/LVGL8/2_LILYPI_StackOverflow_BLE)
* [ESP32 | LVGL8 | Ep 1. Demos with LILY PI][[Video]](https://youtu.be/kRTFc2vY5A8)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/LVGL8/1_LILYPI_ST7796_LovyanGFX)
* [ESP32 | LVGL8 | Ep 0. GFX Setup (ft. LovyanGFX)][[Video]](https://youtu.be/IPCvQ4o_WP8)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/LVGL8/0_ILI9488_LovyanGFX)
* [Mini E-Paper | Ep1. Uploading Emoji to E-Paper from Flutter App (iOS & Android)][[Video]](https://youtu.be/pP9YXFNOBhY)[[Source Code]](https://github.com/0015/ThatProject/tree/master/E-Paper_Projects/01_Emoji2MiniE-Paper)
* [IoT | Cloud Firestore - Ep 4. Firebase Client Flutter App for iOS and Android][[Video]](https://youtu.be/nsopdabOcug)[[Source Code]](https://github.com/0015/ThatProject/tree/master/FIREBASE/Cloud_Firestore_Application/4_iot_firestore_flutter_app)
* [Send an SMS from ESP32 (ft. Twilio)][[Video]](https://youtu.be/SP4pvYCQAfc)[[Source Code]](https://github.com/0015/ThatProject/tree/master/MESSAGE/Twilio/0_ESP32TTGO_FIRESTORE_SMS)
* [ESP32 | Cloud Firestore - Ep 3. Status Icons on Display (The End)][[Video]](https://youtu.be/LR_FgObfuCw)[[Source Code]](https://github.com/0015/ThatProject/tree/master/FIREBASE/Cloud_Firestore_Application/3_Display_Done)
* [ESP32 | Cloud Firestore - Ep 2. Firebase Client For ESP32][[Video]](https://youtu.be/KiF9uGFkA_o)[[Source Code]](https://github.com/0015/ThatProject/tree/master/FIREBASE/Cloud_Firestore_Application/2_Firebase_Client)
* [ESP32 | Cloud Firestore - Ep 1. Firebase Setup][[Video]](https://youtu.be/KV0D8nrsBLg)[[Source Code]](https://github.com/0015/ThatProject/tree/master/FIREBASE/Cloud_Firestore_Application/1_Network_Class)
* [ESP32 | Cloud Firestore - Ep 0. Showing temp/humidity from DHT11 on TTGO display [Upgraded Version]][[Video]](https://youtu.be/aAUIlCWs_bc)[[Source Code]](https://github.com/0015/ThatProject/tree/master/FIREBASE/Cloud_Firestore_Application/0_ESP32TTGO_DHT11)
* [OTA Solution - Build your own OTA platform (2/2, ESP32 OTA Application)][[Video]](https://youtu.be/oNFqwvYYWe4)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_OTA/Simple_OTA_Solution/Simple_OTA_Application)
* [OTA Solution - Build your own OTA platform (1/2, Preparing Python Flask API Server)][[Video]](https://youtu.be/_uTZad8RMZk)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_OTA/Simple_OTA_Solution/Python_Flask_REST_API_Server)
* [AWS IoT | Python MQTT Client for Multiple ESP32CAM][[Video]](https://youtu.be/-0L0PrfuSEo)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_MQTT/3_Python_MQTT_Client_App)
* [AWS IoT | Flutter MQTT Client App [Full Version]][[Video]](https://youtu.be/aY7i0xnQW54)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_MQTT/2_Flutter_MQTT_Client_App/mqtt_esp32cam_viewer_full_version)
* [AWS IoT | Flutter MQTT Client App for macOS - UI Part (For Newbies)][[Video]](https://youtu.be/viGjd3VDlr4)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_MQTT/2_Flutter_MQTT_Client_App/mqtt_esp32cam_viewer_ui_part)
* [AWS IoT | ESP32CAM working as a publisher on MQTT][[Video]](https://youtu.be/7_3qbou_keg)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_MQTT/1_ESP32CAM_AWSMQTT)
* [AWS IoT | How to install Mosquitto Broker on Amazon EC2][[Video]](https://youtu.be/SDrkv2hUzAc)[[Template Code]](https://github.com/0015/ThatProject/tree/master/ESP32_MQTT/0_AWS_Mosquitto_Test)
* [ESP32 | LVGL7 = My Shortcuts for Windows 10 = (ft. BLE HID Keyboard)][[Video]](https://youtu.be/EWKAyQBdcYM)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_LVGL/MyShortcuts_LVGL7)
* [ESP32 | Multi-Touch Test(ft. FT6236)][[Video]](https://youtu.be/8sp4LKYSdEk)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_MultiTouch_FT6236/GetTouchEvent)
* [ESP32CAM | Android(Flutter App) Wired Communication - Base64 Encoding/Decoding [2/2]][[Video]](https://youtu.be/-jygTxRmroA)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam)
* [ESP32CAM | Android(Flutter App) Wired Communication - Baud Rate Test [1/2]][[Video]](https://youtu.be/Mod9gX7NWA8)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.1_BaudRateTest)
* [What's different TTGO T-Camera Plus vs ESP32CAM AI-THINKER?][[Video]](https://youtu.be/ixtT7kt4YdI)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_TTGO/TTGO_T-Camera/CameraWebServerForTCamera)
* [GY-BNO055 | Ep.0: Connecting with ESP32 TTGO via I2C (ft. Heading Direction)][[Video]](https://youtu.be/dgCpOPEA6ZM)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_TTGO/GY-BNO055/TTGO_GY-BNO055_Heading)
* [ESP32 | Walkie-Talkie based on Node.js Server for multi-clients (ft. PCM speaker)][[Video]](https://youtu.be/vq7mPgecGKA)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32_TTGO/Walkie-Talkie_Project/Server_NodeJS)
* [ESP32 | Walkie-Talkie, Half-duplex communication based on WebSocket][[Video]](https://youtu.be/kw30vLdrGE8)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_TTGO/Walkie-Talkie_Project)
* [Wireless Wiretap System using 2x ESP32, INMP441 & MAX98357A][[Video]](https://youtu.be/5q5a5pee4ZQ)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_MICROPHONE/Wiretap_INMP441_MAX98357A_via_websocket)
* [ESP32 Bluetooth LE Secure Server for multi clients (ft. PassKey)][[Video]](https://youtu.be/TwexLJwdLEw)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_TTGO/BLE_Secure_Server)
* [ESP32TTGO - Battery Indicator 🔋⚡][[Video]](https://youtu.be/osAOdmZuvDc)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_TTGO/TTGO_Battery_Indicator)
* [ESP32TTGO | INMP441 - Drawing a meter bar for sound level display (ft. TFT_eFEX)][[Video]](https://youtu.be/IqXVAG8ssjg)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_TTGO/INMP441_MeterBarForSoundLevel)
* [[ESP32TTGO x ESP32CAM] Which One Is Faster? RGB565 vs. JPEG (ft. Dedicated JPEG Decoder)][[Video]](https://youtu.be/aD3C-mGh7I8)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_TTGO/ESP32CAM_WiFi_Direct_v2_Faster)
* [[ESP32TTGO x ESP32CAM] Wi-Fi Direct! Output images of ESP32CAM to TTGO display. (ft. WebSocket)][[Video]](https://youtu.be/OdEmfRKDJts)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_TTGO/ESP32CAM_WiFi_Direct)
* [[ESP32 TTGO] My hardware key to operate my app (Ep.2/2 - Completing App)][[Video]](https://youtu.be/aGuBQSU2oMs)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_TTGO/my_hardware_key_demo_app)
* [[ESP32 TTGO] Getting Started! #StartingLine #BasicSetup (ft. Image Animation)][[Video]](https://youtu.be/Bl1C7Vdl3GA)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_TTGO/AnimationImage)
* [Toy Camera = ESP32CAM + ILI9488 + LVGL7 | Part 2, LVGL Configure #ESP32CAM #TOYCAM][[Video]](https://youtu.be/K4VEvUVOkG0)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_TOY_CAMERA/PART2)
* [Toy Camera = ESP32CAM + ILI9488 + LVGL7 | Part 1, Live Feed Display #ESP32CAM #TOYCAM][[Video]](https://youtu.be/K5Tr0AjK-Uc)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_TOY_CAMERA/PART1)
* [ESP32 | MPU6050 | MahonyAHRS - Adding BLE module(ft. String vs Float)][[Video]](https://youtu.be/lpnG7K0-E88)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_MPU6050_MahonyARHS)
* [ESP32 | MPU6050 - Using MahonyAHRS (ft. dice)][[Video]](https://youtu.be/UgROd5juFtM)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_MPU6050_MahonyARHS)
* [ESP32 | BLE HID - Camera Shutter App for the smartphone [Part. 3/3 ADD BLE HID]][[Video]](https://youtu.be/I6rlpXpBimc)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_LVGL/ESP-IDF_Camera_Timer_For_Smartphone_LVGL7/Part.3/camera_timer_ble_hid)
* [ESP32 | BLE HID - Camera Shutter App for the smartphone [Part. 2/3 UI Design in LVGL]][[Video]](https://youtu.be/IQsND5MwSEQ)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_LVGL/ESP-IDF_Camera_Timer_For_Smartphone_LVGL7/Part.2/camera_timer_ble_hid)
* [ESP32 | BLE HID - Camera Shutter App for the smartphone [Part. 1/3 LVGL on ESP-IDF]][[Video]](https://youtu.be/7-QiGUAWkys)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_LVGL/ESP-IDF_Camera_Timer_For_Smartphone_LVGL7/Part.1/camera_timer_ble_hid)
* [💬Chat App | ESP32 + ESP-NOW + LVGL7 | Part 2/2 - ESP-NOW bidirectional Comm (Primary - Secondary)
][[Video]](https://youtu.be/Kpqz00_IzTc)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_LVGL/ChatApp_LVGL7/Step_2_ESP-NOW)
* [💬Chat App | ESP32 + ESP-NOW + LVGL7 | Part 1/2 - LVGL UI Layout][[Video]](https://youtu.be/zRLQPF5417Y)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_LVGL/ChatApp_LVGL7/Step_1_UI)
* [ESP32 Dynamic WIFI configuration GUI using LVGL7.x][[Video]](https://youtu.be/AvJms6_Pf_o)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_LVGL/DynamicWIFIConnector_LVGL7)
* [ESP32 CAM with Arduino IDE | Tutorial - [Part.10] Multiple CAM Secure Dashboard (ft. HTTPS, WSS)🔒][[Video]](https://youtu.be/mxfj5Jg206A)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_MULTICAM/Part.10-Multiple_CAM_Dashboard_with_HTTPS_WSS)
* [ESP32 CAM with Arduino IDE | Tutorial - [Part.9] Multiple CAM Dashboard With New Features (ft. ⏯️🔴💾)][[Video]](https://youtu.be/ba9NLj0FKRU)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_MULTICAM/Part.9-Multiple_CAM_Dashboard_with_new_features)
* [ESP32 CAM with Arduino IDE | Tutorial - [Part.8] Multiple CAM Dashboard (ft. Modified Jpeg Header)][[Video]](https://youtu.be/rTY2Ibk-gco)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_MULTICAM/Part.8-Multiple_CAM_Dashboard)
* [ESP32 | BLUETOOTH CLASSIC | FLUTTER - Generate your own QR code and display it on the SSD1351🔲][[Video]](https://youtu.be/7HLh-7vONT4)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_BT_CLASSIC/ESP32_SSD1351_QR_BT_SERIAL)
* [ESP32 | BLUETOOTH CLASSIC | FLUTTER - *Realtime* Audio Recorder🗣️🎙️(ft. INMP441)][[Video]](https://youtu.be/AFGC9iYBxFQ)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_BT_CLASSIC/ESP32_INMP441_BT_SERIAL)
* [ESP32CAM | BLUETOOTH CLASSIC | FLUTTER - TWO-WAY Serial BT Communication (ft. uint8_t* buffer)🖼️][[Video]](https://youtu.be/Fl3tDWzTWk8)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_BT_CLASSIC/ESP32CAM_BT_SERIAL)
* [ESP32 | BLUETOOTH CLASSIC | FLUTTER - Let's build BT Serial based on the examples. (Ft. Chat App)][[Video]](https://youtu.be/WUw-_X66dLE)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_BT_CLASSIC/ESP32_BLUETOOTH_SERIAL_DEMO)
* [ESP32CAM | INMP441 - Doorbell🚪🔔 Project Rev.1 (Ft. Telegram)][[Video]](https://youtu.be/Fj21iHHUvf4)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_DOORBELL/Rev.1)
* [ESP32 | INMP441 | Tutorial - [Part.5] Speech-to-Text Powered by Google Cloud machine learning][[Video]](https://youtu.be/RZVzZfndIS0)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_MICROPHONE/ESP32_INMP441_SPEECH_TO_TEXT)
* [ESP32 | INMP441 | Tutorial - [Part.4] Capturing audio from i2s mic to save WAV file (I2S interface)][[Video]](https://youtu.be/qmruNKeIN-o)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_MICROPHONE/ESP32_INMP441_RECORDING)
* [ESP32 | INMP441 | Flutter | Tutorial - [Part.3] App for Sound Level Meter Viewer (ft. BLE Client)][[Video]](https://youtu.be/CcLt-nBLWJU)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_MICROPHONE/ESP32_INMP441_FLUTTER_BLE_APP/flutter_app_slm)
* [ESP32 | INMP441 | Tutorial - [Part.2] Emitting Sound Level Meter through BLE (ft. FreeRTOS)][[Video]](https://youtu.be/F88HRGTiiNw)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_MICROPHONE/ESP32_INMP441_SLM_BLE)
* [ESP32 | INMP441 | Introduce - [Part.1] Sound Level Meter][[Video]](https://youtu.be/QREKVWaZLi4)
* [ESP32 | INMP441 | Tutorial - [Part.0] Set up I2S for Microphone][[Video]](https://youtu.be/m8LwPNXqK9o)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_MICROPHONE/ESP32_INMP441_SETUP)
* [ESP32 | LittlevGL | Arduino IDE - [Part.2] By LittlevGL for Simple Note App📝][[Video]](https://youtu.be/PIzMeCShNZA)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_LVGL/SimpleNoteAPP_LVGL6/Part2)
* [ESP32 | LittlevGL | Arduino IDE - [Part.1] Basic LittlevGL for Simple Note App📝][[Video]](https://youtu.be/dErIWm-IVhc)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_LVGL/SimpleNoteAPP_LVGL6/Part1)
* [ESP32 | LittlevGL | Arduino IDE - [Part.0] Touch Display Setup for Simple Note App📝][[Video]](https://youtu.be/OXUZEHMFFwc)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_LVGL/SimpleNoteAPP_LVGL6/Part0)
* [ESP32 CAM | Google Vision - [Part.7] AI Camera📷🔥(Image labeling)][[Video]](https://youtu.be/bpCCqerQ56o)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_AICamera_Labelling)
* [ESP32 CAM | Flutter App - [Part.6] In wireless directly, a mobile app connecting ESP32CAM (Dash Cam)][[Video]](https://youtu.be/6FUbo9HRCoU)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_Dashcam_FLUTTER)
* [ESP32 CAM | Tutorial - [Part.5] In wireless directly, connecting ESP32CAM to ESP32 (feat. TFT LCD)][[Video]](https://youtu.be/TfuEI1-YrsA)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_WIFI_CONNECT)
* [ESP32 CAM with Flutter | Tutorial - [Part.4] Video Recording with FFmpeg (Baby Monitor)][[Video]](https://youtu.be/Z5vBs8Mk5rA)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_Xiaomi_Clone_FLUTTER/flutter_xiaomi_clone_app_ffmpeg)
* [ESP32 CAM with Flutter | Tutorial - [Part.3] Xiaomi YI Home App Clone (Baby Monitor)][[Video]](https://youtu.be/9GyOTlOGjSA)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_Xiaomi_Clone_FLUTTER/flutter_xiaomi_clone_app)
* [ESP32 CAM with Arduino IDE | Tutorial - [Part.2] World Wide Access to ESP32CAM (feat. GCP)][[Video]](https://youtu.be/CpIkG9N5-JM)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_GoogleCloudServer)
* [ESP32 CAM with Arduino IDE | Tutorial - [Part.1] Streaming into the local network][[Video]](https://youtu.be/kE0idrJYPII)[[Source Code]](https://github.com/0015/ThatProject/tree/master/ESP32CAM_Projects/ESP32_CAM_LocalServer)
* [ESP32 | FLUTTER | FIRESTORE - Dust Sensor, A simple Air Monitor App (Serverless REST API with Firestore)][[Video]](https://youtu.be/Z8ju93IYZ1A)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_dust_sensor_firestore_FLUTTER)
* [ESP32 | FLUTTER | BLE - MPU6050, Rotate your 3d object in the app][[Video]](https://youtu.be/FMZO4UTVZBk)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_MPU6050_ble_FLUTTER)
* [ESP32 | FLUTTER | BLE - Dust Sensor, A simple Air Monitor App (with Graph)][[Video]](https://youtu.be/w6jo2kJanqU)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_dust_sensor_ble_FLUTTER)
* [ESP32 | FLUTTER | WIFI | USB SERIAL - UPDATE WIFI CREDENTIALS VIA USB SERIAL (FEAT. UART)][[Video]](https://youtu.be/Be0vYIiJlyg)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESp32_Flutter_Android_wifi_credential_update_via_USB)
* [ESP32 | FLUTTER | USB SERIAL - HOW TO CONNECT THE ESP32 TO THE ANDROID(FLUTTER) USING THE USB CABLE (feat. UART)][[Video]](https://youtu.be/zk0xY88l6Rc)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_Flutter_Android_usb_serial_comm)
* [ESP32 | FLUTTER | BLE | WIFI - HOW TO UPDATE WIFI SSID & PW VIA BLE in ESP32][[Video]](https://youtu.be/-N52wL8xQzM)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_wifi_ssid_pw_via_ble)
* [ESP32 | FLUTTER | BLE | Data --* Server (feat. JoyPad)][[Video]](https://youtu.be/fQz7aajslJc)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP32_Flutter_JoyPad)
* [ESP32 | FLUTTER | BLE - Local Notification][[Video]](https://youtu.be/a71xc5Dm8xU)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_Flutter_BLE_LocalNoti)
* [ESP32 | BLE | SERVER - CLIENT][[Video]](https://youtu.be/jcGIA99V0c0)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_BLE_to_BLE)
* [ESP32 | FLUTTER | BLE - Ultrasonic Range Finder with 1.5inch OLED, Part 2][[Video]](https://youtu.be/s_BTQveXpwY)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_ultrasonic_range_finder)
* [ESP32 | FLUTTER | BLE - Ultrasonic Range Finder with 1.5inch OLED, Part 1][[Video]](https://youtu.be/sTaa4bGqVwc)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_ultrasonic_range_finder/Esp32_Ultrasonic_module)
* [ESP32 | Flutter | FIREBASE - Flutter application with ESP32 to get the sensor data through FIREBASE realtime DB][[Video]](https://youtu.be/nVrACWPXi8g)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_Flutter_firebase_DHT)
* [ESP32 | Flutter | Ble - Flutter application with ESP32 to get the sensor data through BLE][[Video]](https://youtu.be/13voX5Y9fTc)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_temperature_humidity_ble_FLUTTER)
* [ESP32 Project - Temperature & Humidity Check App with 1.5inch OLED SSD1351 and DHT11][[Video]](https://youtu.be/TF4Dm8Lq7Pc)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_temperature_humidity)
* [ESP32 Project - Hardware SPI vs Software SPI with SSD1351][[Video]](https://youtu.be/COPe5fKlkqA)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_display_ssd1351_jpeg)
* [ESP32 Project - Fast Jpeg images in 3.2-inch TFT LCD (ILI9341)][[Video]](https://youtu.be/4eD6recBq4M)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/Esp32_jpeg)
## NodeMCU(ESP8266) Projects
* [Youtube NodeMCU(ESP8266) Project](https://www.youtube.com/playlist?list=PLnq7JUnBumAxh2Sr-vKQYxeyW7a6qje7x)
* [Twitter Hash Search Application with #️⃣NodeMCU(ESP8266) #️⃣ILI9341][[Video]](https://youtu.be/lhOlv6Y4_vw)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP8266_Twitter_Hash_Search)
* [FIREBASE | FLUTTER | Stream builder from Realtime DB to Flutter(iOS, Android)][[Video]](https://youtu.be/uoQtH2IYBCU)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/FIREBASE/STREAMING_FROM_ESP_TO_FLUTTER/flutter_realtime_dht11)
* [FIREBASE | Streaming from ESP32 to ESP8266(Ft. DHT11 - Temperature, Humidity & Heat Index)][[Video]](https://youtu.be/-iKCn9lTD2Q)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/FIREBASE/STREAMING_FROM_ESP32_TO_ESP8266)
* [ESP-NOW | Communication between NodeMCU(ESP8266) as [Master] and two ESP32 as [Slave]][[Video]](https://youtu.be/F_h22AXZ7ts)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESPNOW/ESPNOW_ESP8266_MASTER_ESP32_SLAVE)
* [NodeMCU(ESP8266) | GPS | CSV Data Logging - GPS Tracker (feat. GPS Visualizer)🛰️][[Video]](https://youtu.be/edD3X6KG8AE)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP8266_GPS_DATA_LOG/ESP8266_GPS_TRACKER)
* [NodeMCU(ESP8266) | GPS | ILI9488 - Showing Google Map with Device Position on Display🗺️][[Video]](https://youtu.be/lQ157ftTnSs)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP8266_GOOGLEMAP_GPS)
* [NodeMCU(ESP8266) | GPS | ILI9488 - Showing the Latitude and Longitude on Display][[Video]](https://youtu.be/9wrHhbfYFXg)[[Source Code]](https://github.com/0015/IdeasNProjects/tree/master/ESP8266_BASIC_GPS)
### Created & Maintained By
[Eric Nam](https://github.com/0015)
([Youtube](https://www.youtube.com/ThatProject))
([Facebook](https://www.facebook.com/groups/138965931539175))
## License
Copyright 2019 - 2022 Eric N
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
| 27,483 | README | md | en | markdown | text | {"qsc_doc_frac_chars_curly_bracket": 0.0, "qsc_doc_frac_words_redpajama_stop": 0.07709286, "qsc_doc_num_sentences": 365.0, "qsc_doc_num_words": 3962, "qsc_doc_num_chars": 27483.0, "qsc_doc_num_lines": 341.0, "qsc_doc_mean_word_length": 5.1708733, "qsc_doc_frac_words_full_bracket": 0.0, "qsc_doc_frac_lines_end_with_readmore": 0.0, "qsc_doc_frac_lines_start_with_bullet": 0.0, "qsc_doc_frac_words_unique": 0.18021201, "qsc_doc_entropy_unigram": 5.11414194, "qsc_doc_frac_words_all_caps": 0.08355668, "qsc_doc_frac_lines_dupe_lines": 0.185, "qsc_doc_frac_chars_dupe_lines": 0.0084884, "qsc_doc_frac_chars_top_2grams": 0.05857373, "qsc_doc_frac_chars_top_3grams": 0.07028848, "qsc_doc_frac_chars_top_4grams": 0.10191829, "qsc_doc_frac_chars_dupe_5grams": 0.55030019, "qsc_doc_frac_chars_dupe_6grams": 0.50715088, "qsc_doc_frac_chars_dupe_7grams": 0.47254356, "qsc_doc_frac_chars_dupe_8grams": 0.45228682, "qsc_doc_frac_chars_dupe_9grams": 0.43398253, "qsc_doc_frac_chars_dupe_10grams": 0.41846049, "qsc_doc_frac_chars_replacement_symbols": 0.0, "qsc_doc_cate_code_related_file_name": 1.0, "qsc_doc_num_chars_sentence_length_mean": 37.87411598, "qsc_doc_frac_chars_hyperlink_html_tag": 0.55783575, "qsc_doc_frac_chars_alphabet": 0.7397449, "qsc_doc_frac_chars_digital": 0.06554602, "qsc_doc_frac_chars_whitespace": 0.07571954, "qsc_doc_frac_chars_hex_words": 0.0} | 0 | {"qsc_doc_frac_chars_replacement_symbols": 0, "qsc_doc_entropy_unigram": 0, "qsc_doc_frac_chars_top_2grams": 0, "qsc_doc_frac_chars_top_3grams": 0, "qsc_doc_frac_chars_top_4grams": 0, "qsc_doc_frac_chars_dupe_5grams": 0, "qsc_doc_frac_chars_dupe_6grams": 0, "qsc_doc_frac_chars_dupe_7grams": 0, "qsc_doc_frac_chars_dupe_8grams": 0, "qsc_doc_frac_chars_dupe_9grams": 0, "qsc_doc_frac_chars_dupe_10grams": 0, "qsc_doc_frac_chars_dupe_lines": 0, "qsc_doc_frac_lines_dupe_lines": 0, "qsc_doc_frac_lines_end_with_readmore": 0, "qsc_doc_frac_lines_start_with_bullet": 0, "qsc_doc_frac_words_all_caps": 0, "qsc_doc_mean_word_length": 0, "qsc_doc_num_chars": 0, "qsc_doc_num_lines": 0, "qsc_doc_num_sentences": 0, "qsc_doc_num_words": 0, "qsc_doc_frac_chars_hex_words": 0, "qsc_doc_frac_chars_hyperlink_html_tag": 1, "qsc_doc_frac_chars_alphabet": 0, "qsc_doc_frac_chars_digital": 0, "qsc_doc_frac_chars_whitespace": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.food.ChargrilledMeat;
import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
import java.util.ArrayList;
public class Burning extends Buff implements Hero.Doom {
private static final float DURATION = 8f;
private float left;
//for tracking burning of hero items
private int burnIncrement = 0;
private static final String LEFT = "left";
private static final String BURN = "burnIncrement";
{
type = buffType.NEGATIVE;
announced = true;
}
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( LEFT, left );
bundle.put( BURN, burnIncrement );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle(bundle);
left = bundle.getFloat( LEFT );
burnIncrement = bundle.getInt( BURN );
}
@Override
public boolean act() {
if (target.isAlive() && !target.isImmune(getClass())) {
int damage = Random.NormalIntRange( 1, 3 + Dungeon.depth/4 );
Buff.detach( target, Chill.class);
if (target instanceof Hero) {
Hero hero = (Hero)target;
hero.damage( damage, this );
burnIncrement++;
//at 4+ turns, there is a (turns-3)/3 chance an item burns
if (Random.Int(3) < (burnIncrement - 3)){
burnIncrement = 0;
ArrayList<Item> burnable = new ArrayList<>();
//does not reach inside of containers
for (Item i : hero.belongings.backpack.items){
if ((i instanceof Scroll && !(i instanceof ScrollOfUpgrade))
|| i instanceof MysteryMeat){
burnable.add(i);
}
}
if (!burnable.isEmpty()){
Item toBurn = Random.element(burnable).detach(hero.belongings.backpack);
GLog.w( Messages.get(this, "burnsup", Messages.capitalize(toBurn.toString())) );
if (toBurn instanceof MysteryMeat){
ChargrilledMeat steak = new ChargrilledMeat();
if (!steak.collect( hero.belongings.backpack )) {
Dungeon.level.drop( steak, hero.pos ).sprite.drop();
}
}
Heap.burnFX( hero.pos );
}
}
} else {
target.damage( damage, this );
}
if (target instanceof Thief) {
Item item = ((Thief) target).item;
if (item instanceof Scroll &&
!(item instanceof ScrollOfUpgrade)) {
target.sprite.emitter().burst( ElmoParticle.FACTORY, 6 );
((Thief)target).item = null;
} else if (item instanceof MysteryMeat) {
target.sprite.emitter().burst( ElmoParticle.FACTORY, 6 );
((Thief)target).item = new ChargrilledMeat();
}
}
} else {
detach();
}
if (Dungeon.level.flamable[target.pos] && Blob.volumeAt(target.pos, Fire.class) == 0) {
GameScene.add( Blob.seed( target.pos, 4, Fire.class ) );
}
spend( TICK );
left -= TICK;
if (left <= 0 ||
(Dungeon.level.water[target.pos] && !target.flying)) {
detach();
}
return true;
}
public void reignite( Char ch ) {
reignite( ch, DURATION );
}
public void reignite( Char ch, float duration ) {
left = duration;
}
@Override
public int icon() {
return BuffIndicator.FIRE;
}
@Override
public void fx(boolean on) {
if (on) target.sprite.add(CharSprite.State.BURNING);
else target.sprite.remove(CharSprite.State.BURNING);
}
@Override
public String heroMessage() {
return Messages.get(this, "heromsg");
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc", dispTurns(left));
}
@Override
public void onDeath() {
Badges.validateDeathFromFire();
Dungeon.fail( getClass() );
GLog.n( Messages.get(this, "ondeath") );
}
}
| 5,799 | Burning | java | en | java | code | {"qsc_code_num_words": 663, "qsc_code_num_chars": 5799.0, "qsc_code_mean_word_length": 6.26093514, "qsc_code_frac_words_unique": 0.3438914, "qsc_code_frac_chars_top_2grams": 0.04769935, "qsc_code_frac_chars_top_3grams": 0.19224283, "qsc_code_frac_chars_top_4grams": 0.21199711, "qsc_code_frac_chars_dupe_5grams": 0.21031077, "qsc_code_frac_chars_dupe_6grams": 0.12093471, "qsc_code_frac_chars_dupe_7grams": 0.02842689, "qsc_code_frac_chars_dupe_8grams": 0.02842689, "qsc_code_frac_chars_dupe_9grams": 0.02842689, "qsc_code_frac_chars_dupe_10grams": 0.02842689, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00687214, "qsc_code_frac_chars_whitespace": 0.17192619, "qsc_code_size_file_byte": 5799.0, "qsc_code_num_lines": 202.0, "qsc_code_num_chars_line_max": 90.0, "qsc_code_num_chars_line_mean": 28.70792079, "qsc_code_frac_chars_alphabet": 0.85755935, "qsc_code_frac_chars_comments": 0.15726849, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.10869565, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.00941273, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.07971014, "qsc_codejava_score_lines_no_logic": 0.26811594, "qsc_codejava_frac_words_no_modifier": 0.91666667, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/LockedFloor.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Bundle;
public class LockedFloor extends Buff {
//the amount of turns remaining before beneficial passive effects turn off
private float left = 50; //starts at 50 turns
@Override
public boolean act() {
spend(TICK);
if (!Dungeon.level.locked)
detach();
if (left >= 1)
left --;
return true;
}
public void addTime(float time){
left += time;
}
public boolean regenOn(){
return left >= 1;
}
private final String LEFT = "left";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put( LEFT, left );
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
left = bundle.getFloat( LEFT );
}
@Override
public int icon() {
return BuffIndicator.LOCKED_FLOOR;
}
@Override
public String toString() {
return Messages.get(this, "name");
}
@Override
public String desc() {
return Messages.get(this, "desc");
}
}
| 2,001 | LockedFloor | java | en | java | code | {"qsc_code_num_words": 260, "qsc_code_num_chars": 2001.0, "qsc_code_mean_word_length": 5.62307692, "qsc_code_frac_words_unique": 0.53076923, "qsc_code_frac_chars_top_2grams": 0.05745554, "qsc_code_frac_chars_top_3grams": 0.10396717, "qsc_code_frac_chars_top_4grams": 0.03898769, "qsc_code_frac_chars_dupe_5grams": 0.09165527, "qsc_code_frac_chars_dupe_6grams": 0.03830369, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01398176, "qsc_code_frac_chars_whitespace": 0.17791104, "qsc_code_size_file_byte": 2001.0, "qsc_code_num_lines": 82.0, "qsc_code_num_chars_line_max": 76.0, "qsc_code_num_chars_line_mean": 24.40243902, "qsc_code_frac_chars_alphabet": 0.87477204, "qsc_code_frac_chars_comments": 0.43728136, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13043478, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.01065719, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.17391304, "qsc_codejava_score_lines_no_logic": 0.30434783, "qsc_codejava_frac_words_no_modifier": 0.88888889, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
0-1-0/lightblue-0.4 | src/mac/LightAquaBlue/BBStreamingOutputStream.m | /*
* Copyright (c) 2009 Bea Lam. All rights reserved.
*
* This file is part of LightBlue.
*
* LightBlue is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LightBlue is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
*/
//
// BBStreamingOutputStream.m
// LightAquaBlue
//
#import "BBStreamingOutputStream.h"
@implementation BBStreamingOutputStream
- (id)initWithDelegate:(id)delegate
{
self = [super init];
mDelegate = delegate;
return self;
}
- (int)write:(const uint8_t *)buffer maxLength:(unsigned int)len
{
//NSLog(@"[BBStreamingOutputStream] writing data...");
int buflen = [mDelegate write:[NSData dataWithBytesNoCopy:(void *)buffer
length:len
freeWhenDone:NO]];
return buflen;
}
- (BOOL)hasSpaceAvailable
{
// must do write to determine whether space is available
return YES;
}
- (void)open
{
mStatus = NSStreamStatusOpen;
}
- (void)close
{
mStatus = NSStreamStatusClosed;
}
- (void)setDelegate:(id)delegate
{
mDelegate = delegate;
}
- (id)delegate
{
return mDelegate;
}
- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode
{
}
- (void)removeFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode
{
}
- (BOOL)setProperty:(id)property forKey:(NSString *)key
{
return NO;
}
- (id)propertyForKey:(NSString *)key
{
return nil;
}
- (NSStreamStatus)streamStatus
{
return mStatus;
}
@end
| 2,012 | BBStreamingOutputStream | m | en | limbo | code | {"qsc_code_num_words": 227, "qsc_code_num_chars": 2012.0, "qsc_code_mean_word_length": 5.9339207, "qsc_code_frac_words_unique": 0.61674009, "qsc_code_frac_chars_top_2grams": 0.01113586, "qsc_code_frac_chars_top_3grams": 0.02895323, "qsc_code_frac_chars_top_4grams": 0.04231626, "qsc_code_frac_chars_dupe_5grams": 0.11432814, "qsc_code_frac_chars_dupe_6grams": 0.04157387, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00385109, "qsc_code_frac_chars_whitespace": 0.22564612, "qsc_code_size_file_byte": 2012.0, "qsc_code_num_lines": 95.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 21.17894737, "qsc_code_frac_chars_alphabet": 0.86071887, "qsc_code_frac_chars_comments": 0.01789264, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.05194805, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.02074899, "qsc_code_frac_chars_long_word_length": 0.01265182, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
00JCIV00/cova | src/Command.zig | //! Container Argument for Sub Commands, Options, and Values.
//!
//! A Command may contain any mix of those Arguments or none at all if it's to be used as a standalone Command.
//!
//! End User Example:
//!
//! ```
//! # Standalone Command
//! myapp help
//!
//! # Command w/ Options and Values
//! myapp -d "This Value belongs to the 'd' Option." --toggle "This is a standalone Value."
//!
//! # Command w/ Sub Command
//! myapp --opt "Option for 'myapp' Command." subcmd --subcmd_opt "Option for 'subcmd' Sub Command."
//! ```
const std = @import("std");
const ascii = std.ascii;
const builtin = std.builtin;
const fmt = std.fmt;
const heap = std.heap;
const json = std.json;
const log = std.log.scoped(.cova);
const mem = std.mem;
const meta = std.meta;
const sort = std.sort;
const ArrayList = std.ArrayList;
const Io = std.Io;
const StaticStringMap = std.StaticStringMap;
const StringArrayHashMap = std.StringArrayHashMapUnmanaged;
const StringHashMap = std.StringHashMapUnmanaged;
const toLower = ascii.toLower;
const toUpper = ascii.toUpper;
const Option = @import("Option.zig");
const Value = @import("Value.zig");
const utils = @import("utils.zig");
const MultiSliceF = utils.MultiSliceFormatter;
/// Config for custom Command Types.
pub const Config = struct {
/// Option Config for this Command Type.
opt_config: Option.Config = .{},
/// Value Config for this Command Type.
val_config: Value.Config = .{},
/// The Global Help Prefix for all instances of this Command Type.
/// This can be overwritten per instance using the `help_prefix` field.
global_help_prefix: []const u8 = "",
/// A custom Help function to override the default `help()` function globally for ALL Command instances of this custom Command Type.
/// This function is 1st in precedence.
///
/// Function parameters:
/// 1. CommandT (This should be the `self` parameter. As such it needs to match the Command Type the function is being called on.)
/// 2. Writer (This is the Writer that will be written to.)
/// 3. Allocator (This does not have to be used within the function, but must be supported in case it's needed. If `null` is passed, this function was called at Comptime.)
global_help_fn: ?*const fn(anytype, anytype, ?mem.Allocator)anyerror!void = null,
/// A custom Usage function to override the default `usage()` function globally for ALL Command instances of this custom Command Type.
/// This function is 1st in precedence.
///
/// Function parameters:
/// 1. CommandT (This should be the `self` parameter. As such it needs to match the Command Type the function is being called on.)
/// 2. Writer (This is the Writer that will be written to.)
/// 3. Allocator (This does not have to be used within the function, but must be supported in case it's needed. If `null` is passed, this function was called at Comptime.)
global_usage_fn: ?*const fn(anytype, anytype, ?mem.Allocator)anyerror!void = null,
/// Help Category Order.
/// The order that Help Categories will be written when writing a Help Message.
help_category_order: []const HelpCategory = &.{ .Prefix, .Usage, .Header, .Aliases, .Examples, .Commands, .Options, .Values },
/// Indent string used for Usage/Help formatting.
/// Note, this will be used as the default across all Argument Types,
/// but it can be overriden in the Option and Value Configs.
indent_fmt: []const u8 = " ",
/// Group Title Format.
/// Used for all Argument Type Groups.
/// Must support the following format types in this order:
/// 1. String (Indent)
/// 2. String (Indent)
/// 3. String (Group Title)
group_title_fmt: []const u8 = " {s}|{s}|\n",
/// Group Separator string used for Help formatting.
/// Used for all Argument Type Groups.
/// Must support the following format types in this order:
/// 1. String (Indent)
/// 2. String (Indent)
group_sep_fmt: []const u8 = "{s}{s}\n",
/// Help Format for the displayed Command
/// Must support the following format types in this order:
/// 1. String (Indent)
/// 2. String (Command Name)
/// 3. String (Indent)
/// 4. String (Command Description)
help_header_fmt: []const u8 =
\\HELP:
\\{s}COMMAND: {s}
\\
\\{s}DESCRIPTION: {s}
\\
\\
,
/// Examples Header Format
/// Must support the following format types in this order:
/// 1. String (Indent)
examples_header_fmt: []const u8 = "{s}EXAMPLE(S):\n",
/// Alias List Format for the displayed Command
/// Must support the following format types in this order:
/// 1. String (Indent)
/// 2. Format (Aliases)
/// Note, there will be curly-brackets `{}` surrounding the list due to how Zig handles printing `[]const []const u8`.
cmd_alias_fmt: []const u8 =
\\{s}ALIAS(ES): {f}
\\
\\
,
/// Usage Header Format
/// Must support the following format types in this order:
/// 1. String (Indent)
/// 2. String (Command)
usage_header_fmt: []const u8 =
\\USAGE:
\\{s}{s}
,
/// Sub Commands Help Title Format
/// Must support the following format types in this order:
/// 1. String (Indent)
subcmds_help_title_fmt: []const u8 = "{s}SUBCOMMANDS:\n",
/// Options Help Title Format
/// Must support the following format types in this order:
/// 1. String (Indent)
opts_help_title_fmt: []const u8 = "{s}OPTIONS:\n",
/// Values Help Title Format
/// Must support the following format types in this order:
/// 1. String (Indent)
vals_help_title_fmt: []const u8 = "{s}VALUES:\n",
/// Sub Commands Help Format.
/// Must support the following format types in this order:
/// 1. String (Command Name)
/// 2. String (Command Description)
subcmds_help_fmt: []const u8 = "{s}: {s}",
/// Sub Commands Usage Format.
/// Must support the following format types in this order:
/// 1. String (Command Name)
subcmds_usage_fmt: []const u8 = "{s}",
/// Sub Commands Alias List Format.
/// Must support the following format types in this order:
/// 1. Format (Aliases)
/// Note, there will be curly-brackets `{}` surrounding the list due to how Zig handles printing `[]const []const u8`.
subcmd_alias_fmt: []const u8 = "[alias(es): {f}]",
/// Example Format
/// Must support the following format types in this order:
/// 1. String (Example)
example_fmt: []const u8 = "{s}",
/// The Default Max Number of Arguments for Commands, Options, and Values individually.
/// This is used for both `init()` and `from()` but can be overwritten for the latter.
max_args: u8 = 25,
/// Include tracking of Argument Indices.
/// If not included, this feature wil be `void`ed to reduce binary size.
include_arg_indices: bool = true,
/// Include Examples in Help Messages.
/// If not included, this feature wil be `void`ed to reduce binary size.
include_examples: bool = true,
/// During parsing, mandate that a Sub Command be used with a Command if one is available.
/// This will not include Usage/Help Commands.
/// This can be overwritten on individual Commands using the `Command.Custom.sub_cmds_mandatory` field.
global_sub_cmds_mandatory: bool = true,
/// During parsing, mandate that all Values for a Command must be filled, otherwise error out.
/// This should generally be set to `true`. Prefer to use Options over Values for Arguments that are not mandatory.
/// This can be overwritten on individual Commands using the `Command.Custom.vals_mandatory` field.
global_vals_mandatory: bool = true,
/// Allow Inheritable Options.
/// These are Options with the `inheritable` flag set that can be accessed from sub-Commands of their Parent Command.
global_allow_inheritable_opts: bool = true,
/// During parsing, mandate that Command instances of this Command Type, and their aliases, must be used in a case-sensitive manner.
/// This will also affect Command Validation, but will NOT affect Tab-Completion.
global_case_sensitive: bool = true,
/// During parsing, allow Abbreviated Command Names. (i.e. 'com' working for 'command')
/// This is seen in programs like `ip` on Linux, but may not be ideal in every use case.
/// Note, this does not check for uniqueness and will simply match on the first Command matching the abbreviation.
allow_abbreviated_cmds: bool = false,
/// The minimum length for an Abbreviated Command Name.
abbreviated_min_len: u16 = 3,
/// Help Categories.
pub const HelpCategory = enum{
/// The `global_help_prefix` or `help_prefix`.
Prefix,
/// The `usage()` function which can be overwritten.
Usage,
/// The `help_header_fmt`.
Header,
/// The Command's Aliases.
Aliases,
/// The Command's Examples.
Examples,
/// The Command's sub-Commands.
Commands,
/// The Command's Options.
Options,
/// The Command's Values.
Values,
};
/// Configuration for `optimized()`.
pub const OptimizeConfig = struct{
/// Set all `_fmt` fields to `""`.
/// This is useful for trimming down the binary size if Cova's Usage/Help functionality isn't being used.
no_formats: bool = true,
/// Remove the following features by setting them to `void`:
/// - `include_arg_indices`
/// - `include_examples`
remove_features: bool = true,
};
/// Return a CommandConfig that is optimized for smaller binary sizes.
pub fn optimized(optimize_config: OptimizeConfig) @This() {
var config: @This() = .{
.include_arg_indices = !optimize_config.remove_features,
.include_examples = !optimize_config.remove_features,
};
config.opt_config = Option.Config.optimized(OptimizeConfig, optimize_config);
config.val_config = Value.Config.optimized(OptimizeConfig, optimize_config);
if (optimize_config.no_formats) {
inline for (meta.fields(@This())) |field| {
if (mem.endsWith(u8, field.name, "_fmt")) @field(config, field.name) = "";
}
}
const conf = config;
return conf;
}
};
/// Create a Command Type with the Base (default) configuration.
pub fn Base() type { return Custom(.{}); }
/// Create a Custom Command Type from the provided Config (`config`).
pub fn Custom(comptime config: Config) type {
return struct {
/// Value Config Setup
const val_config = valConfig: {
var setup_val_config = config.val_config;
setup_val_config.CommandT = @This();
setup_val_config.indent_fmt = setup_val_config.indent_fmt orelse config.indent_fmt;
const setup_val_config_out = setup_val_config;
break :valConfig setup_val_config_out;
};
/// Option Config Setup
const opt_config = optConfig: {
var setup_opt_config = config.opt_config;
setup_opt_config.CommandT = @This();
setup_opt_config.val_config = val_config;
setup_opt_config.indent_fmt = setup_opt_config.indent_fmt orelse config.indent_fmt;
const setup_opt_config_out = setup_opt_config;
break :optConfig setup_opt_config_out;
};
/// The Custom Option type to be used by this Custom Command type.
pub const OptionT = Option.Custom(opt_config);
/// The Custom Value type to be used by this Custom Command type.
pub const ValueT = Value.Custom(val_config);
/// Custom Help Function.
/// Check (`Command.Config`) for details.
pub const global_help_fn = config.global_help_fn;
/// Custom Usage Function.
/// Check (`Command.Config`) for details.
pub const global_usage_fn = config.global_usage_fn;
/// Help Category Order.
/// Check (`Command.Config`) for details.
pub const help_category_order = config.help_category_order;
/// Group Title Format.
/// Check (`Command.Config`) for details.
pub const group_title_fmt = config.group_title_fmt;
/// Group Separator Format.
/// Check (`Command.Config`) for details.
pub const group_sep_fmt = config.group_sep_fmt;
/// Indent Format.
/// Check (`Command.Config`) for details.
pub const indent_fmt = config.indent_fmt;
/// Help Header Format.
/// Check (`Command.Config`) for details.
pub const help_header_fmt = config.help_header_fmt;
/// Alias List Header Format.
/// Check (`Command.Config`) for details.
pub const cmd_alias_fmt = config.cmd_alias_fmt;
/// Usage Header Format.
/// Check (`Command.Config`) for details.
pub const usage_header_fmt = config.usage_header_fmt;
/// Examples Header Format.
/// Check (`Command.Config`) for details.
pub const examples_header_fmt = config.examples_header_fmt;
/// Sub Commands Help Title Format.
/// Check (`Command.Config`) for details.
pub const subcmds_help_title_fmt = config.subcmds_help_title_fmt;
/// Options Help Title Format.
/// Check (`Command.Config`) for details.
pub const opts_help_title_fmt = config.opts_help_title_fmt;
/// Value Help Title Format.
/// Check (`Command.Config`) for details.
pub const vals_help_title_fmt = config.vals_help_title_fmt;
/// Sub Commands Help Format.
/// Check (`Command.Config`) for details.
pub const subcmds_help_fmt = config.subcmds_help_fmt;
/// Sub Commands Usage Format.
/// Check (`Command.Config`) for details.
pub const subcmds_usage_fmt = config.subcmds_usage_fmt;
/// Sub Commands Alias List Format.
/// Check (`Command.Config`) for details.
pub const subcmd_alias_fmt = config.subcmd_alias_fmt;
/// Example List Format.
/// Check (`Command.Config`) for details.
pub const example_fmt = config.example_fmt;
/// Global Help Prefix.
/// Check (`Command.Config`) for details.
pub const global_help_prefix = config.global_help_prefix;
/// Max Args.
/// Check (`Command.Config`) for details.
pub const max_args = config.max_args;
/// Include Argument Indices.
/// Check (`Command.Config`) for details.
pub const include_arg_indices = config.include_arg_indices;
/// Include Examples.
/// Check (`Command.Config`) for details.
pub const include_examples = config.include_examples;
/// Allow Abbreviated Commands.
/// Check (`Command.Config`) for details.
pub const allow_abbreviated_cmds = config.allow_abbreviated_cmds;
/// The minimum length for an Abbreviated Command Name.
/// Check (`Command.Config`) for details.
pub const abbreviated_min_len = config.abbreviated_min_len;
/// The Root Allocator for this Command.
/// This is the Allocator provided to `init()`.
///
/// **Internal Use.**
_root_alloc: ?mem.Allocator = null,
/// The Arena Allocator for this Command.
/// This is created by wrapping the Root Allocator provided to `init()`.
///
/// **Internal Use.**
_arena: ?heap.ArenaAllocator = null,
/// The Allocator for this Command.
/// This is set using `init()`.
///
/// **Internal Use.**
_alloc: ?mem.Allocator = null,
/// Command Groups.
/// These groups are used for organizing sub-Commands in Help messages and other Generated docs.
cmd_groups: ?[]const []const u8 = null,
/// Command Group of this Command.
/// This must line up with one of the Command Groups in the `cmd_groups` of the parent Command or it will be ignored.
/// This can be Validated using `ValidateConfig.check_arg_groups`.
cmd_group: ?[]const u8 = null,
/// Option Groups.
/// These groups are used for organizing Options in Help messages and other Generated docs.
opt_groups: ?[]const []const u8 = null,
/// Value Groups.
/// These groups are used for organizing Values in Help messages and other Generated docs.
val_groups: ?[]const []const u8 = null,
/// The Argument Index of this Command which is determined during parsing.
///
/// *This should be Read-Only for library users.*
arg_idx: if (include_arg_indices) ?u8 else void = if (include_arg_indices) null else {},
/// The list of Sub Commands this Command can take.
sub_cmds: ?[]const @This() = null,
//sub_cmds: if (@inComptime()) ?[]const @This() else ?[]@This() = null,
/// The Sub Command assigned to this Command during Parsing, if any.
///
/// *This should be Read-Only for library users.*
sub_cmd: ?*const @This() = null,
//sub_cmd: ?*@This() = null,
/// The Parent Command of this Command.
/// This will be filled in during Initialization.
parent_cmd: ?*const @This() = null,
/// The list of Options this Command can take.
opts: ?[]const OptionT = null,
/// The list of Values this Command can take.
vals: ?[]const ValueT = null,
/// The Name of this Command for user identification and Usage/Help messages.
name: []const u8,
/// A list of Alias Names for this Command that can be used in place of `name`.
alias_names: ?[]const []const u8 = null,
/// The Prefix message used immediately before a Usage/Help message is displayed.
help_prefix: []const u8 = global_help_prefix,
/// The Description of this Command for Usage/Help messages.
description: []const u8 = "",
/// An optional Verbose Description for this Command.
//verbose_description: ?[]const u8 = null,
/// Hide thie Command from Usage/Help messages.
hidden: bool = false,
examples: if (include_examples) ?[]const []const u8 else void = if (include_examples) null else {},
/// During parsing, mandate that a Sub Command be used with this Command if one is available.
/// Note, this will not include Usage/Help Commands.
sub_cmds_mandatory: bool = config.global_sub_cmds_mandatory,
/// During parsing, mandate that Options in the provided Option Groups be used.
/// This is a SUBSET of the `opt_groups`.
mandatory_opt_groups: ?[]const []const u8 = null,
/// During parsing, mandate that all Values for this Command must be filled, otherwise error out.
/// This should generally be set to `true`. Prefer to use Options over Values for Arguments that are not mandatory.
vals_mandatory: bool = config.global_vals_mandatory,
/// Allows this Command to inherit Options
allow_inheritable_opts: bool = config.global_allow_inheritable_opts,
/// During parsing, mandate that THIS Command, and its aliases, must be used in a case-sensitive manner.
/// This will NOT affect Command Validation nor Tab-Completion.
case_sensitive: bool = config.global_case_sensitive,
/// Config for Getting Options and Values.
pub const GetConfig = struct{
/// An optional Argument Group to filter the returned Options or Values.
arg_group: ?[]const u8 = null,
/// A filter for the status of an Option or Value
status: StatusFilter = .set_or_default,
pub const StatusFilter = enum {
set,
set_or_default,
all,
};
};
/// Argument Groups Types for `checkGroup()`.
pub const ArgumentGroupType = enum{
All,
Command,
Option,
Value,
};
/// Check if an Argument from a specific Argument Group was used.
pub fn checkArgGroup(self: @This(), ArgGroupT: ArgumentGroupType, arg_group: []const u8) bool {
if (utils.indexOfEql(ArgumentGroupType, &.{ .Command, .All }, ArgGroupT)) |_| checkCmdGroup: {
const sub_cmd = self.sub_cmd orelse break :checkCmdGroup;
const sub_cmd_group = sub_cmd.cmd_group orelse break :checkCmdGroup;
if (mem.eql(u8, sub_cmd_group, arg_group)) return true;
}
if (utils.indexOfEql(ArgumentGroupType, &.{ .Option, .All }, ArgGroupT)) |_| checkOptGroup: {
const check_opts = self.getOpts(.{ .arg_group = arg_group }) catch break :checkOptGroup;
if (check_opts.count() > 0) return true;
}
if (utils.indexOfEql(ArgumentGroupType, &.{ .Value, .All }, ArgGroupT)) |_| checkValGroup: {
const check_vals = self.getVals(.{ .arg_group = arg_group }) catch break :checkValGroup;
if (check_vals.count() > 0) return true;
}
return false;
}
/// Set the Argument Index of this Command.
pub fn setArgIdx(self: *const @This(), arg_idx: u8) void {
if (!include_arg_indices) return;
@constCast(self).arg_idx = arg_idx;
}
/// Set the active Sub Command for this Command.
pub fn setSubCmd(self: *const @This(), set_cmd: *const @This()) void {
@constCast(self).sub_cmd = set_cmd;
}
//pub fn setSubCmd(self: *@This(), set_cmd: *@This()) void {
// self.sub_cmd = set_cmd;
//}
/// Get a reference to the Sub Command of this Command that matches the provided Name (`cmd_name`).
pub fn getSubCmd(self: *const @This(), cmd_name: []const u8) ?*const @This() {
if (self.sub_cmds == null) return null;
for (self.sub_cmds.?[0..]) |*cmd| if (mem.eql(u8, cmd.name, cmd_name)) return cmd;
return null;
}
/// Check if the active Sub Command of this Command has the provided Name (`cmd_name`).
/// This is useful for analyzing Commands that DO NOT have Sub Commands that need to be subsequently analyzed.
pub fn checkSubCmd(self: *const @This(), cmd_name: []const u8) bool {
return if (self.sub_cmd) |cmd| mem.eql(u8, cmd.name, cmd_name) else false;
}
/// Returns the active Sub Command of this Command if it matches the provided Name (`cmd_name`).
/// This is useful for analyzing Commands that DO have Sub Commands that need to be subsequently analyzed.
pub fn matchSubCmd(self: *const @This(), cmd_name: []const u8) ?*const @This() {
return if (self.checkSubCmd(cmd_name)) self.sub_cmd.? else null;
}
/// Gets a StringHashMap of the Options from this Command that have a set Value using its initialization Allocator.
/// Memory is owned by this Command's Allocator. Look at the `...Alloc()` version of this method to use a different Allocator.
pub fn getOpts(self: *const @This(), get_config: GetConfig) !StringHashMap(OptionT) {
const alloc = self._alloc orelse return error.CommandNotInitialized;
return self.getOptsAlloc(alloc, get_config);
}
/// Gets a StringHashMap of the Options from this Command that have a set Value using the provided Allocator (`alloc`).
pub fn getOptsAlloc(self: *const @This(), alloc: mem.Allocator, get_config: GetConfig) !StringHashMap(OptionT) {
if (self.opts == null) return error.NoOptionsInCommand;
var map: StringHashMap(OptionT) = .empty;
errdefer map.deinit(alloc);
for (self.opts.?) |opt| {
checkGroup: {
const conf_group = get_config.arg_group orelse break :checkGroup;
const opt_group = opt.opt_group orelse continue;
if (!mem.eql(u8, conf_group, opt_group)) continue;
}
switch (get_config.status) {
.set => if (!opt.val.isSet()) continue,
.set_or_default => if (!opt.val.isSet() and !opt.val.hasDefault()) continue,
else => {},
}
try map.put(alloc, opt.name, opt);
}
return map;
}
/// Config for Checking or Matching multiple Options from this Command.
pub const OptionsCheckConfig = struct{
/// The type of Boolean Logic to be used when checking or matching Options.
logic: CheckLogic = .OR,
/// The maximum number of Options allowed for XOR Logic.
/// This technically breaks from actual XOR Logic, but allows a specific number of Options to be checked or matched.
xor_max: u8 = 1,
/// An optional Option Group to filter Checks/Matches.
opt_group: ?[]const u8 = null,
/// Boolean Logic types for checking/matching Options.
pub const CheckLogic = enum{
/// All Options from the provided list must be set.
AND,
/// At least one Option from the provided list must be set.
OR,
/// Exactly `xor_mx` number of Options from the provided list must be set.
XOR,
};
};
/// Check if certain Options (`opt_names`) of this Command have been set using the provided OptionsCheckConfig (`check_config`).
pub fn checkOpts(self: *const @This(), opt_names: []const []const u8, check_config: OptionsCheckConfig) bool {
const cmd_opts = self.opts orelse return false;
var logic_flag = false;
var opts_count: u8 = 0;
for (cmd_opts) |opt| {
checkGroup: {
const conf_group = check_config.opt_group orelse break :checkGroup;
const opt_group = opt.opt_group orelse continue;
if (!mem.eql(u8, conf_group, opt_group)) continue;
}
_ = utils.indexOfEql([]const u8, opt_names, opt.name) orelse continue;
if (!opt.val.isSet()) continue;
opts_count += 1;
switch (check_config.logic) {
.AND => {
if (opts_count == opt_names.len) {
logic_flag = true;
break;
}
},
.OR => logic_flag = true,
.XOR => {
if (opts_count > check_config.xor_max) {
logic_flag = false;
break;
}
logic_flag = true;
},
}
}
return logic_flag;
}
/// Returns a slice of Options `[]OptionT` Matching the given Options list (`opt_names`) and rules provided in the OptionCheckConfig (`check_config`).
/// This implementation uses this Command's initialization Allocator to allocate the OptionT slice.
pub fn matchOpts(self: *const @This(), opt_names: []const []const u8, check_config: OptionsCheckConfig) ![]OptionT {
const alloc = self._alloc orelse return error.CommandNotInitialized;
return self.matchOptsAlloc(opt_names, alloc, check_config);
}
/// Returns a slice of Options `[]OptionT` Matching the given Options list (`opt_names`) and rules provided in the OptionCheckConfig (`check_config`).
/// This implementation uses the provided Allocator (`alloc`) to allocate the OptionT slice.
pub fn matchOptsAlloc(self: *const @This(), opt_names: []const []const u8, alloc: mem.Allocator, check_config: OptionsCheckConfig) ![]OptionT {
const cmd_opts = self.opts orelse return error.NoOptionsInCommand;
var opts_list: ArrayList(OptionT) = .empty;
errdefer opts_list.deinit(alloc);
var logic_flag = false;
for (cmd_opts) |opt| {
checkGroup: {
const conf_group = check_config.opt_group orelse break :checkGroup;
const opt_group = opt.opt_group orelse continue;
if (!mem.eql(u8, conf_group, opt_group)) continue;
}
_ = utils.indexOfEql([]const u8, opt_names, opt.name) orelse continue;
if (!opt.val.isSet()) continue;
try opts_list.append(alloc, opt);
switch (check_config.logic) {
.AND => {
if (opts_list.items.len == opt_names.len) {
logic_flag = true;
break;
}
},
.OR => logic_flag = true,
.XOR => {
if (opts_list.items.len > check_config.xor_max) {
logic_flag = false;
break;
}
logic_flag = true;
},
}
}
if (!logic_flag) {
return switch (check_config.logic) {
.AND => error.MatchOptionLogicFailAND,
.OR => error.MatchOptionLogicFailOR,
.XOR => error.MatchOptionLogicFailXOR,
};
}
return try opts_list.toOwnedSlice(alloc);
}
/// Gets a slice of all Inheritable Options from this Command and recursively upward through all Parent Commands using the provided Allocator (`alloc`).
/// Memory is owned by this Command's Allocator. Look at the `...Alloc()` version of this method to use a different Allocator.
pub fn inheritableOpts(self: *const @This()) ![]OptionT {
const alloc = self._alloc orelse return error.CommandNotInitialized;
return self.inheritableOptsAlloc(alloc);
}
/// Gets a slice of all Inheritable Options from this Command and recursively upward through all Parent Commands.
pub fn inheritableOptsAlloc(self: *const @This(), alloc: mem.Allocator) ![]OptionT {
var opts_list: ArrayList(OptionT) = .empty;
errdefer opts_list.deinit(alloc);
if (self.opts) |opts| {
for (opts) |opt| {
if (opt.inheritable) try opts_list.append(alloc, opt);
}
}
if (self.parent_cmd) |parent| try (opts_list.appendSlice(alloc, try parent.inheritableOptsAlloc(alloc)));
return try opts_list.toOwnedSlice(alloc);
}
/// Gets a StringHashMap of this Command's Values using its initialization Allocator.
/// Memory is owned by this Command's Allocator. Look at the `...Alloc()` version of this method to use a different Allocator.
pub fn getVals(self: *const @This(), get_config: GetConfig) !StringHashMap(ValueT) {
const alloc = self._alloc orelse return error.CommandNotInitialized;
return self.getValsAlloc(alloc, get_config);
}
/// Gets a StringHashMap of this Command's Values using the provided Allocator (`alloc`).
pub fn getValsAlloc(self: *const @This(), alloc: mem.Allocator, get_config: GetConfig) !StringHashMap(ValueT) {
if (self.vals == null) return error.NoValuesInCommand;
var map: StringHashMap(ValueT) = .empty;
errdefer map.deinit(alloc);
for (self.vals.?) |val| {
checkGroup: {
const conf_group = get_config.arg_group orelse break :checkGroup;
const val_group = val.valGroup() orelse continue;
if (!mem.eql(u8, conf_group, val_group)) continue;
}
switch (get_config.status) {
.set => if (!val.isSet()) continue,
.set_or_default => if (!val.isSet() and !val.hasDefault()) continue,
else => {},
}
try map.put(alloc, val.name(), val);
}
return map;
}
/// Check if a Flag (`flag_name`) has been set on this Command as a Command, Option, or Value.
/// This is particularly useful for checking if Help or Usage has been called.
pub fn checkFlag(self: *const @This(), flag_name: []const u8) bool {
return (
(self.sub_cmd != null and mem.eql(u8, self.sub_cmd.?.name, flag_name)) or
checkOpt: {
if (self.opts != null) {
for (self.opts.?) |opt| {
if (
mem.eql(u8, opt.name, flag_name) and
mem.eql(u8, opt.val.childType(), "bool") and
opt.val.getAs(bool) catch false
)
break :checkOpt true;
}
}
break :checkOpt false;
} or
checkVal: {
if (self.vals != null) {
for (self.vals.?) |val| {
if (
mem.eql(u8, val.name(), flag_name) and
mem.eql(u8, val.childType(), "bool") and
val.getAs(bool) catch false
)
break :checkVal true;
}
}
break :checkVal false;
}
);
}
/// Creates the Help message for this Command and writes it to the provided Writer (`writer`).
/// Check Command.Config for customization options.
pub fn help(self: *const @This(), writer: *Io.Writer) !void {
if (global_help_fn) |helpFn| return helpFn(self, writer, self._alloc);
const alloc = self._alloc orelse return error.CommandNotInitialized;
for (help_category_order) |cat| {
switch (cat) {
.Prefix => try writer.print("{s}\n", .{ self.help_prefix }),
.Usage => try self.usage(writer),
.Header => {
try writer.print(help_header_fmt, .{
indent_fmt, self.name,
indent_fmt, self.description
});
},
.Aliases => {
if (self.alias_names) |aliases| try writer.print(cmd_alias_fmt, .{ indent_fmt, MultiSliceF{ .slices = aliases } });
},
.Examples => showExamples: {
if (!include_examples) break :showExamples;
const examples = self.examples orelse break :showExamples;
try writer.print(examples_header_fmt, .{ indent_fmt });
for (examples) |example| {
try writer.print("{s}{s}", .{ indent_fmt } ** 2);
try writer.print(example_fmt, .{ example });
try writer.print("\n", .{});
}
try writer.print("\n", .{});
},
.Commands => if (self.sub_cmds) |sub_cmds| {
try writer.print(subcmds_help_title_fmt, .{ indent_fmt });
var cmd_map: StringArrayHashMap(@This()) = .empty;
defer cmd_map.deinit(alloc);
for (sub_cmds) |cmd| try cmd_map.put(alloc, cmd.name, cmd);
var remove_list: ArrayList([]const u8) = .empty;
defer remove_list.deinit(alloc);
if (self.cmd_groups) |groups| {
var need_other_title = false;
for (groups) |group| {
var need_title = true;
var cmd_iter = cmd_map.iterator();
cmdGroup: while (cmd_iter.next()) |cmd_entry| {
const cmd = cmd_entry.value_ptr;
if (cmd.hidden) {
try remove_list.append(alloc, cmd.name);
continue;
}
if (mem.eql(u8, cmd.cmd_group orelse continue :cmdGroup, group)) {
if (need_title) {
try writer.print(group_title_fmt, .{ indent_fmt, group });
need_title = false;
need_other_title = true;
}
try writer.print("{s}{s}", .{ indent_fmt, indent_fmt });
try writer.print(subcmds_help_fmt, .{ cmd.name, cmd.description });
if (cmd.alias_names) |aliases| {
try writer.print("\n{s}{s}{s}", .{ indent_fmt, indent_fmt, indent_fmt });
try writer.print(subcmd_alias_fmt, .{ MultiSliceF{ .slices = aliases } });
}
try writer.print("\n", .{});
try remove_list.append(alloc, cmd.name);
}
}
if (!need_title) try writer.print(group_sep_fmt, .{ indent_fmt, indent_fmt });
}
if (need_other_title and remove_list.items.len < cmd_map.count()) try writer.print(group_title_fmt, .{ indent_fmt, "OTHER" });
}
for (remove_list.items) |rem_name| _ = cmd_map.orderedRemove(rem_name);
var cmd_iter = cmd_map.iterator();
while (cmd_iter.next()) |cmd_entry| {
const cmd = cmd_entry.value_ptr;
if (cmd.hidden) continue;
try writer.print("{s}{s}", .{ indent_fmt, indent_fmt });
try writer.print(subcmds_help_fmt, .{ cmd.name, cmd.description });
try writer.print("\n", .{});
}
try writer.print("\n", .{});
},
.Options => if (self.opts) |opts| {
try writer.print(opts_help_title_fmt, .{ indent_fmt });
var opt_map: StringArrayHashMap(OptionT) = .empty;
defer opt_map.deinit(alloc);
for (opts) |opt| try opt_map.put(alloc, opt.name, opt);
var remove_list: ArrayList([]const u8) = .empty;
defer remove_list.deinit(alloc);
if (self.opt_groups) |groups| {
var need_other_title = false;
for (groups) |group| {
var need_title = true;
var opt_iter = opt_map.iterator();
optGroup: while (opt_iter.next()) |opt_entry| {
const opt = opt_entry.value_ptr;
if (opt.hidden) {
try remove_list.append(alloc, opt.name);
continue;
}
if (mem.eql(u8, opt.opt_group orelse continue :optGroup, group)) {
if (need_title) {
try writer.print(group_title_fmt, .{ indent_fmt, group });
need_title = false;
need_other_title = true;
}
try writer.print("{s}{s}", .{ indent_fmt, indent_fmt });
try opt.help(writer);
try writer.print("\n", .{});
try remove_list.append(alloc, opt.name);
}
}
if (!need_title) try writer.print(group_sep_fmt, .{ indent_fmt, indent_fmt });
}
if (need_other_title and remove_list.items.len < opt_map.count()) try writer.print(group_title_fmt, .{ indent_fmt, "OTHER" });
}
for (remove_list.items) |rem_name| _ = opt_map.orderedRemove(rem_name);
var opt_iter = opt_map.iterator();
while (opt_iter.next()) |opt_entry| {
const opt = opt_entry.value_ptr;
if (opt.hidden) continue;
try writer.print("{s}{s}", .{ indent_fmt, indent_fmt });
try opt.help(writer);
try writer.print("\n", .{});
}
try writer.print("\n", .{});
},
.Values => if (self.vals) |vals| {
try writer.print(vals_help_title_fmt, .{ indent_fmt });
var val_map: StringArrayHashMap(ValueT) = .empty;
defer val_map.deinit(alloc);
for (vals) |val| try val_map.put(alloc, val.name(), val);
var remove_list: ArrayList([]const u8) = .empty;
defer remove_list.deinit(alloc);
if (self.val_groups) |groups| {
var need_other_title = false;
for (groups) |group| {
var need_title = true;
var val_iter = val_map.iterator();
valGroup: while (val_iter.next()) |val_entry| {
const val = val_entry.value_ptr;
if (mem.eql(u8, val.valGroup() orelse continue :valGroup, group)) {
if (need_title) {
try writer.print(group_title_fmt, .{ indent_fmt, group });
need_title = false;
need_other_title = true;
}
try writer.print("{s}{s}", .{ indent_fmt, indent_fmt });
try val.help(writer);
try writer.print("\n", .{});
try remove_list.append(alloc, val.name());
}
}
if (!need_title) try writer.print(group_sep_fmt, .{ indent_fmt, indent_fmt });
}
if (need_other_title and remove_list.items.len < val_map.count()) try writer.print(group_title_fmt, .{ indent_fmt, "OTHER" });
}
for (remove_list.items) |rem_name| _ = val_map.orderedRemove(rem_name);
var val_iter = val_map.iterator();
while (val_iter.next()) |val_entry| {
const val = val_entry.value_ptr;
try writer.print("{s}{s}", .{ indent_fmt, indent_fmt });
try val.help(writer);
try writer.print("\n", .{});
}
try writer.print("\n", .{});
},
}
}
}
/// Creates the Usage message for this Command and writes it to the provided Writer (`writer`).
pub fn usage(self: *const @This(), writer: anytype) !void {
if (global_usage_fn) |usageFn| return usageFn(self, writer, self._alloc);
try writer.print(usage_header_fmt, .{ indent_fmt, self.name });
if (self.opts) |opts| {
var post_sep: []const u8 = " | ";
var hidden_count: u8 = 0;
for (opts, 0..) |opt, idx| {
if (opt.hidden) {
hidden_count += 1;
continue;
}
try opt.usage(writer);
if (idx == opts.len - 1) post_sep = "";
try writer.print("{s}", .{ post_sep });
}
if (hidden_count < opts.len) try writer.print("\n{s}{s} ", .{ indent_fmt, self.name });
}
if (self.vals) |vals| {
var post_sep: []const u8 = " | ";
for (vals, 0..) |val, idx| {
try val.usage(writer);
if (idx == vals.len - 1) post_sep = "";
try writer.print("{s}", .{ post_sep });
}
try writer.print("\n{s}{s} ", .{ indent_fmt, self.name });
}
if (self.sub_cmds) |cmds| {
var post_sep: []const u8 = " | ";
for (cmds, 0..) |cmd, idx| {
if (cmd.hidden) continue;
try writer.print(subcmds_usage_fmt, .{ cmd.name });
if (idx == cmds.len - 1) post_sep = "";
try writer.print("{s}", .{ post_sep });
}
}
try writer.print("\n\n", .{});
}
/// Check if Usage or Help have been set and call their respective methods.
/// Output will be written to the provided Writer (`writer`).
pub fn checkUsageHelp(self: *const @This(), writer: anytype) !bool {
if (self.checkFlag("usage")) {
try self.usage(writer);
return true;
}
if (self.checkFlag("help")) {
try self.help(writer);
return true;
}
return false;
}
/// Config for creating Commands from Structs using `from()`.
pub const FromConfig = struct {
/// Ignore incompatible Types.
ignore_incompatible: bool = true,
/// Ignore prefix.
/// Any Field that matches this prefix will not be converted in to an Argument Type.
/// Setting this to `null` will disable prefix checks.
ignore_prefix: ?[]const u8 = "_",
/// Ignore the first field or parameter.
/// This is particularly useful when converting a Function that has a `self` parameter.
ignore_first: bool = false,
/// Convert underscores '_' to dashes '-' in field names.
/// Be sure to set the counterpart to this flag in the `ToConfig` if this Command will be converted back to a Struct or Union.
convert_syntax: bool = true,
/// Attempt to create Short Options.
/// This will attempt to make a short option name from the first letter of the field name in lowercase then uppercase,
/// sequentially working through each next letter if the previous one has already been used.
/// (Note, user must deconflict for 'u' and 'h' if using auto-generated Usage/Help Options.)
attempt_short_opts: bool = true,
/// A list of Option Short Names to Exclude if attempting to create Short Options.
excluded_short_opts: []const u8 = &.{ 'u', 'h' },
/// Convert Fields with default values to Options instead of Values.
/// There's a corresponding field in the `ToConfig`.
default_val_opts: bool = false,
/// A Name for the Command.
/// A null value will default to the Type name of the Struct.
cmd_name: ?[]const u8 = null,
/// A list of Alias Names for this Command.
cmd_alias_names: ?[]const []const u8 = null,
/// A Description for the Command.
cmd_description: []const u8 = "",
/// Example(s) for the Command.
cmd_examples: if (include_examples) ?[]const []const u8 else void = if (include_examples) null else {},
/// A Help Prefix for the Command.
cmd_help_prefix: []const u8 = global_help_prefix,
/// Command Groups for this Command
cmd_groups: ?[]const []const u8 = null,
/// Command Group for this Command.
cmd_group: ?[]const u8 = null,
/// Hide this Command.
cmd_hidden: bool = false,
/// Descriptions of the Command's Arguments (Sub Commands, Options, and Values).
/// When converting a Struct or Union, these Descriptions will be used across this Command and all of its sub-Commands.
/// When converting a Function, these Argument Names and Descriptions will be used for this Command only (no sub-Commands).
/// Note, for Functions, the Argument Names and Descriptions must be given in the proper Parameter order.
///
/// Format: `.{ "argument_name", "Description of the Argument." }`
sub_descriptions: []const struct { []const u8, []const u8 } = &.{ .{ "__nosubdescriptionsprovided__", "" } },
/// During parsing, mandate that a Sub Command be used with a Command if one is available.
/// This will not include Usage/Help Commands.
sub_cmds_mandatory: bool = config.global_sub_cmds_mandatory,
/// During parsing, mandate that all Values for a Command must be filled, otherwise error out.
/// This should generally be set to `true`. Prefer to use Options over Values for Arguments that are not mandatory.
vals_mandatory: bool = config.global_vals_mandatory,
/// During parsing, mandate that THIS Command, and its aliases, must be used in a case-sensitive manner.
/// This will NOT affect Command Validation nor Tab-Completion.
case_sensitive: bool = config.global_case_sensitive,
/// Max number of Sub Commands.
max_cmds: u8 = max_args,
/// Max number of Options.
max_opts: u8 = max_args,
/// Max number of Values.
max_vals: u8 = max_args,
};
/// Create a Command from the provided Type (`FromT`).
/// The provided Type must be a Comptime-known Function, Struct, or Union.
pub fn from(comptime FromT: type, comptime from_config: FromConfig) @This() {
const from_info = @typeInfo(FromT);
return switch (from_info) {
.@"fn" => fromFn(FromT, from_config),
.@"struct", .@"union" => fromStructOrUnion(FromT, from_config),
else => @compileError("The provided type '" ++ @typeName(FromT) ++ "' must be a Function, Struct, or Union."),
};
}
/// Create a Command from the provided Struct (`FromStruct`).
/// The provided Struct must be Comptime-known.
///
/// Field Types are converted as follows:
/// - Functions, Structs, Unions = Commands
/// - Valid Values = Single-Values (Valid Values can be found under `Value.zig/Generic`.)
/// - Valid Optionals = Single-Options (Valid Optionals are nullable versions of Valid Values.)
/// - Arrays of Valid Values = Multi-Values
/// - Arrays of Valid Optionals = Multi-Options
pub fn fromStructOrUnion(comptime FromT: type, comptime from_config: FromConfig) @This() {
const from_info = @typeInfo(FromT);
if (from_info != .@"struct" and from_info != .@"union") @compileError("Provided Type is not a Struct or Union.");
var from_cmds_buf: [from_config.max_cmds]@This() = undefined;
const from_cmds = from_cmds_buf[0..];
var cmds_idx: u8 = 0;
var from_opts_buf: [from_config.max_opts]OptionT = undefined;
const from_opts = from_opts_buf[0..];
var opts_idx: u8 = 0;
var short_names_buf: [from_config.max_opts]u8 = undefined;
const short_names = short_names_buf[0..];
var short_idx: u8 = 0;
var from_vals_buf: [from_config.max_vals]ValueT = undefined;
const from_vals = from_vals_buf[0..];
var vals_idx: u8 = 0;
// TODO: Make this a nullable field and just use null conditional syntax for adding descriptions below.
const arg_descriptions = StaticStringMap([]const u8).initComptime(from_config.sub_descriptions);
const fields = meta.fields(FromT);
const start_idx = if (from_config.ignore_first) 1 else 0;
inline for (fields[start_idx..]) |field| {
if (from_config.ignore_prefix) |prefix| {
if (field.name.len > prefix.len and mem.eql(u8, field.name[0..prefix.len], prefix)) continue;
}
var arg_name_buf: [field.name.len]u8 = field.name[0..].*;
const arg_name = if (!from_config.convert_syntax) field.name else argName: {
_ = mem.replace(u8, field.name[1..], "_", "-", arg_name_buf[1..]);
const arg_name_out = arg_name_buf;
break :argName arg_name_out[0..];
};
const arg_description = arg_descriptions.get(field.name);
// Handle Argument Types.
switch (field.type) {
@This() => {
if (field.default_value_ptr != null) {
from_cmds[cmds_idx] = @as(*field.type, @ptrCast(@alignCast(@constCast(field.default_value_ptr)))).*;
cmds_idx += 1;
continue;
}
},
OptionT => {
if (field.default_value_ptr != null) {
from_opts[opts_idx] = @as(*field.type, @ptrCast(@alignCast(@constCast(field.default_value_ptr)))).*;
opts_idx += 1;
continue;
}
},
ValueT => {
if (field.default_value_ptr != null) {
from_vals[vals_idx] = @as(*field.type, @ptrCast(@alignCast(@constCast(field.default_value_ptr)))).*;
vals_idx += 1;
continue;
}
},
else => {},
}
const field_info = @typeInfo(field.type);
// Handle non-Argument Types.
switch (field_info) {
// Commands
.@"fn", .@"struct" => {
const sub_config = comptime subConfig: {
var new_config = from_config;
new_config.cmd_name = arg_name;
new_config.cmd_description = arg_description orelse "The '" ++ arg_name ++ "' Command.";
break :subConfig new_config;
};
from_cmds[cmds_idx] = from(field.type, sub_config);
cmds_idx += 1;
},
// Options
// TODO - Handle Command Types passed as Optionals?
.optional => {
from_opts[opts_idx] = (OptionT.from(field, .{
.name = arg_name,
.short_name = if (from_config.attempt_short_opts) optShortName(
arg_name,
short_names,
&short_idx,
from_config.excluded_short_opts,
) else null,
.long_name = arg_name,
.ignore_incompatible = from_config.ignore_incompatible,
.opt_description = arg_description orelse "The '" ++ arg_name ++ "' Option.",
}) orelse continue);
opts_idx += 1;
},
// Values
.bool, .int, .float, .pointer, .@"enum" => {
if (from_config.default_val_opts and field.default_value_ptr != null) {
from_opts[opts_idx] = (OptionT.from(field, .{
.name = arg_name,
.short_name = if (from_config.attempt_short_opts) optShortName(
arg_name,
short_names,
&short_idx,
from_config.excluded_short_opts,
) else null,
.long_name = arg_name,
.ignore_incompatible = from_config.ignore_incompatible,
.opt_description = arg_description,
}) orelse continue);
opts_idx += 1;
continue;
}
from_vals[vals_idx] = (ValueT.from(field, .{
.ignore_incompatible = from_config.ignore_incompatible,
.val_name = arg_name,
.val_description = arg_description orelse "The '" ++ arg_name ++ "' Value.",
}) orelse continue);
vals_idx += 1;
},
// Multi
.array => |ary| {
const ary_info = @typeInfo(ary.child);
switch (ary_info) {
// Options
.optional => {
from_opts[opts_idx] = OptionT.from(field, .{
.name = arg_name,
.short_name = if (from_config.attempt_short_opts) optShortName(
arg_name,
short_names,
&short_idx,
from_config.excluded_short_opts,
) else null,
.long_name = arg_name,
.ignore_incompatible = from_config.ignore_incompatible,
.opt_description = arg_description orelse "The '" ++ arg_name ++ "' Value.",
}) orelse continue;
opts_idx += 1;
},
// Values
.bool, .int, .float, .pointer, .@"enum" => {
from_vals[vals_idx] = ValueT.from(field, .{
.ignore_incompatible = from_config.ignore_incompatible,
.val_name = arg_name,
.val_description = arg_description orelse "The '" ++ arg_name ++ "' Value.",
}) orelse continue;
vals_idx += 1;
},
else => if (!from_config.ignore_incompatible) @compileError("The field '" ++ field.name ++ "' of Type 'Array' is incompatible. Arrays must contain one of the following Types: Bool, Int, Float, Pointer (const u8), or their Optional counterparts."),
}
},
// Incompatible
else => if (!from_config.ignore_incompatible) @compileError("The field '" ++ field.name ++ "' of Type '" ++ @typeName(field.type) ++ "' is incompatible as it cannot be converted to a Command, Option, or Value."),
}
}
var cmd_name_buf: [@typeName(FromT).len]u8 = undefined;
const cmd_name = if (from_config.cmd_name) |c_name| c_name else cmdName: {
if (!from_config.convert_syntax) break :cmdName @typeName(FromT) else {
_ = mem.replace(u8, @typeName(FromT), "_", "-", cmd_name_buf[0..]);
const cmd_name_out = cmd_name_buf;
break :cmdName cmd_name_out[0..];
}
};
const from_cmds_out = from_cmds_buf;
const from_opts_out = from_opts_buf;
const from_vals_out = from_vals_buf;
return @This(){
.name = cmd_name,
.alias_names = from_config.cmd_alias_names,
.description = from_config.cmd_description,
.examples = from_config.cmd_examples,
.hidden = from_config.cmd_hidden,
.help_prefix = from_config.cmd_help_prefix,
.cmd_groups = from_config.cmd_groups,
.cmd_group = from_config.cmd_group,
.sub_cmds = if (cmds_idx > 0) from_cmds_out[0..cmds_idx] else null,
.opts = if (opts_idx > 0) from_opts_out[0..opts_idx] else null,
.vals = if (vals_idx > 0) from_vals_out[0..vals_idx] else null,
.sub_cmds_mandatory = from_config.sub_cmds_mandatory,
.vals_mandatory = from_config.vals_mandatory,
.case_sensitive = from_config.case_sensitive,
};
}
/// Create a deconflicted Option short name from the provided `arg_name` and existing `short_names`.
fn optShortName(
arg_name: []const u8,
short_names: []u8,
short_idx: *u8,
excluded_short_opts: []const u8,
) ?u8 {
return shortName: {
for (arg_name) |char| {
const ul_chars: [2]u8 = .{ toLower(char), toUpper(char) };
for (ul_chars) |ul| {
if (
short_idx.* > 0 and (
utils.indexOfEql(u8, short_names[0..short_idx.*], ul) != null or
utils.indexOfEql(u8, excluded_short_opts[0..], ul) != null
)
) continue;
short_names[short_idx.*] = ul;
short_idx.* += 1;
break :shortName ul;
}
}
break :shortName null;
};
}
/// Create a Command from the provided Function (`from_fn`).
/// The provided Function must be Comptime-known.
///
/// Types are converted as follows:
/// - Functions, Structs, Unions = Commands
/// - Valid Single-Parameters = Single-Values (Valid Values can be found under `Value.zig/Generic`.)
/// - Valid Array/Slice-Parameters = Multi-Values
/// - Note: Options can not be generated from Functions due to the lack of parameter names in `std.builtin.Type.@"fn".Param`.
pub fn fromFn(comptime FromFn: type, comptime from_config: FromConfig) @This() {
const from_info = @typeInfo(FromFn);
if (from_info != .@"fn") @compileError("Provided Type is not a Function.");
var from_cmds_buf: [from_config.max_cmds]@This() = undefined;
const from_cmds = from_cmds_buf[0..];
var cmds_idx: u8 = 0;
var from_vals_buf: [from_config.max_vals]ValueT = undefined;
const from_vals = from_vals_buf[0..];
var vals_idx: u8 = 0;
const arg_details = from_config.sub_descriptions; //StaticStringMap([]const u8).initComptime(from_config.sub_descriptions);
const params = from_info.@"fn".params;
const start_idx = if (from_config.ignore_first) 1 else 0;
inline for (params[start_idx..], 0..) |param, idx| {
const arg_name: ?[]const u8 = if (idx < arg_details.len) arg_details[idx][0] else null;
const arg_description = if (idx < arg_details.len) arg_details[idx][1] else "";
//const arg_description = "No description. (Descriptions cannot currently be generated from Function Parameters.)";//arg_descriptions.get(param.name);
// Handle Argument Types.
switch (@typeInfo(param.type.?)) {
// Commands
.@"fn", .@"struct", .@"union" => {
const sub_config = comptime subConfig: {
var new_config = from_config;
new_config.cmd_name = arg_name orelse "cmd-" ++ &.{ cmds_idx + 48 };
new_config.cmd_description = arg_description orelse "The '" ++ new_config.cmd_name ++ "' Command.";
new_config.sub_descriptions = &.{ .{ "__nosubdescriptionsprovided__", "" } };
break :subConfig new_config;
};
from_cmds[cmds_idx] = from(param, sub_config);
cmds_idx += 1;
},
// Values
.bool, .int, .float, .optional, .pointer, .@"enum" => {
from_vals[vals_idx] = (ValueT.from(param, .{
.ignore_incompatible = from_config.ignore_incompatible,
.val_name = arg_name orelse "val-" ++ .{ '0', (vals_idx + 48) },
.val_description = arg_description,
}) orelse continue);
vals_idx += 1;
},
// Multi
.array => |ary| {
const ary_info = @typeInfo(ary.child);
switch (ary_info) {
// Values
.bool, .int, .float, .optional, .pointer, .@"enum" => {
from_vals[vals_idx] = ValueT.from(param, .{
.ignore_incompatible = from_config.ignore_incompatible,
.val_name = arg_name orelse "val-" ++ .{ '0', (vals_idx + 48) },
.val_description = arg_description
}) orelse continue;
vals_idx += 1;
},
else => if (!from_config.ignore_incompatible) @compileError("The parameter of Type 'Array' is incompatible. Arrays must contain one of the following Types: Bool, Int, Float, Pointer (const u8), or their Optional counterparts."),
}
},
// Incompatible
else => if (!from_config.ignore_incompatible) @compileError("The parameter of Type '" ++ @typeName(param.type) ++ "' is incompatible as it cannot be converted to a Command or Value."),
}
}
const from_cmds_out = from_cmds_buf;
const from_vals_out = from_vals_buf;
return @This(){
.name = if (from_config.cmd_name) |c_name| c_name else @typeName(FromFn),
.alias_names = from_config.cmd_alias_names,
.description = from_config.cmd_description,
.examples = from_config.cmd_examples,
.hidden = from_config.cmd_hidden,
.cmd_groups = from_config.cmd_groups,
.cmd_group = from_config.cmd_group,
.help_prefix = from_config.cmd_help_prefix,
.sub_cmds = if (cmds_idx > 0) from_cmds_out[0..cmds_idx] else null,
.vals = if (vals_idx > 0) from_vals_out[0..vals_idx] else null,
.sub_cmds_mandatory = from_config.sub_cmds_mandatory,
.vals_mandatory = true,
.case_sensitive = from_config.case_sensitive,
};
}
/// Config for creating Structs from Commands using `to()`.
pub const ToConfig = struct {
/// Allow Unset Options and Values to be included.
/// When this is active, an attempt will be made to use the Struct's default value (if available) in the event of an Unset Option/Value.
allow_unset: bool = true,
/// Ignore Incompatible Types. Incompatible Types are those that fall outside of the conversion rules listed under `from()`.
/// When this is active, an attempt will be made to use the Struct's default value (if available) in the event of an Incompatible Type.
/// This will also allow Values to be set to sane defaults for Integers and Floats (0) as well as Strings ("").
allow_incompatible: bool = true,
/// Convert dashes '-' to underscores '_' in field names.
/// Be sure to set the counterpart to this flag in the `FromConfig` if this Command will be converted from a Struct or Union.
convert_syntax: bool = true,
/// Allow Fields with a default value to come from Options or Values.
/// There's a corresponding field in the `FromConfig`.
default_val_opts: bool = true,
};
/// Convert this Command to an instance of the provided Struct or Union Type (`toT`).
/// This is the inverse of `from()`.
///
/// Types are converted as follows:
/// - Commmands: Structs or Unions by recursively calling `to()`.
/// - Single-Options: Optional versions of Values.
/// - Single-Values: Booleans, Integers (Signed/Unsigned), and Pointers (`[]const u8`) only)
/// - Multi-Options/Values: Arrays of the corresponding Optionals or Values.
// TODO: Catch more error cases for Incompatible Types (i.e. Pointer not (`[]const u8`).
pub fn to(self: *const @This(), comptime ToT: type, to_config: ToConfig) !ToT {
const alloc = self._alloc orelse return error.CommandNotInitialized;
const type_info = @typeInfo(ToT);
if (type_info == .@"union") {
const vals_idx = if (self.vals) |vals| valsIdx: {
var idx: u8 = 0;
for (vals) |val| { if (val.isSet()) idx += 1; }
break :valsIdx idx;
} else 0;
const opts_idx = if (self.opts) |opts| optsIdx: {
var idx: u8 = 0;
for (opts) |opt| {
if (
opt.val.isSet() and
!mem.eql(u8, opt.name, "usage") and
!mem.eql(u8, opt.name, "help")
) idx += 1;
}
break :optsIdx idx;
} else 0;
const total_idx = vals_idx + opts_idx;
if (total_idx > 1) {
log.err("Commands from Unions can only hold 1 Value or Option, but '{d}' were given.", .{ total_idx });
return error.ExpectedOnlyOneValOrOpt;
}
}
const vals = getVals: {
var vals_list: ArrayList(ValueT) = .empty;
errdefer vals_list.deinit(alloc);
try vals_list.appendSlice(alloc, self.vals orelse &.{});
if (to_config.default_val_opts) optVals: {
for (self.opts orelse break :optVals) |opt| try vals_list.append(alloc, opt.val);
}
break :getVals try vals_list.toOwnedSlice(alloc);
};
defer alloc.free(vals);
var out: ToT = undefined;
const fields = meta.fields(ToT);
inline for (fields) |field| {
if (field.type == @This() or field.type == OptionT or field.type == ValueT) continue;
var arg_name_buf: [field.name.len]u8 = field.name[0..].*;
const arg_name = if (!to_config.convert_syntax) field.name else argName: {
_ = mem.replace(u8, field.name[1..], "_", "-", arg_name_buf[1..]);
break :argName arg_name_buf[0..];
};
const field_info = @typeInfo(field.type);
switch (field_info) {
// Commands
.@"struct" => {
@field(out, field.name) =
if (self.sub_cmd != null and mem.eql(u8, self.sub_cmd.?.name, arg_name))
try self.sub_cmd.?.to(field.type, to_config)
else if (to_config.allow_unset) field.type{}
else return error.ValueNotSet;
},
.@"union" => if (self.sub_cmd != null and mem.eql(u8, self.sub_cmd.?.name, arg_name)) {
return @unionInit(ToT, field.name, try self.sub_cmd.?.to(field.type, to_config));
},
// Options
.optional => |f_opt| if (self.opts) |opts| {
for (opts) |opt| {
if (mem.eql(u8, opt.name, arg_name)) {
if (!opt.val.isSet() and type_info == .@"struct") {
if (!to_config.allow_unset) return error.ValueNotSet;
@field(out, field.name) =
if (field.default_value_ptr) |def_val| @as(*field.type, @ptrCast(@alignCast(@constCast(def_val)))).*
else null;
break;
}
if (type_info == .@"union") return @unionInit(ToT, field.name, opt.val.getAs(f_opt.child) catch continue);
@field(out, field.name) = try opt.val.getAs(f_opt.child);
}
}
},
// Values
.bool, .int, .float, .pointer, .@"enum" => {
for (vals) |val| {
if (mem.eql(u8, val.name(), arg_name)) {
//if (!val.isSet() and val.entryIdx() == val.maxEntries() and type_info == .@"struct") {
if (!val.isSet() and type_info == .@"struct") {
if (!to_config.allow_unset) return error.ValueNotSet;
const def_val = field.default_value_ptr orelse {
log.err("The Field '{s}' has no default value.", .{ field.name });
return error.NoDefaultValue;
};
@field(out, field.name) = @as(*field.type, @ptrCast(@alignCast(@constCast(def_val)))).*;
break;
}
if (type_info == .@"union") return @unionInit(ToT, field.name, val.getAs(field.type) catch continue);
@field(out, field.name) = val.getAs(field.type) catch |err| setVal: {
if (!to_config.allow_incompatible) return error.IncompatibleType;
break :setVal switch (field_info) {
.bool => false,
.int, .float, => @as(field.type, 0),
.pointer => "",
else => return err,
};
};
}
}
},
// Multi
.array => |ary| {
const ary_info = @typeInfo(ary.child);
switch (ary_info) {
// - Options
.optional => |a_opt| if (self.opts) |opts| {
for (opts) |opt| {
if (mem.eql(u8, opt.name, arg_name)) {
if (!opt.val.isSet() and type_info == .@"struct") {
if (!to_config.allow_unset) return error.ValueNotSet;
@field(out, field.name) =
if (field.default_value_ptr) |def_val|
@as(*field.type, @ptrCast(@alignCast(@constCast(def_val)))).*
else .{ null } ** ary.len;
break;
}
const val_tag = if (a_opt.child == []const u8) "string" else @typeName(a_opt.child);
var f_ary: field.type = undefined;
for (f_ary[0..], 0..) |*elm, idx| elm.* = @field(opt.val.generic, val_tag)._set_args[idx];
if (type_info == .@"union") return @unionInit(ToT, field.name, f_ary);
@field(out, field.name) = f_ary;
break;
}
}
},
// - Values
.bool, .int, .float, .pointer => {
for (vals) |val| {
if (mem.eql(u8, val.name(), arg_name)) {
if (!val.isSet() and val.entryIdx() == val.maxEntries() and type_info == .@"struct") {
if (!to_config.allow_unset) return error.ValueNotSet;
const def_val = field.default_value_ptr orelse {
log.err("The Field '{s}' has no default value.", .{ field.name });
return error.NoDefaultValue;
};
@field(out, field.name) = @as(*field.type, @ptrCast(@alignCast(@constCast(def_val)))).*;
break;
}
const val_tag = if (ary.child == []const u8) "string" else @typeName(ary.child);
var f_ary: field.type = undefined;
for (f_ary[0..], 0..) |*elm, idx| elm.* = @field(val.generic, val_tag)._set_args[idx] orelse elmVal: {
break :elmVal switch (ary_info) {
.bool => false,
.int, .float, => @as(ary.child, 0),
.pointer => "",
else => if (!to_config.allow_incompatible) return error.IncompatibleType,
};
};
if (type_info == .@"union") return @unionInit(ToT, field.name, f_ary);
@field(out, field.name) = f_ary;
break;
}
}
},
else => {
if (!to_config.allow_incompatible) return error.IncompatibleType;
},
}
},
else => {
if (!to_config.allow_incompatible) return error.IncompatibleType;
},
}
}
return out;
}
/// Call this Command as the provided Function (`call_fn`), returning the provided Return Type (`ReturnT`).
/// If the Return Type is an Error Union, this method expects only the payload Type.
/// If the Function has a `self` parameter it can be provided using (`fn_self`).
/// This effectively wraps the `@call()` builtin function by using this Command's Values as the function parameters.
pub fn callAs(self: *const @This(), comptime call_fn: anytype, fn_self: anytype, comptime ReturnT: type) !ReturnT {
const fn_info = @typeInfo(@TypeOf(call_fn));
const fn_name = @typeName(@TypeOf(call_fn));
if (fn_info != .@"fn") {
log.err("Expected a Function but received '{s}'.", .{ fn_name });
return error.ExpectedFn;
}
if (self.vals == null or self.vals.?.len < fn_info.@"fn".params.len) {
log.err("The provided function requires {d} parameters but only {d} was/were provided.", .{
fn_info.@"fn".params.len,
if (self.vals == null) 0 else self.vals.?.len });
return error.ExpectedMoreParameters;
}
if (fn_info.@"fn".return_type.? != ReturnT) checkErrorUnion: {
const return_info = @typeInfo(fn_info.@"fn".return_type.?);
if (return_info == .error_union and return_info.error_union.payload == ReturnT) break :checkErrorUnion;
log.err("The return type of '{s}' does not match the provided return type '{s}'.", .{ fn_name, @typeName(ReturnT) });
return error.ReturnTypeMismatch;
}
const params = valsToParams: {
const param_types = comptime paramTypes: {
var types: [fn_info.@"fn".params.len]type = undefined;
for (types[0..], fn_info.@"fn".params) |*T, param| T.* = param.type.?;
break :paramTypes types;
};
var params_tuple: meta.Tuple(param_types[0..]) = undefined;
const start_idx = if (@TypeOf(fn_self) == param_types[0]) 1 else 0;
if (start_idx == 1) params_tuple[0] = fn_self;
inline for (self.vals.?, ¶ms_tuple, 0..) |val, *param, idx| {
if (idx < start_idx) continue;
param.* = try val.getAs(@TypeOf(param.*));
}
break :valsToParams params_tuple;
};
return @call(.auto, call_fn, params);
}
/// Create Sub Commands Enum.
/// This is useful for switching on the Sub Commands of this Command during analysis, but the Command (`self`) must be comptime-known.
/// Prefer to use `checkSubCmd`() and `matchSubCmd`() with conditional `if` statements.
pub fn SubCommandsEnum(comptime self: *const @This()) ?type {
if (self.sub_cmds == null) return null; //@compileError("Could not create Sub Commands Enum. This Command has no Sub Commands.");
var cmd_fields: [self.sub_cmds.?.len]builtin.Type.EnumField = undefined;
for (self.sub_cmds.?, cmd_fields[0..], 0..) |cmd, *field, idx| {
field.* = .{
.name = cmd.name,
.value = idx,
};
}
return @Type(builtin.Type{
.@"enum" = .{
.tag_type = u8,
.fields = cmd_fields[0..],
.decls = &.{},
.is_exhaustive = true,
}
});
}
/// Config for the Validation of this Command.
pub const ValidateConfig = struct {
// Check Argument Groups to ensure they exist.
check_arg_groups: bool = true,
// Check Command Alias Names to ensure they're distinct.
check_cmd_aliases: bool = true,
// Check Option Alias Names to ensure they're distinct.
check_opt_aliases: bool = true,
// Check for Usage/Help Commands
check_help_cmds: bool = true,
// Check for Usage/Help Options
check_help_opts: bool = true,
};
/// Validate this Command during Comptime using the provided ValidateConfig (`valid_config`).
/// This will check for:
/// - Distinct Sub Commands, Options, and Values
/// - Existing Argument Groups
/// - Distinct Command & Option Alias Names.
pub fn validate(comptime self: *const @This(), comptime valid_config: ValidateConfig) void {
comptime {
@setEvalBranchQuota(100_000);
const usage_help_strs = .{ "usage", "help" } ++ (.{ "" } ** (max_args - 2));
// Check for distinct Sub Commands and Validate them.
if (self.sub_cmds) |cmds| {
const idx_offset: u2 = if (valid_config.check_help_cmds) 2 else 0;
var distinct_cmd: [max_args][]const u8 =
if (!valid_config.check_help_cmds) .{ "" } ** max_args
else usage_help_strs;
for (cmds, 0..) |cmd, idx| {
if (self.case_sensitive and utils.indexOfEql([]const u8, distinct_cmd[0..idx], cmd.name) != null)
@compileError("The Sub Command '" ++ cmd.name ++ "' is set more than once.");
if (!self.case_sensitive and utils.indexOfEqlIgnoreCase(distinct_cmd[0..idx], cmd.name) != null)
@compileError("The Sub Command '" ++ cmd.name ++ "' is set more than once.");
distinct_cmd[idx + idx_offset] = cmd.name;
}
}
// Check for distinct Options.
if (self.opts) |opts| {
const idx_offset: u2 = if (valid_config.check_help_cmds) 2 else 0;
var distinct_name: [max_args][]const u8 =
if (!valid_config.check_help_opts) .{ "" } ** max_args
else usage_help_strs;
var distinct_short: [max_args]u8 =
if (!valid_config.check_help_opts) .{ ' ' } ** max_args
else .{ 'u', 'h' } ++ (.{ ' ' } ** (max_args - 2));
var distinct_long: [max_args][]const u8 =
if (!valid_config.check_help_opts) .{ "" } ** max_args
else usage_help_strs;
for (opts, 0..) |opt, idx| {
if (utils.indexOfEql([]const u8, distinct_name[0..], opt.name) != null)
@compileError("The Option '" ++ opt.name ++ "' is set more than once.");
distinct_name[idx + idx_offset] = opt.name;
if (opt.short_name != null and utils.indexOfEql(u8, distinct_short[0..], opt.short_name.?) != null)
@compileError("The Option Short Name '" ++ .{ opt.short_name.? } ++ "' is set more than once.");
distinct_short[idx + idx_offset] = opt.short_name orelse ' ';
if (opt.long_name) |long_name| {
if (
(opt.case_sensitive and utils.indexOfEql([]const u8, distinct_long[0..], long_name) != null) or
(!opt.case_sensitive and utils.indexOfEqlIgnoreCase(distinct_long[0..], long_name) != null)
) @compileError("The Option Long Name '" ++ long_name ++ "' is set more than once.");
}
distinct_long[idx + idx_offset] = opt.long_name orelse "a!garbage@long#name$";
}
}
// Check for distinct Values.
if (self.vals) |vals| {
var distinct_val: [max_args][]const u8 = .{ "" } ** max_args;
for (vals, 0..) |val, idx| {
if (utils.indexOfEql([]const u8, distinct_val[0..], val.name()) != null)
@compileError("The Value '" ++ val.name ++ "' is set more than once.");
distinct_val[idx] = val.name();
}
}
// Check for existing Argument Groups.
if (valid_config.check_arg_groups) {
// - Command Groups.
if (self.sub_cmds) |cmds| cmdGroups: {
const groups = self.cmd_groups orelse break :cmdGroups;
checkCmds: for (cmds) |cmd| {
if (utils.indexOfEql([]const u8, groups, cmd.cmd_group orelse continue :checkCmds) == null)
@compileError("The Command '" ++ cmd.name ++ "' has non-existent Group '" ++ cmd.cmd_group.? ++ "'.\n" ++
"This validation check can be disabled using `Command.Custom.ValidateConfig.check_arg_groups`.");
}
}
// - Option Groups.
if (self.opts) |opts| optGroups: {
const groups = self.opt_groups orelse break :optGroups;
checkCmds: for (opts) |opt| {
if (utils.indexOfEql([]const u8, groups, opt.opt_group orelse continue :checkCmds) == null)
@compileError("The Option '" ++ opt.name ++ "' has non-existent Group '" ++ opt.opt_group.? ++ "'.\n" ++
"This validation check can be disabled using `Command.Custom.ValidateConfig.check_arg_groups`.");
}
}
// - Mandatory Option Groups.
if (self.mandatory_opt_groups) |man_groups| {
if (self.opt_groups) |groups| {
for (man_groups) |man_group| {
if (utils.indexOfEql([]const u8, groups, man_group) == null)
@compileError(fmt.comptimePrint("The Mandatory Option Group {s} is not in the given Option Groups.", .{ man_group }));
}
}
else @compileError("Mandatory Option Groups must be a subset of Option Groups but no Option Groups were given.");
}
// - Value Groups.
if (self.vals) |vals| valGroups: {
const groups = self.val_groups orelse break :valGroups;
checkCmds: for (vals) |val| {
if (utils.indexOfEql([]const u8, groups, val.valGroup() orelse continue :checkCmds) == null)
@compileError("The Value '" ++ val.name() ++ "' has non-existent Group '" ++ val.valGroup.? ++ "'.\n" ++
"This validation check can be disabled using `Command.Custom.ValidateConfig.check_arg_groups`.");
}
}
}
// Check for Distinct Command Alias Names.
if (valid_config.check_cmd_aliases) distinctAliases: {
const cmds = self.sub_cmds orelse break :distinctAliases;
checkCmds1: for (cmds) |cmd_1| {
checkCmds2: for (cmds) |cmd_2| {
if (mem.eql(u8, cmd_1.name, cmd_2.name)) continue :checkCmds2;
checkAliases: for (cmd_1.alias_names orelse continue :checkCmds1) |alias| {
const case_sense = cmd_1.case_sensitive or cmd_2.case_sensitive;
if (
(case_sense and mem.eql(u8, cmd_2.name, alias)) or
(!case_sense and ascii.eqlIgnoreCase(cmd_2.name, alias))
)
@compileError(
"The Command '" ++ cmd_1.name ++ "' has Alias '" ++ alias ++ "' which overshadows the Command '" ++
cmd_2.name ++ "'.\n" ++
"This validation check can be disabled using `Command.Custom.ValidateConfig.check_cmd_aliases`."
);
if (
(case_sense and utils.indexOfEql([]const u8, cmd_2.alias_names orelse continue :checkAliases, alias) != null) or
(!case_sense and utils.indexOfEqlIgnoreCase(cmd_2.alias_names orelse continue :checkAliases, alias) != null)
)
@compileError(
"The Command '" ++ cmd_1.name ++ "' has Alias '" ++ alias ++ "' which overshadows an Alias of the Command '" ++
cmd_2.name ++ "'.\n" ++
"This validation check can be disabled using `Command.Custom.ValidateConfig.check_cmd_aliases`."
);
}
}
}
}
// Check for Distinct Option Alias Long Names.
if (valid_config.check_opt_aliases) distinctAliases: {
const opts = self.opts orelse break :distinctAliases;
checkCmds1: for (opts) |opt_1| {
const opt_1_ln = opt_1.long_name orelse {
if (opt_1.alias_long_names) |_| @compileError(fmt.comptimePrint("The Option {s} has aliases but no long name.", .{ opt_1.name }));
continue :checkCmds1;
};
checkCmds2: for (opts) |opt_2| {
const opt_2_ln = opt_2.long_name orelse {
if (opt_2.alias_long_names) |_| @compileError(fmt.comptimePrint("The Option {s} has aliases but no long name.", .{ opt_2.name }));
continue :checkCmds2;
};
if (mem.eql(u8, opt_1_ln, opt_2_ln)) continue :checkCmds2;
checkAliases: for (opt_1.alias_long_names orelse continue :checkCmds1) |alias| {
const case_sense = opt_1.case_sensitive or opt_2.case_sensitive;
if (
(case_sense and mem.eql(u8, opt_2_ln, alias)) or
(!case_sense and ascii.eqlIgnoreCase(opt_2_ln, alias))
)
@compileError(
"The Option '" ++ opt_1.name ++ "' has Alias '" ++ alias ++ "' which overshadows the Option '" ++
opt_2_ln ++ "'.\n" ++
"This validation check can be disabled using `Command.Custom.ValidateConfig.check_opt_aliases`."
);
if (
(case_sense and utils.indexOfEql([]const u8, opt_2.alias_long_names orelse continue :checkAliases, alias) != null) or
(!case_sense and utils.indexOfEqlIgnoreCase(opt_2.alias_long_names orelse continue :checkAliases, alias) != null)
)
@compileError(
"The Option '" ++ opt_1.name ++ "' has Alias '" ++ alias ++ "' which overshadows an Alias of the Option '" ++
opt_2.name ++ "'.\n" ++
"This validation check can be disabled using `Command.Custom.ValidateConfig.check_opt_aliases`."
);
}
}
}
}
}
}
/// Config for auto-generating Usage/Help Commands & Options during Initialization.
pub const UsageHelpConfig = struct{
/// Add Usage/Help message Commands to this Command.
add_help_cmds: bool = true,
/// Add Usage/Help message Options to this Command.
add_help_opts: bool = true,
/// Set a name for the Usage Options inner Value.
/// This only takes effect if `add_help_opts` is `true`.
usage_val_name: []const u8 = "usage_flag",
/// Set a name for the Help Options inner Value.
/// This only takes effect if `add_help_opts` is `true`.
help_val_name: []const u8 = "help_flag",
/// Set a description format for the Usage Command & Option.
/// Must support the following format types in this order:
/// 1. String (Command Name)
usage_desc_fmt: []const u8 = "Show the '{s}' usage display.",
/// Set a description format for the Help Command & Option.
/// Must support the following format types in this order:
/// 1. String (Command Name)
help_desc_fmt: []const u8 = "Show the '{s}' help display.",
/// Add Help Argument Group for Usage/Help Commands.
/// Note, this will only take effect if `add_help_cmds` is `true`.
add_cmd_help_group: AddHelpGroup = .AddIfOthers,
/// Add Help Argument Group for Usage/Help Options.
/// Note, this will only take effect if `add_help_opts` is `true`.
add_opt_help_group: AddHelpGroup = .AddIfOthers,
/// Help Argument Group Name.
help_group_name: []const u8 = "HELP",
/// Determine behavior for adding a Help Argument Group.
pub const AddHelpGroup = enum{
/// Add if there are other Argument Groups.
AddIfOthers,
/// Add regardless of other Argument Groups.
Add,
/// Do not add.
DoNotAdd,
};
};
/// Config for the Initialization of this Command.
pub const InitConfig = struct {
/// Validate this Command.
validate_cmd: bool = true,
/// Validation Config
valid_config: ValidateConfig = .{},
/// Usage/Help Config
help_config: UsageHelpConfig = .{},
/// Initialize this Command's Sub Commands.
init_subcmds: bool = true,
};
/// Initialize this Command with the provided InitConfig (`init_config`) by duplicating it with the provided Allocator (`alloc`) for Runtime use.
/// This should be used after this Command has been created in Comptime.
pub fn init(comptime self: *const @This(), alloc: mem.Allocator, comptime init_config: InitConfig) !*@This() {
return self.initCtx(init_config, true, null, alloc);
}
/// Initialize Recursively with Context (`is_root_cmd`).
/// *INTERNAL USE*
fn initCtx(
comptime self: *const @This(),
comptime init_config: InitConfig,
comptime is_root_cmd: bool,
parent_cmd: ?*const @This(),
init_alloc: mem.Allocator
) !if (is_root_cmd) *@This() else @This() {
const help_config = init_config.help_config;
if (init_config.validate_cmd) {
comptime var valid_config = init_config.valid_config;
valid_config.check_help_cmds = help_config.add_help_cmds;
valid_config.check_help_opts = help_config.add_help_opts;
const val_conf = valid_config;
self.validate(val_conf);
}
var init_cmd,
const alloc = setup: {
var cmd = try init_alloc.create(@This());
cmd.* = self.*;
if (is_root_cmd) {
cmd._root_alloc = init_alloc;
cmd._arena = heap.ArenaAllocator.init(init_alloc);
cmd._alloc = cmd._arena.?.allocator();
}
else cmd._alloc = init_alloc;
break :setup .{ cmd, cmd._alloc.? };
};
init_cmd.parent_cmd = parent_cmd;
const usage_description = fmt.comptimePrint(help_config.usage_desc_fmt, .{ self.name });
const help_description = fmt.comptimePrint(help_config.help_desc_fmt, .{ self.name });
if (help_config.add_help_cmds and (utils.indexOfEql([]const u8, &.{ "help", "usage" }, self.name) == null)) {
const add_cmd_help_group = switch (help_config.add_cmd_help_group) {
.AddIfOthers => ifOthers: {
if (init_cmd.cmd_groups) |cmd_groups| {
init_cmd.cmd_groups = try mem.concat(alloc, []const u8, &.{ cmd_groups, &.{ help_config.help_group_name } });
break :ifOthers true;
}
break :ifOthers false;
},
.Add => add: {
init_cmd.cmd_groups =
if (init_cmd.cmd_groups) |cmd_groups| try mem.concat(alloc, []const u8, &.{ cmd_groups, &.{ help_config.help_group_name } })
else try alloc.dupe([]const u8, &.{ help_config.help_group_name });
break :add true;
},
.DoNotAdd => false,
};
const help_sub_cmds = [2]@This(){
.{
.name = "usage",
.cmd_group = if (add_cmd_help_group) help_config.help_group_name else null,
.help_prefix = init_cmd.name,
.description = usage_description,
.parent_cmd = init_cmd,
._alloc = alloc,
},
.{
.name = "help",
.cmd_group = if (add_cmd_help_group) help_config.help_group_name else null,
.help_prefix = init_cmd.name,
.description = help_description,
.parent_cmd = init_cmd,
._alloc = alloc,
}
};
init_cmd.sub_cmds =
if (init_cmd.sub_cmds != null) try mem.concat(alloc, @This(), &.{ init_cmd.sub_cmds.?, help_sub_cmds[0..] })
else try alloc.dupe(@This(), help_sub_cmds[0..]);
}
if (init_config.init_subcmds) addSubCmds: {
const sub_cmds = if (self.sub_cmds) |s_cmds| s_cmds else break :addSubCmds;
const sub_len = init_cmd.sub_cmds.?.len;
var init_subcmds = try alloc.alloc(@This(), sub_len);
inline for (sub_cmds, 0..) |cmd, idx| init_subcmds[idx] = try cmd.initCtx(init_config, false, init_cmd, alloc);
if (help_config.add_help_cmds and (utils.indexOfEql([]const u8, &.{ "help", "usage" }, self.name) == null)) {
init_subcmds[sub_len - 2] = init_cmd.sub_cmds.?[sub_len - 2];
init_subcmds[sub_len - 1] = init_cmd.sub_cmds.?[sub_len - 1];
}
init_cmd.sub_cmds = init_subcmds;
}
if (self.opts) |opts| {
var init_opts = try alloc.alloc(@This().OptionT, opts.len);
inline for (opts, init_opts[0..]) |opt, *i_opt| {
i_opt.* = opt.init(alloc);
i_opt.*.parent_cmd = init_cmd;
i_opt.*.val.parent_cmd = init_cmd;
}
init_cmd.opts = init_opts;
}
if (help_config.add_help_opts) {
const add_opt_help_group = switch (help_config.add_opt_help_group) {
.AddIfOthers => ifOthers: {
if (init_cmd.opt_groups) |opt_groups| {
init_cmd.opt_groups = try mem.concat(alloc, []const u8, &.{ opt_groups, &.{ help_config.help_group_name } });
break :ifOthers true;
}
break :ifOthers false;
},
.Add => add: {
init_cmd.opt_groups =
if (init_cmd.opt_groups) |opt_groups| try mem.concat(alloc, []const u8, &.{ opt_groups, &.{ help_config.help_group_name } })
else try alloc.dupe([]const u8, &.{ help_config.help_group_name });
break :add true;
},
.DoNotAdd => false,
};
var help_opts = [2]OptionT{
.{
._alloc = alloc,
.opt_group = if (add_opt_help_group) help_config.help_group_name else null,
.name = "usage",
.short_name = 'u',
.long_name = "usage",
.description = usage_description,
.parent_cmd = init_cmd,
.val = ValueT.ofType(bool, .{ .name = "usage_flag" }),
},
.{
._alloc = alloc,
.opt_group = if (add_opt_help_group) help_config.help_group_name else null,
.name = "help",
.short_name = 'h',
.long_name = "help",
.description = help_description,
.parent_cmd = init_cmd,
.val = ValueT.ofType(bool, .{ .name = "help_flag" }),
},
};
for (help_opts[0..]) |*opt| opt.* = opt.init(alloc);
init_cmd.opts =
if (init_cmd.opts) |init_opts| try mem.concat(alloc, @This().OptionT, &.{ init_opts, help_opts[0..] })
else try alloc.dupe(OptionT, help_opts[0..]);
}
if (self.vals) |vals| {
var init_vals = try alloc.alloc(@This().ValueT, vals.len);
inline for (vals, init_vals[0..]) |val, *i_val| {
i_val.* = val.init(alloc);
i_val.*.parent_cmd = init_cmd;
}
init_cmd.vals = init_vals;
}
return if (is_root_cmd) init_cmd else init_cmd.*;
}
/// De-initialize the Root Command with its Arena Allocator.
/// If this Command has not yet been initialized or is not the Root Command, this does nothing.
pub fn deinit(self: *const @This()) void {
if (self._arena) |arena| arena.deinit();
if (self._root_alloc) |root_alloc| root_alloc.destroy(self);
}
/// Reset the Root Command with the provided Setup Command (`setup_cmd`), InitConfig (`init_config`), and the Command's current Root Allocator.
/// If this Command has not yet been initialized or is not the Root Command, this does nothing.
pub fn reset(self: *const @This(), comptime setup_cmd: @This(), comptime init_config: InitConfig) !void {
const alloc = self._root_alloc orelse return;
self.deinit();
self = try setup_cmd.init(alloc, init_config);
}
};
}
| 109,022 | Command | zig | en | zig | code | {"qsc_code_num_words": 11279, "qsc_code_num_chars": 109022.0, "qsc_code_mean_word_length": 4.70671159, "qsc_code_frac_words_unique": 0.06348081, "qsc_code_frac_chars_top_2grams": 0.01252661, "qsc_code_frac_chars_top_3grams": 0.01239475, "qsc_code_frac_chars_top_4grams": 0.00949385, "qsc_code_frac_chars_dupe_5grams": 0.56650404, "qsc_code_frac_chars_dupe_6grams": 0.51253603, "qsc_code_frac_chars_dupe_7grams": 0.46408725, "qsc_code_frac_chars_dupe_8grams": 0.41759753, "qsc_code_frac_chars_dupe_9grams": 0.38630927, "qsc_code_frac_chars_dupe_10grams": 0.3584305, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00586008, "qsc_code_frac_chars_whitespace": 0.3942507, "qsc_code_size_file_byte": 109022.0, "qsc_code_num_lines": 1991.0, "qsc_code_num_chars_line_max": 276.0, "qsc_code_num_chars_line_mean": 54.75740834, "qsc_code_frac_chars_alphabet": 0.79800121, "qsc_code_frac_chars_comments": 0.22498211, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.34527912, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.00137836, "qsc_code_frac_chars_string_length": 0.03941155, "qsc_code_frac_chars_long_word_length": 0.0047933, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.00150678, "qsc_code_frac_lines_assert": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
0-1-0/lightblue-0.4 | src/mac/LightAquaBlue/BBBluetoothChannelDelegate.h | /*
* Copyright (c) 2009 Bea Lam. All rights reserved.
*
* This file is part of LightBlue.
*
* LightBlue is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LightBlue is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
*/
//
// BBBluetoothChannelDelegate.h
// LightAquaBlue
//
// Provides a delegate for RFCOMM and L2CAP channels. This is only intended
// for use from the LightBlue library.
//
#include <Foundation/Foundation.h>
@class IOBluetoothRFCOMMChannel;
@class IOBluetoothL2CAPChannel;
@interface BBBluetoothChannelDelegate : NSObject {
id m_delegate;
}
- (id)initWithDelegate:(id)delegate;
+ (IOReturn)synchronouslyWriteData:(NSData *)data
toRFCOMMChannel:(IOBluetoothRFCOMMChannel *)channel;
+ (IOReturn)synchronouslyWriteData:(NSData *)data
toL2CAPChannel:(IOBluetoothL2CAPChannel *)channel;
@end
/*
* These are the methods that should be implemented by the delegate of this
* delegate (very awkward, but that's what it is).
*/
@protocol BBBluetoothChannelDelegateObserver
- (void)channelData:(id)channel data:(NSData *)data;
- (void)channelClosed:(id)channel;
@end
| 1,692 | BBBluetoothChannelDelegate | h | en | c | code | {"qsc_code_num_words": 205, "qsc_code_num_chars": 1692.0, "qsc_code_mean_word_length": 5.92682927, "qsc_code_frac_words_unique": 0.57560976, "qsc_code_frac_chars_top_2grams": 0.01234568, "qsc_code_frac_chars_top_3grams": 0.03209877, "qsc_code_frac_chars_top_4grams": 0.04691358, "qsc_code_frac_chars_dupe_5grams": 0.06748971, "qsc_code_frac_chars_dupe_6grams": 0.04609053, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00662739, "qsc_code_frac_chars_whitespace": 0.19739953, "qsc_code_size_file_byte": 1692.0, "qsc_code_num_lines": 58.0, "qsc_code_num_chars_line_max": 90.0, "qsc_code_num_chars_line_mean": 29.17241379, "qsc_code_frac_chars_alphabet": 0.88807069, "qsc_code_frac_chars_comments": 0.61702128, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.25, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codec_frac_lines_func_ratio": 0.0, "qsc_codec_cate_bitsstdc": 0.0, "qsc_codec_nums_lines_main": 0, "qsc_codec_frac_lines_goto": 0.0, "qsc_codec_cate_var_zero": 0.0, "qsc_codec_score_lines_no_logic": 0.0625, "qsc_codec_frac_lines_print": 0.0, "qsc_codec_frac_lines_preprocessor_directives": null} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codec_frac_lines_func_ratio": 0, "qsc_codec_nums_lines_main": 0, "qsc_codec_score_lines_no_logic": 0, "qsc_codec_frac_lines_preprocessor_directives": 0, "qsc_codec_frac_lines_print": 0} |
00JCIV00/cova | src/cova.zig | //! Cova. Commands, Options, Values, Arguments. A simple yet robust command line argument parsing library for Zig.
//!
//! Cova is based on the idea that Arguments will fall into one of three types: Commands, Options, or Values. These types are assembled into a single Command struct which is then used to parse argument tokens.
//!
//! Checkout Cova's [GitHub Wiki Guide](https://github.com/00JCIV00/cova/wiki) for more info!
// Standard
const builtin = @import("builtin");
const std = @import("std");
const ascii = std.ascii;
const log = std.log.scoped(.cova);
const mem = std.mem;
const meta = std.meta;
const proc = std.process;
const testing = std.testing;
const Io = std.Io;
// Cova
pub const Command = @import("Command.zig");
pub const Option = @import("Option.zig");
pub const Value = @import("Value.zig");
pub const generate = @import("generate.zig");
pub const utils = @import("utils.zig");
/// Config for custom argument tokenization using `tokenizeArgs()`.
pub const TokenizeConfig = struct{
/// Delimiter Characters
delimiters: []const u8 = " ",
/// Grouping Open Characters
/// Note, these Characters must line up with `groupers_close` in pairs. These pairs represent either side of a grouped argument.
/// For example, setting open to `'('` and closed to `')'` will group all tokens between parantheses into one argument as seen here:
///
/// `my-cmd --str-opt (this whole string will be one argument.)`
groupers_open: []const u8 = "\"'",
/// Grouping Close Characters
/// Refer to `groupers_open` for more info.
groupers_close: []const u8 = "\"'",
};
/// Tokenize an Argument String (`arg_str`) into a slice of Strings using the provided Allocator (`alloc`) and TokenizeConfig (`token_config`).
/// By default, this handles basic quoting using single or double quotes (`'` or `"`) with no support for escape sequences.
pub fn tokenizeArgs(arg_str: []const u8, alloc: mem.Allocator, token_config: TokenizeConfig) ![]const []const u8 {
var start: usize = 0;
var end: usize = 0;
var quote_char: ?u8 = null;
var args_list: std.ArrayListUnmanaged([]const u8) = .{};
if (token_config.groupers_open.len != token_config.groupers_close.len) {
log.err("The length of `token_config.groupers_open` must match that of `token_config.groupers_close`. These should be open/close pairs.", .{});
return error.UnbalancedGrouperPairs;
}
for (arg_str, 0..) |char, idx| {
if (mem.indexOfScalar(u8, token_config.delimiters, char) != null and quote_char == null) {
end = idx;
if (start == end) {
start += 1;
continue;
}
try args_list.append(alloc, arg_str[start..end]);
start = end + 1;
}
else if (quote_char == null and mem.indexOfScalar(u8, token_config.groupers_open, char) != null) {
if (mem.indexOfScalar(u8, token_config.groupers_open, char)) |close_idx| {
quote_char = token_config.groupers_close[close_idx];
start = idx + 1;
}
}
else if (quote_char) |q_char| {
if (char == q_char) {
end = idx;
try args_list.append(alloc, arg_str[start..end]);
start = end + 1;
quote_char = null;
}
}
else if (idx == arg_str.len - 1) {
end = arg_str.len;
try args_list.append(alloc, arg_str[start..end]);
}
}
return try args_list.toOwnedSlice(alloc);
}
/// A basic Raw Argument Iterator.
/// This is intended for testing, but can also be used to process an externally sourced slice of utf-8 argument tokens.
pub const RawArgIterator = struct {
index: u16 = 0,
args: []const [:0]const u8,
/// Get the Next argument token and advance this Iterator.
pub fn next(self: *@This()) ?[:0]const u8 {
self.index += 1;
return if (self.index > self.args.len) null else self.args[self.index - 1];
}
/// Peek at the next argument token without advancing this Iterator.
pub fn peek(self: *@This()) ?[:0]const u8 {
const peek_arg = self.next();
self.index -= 1;
return peek_arg;
}
};
/// A Generic Interface for Argument Iterators.
pub const ArgIteratorGeneric = union(enum) {
raw: RawArgIterator,
zig: proc.ArgIterator,
/// Get the Next argument token and advance this Iterator.
pub fn next(self: *@This()) ?[:0]const u8 {
return switch (meta.activeTag(self.*)) {
inline else => |tag| @field(self, @tagName(tag)).next(),
};
}
/// Peek at the next argument token without advancing this Iterator.
pub fn peek(self: *@This()) ?[:0]const u8 {
switch (meta.activeTag(self.*)) {
.raw => return self.raw.peek(),
inline else => |tag| {
var iter = @field(self, @tagName(tag));
// TODO: Create a PR for this in `std.process`?
if (builtin.os.tag != .windows) {
const peek_arg = iter.next();
iter.inner.index -= 1;
return peek_arg;
}
else {
const iter_idx = iter.inner.index;
const iter_start = iter.inner.start;
const iter_end = iter.inner.end;
const peek_arg = iter.next();
iter.inner.index = iter_idx;
iter.inner.start = iter_start;
iter.inner.end = iter_end;
return peek_arg;
}
},
}
}
/// Reset this Argument Iterator.
pub fn reset(self: *@This()) void {
switch (meta.activeTag(self.*)) {
.raw => self.raw.index = 0,
inline else => |tag| {
var iter = &@field(self, @tagName(tag));
if (builtin.os.tag != .windows) iter.inner.index = 0
else {
iter.inner.index = 0;
iter.inner.start = 0;
iter.inner.end = 0;
}
},
}
}
/// Get the current Index of this Iterator.
pub fn index(self: *@This()) usize {
return switch (meta.activeTag(self.*)) {
.raw => self.raw.index,
.zig => self.zig.inner.index,
};
}
/// Create a copy of this Generic Interface from the provided ArgIterator (`arg_iter`).
pub fn from(arg_iter: anytype) @This() {
const iter_type = @TypeOf(arg_iter);
return genIter: inline for (meta.fields(@This())) |field| {
if (field.type == iter_type) break :genIter @unionInit(@This(), field.name, arg_iter);
}
else @compileError("The provided Type '" ++ @typeName(iter_type) ++ "' is not supported by the ArgIteratorGeneric Interface.");
}
/// Initialize a copy of this Generic Interface as a `std.process.ArgIterator` which is Zig's cross-platform ArgIterator. If needed, this will use the provided Allocator (`alloc`).
pub fn init(alloc: mem.Allocator) !@This() {
return from(try proc.argsWithAllocator(alloc));
}
/// De-initialize a copy of this Generic Interface made with `init()`.
pub fn deinit(self: *@This()) void {
if (meta.activeTag(self.*) == .zig) self.zig.deinit();
return;
}
};
/// Config for custom argument token Parsing using `parseArgs()`.
pub const ParseConfig = struct {
/// Skip the first Argument (in a typical shell, this is the executable's name).
/// This should generally be set to `true`, but the option is here for unforeseen outliers.
skip_first_arg: bool = true,
/// Auto-handle Usage/Help messages during parsing.
/// This is especially useful if used in conjuction with the default auto-generated Usage/Help messages from Command and Option.
/// Note, this will return with `error.UsageHelpCalled` so the library user can terminate the program early afterwards if desired.
auto_handle_usage_help: bool = true,
/// Decide how to react to parsing errors.
err_reaction: ParseErrorReaction = .Help,
/// Enable Option Termination using the long prefix without an Option (default `--` per the POSIX standard).
/// Note, this will cause the remainder of the argument tokens to be read in as either Commands or Values.
enable_opt_termination: bool = true,
/// Override the Option Termination Symbol.
/// Leaving this null will default to the long prefix of the associated Option Type.
set_opt_termination_symbol: ?[]const u8 = null,
/// Reactions for Parsing Errors.
const ParseErrorReaction = enum {
/// Display the current Argument's Usage message.
Usage,
/// Display the current Argument's Help message.
Help,
/// Do nothing. This is useful for custom handling.
None,
};
};
/// Parse the provided Argument tokens (`args`) into Commands, Options, and Values.
/// The parsed result is stored to the provided `CommandT` (`cmd`) for user analysis.
pub fn parseArgs(
args: *ArgIteratorGeneric,
comptime CommandT: type,
cmd: *const CommandT,
writer: anytype,
parse_config: ParseConfig,
) !void {
var parse_ctx: ParseCtx = .{
.arg_idx = if (parse_config.skip_first_arg) 1 else 0,
};
try parseArgsCtx(
args,
CommandT,
cmd,
writer,
parse_config,
&parse_ctx,
);
}
/// Parse Context used to maintain state for recursive parsing of Commands.
const ParseCtx = struct{
usage_help_flag: bool = false,
arg_idx: u8 = 0,
};
/// Parse the provided Argument tokens (`args`) into Commands, Options, and Values.
/// The parsed result is stored to the provided `CommandT` (`cmd`) for user analysis.
fn parseArgsCtx(
args: *ArgIteratorGeneric,
comptime CommandT: type,
cmd: *const CommandT,
writer: *Io.Writer,
parse_config: ParseConfig,
parse_ctx: *ParseCtx,
) !void {
if (cmd._alloc == null) return error.CommandNotInitialized;
// Current Command State
const OptionT = CommandT.OptionT;
var val_idx: u8 = 0;
var opt_term: bool = false;
// Bypass argument 0 (the filename being executed);
const init_arg = if (parse_config.skip_first_arg and args.index() == 0) args.next() else args.peek();
log.debug("Parsing Command '{s}'...", .{ cmd.name });
log.debug("Initial Arg: {s}", .{ init_arg orelse "END OF ARGS!" });
defer log.debug("Finished Parsing '{s}'.", .{ cmd.name });
// Parse all Arguments within the Current Command
parseArg: while (args.next()) |arg| {
// Check for Usage/Help flags and run their respective methods.
if (parse_config.auto_handle_usage_help and try cmd.checkUsageHelp(writer)) return error.UsageHelpCalled;
// Current Argument State
log.debug("Current Arg: {s}", .{ arg });
if (init_arg == null) break :parseArg;
var unmatched = false;
// Check for a Sub Command first...
if (cmd.sub_cmds) |cmds| {
log.debug("Attempting to Parse Commands...", .{});
checkCmds: for (cmds) |*sub_cmd| {
const should_parse = shouldParse: {
if (sub_cmd.case_sensitive) {
if (
mem.eql(u8, sub_cmd.name, arg) or
(
CommandT.allow_abbreviated_cmds and
arg.len >= @min(sub_cmd.name.len, CommandT.abbreviated_min_len) and
mem.indexOf(u8, sub_cmd.name, arg) != null and sub_cmd.name[0] == arg[0]
)
) break :shouldParse true
else {
for (sub_cmd.alias_names orelse continue :checkCmds) |alias| {
if (
mem.eql(u8, alias, arg) or
(
CommandT.allow_abbreviated_cmds and
arg.len >= @min(alias.len, CommandT.abbreviated_min_len) and
mem.indexOf(u8, alias, arg) != null and alias[0] == arg[0]
)
) break :shouldParse true;
}
}
}
else {
if (ascii.eqlIgnoreCase(sub_cmd.name, arg)) break :shouldParse true
else for (sub_cmd.alias_names orelse continue :checkCmds) |alias| if (ascii.eqlIgnoreCase(alias, arg)) break :shouldParse true;
}
break :shouldParse false;
};
if (should_parse) {
cmd.setArgIdx(parse_ctx.arg_idx);
parse_ctx.*.arg_idx += 1;
parseArgsCtx(args, CommandT, sub_cmd, writer, parse_config, parse_ctx) catch |err| return err;
cmd.setSubCmd(sub_cmd);
continue :parseArg;
}
}
unmatched = true;
log.debug("No Commands Matched for Command '{s}'.", .{ cmd.name });
}
// ...Then for any Options...
var inherit_cmd: ?*const CommandT = cmd;
var inheriting = false;
inheritOpts: while (inherit_cmd) |opts_cmd| : ({
if (cmd.allow_inheritable_opts) {
inherit_cmd = inherit_cmd.?.parent_cmd;
inheriting = true;
if (inherit_cmd) |i_cmd| log.debug("Attempting to Parse Inherited Options for '{s}'...", .{ i_cmd.name })
else log.debug("No higher parent Command to inherit from for '{s}'.", .{ opts_cmd.name });
}
else inherit_cmd = null;
}) {
const parse_opts = opts_cmd.opts orelse continue;
log.debug("Attempting to Parse Options...", .{});
// - Check for Option Termination
opt_term = optTerm: {
const opt_term_sym =
parse_config.set_opt_termination_symbol orelse
OptionT.long_prefix orelse
break :optTerm false;
if (mem.eql(u8, arg, opt_term_sym) and parse_config.enable_opt_termination) {
log.debug("Terminated Option Parsing!", .{});
break :optTerm true;
}
break :optTerm false;
};
if (opt_term) continue :parseArg;
// - Short Options
if (OptionT.short_prefix) |short_pf| checkShortOpt: {
if (arg.len < 1 or !(arg[0] == short_pf and arg[1] != short_pf)) break :checkShortOpt;
log.debug("Parsing Short Option...", .{});
const short_opts = arg[1..];
shortOpts: for (short_opts, 0..) |short_opt, short_idx| {
for (parse_opts) |*opt| {
if (cmd.allow_inheritable_opts and inheriting and !opt.inheritable) continue :shortOpts;
if (opt.short_name != null and short_opt == opt.short_name.?) {
// Handle Argument provided to this Option with the Option/Value Separator (like '=') instead of ' '.
if (mem.indexOfScalar(u8, CommandT.OptionT.opt_val_seps, short_opts[short_idx + 1]) != null) {
if (mem.eql(u8, opt.val.childType(), "bool") and !opt.val.hasCustomParseFn()) {
log.err("The Option '{c}{?c}: {s}' is a Boolean/Toggle and cannot take an argument.", .{
short_pf,
opt.short_name,
opt.name,
});
try errReaction(parse_config.err_reaction, opt, writer);
try writer.print("\n", .{});
return error.boolCannotTakeArgument;
}
if (short_idx + 2 >= short_opts.len) return error.EmptyArgumentProvidedToOption;
const opt_arg = short_opts[(short_idx + 2)..];
opt.val.set(opt_arg) catch {
if (cmd.allow_inheritable_opts) continue :inheritOpts;
log.err("Could not parse Option '{c}{?c}: {s}'.", .{
short_pf,
opt.short_name,
opt.name,
});
try errReaction(parse_config.err_reaction, opt, writer);
try writer.print("\n", .{});
return error.CouldNotParseOption;
};
try opt.setArgIdx(parse_ctx.arg_idx);
parse_ctx.*.arg_idx += 1;
log.debug("Parsed Option '{c}'.", .{ opt.short_name.? });
continue :parseArg;
}
// Handle final Option in a chain of Short Options
else if (short_idx == short_opts.len - 1) {
if (mem.eql(u8, opt.val.childType(), "bool")) try @constCast(opt).val.set("true")
else {
parseOpt(args, OptionT, opt) catch {
if (cmd.allow_inheritable_opts) continue :inheritOpts;
log.err("Could not parse Option '{c}{c}: {s}'.", .{
short_pf,
opt.short_name.?,
opt.name,
});
try errReaction(parse_config.err_reaction, opt, writer);
try writer.print("\n", .{});
return error.CouldNotParseOption;
};
}
try opt.setArgIdx(parse_ctx.arg_idx);
parse_ctx.*.arg_idx += 1;
log.debug("Parsed Option '{c}'.", .{ opt.short_name.? });
continue :parseArg;
}
// Handle a boolean Option before the final Short Option in a chain.
else if (mem.eql(u8, opt.val.childType(), "bool")) {
try @constCast(opt).val.set("true");
try opt.setArgIdx(parse_ctx.arg_idx);
parse_ctx.*.arg_idx += 1;
log.debug("Parsed Option '{c}'.", .{ opt.short_name.? });
continue :shortOpts;
}
// Handle a non-boolean Option that allows an Empty Value.
else if (opt.allow_empty) {
opt.val.setEmpty() catch
log.err("The Option '{s}' has already been set.", .{ opt.name });
continue :shortOpts;
}
// Handle a non-boolean Option which is given a Value without a space ' ' to separate them.
else if (CommandT.OptionT.allow_opt_val_no_space) {
var short_names_buf: [CommandT.max_args]u8 = undefined;
const short_names = short_names_buf[0..];
for (cmd.opts.?, 0..) |s_opt, idx| short_names[idx] = s_opt.short_name.?;
if (mem.indexOfScalar(u8, short_names, short_opts[short_idx + 1]) == null) {
try @constCast(opt).val.set(short_opts[(short_idx + 1)..]);
try opt.setArgIdx(parse_ctx.arg_idx);
parse_ctx.*.arg_idx += 1;
log.debug("Parsed Option '{?c}'.", .{ opt.short_name });
continue :parseArg;
}
}
}
}
if (cmd.allow_inheritable_opts) continue :inheritOpts;
log.err("Could not parse Option '{c}{c}'.", .{ short_pf, short_opt });
try errReaction(parse_config.err_reaction, cmd, writer);
try writer.print("\n", .{});
return error.CouldNotParseOption;
}
}
// - Long Options
if (OptionT.long_prefix) |long_pf| checkLongOpt: {
if (arg.len < long_pf.len or !mem.eql(u8, arg[0..long_pf.len], long_pf)) break :checkLongOpt;
log.debug("Parsing Long Option...", .{});
const split_idx = (mem.indexOfAny(u8, arg[long_pf.len..], OptionT.opt_val_seps) orelse arg.len - long_pf.len) + long_pf.len;
const long_opt = arg[long_pf.len..split_idx];
const sep_arg = if (split_idx < arg.len) arg[split_idx + 1..] else "";
const sep_flag = mem.indexOfAny(u8, arg[long_pf.len..], OptionT.opt_val_seps) != null;
longOpts: for (parse_opts) |*opt| {
if (cmd.allow_inheritable_opts and inheriting and !opt.inheritable) continue :longOpts;
const opt_long_name = opt.long_name orelse continue :longOpts;
var long_names: [17][]const u8 = undefined;
var long_names_len: usize = 1;
long_names[0] = opt_long_name;
if (opt.alias_long_names) |aliases| {
long_names_len += aliases.len;
for (aliases, 0..) |alias, idx| long_names[idx + 1] = alias;
}
for (long_names[0..long_names_len]) |long_name| {
if (matchOpt: {
break :matchOpt if (opt.case_sensitive)
mem.eql(u8, long_opt, long_name) or
(
OptionT.allow_abbreviated_long_opts and
mem.indexOf(u8, long_name, long_opt) != null and long_name[0] == long_opt[0]
)
else
ascii.eqlIgnoreCase(long_opt, long_name) or
(
OptionT.allow_abbreviated_long_opts and
ascii.indexOfIgnoreCase(long_name, long_opt) != null and
ascii.eqlIgnoreCase(long_name[0..1], long_opt[0..1])
);
}) {
if (sep_flag) {
if (mem.eql(u8, opt.val.childType(), "bool") and !opt.val.hasCustomParseFn()) {
log.err("The Option '{s}{s}: {s}' is a Boolean/Toggle and cannot take an argument.", .{
long_pf,
long_name,
opt.name,
});
try errReaction(parse_config.err_reaction, opt, writer);
try writer.print("\n", .{});
return error.boolCannotTakeArgument;
}
if (sep_arg.len == 0) return error.EmptyArgumentProvidedToOption;
opt.val.set(sep_arg) catch {
if (cmd.allow_inheritable_opts) continue :inheritOpts;
log.err("Could not parse Option '{s}{s}: {s}'.", .{
long_pf,
long_name,
opt.name,
});
try errReaction(parse_config.err_reaction, opt, writer);
try writer.print("\n", .{});
return error.CouldNotParseOption;
};
try opt.setArgIdx(parse_ctx.arg_idx);
parse_ctx.*.arg_idx += 1;
log.debug("Parsed Option '{?s}'.", .{ opt.long_name });
continue :parseArg;
}
// Handle Boolean/Toggle Option.
if (mem.eql(u8, opt.val.childType(), "bool")) try @constCast(opt).val.set("true")
// Handle Option with normal Argument.
else {
parseOpt(args, OptionT, opt) catch {
if (cmd.allow_inheritable_opts) continue :inheritOpts;
log.err("Could not parse Option '{s}{s}: {s}'.", .{
long_pf,
long_name,
opt.name,
});
try errReaction(parse_config.err_reaction, opt, writer);
try writer.print("\n", .{});
return error.CouldNotParseOption;
};
}
try opt.setArgIdx(parse_ctx.arg_idx);
parse_ctx.*.arg_idx += 1;
log.debug("Parsed Option '{?s}'.", .{ opt.long_name });
continue :parseArg;
}
}
}
if (cmd.allow_inheritable_opts) continue :inheritOpts;
log.err("Could not parse Argument '{s}{s}' to an Option.", .{ long_pf, long_opt });
try errReaction(parse_config.err_reaction, cmd, writer);
try writer.print("\n", .{});
return error.CouldNotParseOption;
}
unmatched = true;
log.debug("No Options Matched for Command '{s}'.", .{ opts_cmd.name });
if (cmd.allow_inheritable_opts) continue :inheritOpts;
}
// ...Finally, for any Values.
if (cmd.vals) |vals| {
log.debug("Attempting to Parse Values...", .{});
if (val_idx >= vals.len) {
log.err("Too many Values provided for Command '{s}'.", .{ cmd.name });
try errReaction(parse_config.err_reaction, cmd, writer);
return error.TooManyValues;
}
var cur_val: ?*const CommandT.ValueT = &vals[val_idx];
while (cur_val) |val| : (cur_val = &vals[val_idx]) {
val.set(arg) catch {
log.debug("Could not parse Argument '{s}' to Value '{s}'.", .{ arg, val.name() });
if (val_idx + 1 < vals.len and !cmd.vals_mandatory) {
val_idx += 1;
continue;
}
log.err("Could not parse Argument '{s}' to any Value for Command '{s}'.", .{ arg, cmd.name });
try errReaction(parse_config.err_reaction, cmd, writer);
log.err("", .{});
return error.CouldNotParseValue;
};
if (val.entryIdx() == val.maxEntries()) val_idx += 1;
try val.setArgIdx(parse_ctx.arg_idx);
parse_ctx.*.arg_idx += 1;
log.debug("Parsed Value '{s}'.", .{ val.name() });
continue :parseArg;
}
}
// Check if the Command expected an Argument but didn't get a match.
if (unmatched) {
log.err("Unrecognized Argument '{s}' for Command '{s}'.", .{ arg, cmd.name });
try errReaction(parse_config.err_reaction, cmd, writer);
return error.UnrecognizedArgument;
}
// For Commands that expect no Arguments but are given one, fail to the Help message.
else {
log.err("Command '{s}' does not expect any arguments, but '{s}' was passed.", .{ cmd.name, arg });
try errReaction(parse_config.err_reaction, cmd, writer);
return error.UnexpectedArgument;
}
}
// Check if a Sub Command has been set if it is Mandated for the current Command.
if (
cmd.sub_cmds_mandatory and cmd.sub_cmd == null and
!(
cmd.sub_cmds != null and cmd.sub_cmds.?.len == 2 and
(
mem.eql(u8, cmd.sub_cmds.?[0].name, "usage") or
mem.eql(u8, cmd.sub_cmds.?[0].name, "help")
)
) and
!(cmd.checkFlag("help") or cmd.checkFlag("usage")) //and
// !(mem.eql(u8, cmd.name, "help") or mem.eql(u8, cmd.name, "usage"))
) {
log.err("Command '{s}' requires a Sub Command.", .{ cmd.name });
try errReaction(parse_config.err_reaction, cmd, writer);
return error.ExpectedSubCommand;
}
// Check that all Mandatory Options have been set.
if (cmd.opts) |opts| manOpts: {
if (!parse_ctx.usage_help_flag) parse_ctx.*.usage_help_flag = (cmd.checkFlag("help") or cmd.checkFlag("usage"));
if (parse_ctx.usage_help_flag) break :manOpts;
for (opts) |opt| {
const group_man = groupMan: {
const man_groups = cmd.mandatory_opt_groups orelse break :groupMan false;
const group = opt.opt_group orelse break :groupMan false;
break :groupMan utils.indexOfEql([]const u8, man_groups, group) != null;
};
if (
(opt.mandatory or group_man) and
!(opt.val.isSet() or opt.val.hasDefault())
) {
log.err("Option '{s}' is mandatory.", .{ opt.name });
try errReaction(parse_config.err_reaction, cmd, writer);
return error.ExpectedOption;
}
}
}
// Check for missing Values if they are Mandated for the current Command.
if (!parse_ctx.usage_help_flag) parse_ctx.*.usage_help_flag = (cmd.checkFlag("help") or cmd.checkFlag("usage"));
if (cmd.vals_mandatory and
cmd.vals != null and
val_idx < cmd.vals.?.len and
!parse_ctx.usage_help_flag
) {
log.err("Command '{s}' expects {d} Value(s), but received {d}.", .{
cmd.name,
cmd.vals.?.len,
val_idx,
});
try errReaction(parse_config.err_reaction, cmd, writer);
return error.ExpectedMoreValues;
}
// Check for Usage/Help flags and run their respective methods.
if (parse_config.auto_handle_usage_help and try cmd.checkUsageHelp(writer)) return error.UsageHelpCalled;
}
/// Parse the provided `OptionType` (`opt`).
fn parseOpt(args: *ArgIteratorGeneric, comptime OptionType: type, opt: *const OptionType) !void {
const peek_arg = args.peek();
const set_arg =
if (peek_arg == null or peek_arg.?[0] == '-') setArg: {
if (!(mem.eql(u8, opt.val.childType(), "bool"))) {
if (opt.allow_empty) {
opt.val.setEmpty() catch
log.err("The Option '{s}' has already been set.", .{ opt.name });
return;
}
else if (!opt.val.hasCustomParseFn())
return error.EmptyArgumentProvidedToOption;
}
_ = args.next();
break :setArg "true";
}
else args.next().?;
log.debug("Current Arg: {s}", .{ set_arg });
try opt.val.set(set_arg);
}
/// React to Parsing Errors with the given Reaction (`reaction`) based on the provided Argument (`arg`) to the provided Writer (`writer`).
fn errReaction(reaction: ParseConfig.ParseErrorReaction, arg: anytype, writer: anytype) !void {
return switch(reaction) {
.Usage => arg.usage(writer),
.Help => arg.help(writer),
.None => {},
};
}
// TESTING
const TestCommand = Command.Custom(.{
.global_vals_mandatory = false,
.global_sub_cmds_mandatory = false,
});
const TestValue = TestCommand.ValueT;
const test_setup_cmd: TestCommand = .{
.name = "test-cmd",
.description = "A Test Command.",
.sub_cmds = &.{
.{
.name = "sub-test-cmd",
.description = "A Test Sub Command.",
.opts = &.{
.{
.name = "sub_string_opt",
.description = "A test sub string long option.",
.short_name = 'S',
.long_name = "sub-string",
.val = TestValue.ofType([]const u8, .{
.name = "sub_string_opt_val",
.description = "A test sub string opt value.",
}),
},
.{
.name = "sub_int_opt",
.description = "A test sub integer option.",
.short_name = 'I',
.long_name = "sub-int",
.val = TestValue.ofType(i16, .{
.name = "int_opt_val",
.description = "A test sub integer opt value.",
}),
},
},
},
},
.opts = &.{
.{
.name = "string_opt",
.description = "A test string long option.",
.short_name = 's',
.long_name = "string",
.val = TestValue.ofType([]const u8, .{
.name = "string_opt_val",
.description = "A test string opt value.",
.set_behavior = .Multi,
.max_entries = 6,
}),
},
.{
.name = "int_opt",
.description = "A test integer option.",
.short_name = 'i',
.long_name = "int",
.val = TestValue.ofType(i16, .{
.name = "int_opt_val",
.description = "A test integer opt value.",
.valid_fn = struct{ fn valFn(int: i16, alloc: mem.Allocator) bool { _ = alloc; return int <= 666; } }.valFn,
.set_behavior = .Multi,
.max_entries = 6,
}),
},
.{
.name = "float_opt",
.description = "A test float option.",
.short_name = 'f',
.long_name = "float",
.val = TestValue.ofType(f16, .{
.name = "float_opt_val",
.description = "An float opt value.",
.valid_fn = struct{ fn valFn(float: f16, alloc: mem.Allocator) bool { _ = alloc; return float < 30000; } }.valFn,
.set_behavior = .Multi,
.max_entries = 6,
}),
},
.{
.name = "toggle_opt",
.description = "A test toggle/boolean option.",
.short_name = 't',
.long_name = "toggle",
.val = TestValue.ofType(bool, .{
.name = "toggle_opt_val",
.description = "A test toggle/boolean option value.",
}),
},
},
.vals = &.{
TestValue.ofType([]const u8, .{
.name = "string_val",
.description = "A test string value.",
.default_val = "test",
}),
},
};
const TestCmdFromStruct = struct {
pub const SubCmdFromStruct = struct {
sub_bool: bool = false,
sub_float: f32 = 0,
};
// Command
@"sub-cmd": SubCmdFromStruct = .{
.sub_bool = true,
.sub_float = 0,
},
// Options
int: ?i32 = 26,
str: ?[]const u8 = "Opt string.",
str2: ?[]const u8 = "Opt string 2.",
flt: ?f16 = 0,
int2: ?u16 = 0,
multi_str: [5]?[]const u8,
multi_int: [3]?u8,
// Values
struct_bool: bool = false,
struct_str: []const u8 = "Val string.",
struct_int: i64,
multi_int_val: [2]u16,
// Cova Command
cova_cmd: TestCommand = .{
.name = "test-struct-cova-cmd",
.description = "A test cova Command within a struct.",
},
// Cova Option
cova_opt: TestCommand.OptionT = .{
.name = "test_struct_cova_opt",
.description = "A test cova Option within a struct.",
},
// Cova Value
cova_val: TestValue = TestValue.ofType(i8, .{
.name = "test_struct_cova_val",
.description = "A test cova Value within a struct.",
.default_val = 50,
}),
};
const test_setup_cmd_from_struct = TestCommand.from(TestCmdFromStruct, .{});
test "tokenize args" {
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const alloc = arena.allocator();
const arg_str = "cova struct-cmd --multi-str \"demo str\" -m 'a \"quoted string\"' -m \"A string using an 'apostrophe'\" 50";
const test_toks = try tokenizeArgs(arg_str, alloc, .{});
const expect_toks = [_][]const u8{ "cova", "struct-cmd", "--multi-str", "demo str", "-m", "a \"quoted string\"", "-m", "A string using an 'apostrophe'", "50" };
for (test_toks, expect_toks[0..]) |t_tok, e_tok| try testing.expectEqualStrings(t_tok, e_tok);
}
test "command setup" {
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const alloc = arena.allocator();
const test_cmd = try test_setup_cmd.init(alloc, .{});
defer test_cmd.deinit();
const test_cmd_from_struct = try test_setup_cmd_from_struct.init(
alloc,
.{
.help_config = .{
.add_help_cmds = false,
.add_help_opts = false,
},
},
);
defer test_cmd_from_struct.deinit();
}
test "argument parsing" {
testing.log_level = .info;
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const alloc = arena.allocator();
var writer_list: std.ArrayListUnmanaged(u8) = .{};
defer writer_list.deinit(alloc);
const writer = writer_list.writer(alloc);
const test_args: []const []const [:0]const u8 = &.{
&.{ "test-cmd", "sub_test_cmd", "sub-test-cmd", "--sub-string", "sub cmd string opt", "--sub-int=15984" },
&.{ "test-cmd", "--string", "string opt 1", "--str", "string opt 2", "--string=string_opt_3", "-s", "string opt 4", "-s=string_opt_5", "-s_string_opt_6", "string value text" },
&.{ "test-cmd", "--int", "11", "--in", "22", "--int=33", "-i", "444", "-i=555", "-i666", "string value text" },
&.{ "test-cmd", "--float", "1111.12", "--flo", "2222.123", "--float=3333.1234", "-f", "4444.12345", "-f=5555.123456", "-f6666.1234567", "string value text" },
&.{ "test-cmd", "--toggle", "-t", "string value text", },
&.{ "test-cmd", "string value text", },
};
for (test_args) |tokens_list| {
const test_cmd = try test_setup_cmd.init(alloc, .{});
defer test_cmd.deinit();
const raw_iter = RawArgIterator{ .args = tokens_list };
var test_iter = ArgIteratorGeneric.from(raw_iter);
try parseArgs(&test_iter, TestCommand, test_cmd, writer, .{});
}
}
test "argument analysis" {
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const alloc = arena.allocator();
var writer_list: std.ArrayListUnmanaged(u8) = .{};
defer writer_list.deinit(alloc);
const writer = writer_list.writer(alloc);
const test_cmd = try test_setup_cmd.init(alloc, .{});
defer test_cmd.deinit();
const test_args: []const [:0]const u8 = &.{ "test-cmd", "--string", "opt string 1", "-s", "opt string 2", "--int=1,22,333,444,555,666", "--flo=5.1", "-f10.1,20.2,30.3", "-t", "val string", "sub-test-cmd", "--sub-s=sub_opt_str", "--sub-int", "21523", "help" };
const raw_iter = RawArgIterator{ .args = test_args };
var test_iter = ArgIteratorGeneric.from(raw_iter);
parseArgs(&test_iter, TestCommand, test_cmd, writer, .{}) catch |err| {
switch (err) {
error.UsageHelpCalled => {},
else => {
try writer.print("Parsing Error during Testing: {!}\n", .{ err });
return err;
},
}
};
try utils.displayCmdInfo(TestCommand, test_cmd, alloc, writer, false);
//_ = test_setup_cmd.SubCommandsEnum();
}
| 41,334 | cova | zig | en | zig | code | {"qsc_code_num_words": 4366, "qsc_code_num_chars": 41334.0, "qsc_code_mean_word_length": 4.63719652, "qsc_code_frac_words_unique": 0.12207971, "qsc_code_frac_chars_top_2grams": 0.00889065, "qsc_code_frac_chars_top_3grams": 0.01343475, "qsc_code_frac_chars_top_4grams": 0.01106391, "qsc_code_frac_chars_dupe_5grams": 0.43544404, "qsc_code_frac_chars_dupe_6grams": 0.38249531, "qsc_code_frac_chars_dupe_7grams": 0.3503902, "qsc_code_frac_chars_dupe_8grams": 0.32050775, "qsc_code_frac_chars_dupe_9grams": 0.2946261, "qsc_code_frac_chars_dupe_10grams": 0.27842537, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01184006, "qsc_code_frac_chars_whitespace": 0.37678425, "qsc_code_size_file_byte": 41334.0, "qsc_code_num_lines": 879.0, "qsc_code_num_chars_line_max": 265.0, "qsc_code_num_chars_line_mean": 47.02389078, "qsc_code_frac_chars_alphabet": 0.77410714, "qsc_code_frac_chars_comments": 0.12945759, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.32631579, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.02763158, "qsc_code_frac_chars_string_length": 0.09384987, "qsc_code_frac_chars_long_word_length": 0.00291804, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.00113766, "qsc_code_frac_lines_assert": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
0-1-0/lightblue-0.4 | src/mac/LightAquaBlue/BBStreamingInputStream.m | /*
* Copyright (c) 2009 Bea Lam. All rights reserved.
*
* This file is part of LightBlue.
*
* LightBlue is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LightBlue is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
*/
//
// BBDelegatingInputStream.m
// LightAquaBlue
//
#import "BBStreamingInputStream.h"
@implementation BBStreamingInputStream
- (id)initWithDelegate:(id)delegate
{
self = [super init];
mDelegate = delegate;
mStatus = NSStreamStatusNotOpen;
return self;
}
- (int)read:(uint8_t *)buffer maxLength:(unsigned int)maxLength
{
NSData *data = [mDelegate readDataWithMaxLength:maxLength];
if (!data)
return -1;
int copyLength = [data length] < maxLength ? [data length] : maxLength;
[data getBytes:buffer length:copyLength];
return copyLength;
}
- (BOOL)getBuffer:(uint8_t **)buffer length:(unsigned int *)len
{
// we cannot access buffer data without calling read:maxLength:
return NO;
}
- (BOOL)hasBytesAvailable
{
// don't know whether bytes are available until read:maxLength: is called
return YES;
}
- (void)open
{
mStatus = NSStreamStatusOpen;
}
- (void)close
{
mStatus = NSStreamStatusClosed;
}
- (void)setDelegate:(id)delegate
{
mDelegate = delegate;
}
- (id)delegate
{
return mDelegate;
}
- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode
{
}
- (void)removeFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode
{
}
- (BOOL)setProperty:(id)property forKey:(NSString *)key
{
return NO;
}
- (id)propertyForKey:(NSString *)key
{
return nil;
}
- (NSStreamStatus)streamStatus
{
return mStatus;
}
@end
| 2,180 | BBStreamingInputStream | m | en | limbo | code | {"qsc_code_num_words": 257, "qsc_code_num_chars": 2180.0, "qsc_code_mean_word_length": 5.91828794, "qsc_code_frac_words_unique": 0.56809339, "qsc_code_frac_chars_top_2grams": 0.00986193, "qsc_code_frac_chars_top_3grams": 0.02564103, "qsc_code_frac_chars_top_4grams": 0.03747535, "qsc_code_frac_chars_dupe_5grams": 0.10124918, "qsc_code_frac_chars_dupe_6grams": 0.03681788, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00455581, "qsc_code_frac_chars_whitespace": 0.19449541, "qsc_code_size_file_byte": 2180.0, "qsc_code_num_lines": 106.0, "qsc_code_num_chars_line_max": 78.0, "qsc_code_num_chars_line_mean": 20.56603774, "qsc_code_frac_chars_alphabet": 0.86161731, "qsc_code_frac_chars_comments": 0.01605505, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.07142857, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
0-1-0/lightblue-0.4 | src/mac/LightAquaBlue/BBLocalDevice.m | /*
* Copyright (c) 2009 Bea Lam. All rights reserved.
*
* This file is part of LightBlue.
*
* LightBlue is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LightBlue is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LightBlue. If not, see <http://www.gnu.org/licenses/>.
*/
//
// BBLocalDevice.m
// LightAquaBlue
//
#import <IOBluetooth/IOBluetooth.h>
#import "BBLocalDevice.h"
@implementation BBLocalDevice
+ (NSString *)getName
{
return [[IOBluetoothHostController defaultController] nameAsString];
}
+ (NSString *)getAddressString
{
return [[IOBluetoothHostController defaultController] addressAsString];
}
+ (BluetoothClassOfDevice)getClassOfDevice
{
return [[IOBluetoothHostController defaultController] classOfDevice];
}
+ (BOOL)isPoweredOn
{
BluetoothHCIPowerState powerState = [IOBluetoothHostController defaultController].powerState;
return powerState == kBluetoothHCIPowerStateON;
}
@end
| 1,387 | BBLocalDevice | m | en | limbo | code | {"qsc_code_num_words": 156, "qsc_code_num_chars": 1387.0, "qsc_code_mean_word_length": 6.72435897, "qsc_code_frac_words_unique": 0.63461538, "qsc_code_frac_chars_top_2grams": 0.16015253, "qsc_code_frac_chars_top_3grams": 0.03717827, "qsc_code_frac_chars_top_4grams": 0.05433746, "qsc_code_frac_chars_dupe_5grams": 0.07816969, "qsc_code_frac_chars_dupe_6grams": 0.05338418, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.00430293, "qsc_code_frac_chars_whitespace": 0.16222062, "qsc_code_size_file_byte": 1387.0, "qsc_code_num_lines": 54.0, "qsc_code_num_chars_line_max": 95.0, "qsc_code_num_chars_line_mean": 25.68518519, "qsc_code_frac_chars_alphabet": 0.89845095, "qsc_code_frac_chars_comments": 0.04470079, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.04878049, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Thorns.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.watabou.utils.Random;
public class Thorns extends Armor.Glyph {
private static ItemSprite.Glowing RED = new ItemSprite.Glowing( 0x660022 );
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
int level = Math.max(0, armor.level());
// lvl 0 - 16.7%
// lvl 1 - 28.6%
// lvl 2 - 37.5%
if ( Random.Int( level + 6) >= 5) {
Buff.affect( attacker, Bleeding.class).set( 4 + level );
}
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return RED;
}
}
| 1,722 | Thorns | java | en | java | code | {"qsc_code_num_words": 235, "qsc_code_num_chars": 1722.0, "qsc_code_mean_word_length": 5.45957447, "qsc_code_frac_words_unique": 0.54893617, "qsc_code_frac_chars_top_2grams": 0.07950117, "qsc_code_frac_chars_top_3grams": 0.1777085, "qsc_code_frac_chars_top_4grams": 0.17147311, "qsc_code_frac_chars_dupe_5grams": 0.26344505, "qsc_code_frac_chars_dupe_6grams": 0.12938426, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02777778, "qsc_code_frac_chars_whitespace": 0.16376307, "qsc_code_size_file_byte": 1722.0, "qsc_code_num_lines": 55.0, "qsc_code_num_chars_line_max": 77.0, "qsc_code_num_chars_line_mean": 31.30909091, "qsc_code_frac_chars_alphabet": 0.86319444, "qsc_code_frac_chars_comments": 0.48141696, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.09090909, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00895857, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.04545455, "qsc_codejava_score_lines_no_logic": 0.45454545, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Swiftness.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
public class Swiftness extends Armor.Glyph {
private static ItemSprite.Glowing YELLOW = new ItemSprite.Glowing( 0xFFFF00 );
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
//no proc effect, see armor.speedfactor for effect.
return damage;
}
@Override
public ItemSprite.Glowing glowing() {
return YELLOW;
}
}
| 1,409 | Swiftness | java | en | java | code | {"qsc_code_num_words": 191, "qsc_code_num_chars": 1409.0, "qsc_code_mean_word_length": 5.64397906, "qsc_code_frac_words_unique": 0.57591623, "qsc_code_frac_chars_top_2grams": 0.06307978, "qsc_code_frac_chars_top_3grams": 0.14100186, "qsc_code_frac_chars_top_4grams": 0.0528757, "qsc_code_frac_chars_dupe_5grams": 0.16512059, "qsc_code_frac_chars_dupe_6grams": 0.05194805, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01694915, "qsc_code_frac_chars_whitespace": 0.16252661, "qsc_code_size_file_byte": 1409.0, "qsc_code_num_lines": 42.0, "qsc_code_num_chars_line_max": 80.0, "qsc_code_num_chars_line_mean": 33.54761905, "qsc_code_frac_chars_alphabet": 0.89661017, "qsc_code_frac_chars_comments": 0.59048971, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.13333333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.01386482, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.06666667, "qsc_codejava_score_lines_no_logic": 0.46666667, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
0015/ThatProject | Esp32_temperature_humidity/Esp32_temperature_humidity.ino | #include "SPIFFS.h"
#include <JPEGDecoder.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 19
#define DHTTYPE DHT11
DHT_Unified dht(DHTPIN, DHTTYPE);
uint32_t delayMS;
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128
#define SCLK_PIN 18
#define MOSI_PIN 23
#define DC_PIN 17
#define CS_PIN 5
#define RST_PIN 4
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
const String fileTemperature = "/temperature.jpg";
const String fileHumidity = "/humidity.jpg";
Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, CS_PIN, DC_PIN, MOSI_PIN, SCLK_PIN, RST_PIN);
int prev_temp;
int prev_humidity;
void setup() {
Serial.begin(115200);
// Initialize device.
tft.begin();
tft.fillRect(0,0,128,128,WHITE);
dht.begin();
// Print temperature sensor details.
sensor_t sensor;
dht.temperature().getSensor(&sensor);
// Print humidity sensor details.
dht.humidity().getSensor(&sensor);
// Set delay between sensor readings based on sensor details.
delayMS = sensor.min_delay / 1000;
if(!SPIFFS.begin()){
while(1) yield();
}
initScreen();
}
void initScreen(){
drawFSJpeg(fileTemperature.c_str(), 0, 0);
drawFSJpeg(fileHumidity.c_str(), 0, 64);
tft.setCursor(72, 24);
tft.setTextColor(BLACK);
tft.setTextSize(3);
tft.print("?");
tft.setCursor(72, 88);
tft.setTextColor(BLACK);
tft.setTextSize(3);
tft.print("?");
}
void loop() {
// Delay between measurements.
delay(delayMS);
// Get temperature event and print its value.
sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature)) {
Serial.println(F("Error reading temperature!"));
}
else {
Serial.print(F("Temperature: "));
Serial.print(event.temperature);
Serial.println(F("°C"));
updateTemp((int)event.temperature);
}
// Get humidity event and print its value.
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) {
Serial.println(F("Error reading humidity!"));
}
else {
Serial.print(F("Humidity: "));
Serial.print(event.relative_humidity);
Serial.println(F("%"));
updateHumidity((int)event.relative_humidity);
}
}
void updateTemp(int temp){
if(prev_temp != temp){
tft.fillRect(64, 0, 128, 64, WHITE);
tft.setCursor(70, 24);
tft.setTextColor(BLACK);
tft.setTextSize(3);
String tempString = "";
tempString += temp;
tempString += "C";
tft.print(tempString);
prev_temp = temp;
}
}
void updateHumidity(int humidity){
if(prev_humidity != humidity){
tft.fillRect(64, 64, 128, 128, WHITE);
tft.setCursor(70, 88);
tft.setTextColor(BLACK);
tft.setTextSize(3);
String humidityString = "";
humidityString += humidity;
humidityString += "%";
tft.print(humidityString);
prev_humidity = humidity;
}
}
/*====================================================================================
This sketch contains support functions to render the Jpeg images.
Created by Bodmer 15th Jan 2017
==================================================================================*/
// Return the minimum of two values a and b
#define minimum(a,b) (((a) < (b)) ? (a) : (b))
//====================================================================================
// This function opens the Filing System Jpeg image file and primes the decoder
//====================================================================================
void drawFSJpeg(const char *filename, int xpos, int ypos) {
Serial.println("=====================================");
Serial.print("Drawing file: "); Serial.println(filename);
Serial.println("=====================================");
// Open the file (the Jpeg decoder library will close it)
fs::File jpgFile = SPIFFS.open( filename, "r"); // File handle reference for SPIFFS
// File jpgFile = SD.open( filename, FILE_READ); // or, file handle reference for SD library
if ( !jpgFile ) {
Serial.print("ERROR: File \""); Serial.print(filename); Serial.println ("\" not found!");
return;
}
// To initialise the decoder and provide the file, we can use one of the three following methods:
//boolean decoded = JpegDec.decodeFsFile(jpgFile); // We can pass the SPIFFS file handle to the decoder,
//boolean decoded = JpegDec.decodeSdFile(jpgFile); // or we can pass the SD file handle to the decoder,
boolean decoded = JpegDec.decodeFsFile(filename); // or we can pass the filename (leading / distinguishes SPIFFS files)
// The filename can be a String or character array
if (decoded) {
// print information about the image to the serial port
jpegInfo();
// render the image onto the screen at given coordinates
jpegRender(xpos, ypos);
}
else {
Serial.println("Jpeg file format not supported!");
}
}
//====================================================================================
// Decode and paint onto the TFT screen
//====================================================================================
void jpegRender(int xpos, int ypos) {
// retrieve infomration about the image
uint16_t *pImg;
uint16_t mcu_w = JpegDec.MCUWidth;
uint16_t mcu_h = JpegDec.MCUHeight;
uint32_t max_x = JpegDec.width;
uint32_t max_y = JpegDec.height;
// Jpeg images are draw as a set of image block (tiles) called Minimum Coding Units (MCUs)
// Typically these MCUs are 16x16 pixel blocks
// Determine the width and height of the right and bottom edge image blocks
uint32_t min_w = minimum(mcu_w, max_x % mcu_w);
uint32_t min_h = minimum(mcu_h, max_y % mcu_h);
// save the current image block size
uint32_t win_w = mcu_w;
uint32_t win_h = mcu_h;
// record the current time so we can measure how long it takes to draw an image
uint32_t drawTime = millis();
// save the coordinate of the right and bottom edges to assist image cropping
// to the screen size
max_x += xpos;
max_y += ypos;
// read each MCU block until there are no more
while ( JpegDec.read()) {
// save a pointer to the image block
pImg = JpegDec.pImage;
// calculate where the image block should be drawn on the screen
int mcu_x = JpegDec.MCUx * mcu_w + xpos;
int mcu_y = JpegDec.MCUy * mcu_h + ypos;
// check if the image block size needs to be changed for the right edge
if (mcu_x + mcu_w <= max_x) win_w = mcu_w;
else win_w = min_w;
// check if the image block size needs to be changed for the bottom edge
if (mcu_y + mcu_h <= max_y) win_h = mcu_h;
else win_h = min_h;
// copy pixels into a contiguous block
if (win_w != mcu_w)
{
for (int h = 1; h < win_h-1; h++)
{
memcpy(pImg + h * win_w, pImg + (h + 1) * mcu_w, win_w << 1);
}
}
// draw image MCU block only if it will fit on the screen
if ( ( mcu_x + win_w) <= tft.width() && ( mcu_y + win_h) <= tft.height())
{
tft.drawRGBBitmap(mcu_x, mcu_y, pImg, win_w, win_h);
}
// Stop drawing blocks if the bottom of the screen has been reached,
// the abort function will close the file
else if ( ( mcu_y + win_h) >= tft.height()) JpegDec.abort();
}
// calculate how long it took to draw the image
drawTime = millis() - drawTime;
// print the results to the serial port
Serial.print ("Total render time was : "); Serial.print(drawTime); Serial.println(" ms");
Serial.println("=====================================");
}
//====================================================================================
// Send time taken to Serial port
//====================================================================================
void jpegInfo() {
Serial.println(F("==============="));
Serial.println(F("JPEG image info"));
Serial.println(F("==============="));
Serial.print(F( "Width :")); Serial.println(JpegDec.width);
Serial.print(F( "Height :")); Serial.println(JpegDec.height);
Serial.print(F( "Components :")); Serial.println(JpegDec.comps);
Serial.print(F( "MCU / row :")); Serial.println(JpegDec.MCUSPerRow);
Serial.print(F( "MCU / col :")); Serial.println(JpegDec.MCUSPerCol);
Serial.print(F( "Scan type :")); Serial.println(JpegDec.scanType);
Serial.print(F( "MCU width :")); Serial.println(JpegDec.MCUWidth);
Serial.print(F( "MCU height :")); Serial.println(JpegDec.MCUHeight);
Serial.println(F("==============="));
}
//====================================================================================
// Open a Jpeg file and dump it to the Serial port as a C array
//====================================================================================
void createArray(const char *filename) {
fs::File jpgFile; // File handle reference for SPIFFS
// File jpgFile; // File handle reference For SD library
if ( !( jpgFile = SPIFFS.open( filename, "r"))) {
Serial.println(F("JPEG file not found"));
return;
}
uint8_t data;
byte line_len = 0;
Serial.println("// Generated by a JPEGDecoder library example sketch:");
Serial.println("// https://github.com/Bodmer/JPEGDecoder");
Serial.println("");
Serial.println("#if defined(__AVR__)");
Serial.println(" #include <avr/pgmspace.h>");
Serial.println("#endif");
Serial.println("");
Serial.print("const uint8_t ");
while (*filename != '.') Serial.print(*filename++);
Serial.println("[] PROGMEM = {"); // PROGMEM added for AVR processors, it is ignored by Due
while ( jpgFile.available()) {
data = jpgFile.read();
Serial.print("0x"); if (abs(data) < 16) Serial.print("0");
Serial.print(data, HEX); Serial.print(",");// Add value and comma
line_len++;
if ( line_len >= 32) {
line_len = 0;
Serial.println();
}
}
Serial.println("};\r\n");
// jpgFile.seek( 0, SeekEnd);
jpgFile.close();
}
//====================================================================================
| 10,271 | Esp32_temperature_humidity | ino | en | cpp | code | {"qsc_code_num_words": 1264, "qsc_code_num_chars": 10271.0, "qsc_code_mean_word_length": 4.67958861, "qsc_code_frac_words_unique": 0.26344937, "qsc_code_frac_chars_top_2grams": 0.07472527, "qsc_code_frac_chars_top_3grams": 0.0202874, "qsc_code_frac_chars_top_4grams": 0.01555368, "qsc_code_frac_chars_dupe_5grams": 0.17075232, "qsc_code_frac_chars_dupe_6grams": 0.10600169, "qsc_code_frac_chars_dupe_7grams": 0.08655959, "qsc_code_frac_chars_dupe_8grams": 0.05815723, "qsc_code_frac_chars_dupe_9grams": 0.01555368, "qsc_code_frac_chars_dupe_10grams": 0.01555368, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0198103, "qsc_code_frac_chars_whitespace": 0.18907604, "qsc_code_size_file_byte": 10271.0, "qsc_code_num_lines": 326.0, "qsc_code_num_chars_line_max": 123.0, "qsc_code_num_chars_line_mean": 31.50613497, "qsc_code_frac_chars_alphabet": 0.69023892, "qsc_code_frac_chars_comments": 0.35264336, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.11111111, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.10994134, "qsc_code_frac_chars_long_word_length": 0.02015341, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.00721913, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codecpp_frac_lines_preprocessor_directives": 0.1352657, "qsc_codecpp_frac_lines_func_ratio": 0.05797101, "qsc_codecpp_cate_bitsstdc": 0.0, "qsc_codecpp_nums_lines_main": 0.0, "qsc_codecpp_frac_lines_goto": 0.0, "qsc_codecpp_cate_var_zero": 0.0, "qsc_codecpp_score_lines_no_logic": 0.11111111, "qsc_codecpp_frac_lines_print": 0.0} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codecpp_frac_lines_func_ratio": 0, "qsc_codecpp_nums_lines_main": 0, "qsc_codecpp_score_lines_no_logic": 0, "qsc_codecpp_frac_lines_preprocessor_directives": 0, "qsc_codecpp_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Rat.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.sprites.RatSprite;
import com.watabou.utils.Random;
public class Rat extends Mob {
{
spriteClass = RatSprite.class;
HP = HT = 8;
defenseSkill = 2;
maxLvl = 5;
}
@Override
public int damageRoll() {
return Random.NormalIntRange( 1, 4 );
}
@Override
public int attackSkill( Char target ) {
return 8;
}
@Override
public int drRoll() {
return Random.NormalIntRange(0, 1);
}
}
| 1,364 | Rat | java | en | java | code | {"qsc_code_num_words": 185, "qsc_code_num_chars": 1364.0, "qsc_code_mean_word_length": 5.38918919, "qsc_code_frac_words_unique": 0.61621622, "qsc_code_frac_chars_top_2grams": 0.0330993, "qsc_code_frac_chars_top_3grams": 0.03911735, "qsc_code_frac_chars_top_4grams": 0.05717151, "qsc_code_frac_chars_dupe_5grams": 0.08224674, "qsc_code_frac_chars_dupe_6grams": 0.05616851, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02260398, "qsc_code_frac_chars_whitespace": 0.18914956, "qsc_code_size_file_byte": 1364.0, "qsc_code_num_lines": 52.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 26.23076923, "qsc_code_frac_chars_alphabet": 0.87884268, "qsc_code_frac_chars_comments": 0.57258065, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.125, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.125, "qsc_codejava_score_lines_no_logic": 0.33333333, "qsc_codejava_frac_words_no_modifier": 0.75, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Bandit.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.sprites.BanditSprite;
import com.watabou.utils.Random;
public class Bandit extends Thief {
public Item item;
{
spriteClass = BanditSprite.class;
//1 in 50 chance to be a crazy bandit, equates to overall 1/100 chance.
lootChance = 0.5f;
}
@Override
protected boolean steal( Hero hero ) {
if (super.steal( hero )) {
Buff.prolong( hero, Blindness.class, Random.Int( 2, 5 ) );
Buff.affect( hero, Poison.class ).set(Random.Int(5, 7) );
Buff.prolong( hero, Cripple.class, Random.Int( 3, 8 ) );
Dungeon.observe();
return true;
} else {
return false;
}
}
}
| 1,957 | Bandit | java | en | java | code | {"qsc_code_num_words": 258, "qsc_code_num_chars": 1957.0, "qsc_code_mean_word_length": 5.71705426, "qsc_code_frac_words_unique": 0.51162791, "qsc_code_frac_chars_top_2grams": 0.10372881, "qsc_code_frac_chars_top_3grams": 0.23186441, "qsc_code_frac_chars_top_4grams": 0.23864407, "qsc_code_frac_chars_dupe_5grams": 0.23864407, "qsc_code_frac_chars_dupe_6grams": 0.18711864, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.0194057, "qsc_code_frac_chars_whitespace": 0.15738375, "qsc_code_size_file_byte": 1957.0, "qsc_code_num_lines": 59.0, "qsc_code_num_chars_line_max": 74.0, "qsc_code_num_chars_line_mean": 33.16949153, "qsc_code_frac_chars_alphabet": 0.8750758, "qsc_code_frac_chars_comments": 0.43536025, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 0.0, "qsc_codejava_frac_lines_func_ratio": 0.03448276, "qsc_codejava_score_lines_no_logic": 0.48275862, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": 1.0, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 0, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Albino.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat;
import com.shatteredpixel.shatteredpixeldungeon.sprites.AlbinoSprite;
import com.watabou.utils.Random;
public class Albino extends Rat {
{
spriteClass = AlbinoSprite.class;
HP = HT = 15;
EXP = 2;
loot = new MysteryMeat();
lootChance = 1f;
}
@Override
public int attackProc( Char enemy, int damage ) {
damage = super.attackProc( enemy, damage );
if (Random.Int( 2 ) == 0) {
Buff.affect( enemy, Bleeding.class ).set( damage );
}
return damage;
}
}
| 1,601 | Albino | java | en | java | code | {"qsc_code_num_words": 210, "qsc_code_num_chars": 1601.0, "qsc_code_mean_word_length": 5.69047619, "qsc_code_frac_words_unique": 0.57619048, "qsc_code_frac_chars_top_2grams": 0.08535565, "qsc_code_frac_chars_top_3grams": 0.19079498, "qsc_code_frac_chars_top_4grams": 0.18410042, "qsc_code_frac_chars_dupe_5grams": 0.20251046, "qsc_code_frac_chars_dupe_6grams": 0.13891213, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01728024, "qsc_code_frac_chars_whitespace": 0.1686446, "qsc_code_size_file_byte": 1601.0, "qsc_code_num_lines": 51.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 31.39215686, "qsc_code_frac_chars_alphabet": 0.88054095, "qsc_code_frac_chars_comments": 0.48782011, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.0, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.04166667, "qsc_codejava_score_lines_no_logic": 0.375, "qsc_codejava_frac_words_no_modifier": 0.5, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/FetidRat.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.StenchGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.FetidRatSprite;
import com.watabou.utils.Random;
public class FetidRat extends Rat {
{
spriteClass = FetidRatSprite.class;
HP = HT = 20;
defenseSkill = 5;
EXP = 4;
state = WANDERING;
properties.add(Property.MINIBOSS);
properties.add(Property.DEMONIC);
}
@Override
public int attackSkill( Char target ) {
return 12;
}
@Override
public int drRoll() {
return Random.NormalIntRange(0, 2);
}
@Override
public int attackProc( Char enemy, int damage ) {
damage = super.attackProc( enemy, damage );
if (Random.Int(3) == 0) {
Buff.affect(enemy, Ooze.class).set( 20f );
}
return damage;
}
@Override
public int defenseProc( Char enemy, int damage ) {
GameScene.add(Blob.seed(pos, 20, StenchGas.class));
return super.defenseProc(enemy, damage);
}
@Override
public void die( Object cause ) {
super.die( cause );
Ghost.Quest.process();
}
{
immunities.add( StenchGas.class );
}
} | 2,312 | FetidRat | java | en | java | code | {"qsc_code_num_words": 292, "qsc_code_num_chars": 2312.0, "qsc_code_mean_word_length": 5.92123288, "qsc_code_frac_words_unique": 0.50342466, "qsc_code_frac_chars_top_2grams": 0.08849046, "qsc_code_frac_chars_top_3grams": 0.1978022, "qsc_code_frac_chars_top_4grams": 0.20358589, "qsc_code_frac_chars_dupe_5grams": 0.26257953, "qsc_code_frac_chars_dupe_6grams": 0.15962984, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01590559, "qsc_code_frac_chars_whitespace": 0.15700692, "qsc_code_size_file_byte": 2312.0, "qsc_code_num_lines": 87.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 26.57471264, "qsc_code_frac_chars_alphabet": 0.87121601, "qsc_code_frac_chars_comments": 0.33780277, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.1, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.1, "qsc_codejava_score_lines_no_logic": 0.34, "qsc_codejava_frac_words_no_modifier": 0.83333333, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 1, "qsc_code_frac_chars_top_4grams": 1, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
00-Evan/shattered-pixel-dungeon-gdx | core/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Snake.java | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2019 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.sprites.SnakeSprite;
import com.watabou.utils.Random;
public class Snake extends Mob {
{
spriteClass = SnakeSprite.class;
HP = HT = 4;
defenseSkill = 25;
EXP = 2;
maxLvl = 7;
loot = Generator.Category.SEED;
lootChance = 0.25f;
}
@Override
public int damageRoll() {
return Random.NormalIntRange( 1, 4 );
}
@Override
public int attackSkill( Char target ) {
return 10;
}
}
| 1,433 | Snake | java | en | java | code | {"qsc_code_num_words": 191, "qsc_code_num_chars": 1433.0, "qsc_code_mean_word_length": 5.52356021, "qsc_code_frac_words_unique": 0.63874346, "qsc_code_frac_chars_top_2grams": 0.06445498, "qsc_code_frac_chars_top_3grams": 0.14407583, "qsc_code_frac_chars_top_4grams": 0.05402844, "qsc_code_frac_chars_dupe_5grams": 0.07772512, "qsc_code_frac_chars_dupe_6grams": 0.05308057, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02482877, "qsc_code_frac_chars_whitespace": 0.18492673, "qsc_code_size_file_byte": 1433.0, "qsc_code_num_lines": 54.0, "qsc_code_num_chars_line_max": 72.0, "qsc_code_num_chars_line_mean": 26.53703704, "qsc_code_frac_chars_alphabet": 0.87842466, "qsc_code_frac_chars_comments": 0.54431263, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.08333333, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.0, "qsc_code_frac_chars_long_word_length": 0.0, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codejava_cate_var_zero": 1.0, "qsc_codejava_frac_lines_func_ratio": 0.08333333, "qsc_codejava_score_lines_no_logic": 0.33333333, "qsc_codejava_frac_words_no_modifier": 0.66666667, "qsc_codejava_frac_words_legal_var_name": null, "qsc_codejava_frac_words_legal_func_name": 1.0, "qsc_codejava_frac_words_legal_class_name": 1.0, "qsc_codejava_frac_lines_print": 0.0} | 0 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codejava_cate_var_zero": 1, "qsc_codejava_frac_lines_func_ratio": 0, "qsc_codejava_score_lines_no_logic": 0, "qsc_codejava_frac_lines_print": 0} |
0015/ThatProject | ESP8266_Twitter_Hash_Search/List_SPIFFS.h | //https://github.com/Bodmer/TJpg_Decoder
/***************************************************************************************
** Function name: listSPIFFS
** Description: Listing SPIFFS files
***************************************************************************************/
#ifdef ESP8266
void listSPIFFS(void) {
Serial.println(F("\r\nListing SPIFFS files:"));
fs::Dir dir = SPIFFS.openDir("/"); // Root directory
static const char line[] PROGMEM = "=================================================";
Serial.println(FPSTR(line));
Serial.println(F(" File name Size"));
Serial.println(FPSTR(line));
while (dir.next()) {
String fileName = dir.fileName();
Serial.print(fileName);
int spaces = 33 - fileName.length(); // Tabulate nicely
if (spaces < 1) spaces = 1;
while (spaces--) Serial.print(" ");
fs::File f = dir.openFile("r");
String fileSize = (String) f.size();
spaces = 10 - fileSize.length(); // Tabulate nicely
if (spaces < 1) spaces = 1;
while (spaces--) Serial.print(" ");
Serial.println(fileSize + " bytes");
}
Serial.println(FPSTR(line));
Serial.println();
delay(1000);
}
//====================================================================================
#elif defined ESP32
void listSPIFFS(void) {
Serial.println(F("\r\nListing SPIFFS files:"));
static const char line[] PROGMEM = "=================================================";
Serial.println(FPSTR(line));
Serial.println(F(" File name Size"));
Serial.println(FPSTR(line));
fs::File root = SPIFFS.open("/");
if (!root) {
Serial.println(F("Failed to open directory"));
return;
}
if (!root.isDirectory()) {
Serial.println(F("Not a directory"));
return;
}
fs::File file = root.openNextFile();
while (file) {
if (file.isDirectory()) {
Serial.print("DIR : ");
String fileName = file.name();
Serial.print(fileName);
} else {
String fileName = file.name();
Serial.print(" " + fileName);
// File path can be 31 characters maximum in SPIFFS
int spaces = 33 - fileName.length(); // Tabulate nicely
if (spaces < 1) spaces = 1;
while (spaces--) Serial.print(" ");
String fileSize = (String) file.size();
spaces = 10 - fileSize.length(); // Tabulate nicely
if (spaces < 1) spaces = 1;
while (spaces--) Serial.print(" ");
Serial.println(fileSize + " bytes");
}
file = root.openNextFile();
}
Serial.println(FPSTR(line));
Serial.println();
delay(1000);
}
#endif
| 2,643 | List_SPIFFS | h | en | c | code | {"qsc_code_num_words": 261, "qsc_code_num_chars": 2643.0, "qsc_code_mean_word_length": 5.14942529, "qsc_code_frac_words_unique": 0.27969349, "qsc_code_frac_chars_top_2grams": 0.1547619, "qsc_code_frac_chars_top_3grams": 0.0625, "qsc_code_frac_chars_top_4grams": 0.09821429, "qsc_code_frac_chars_dupe_5grams": 0.61607143, "qsc_code_frac_chars_dupe_6grams": 0.61607143, "qsc_code_frac_chars_dupe_7grams": 0.61607143, "qsc_code_frac_chars_dupe_8grams": 0.55505952, "qsc_code_frac_chars_dupe_9grams": 0.48958333, "qsc_code_frac_chars_dupe_10grams": 0.48958333, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.01536246, "qsc_code_frac_chars_whitespace": 0.21188044, "qsc_code_size_file_byte": 2643.0, "qsc_code_num_lines": 88.0, "qsc_code_num_chars_line_max": 91.0, "qsc_code_num_chars_line_mean": 30.03409091, "qsc_code_frac_chars_alphabet": 0.62986078, "qsc_code_frac_chars_comments": 0.20393492, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.5483871, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.14448669, "qsc_code_frac_chars_long_word_length": 0.04657795, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codec_frac_lines_func_ratio": 0.03225806, "qsc_codec_cate_bitsstdc": 0.0, "qsc_codec_nums_lines_main": 0, "qsc_codec_frac_lines_goto": 0.0, "qsc_codec_cate_var_zero": 0.0, "qsc_codec_score_lines_no_logic": 0.06451613, "qsc_codec_frac_lines_print": 0.0, "qsc_codec_frac_lines_preprocessor_directives": null} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codec_frac_lines_func_ratio": 0, "qsc_codec_nums_lines_main": 0, "qsc_codec_score_lines_no_logic": 0, "qsc_codec_frac_lines_preprocessor_directives": 0, "qsc_codec_frac_lines_print": 0} |
0015/ThatProject | ESP8266_Twitter_Hash_Search/ESP8266_Twitter_Hash_Search.ino | #include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <TimeLib.h>
#include <ArduinoJson.h>
#include <TwitterWebAPI.h>
#include <TJpg_Decoder.h>
// Include SPIFFS
#define FS_NO_GLOBALS
#include <FS.h>
#include "List_SPIFFS.h"
#include "Web_Fetch.h"
#include "SPI.h"
#include "TFT_eSPI.h"
TFT_eSPI tft = TFT_eSPI();
#ifndef WIFICONFIG
const char* ssid = "<YOUR_WIFI_SSID>";
const char* password = "<YOUR_WIFI_PW>";
#endif
std::string search_str = "#WeWantToPlay"; // Default search word for twitter
const char *ntp_server = "pool.ntp.org"; // time1.google.com, time.nist.gov, pool.ntp.org
int timezone = -7; // Pacific Daylight Time -07:00 HRS
unsigned long twi_update_interval = 10; // (seconds) minimum 5s (180 API calls/15 min). Any value less than 5 is ignored!
#ifndef TWITTERINFO // Obtain these by creating an app @ https://apps.twitter.com/
static char const consumer_key[] = "<API_Key>";
static char const consumer_sec[] = "<API_Key_Secret>";
static char const accesstoken[] = "<Access_Token>";
static char const accesstoken_sec[] = "<Access_Token_Secret>";
#endif
const char* userProfileImage = "/profile_user.jpg";
const char* placeholderImage = "/placeholder.jpg";
unsigned long api_mtbs = twi_update_interval * 1000; //mean time between api requests
unsigned long api_lasttime = 0;
String search_msg = "No Message Yet!";
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, ntp_server, timezone*3600, 60000); // NTP server pool, offset (in seconds), update interval (in milliseconds)
TwitterClient tcr(timeClient, consumer_key, consumer_sec, accesstoken, accesstoken_sec);
void initSPIFFS(){
// Initialise SPIFFS
if (!SPIFFS.begin()) {
Serial.println("SPIFFS initialisation failed!");
while (1) yield(); // Stay here twiddling thumbs waiting
}
Serial.println("\r\nInitialisation done.");
//SPIFFS.format(); //Only for the first time!
listSPIFFS();
}
bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t* bitmap)
{
if ( y >= tft.height() ) return 0;
tft.pushImage(x, y, w, h, bitmap);
return 1;
}
void initTFT(){
tft.init();
tft.fillScreen(TFT_BLACK);
tft.setRotation(3);
tft.setTextColor(TFT_WHITE);
tft.setFreeFont(&FreeSans9pt7b);
tft.setCursor(0, 30);
tft.println("Twitter Hashtag Search");
TJpgDec.setJpgScale(1);
TJpgDec.setSwapBytes(true);
TJpgDec.setCallback(tft_output);
}
void printToTFT(String msg){
tft.println(msg);
}
void showTweet(){
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE);
tft.setFreeFont(&FreeSansBold12pt7b);
tft.setCursor(120, 40);
tft.println(search_str.c_str());
tft.setFreeFont(&FreeSans9pt7b);
tft.setCursor(0, 80);
tft.println(search_msg.c_str());
}
void setup(void){
Serial.begin(115200);
initSPIFFS();
initTFT();
// WiFi Connection
WiFi.begin(ssid, password);
Serial.print("\nConnecting to ");
Serial.print(ssid);
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected. yay!");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
printToTFT("WIFI Connected!");
delay(100);
// Connect to NTP and force-update time
tcr.startNTP();
Serial.println("NTP Synced");
printToTFT("NTP Synced!");
delay(100);
printToTFT("Loading...");
}
void extractJSON(String tmsg) {
//Serial.println(tmsg);
size_t len = tmsg.length();
Serial.printf("msg length: %d\n", len);
if(len < 1000) return;
DynamicJsonDocument doc(len*2);
DeserializationError error = deserializeJson(doc, tmsg, DeserializationOption::NestingLimit(20));
if(error){
Serial.print(F("DeserializeJson() failed: "));
Serial.println(error.c_str());
return;
}
if(doc.containsKey("statuses")){
String userT = doc["statuses"][0]["user"]["screen_name"];
String text = doc["statuses"][0]["text"];
if(text != ""){
search_msg = "@" + userT + " says " + text;
}
showTweet();
TJpgDec.drawFsJpg(10, 10, placeholderImage);
String profile_image_url = doc["statuses"][0]["user"]["profile_image_url"];
Serial.println(profile_image_url);
if(profile_image_url.indexOf("_normal") > 0){
bool loaded_ok = getFile(profile_image_url, userProfileImage);
listSPIFFS();
if(loaded_ok){
uint16_t w = 0, h = 0;
TJpgDec.getFsJpgSize(&w, &h, userProfileImage);
if(w !=0 && h != 0){
TJpgDec.drawFsJpg(10, 10, userProfileImage);
}
}
}
}else if(doc.containsKey("errors")){
String err = doc["errors"][0];
search_msg = err;
}else{
Serial.println("No Useful Data");
}
}
void loop(void){
if (millis() > api_lasttime + api_mtbs) {
extractJSON(tcr.searchTwitter(search_str));
api_lasttime = millis();
}
delay(2);
yield();
}
| 4,945 | ESP8266_Twitter_Hash_Search | ino | en | cpp | code | {"qsc_code_num_words": 622, "qsc_code_num_chars": 4945.0, "qsc_code_mean_word_length": 5.19292605, "qsc_code_frac_words_unique": 0.40032154, "qsc_code_frac_chars_top_2grams": 0.02972136, "qsc_code_frac_chars_top_3grams": 0.02321981, "qsc_code_frac_chars_top_4grams": 0.01424149, "qsc_code_frac_chars_dupe_5grams": 0.06408669, "qsc_code_frac_chars_dupe_6grams": 0.04334365, "qsc_code_frac_chars_dupe_7grams": 0.0, "qsc_code_frac_chars_dupe_8grams": 0.0, "qsc_code_frac_chars_dupe_9grams": 0.0, "qsc_code_frac_chars_dupe_10grams": 0.0, "qsc_code_frac_chars_replacement_symbols": 0.0, "qsc_code_frac_chars_digital": 0.02757941, "qsc_code_frac_chars_whitespace": 0.17876643, "qsc_code_size_file_byte": 4945.0, "qsc_code_num_lines": 184.0, "qsc_code_num_chars_line_max": 140.0, "qsc_code_num_chars_line_mean": 26.875, "qsc_code_frac_chars_alphabet": 0.76779118, "qsc_code_frac_chars_comments": 0.12416582, "qsc_code_cate_xml_start": 0.0, "qsc_code_frac_lines_dupe_lines": 0.08695652, "qsc_code_cate_autogen": 0.0, "qsc_code_frac_lines_long_string": 0.0, "qsc_code_frac_chars_string_length": 0.12029554, "qsc_code_frac_chars_long_word_length": 0.00484876, "qsc_code_frac_lines_string_concat": 0.0, "qsc_code_cate_encoded_data": 0.0, "qsc_code_frac_chars_hex_words": 0.0, "qsc_code_frac_lines_prompt_comments": 0.0, "qsc_code_frac_lines_assert": 0.0, "qsc_codecpp_frac_lines_preprocessor_directives": 0.13043478, "qsc_codecpp_frac_lines_func_ratio": 0.08695652, "qsc_codecpp_cate_bitsstdc": 0.0, "qsc_codecpp_nums_lines_main": 0.0, "qsc_codecpp_frac_lines_goto": 0.0, "qsc_codecpp_cate_var_zero": 0.0, "qsc_codecpp_score_lines_no_logic": 0.19565217, "qsc_codecpp_frac_lines_print": 0.00724638} | 1 | {"qsc_code_frac_chars_replacement_symbols": 0, "qsc_code_num_words": 0, "qsc_code_num_chars": 0, "qsc_code_mean_word_length": 0, "qsc_code_frac_chars_top_2grams": 0, "qsc_code_frac_chars_top_3grams": 0, "qsc_code_frac_chars_top_4grams": 0, "qsc_code_frac_chars_dupe_5grams": 0, "qsc_code_frac_chars_dupe_6grams": 0, "qsc_code_frac_chars_dupe_7grams": 0, "qsc_code_frac_chars_dupe_8grams": 0, "qsc_code_frac_chars_dupe_9grams": 0, "qsc_code_frac_chars_dupe_10grams": 0, "qsc_code_frac_lines_dupe_lines": 0, "qsc_code_size_file_byte": 0, "qsc_code_num_lines": 0, "qsc_code_num_chars_line_max": 0, "qsc_code_num_chars_line_mean": 0, "qsc_code_frac_chars_alphabet": 0, "qsc_code_frac_chars_digital": 0, "qsc_code_frac_chars_whitespace": 0, "qsc_code_frac_chars_comments": 0, "qsc_code_cate_xml_start": 0, "qsc_code_cate_autogen": 0, "qsc_code_frac_lines_long_string": 0, "qsc_code_frac_chars_string_length": 0, "qsc_code_frac_chars_long_word_length": 0, "qsc_code_cate_encoded_data": 0, "qsc_code_frac_chars_hex_words": 0, "qsc_code_frac_lines_prompt_comments": 0, "qsc_code_frac_lines_assert": 0, "qsc_codecpp_frac_lines_func_ratio": 0, "qsc_codecpp_nums_lines_main": 0, "qsc_codecpp_score_lines_no_logic": 0, "qsc_codecpp_frac_lines_preprocessor_directives": 0, "qsc_codecpp_frac_lines_print": 0} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.